home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1992-1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include "Indicators.h"
- #include "Render.h"
-
- void draw_needle(Boolean draw_it)
- {
- static float data1_1[][3] = {
- {-12.0, 0.0, 0.0}, {-11.0, -1.0, 0.0}, {-11.0, 0.0, 0.0}};
- static float data1_2[][3] = {
- {-11.0, -1.0, 0.0}, {0.0,-1.0,0.0}, {0.0, 0.0,0.0}, {-11.0, 0.0, 0.0}};
- static float data1_3[][3] = {
- {0.0, -1.0, 0.0}, {1.0, -1.0, 0.0}, {0.0, 0.0, 0.0}};
-
- static float data2_1[][3] = {
- {-12.0, 0.0, 0.0}, {-11.0, 0.0, 0.0}, {-11.0, 1.0, 0.0}};
- static float data2_2[][3] = {
- {-11.0, 0.0, 0.0}, {0.0,0.0,0.0}, {0.0, 1.0,0.0}, {-11.0, 1.0, 0.0}};
- static float data2_3[][3] = {
- {0.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}};
-
- static float data3[][3] = {
- {0.0, 0.0, 0.0}, {1.0, -1.0, 0.0}, {1.0, 1.0, 0.0}};
-
- if (!draw_it)
- color(CLEAR);
-
- pushmatrix();
-
- scale(1.0/12.0,1.0/12.0,1.0/12.0);
-
- if (draw_it)
- color(GREY1);
- bgnpolygon();
- v3f(data1_1[0]);
- v3f(data1_1[1]);
- v3f(data1_1[2]);
- endpolygon();
- bgnpolygon();
- v3f(data1_2[0]);
- v3f(data1_2[1]);
- v3f(data1_2[2]);
- v3f(data1_2[3]);
- endpolygon();
- bgnpolygon();
- v3f(data1_3[0]);
- v3f(data1_3[1]);
- v3f(data1_3[2]);
- endpolygon();
-
- if (draw_it)
- color(GREY2);
- bgnpolygon();
- v3f(data2_1[0]);
- v3f(data2_1[1]);
- v3f(data2_1[2]);
- endpolygon();
- bgnpolygon();
- v3f(data2_2[0]);
- v3f(data2_2[1]);
- v3f(data2_2[2]);
- v3f(data2_2[3]);
- endpolygon();
- bgnpolygon();
- v3f(data2_3[0]);
- v3f(data2_3[1]);
- v3f(data2_3[2]);
- endpolygon();
-
- if (draw_it)
- color(GREY3);
- bgnpolygon();
- v3f(data3[0]);
- v3f(data3[1]);
- v3f(data3[2]);
- endpolygon();
-
- popmatrix();
- }
-
-
- // Draws a generic counter-clockwise dial.
- // Leaves the font set appropriate for gage units labelling.
- void draw_dial(
- float world_diam,
- float world_per_pixel,
- float start_angle, float end_angle,
- float small_tick_size, float big_tick_size,
- float label_pos,
- int start_value, int end_value,
- int small_tick_increment,
- float label_multiplier,
- int small_ticks_per_big_tick,
- int big_ticks_per_label)
- {
- static float outside[2], small[2], big[2], label[2];
-
- // starting locations at zero degrees (pos-x axis)
- outside[0] = world_diam;
- outside[1] = 0.0;
-
- small[0] = small_tick_size*world_diam;
- small[1] = 0.0;
-
- big[0] = big_tick_size*world_diam;
- big[1] = 0.0;
-
- float angle_step =
- (start_angle - end_angle)/((float)end_value/(float)small_tick_increment);
-
- float angle = start_angle;
-
- fmfonthandle font1 = fmfindfont("Hlv");
- float pnt_size = (world_diam/world_per_pixel)/10.0;
- fmfonthandle font = fmscalefont(font1, pnt_size);
- fmsetfont(font);
-
- int small_tick_count = 0;
- int big_tick_count = 0;
-
- for (int i = start_value; i <= end_value; i += small_tick_increment)
- {
- // draw major tick?
- if (small_tick_count++%small_ticks_per_big_tick == 0)
- {
- pushmatrix();
- rot(angle,'z');
- cpack(ORANGE);
- bgnline();
- v2f(outside); v2f(big);
- endline();
- popmatrix();
-
- // label the major tick?
-
- if ((big_tick_count++%big_ticks_per_label == 0) &&
- (label_multiplier != 0.0))
- {
-
- char buf[8];
- sprintf(buf,"%d",(int)((float)i * label_multiplier));
-
- long width = fmgetstrwidth(font, buf);
-
- // position text string
-
- // XXX ANSI cosf and sinf undefined!!!
- float c = (float) cos(angle*M_PI/180.0);
- float s = (float) sin(angle*M_PI/180.0);
-
- label[0] = label_pos*world_diam*c;
- label[1] = label_pos*world_diam*s;
-
- // Correct for lower left origin of character string
- label[0] -= world_per_pixel*((float)width/2.0);
- label[1] -= world_per_pixel*(pnt_size/2.0);
-
- cmov2(label[0],label[1]);
- fmprstr(buf);
- }
-
- }
- else
- {
- // draw minor tick
- pushmatrix();
- rot(angle,'z');
- cpack(ORANGE);
- bgnline();
- v2f(outside); v2f(small);
- endline();
- popmatrix();
- }
-
- angle -= angle_step;
- }
- }
-
- // bulbous box
- void bulbous_box(float x1, float y1, float x2, float y2, float diam)
- {
- float width, height, left, bottom;
-
- if (x1 < x2)
- {
- width = x2 - x1;
- left = x1;
- }
- else
- {
- width = x1 - x2;
- left = x2;
- }
-
- if (y1 < y2)
- {
- height = y2 - y1;
- bottom = y1;
- }
- else
- {
- height = y1 - y2;
- bottom = y2;
- }
-
- pushmatrix();
- translate(left+width/2.0,bottom+height/2.0,0.0);
-
- /// this draws a rect about the origin
- pushmatrix();
- translate(width/2.0,0.0,0.0);
- scale(diam,height,diam);
- rotate(900,'x');
- fcylinder();
- popmatrix();
-
- pushmatrix();
- translate(-width/2.0,0.0,0.0);
- scale(diam,height,diam);
- rotate(900,'x');
- fcylinder();
- popmatrix();
-
- pushmatrix();
- translate(0.0,height/2.0,0.0);
- scale(width,diam,diam);
- rotate(900,'y');
- fcylinder();
- popmatrix();
-
- pushmatrix();
- translate(0.0,-height/2.0,0.0);
- scale(width,diam,diam);
- rotate(900,'y');
- fcylinder();
- popmatrix();
-
- popmatrix();
- }
-
-
-
- void draw_steering_spoke(Boolean draw_it)
- {
- int i;
-
- static float spoke1_data[][3] = {
- {1.3, -.4, 0.0},
- {6.45, -.4, 0.0},
- {6.45, -.3, 0.0},
- {1.3, -.3, 0.0},
- };
-
- static float spoke2_data[][3] = {
- {1.3, -.3, 0.0},
- {6.45, -.3, 0.0},
- {6.45, .3, 0.0},
- {1.3, .3, 0.0},
- };
-
- static float spoke3_data[][3] = {
- {1.3, .3, 0.0},
- {6.45, .3, 0.0},
- {6.45, .4, 0.0},
- {1.3, .4, 0.0},
- };
-
- if (draw_it)
- color(GREY1);
- else
- color(CLEAR);
- bgnpolygon();
- for (i = 0; i < np(spoke2_data); i++)
- v3f(spoke1_data[i]);
- endpolygon();
-
- if (draw_it)
- color(GREY2);
- else
- color(CLEAR);
- bgnpolygon();
- for (i = 0; i < np(spoke2_data); i++)
- v3f(spoke2_data[i]);
- endpolygon();
-
- if (draw_it)
- color(GREY3);
- else
- color(CLEAR);
- bgnpolygon();
- for (i = 0; i < np(spoke2_data); i++)
- v3f(spoke3_data[i]);
- endpolygon();
- }
-
-
-
-