4 #ifdef USE_HUD_TextList
5 #define textString( x , y, text, font ) TextString( text, x , y )
7 #define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
10 //========== Top of hud_card class member definitions =============
19 float max_value, // 360
40 instr_scale( x,y,width,height,
43 max_value, min_value, disp_scaling,
44 major_divs, minor_divs, modulus,
46 val_span ( value_span),
48 draw_tick_bottom (tick_bottom),
49 draw_tick_top (tick_top),
50 draw_tick_right (tick_right),
51 draw_tick_left (tick_left),
52 draw_cap_bottom (cap_bottom),
53 draw_cap_top (cap_top),
54 draw_cap_right (cap_right),
55 draw_cap_left (cap_left),
56 marker_offset (mark_offset),
57 pointer (pointer_enable),
58 pointer_type (type_pointer)
61 half_width_units = range_to_show() / 2.0;
62 // UINT options = get_options();
63 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
64 // huds_right = options & HUDS_RIGHT;
65 // huds_left = options & HUDS_LEFT;
66 // huds_vert = options & HUDS_VERT;
67 // huds_notext = options & HUDS_NOTEXT;
68 // huds_top = options & HUDS_TOP;
69 // huds_bottom = options & HUDS_BOTTOM;
76 hud_card( const hud_card & image):
77 instr_scale( (const instr_scale & ) image),
78 val_span( image.val_span),
80 half_width_units (image.half_width_units),
81 draw_tick_bottom (image.draw_tick_bottom),
82 draw_tick_top (image.draw_tick_top),
83 draw_tick_right (image.draw_tick_right),
84 draw_tick_left (image.draw_tick_left),
85 draw_cap_bottom (image.draw_cap_bottom),
86 draw_cap_top (image.draw_cap_top),
87 draw_cap_right (image.draw_cap_right),
88 draw_cap_left (image.draw_cap_left),
89 marker_offset (image.marker_offset),
90 pointer (image.pointer),
91 pointer_type (image.pointer_type)
94 // UINT options = get_options();
95 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
96 // huds_right = options & HUDS_RIGHT;
97 // huds_left = options & HUDS_LEFT;
98 // huds_vert = options & HUDS_VERT;
99 // huds_notext = options & HUDS_NOTEXT;
100 // huds_top = options & HUDS_TOP;
101 // huds_bottom = options & HUDS_BOTTOM;
104 hud_card & hud_card ::
105 operator = (const hud_card & rhs )
107 if( !( this == &rhs)){
108 instr_scale::operator = (rhs);
109 val_span = rhs.val_span;
110 half_width_units = rhs.half_width_units;
111 draw_tick_bottom = rhs.draw_tick_bottom;
112 draw_tick_top = rhs.draw_tick_top;
113 draw_tick_right = rhs.draw_tick_right;
114 draw_tick_left = rhs.draw_tick_left;
115 draw_cap_bottom = rhs.draw_cap_bottom;
116 draw_cap_top = rhs.draw_cap_top;
117 draw_cap_right = rhs.draw_cap_right;
118 draw_cap_left = rhs.draw_cap_left;
119 marker_offset = rhs.marker_offset;
121 pointer = rhs.pointer;
122 pointer_type = rhs.pointer_type;
129 draw( void ) // (HUD_scale * pscale )
132 float vmin = 0.0, vmax = 0.0;
137 int text_x = 0, text_y = 0;
145 POINT mid_scr = get_centroid();
146 float cur_value = get_value();
147 RECT scrn_rect = get_location();
148 UINT options = get_options();
150 height = scrn_rect.top + scrn_rect.bottom;
151 width = scrn_rect.left + scrn_rect.right;
152 marker_xs = scrn_rect.left; // x start
158 text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
163 vmin = cur_value - half_width_units; // width units == needle travel
164 vmax = cur_value + half_width_units; // or picture unit span.
170 // Draw the basic markings for the scale...
172 if( huds_vert(options) ) { // Vertical scale
173 if (draw_tick_bottom) {
174 drawOneLine( scrn_rect.left, // Bottom tick bar
178 } // endif draw_tick_bottom
180 drawOneLine( scrn_rect.left, // Top tick bar
184 } // endif draw_tick_top
186 marker_xs = scrn_rect.left; // x start
187 marker_xe = width; // x extent
190 // glBegin(GL_LINES);
193 // glVertex2f( marker_xs, scrn_rect.top);
194 // glVertex2f( marker_xe, scrn_rect.top);
197 // glVertex2f( marker_xs, marker_ye);
198 // glVertex2f( marker_xe, marker_ye );
202 // We do not use else in the following so that combining the
203 // two options produces a "caged" display with double
204 // carrots. The same is done for horizontal card indicators.
206 if( huds_left(options) ) { // Calculate x marker offset
208 if (draw_cap_right) {
210 drawOneLine( marker_xe, scrn_rect.top,
211 marker_xe, marker_ye); // Cap right side
214 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
216 // drawOneLine( marker_xs, mid_scr.y,
217 // marker_xe, mid_scr.y + scrn_rect.right / 6);
218 // drawOneLine( marker_xs, mid_scr.y,
219 // marker_xe, mid_scr.y - scrn_rect.right / 6);
223 if(pointer_type=="fixed") {
224 glBegin(GL_LINE_STRIP);
225 glVertex2f( marker_offset+marker_xe, text_y + scrn_rect.right / 6);
226 glVertex2f( marker_offset+marker_xs, text_y);
227 glVertex2f( marker_offset+marker_xe, text_y - scrn_rect.right / 6);
230 if(pointer_type=="moving") {
231 //Code for Moving Type Pointer to be included.
237 if( huds_right(options) ) { // We'll default this for now.
239 drawOneLine( scrn_rect.left, scrn_rect.top,
240 scrn_rect.left, marker_ye ); // Cap left side
243 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
245 // drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
246 // marker_xe, mid_scr.y );
247 // drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
248 // marker_xe, mid_scr.y);
252 if(pointer_type=="fixed") {
253 glBegin(GL_LINE_STRIP);
254 glVertex2f( -marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6);
255 glVertex2f( -marker_offset+marker_xe, text_y );
256 glVertex2f( -marker_offset+scrn_rect.left, text_y - scrn_rect.right / 6);
260 if(pointer_type=="moving") {
261 // Code for Moving Type Pointer to be included.
267 // At this point marker x_start and x_end values are transposed.
268 // To keep this from confusing things they are now interchanged.
269 if(huds_both(options)) {
270 marker_ye = marker_xs;
271 marker_xs = marker_xe;
272 marker_xe = marker_ye;
275 // Work through from bottom to top of scale. Calculating where to put
276 // minor and major ticks.
278 // draw scale or tape
279 // last = FloatToInt(vmax)+1;
280 // i = FloatToInt(vmin);
281 last = (int)vmax + 1;
283 for( ; i <last ; i++ ) {
291 if( condition ) { // Show a tick if necessary
292 // Calculate the location of this tick
293 marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
294 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
295 // Block calculation artifact from drawing ticks below min coordinate.
296 // Calculation here accounts for text height.
298 if(( marker_ys < (scrn_rect.top + 4)) |
299 ( marker_ys > (height - 4)))
305 // if( (i%div_min()) == 0) {
306 if( !(i%(int)div_min())) {
307 if((( marker_ys - 5) > scrn_rect.top ) &&
308 (( marker_ys + 5) < (height))){
309 if( huds_both(options) ) {
310 drawOneLine( scrn_rect.left, marker_ys,
311 marker_xs, marker_ys );
312 drawOneLine( marker_xe, marker_ys,
314 // glBegin(GL_LINES);
315 // glVertex2f( scrn_rect.left, marker_ys );
316 // glVertex2f( marker_xs, marker_ys );
317 // glVertex2f( marker_xe, marker_ys);
318 // glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
321 if( huds_left(options) ) {
322 drawOneLine( marker_xs + 4, marker_ys,
323 marker_xe, marker_ys );
325 drawOneLine( marker_xs, marker_ys,
326 marker_xe - 4, marker_ys );
334 if( !(i%(int)div_max()) ) {
338 disp_val += modulo();
340 // disp_val = i % (int)modulo();
342 disp_val = i % (int) modulo(); // ?????????
347 lenstr = sprintf( TextScale, "%d",
348 FloatToInt(disp_val * data_scaling()/*+.5*/));
349 // (int)(disp_val * data_scaling() +.5));
350 if(( (marker_ys - 8 ) > scrn_rect.top ) &&
351 ( (marker_ys + 8) < (height))){
352 if( huds_both(options) ) {
353 // drawOneLine( scrn_rect.left, marker_ys,
354 // marker_xs, marker_ys);
355 // drawOneLine( marker_xs, marker_ys,
356 // scrn_rect.left + scrn_rect.right,
358 glBegin(GL_LINE_STRIP);
359 glVertex2f( scrn_rect.left, marker_ys );
360 glVertex2f( marker_xs, marker_ys);
361 glVertex2f( width, marker_ys);
363 if( !huds_notext(options)) {
364 textString ( marker_xs + 2, marker_ys,
365 TextScale, GLUT_BITMAP_8_BY_13 );
368 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
369 if( !huds_notext(options) ) {
370 if( huds_left(options) ) {
371 textString( marker_xs - 8 * lenstr - 2,
373 TextScale, GLUT_BITMAP_8_BY_13 );
375 textString( marker_xe + 3 * lenstr,
377 TextScale, GLUT_BITMAP_8_BY_13 );
381 } // Else read oriented right
382 } // End if modulo division by major interval is zero
383 } // End if major interval divisor non-zero
384 } // End if condition
385 } // End for range of i from vmin to vmax
386 } // End if VERTICAL SCALE TYPE
387 else { // Horizontal scale by default
389 if (draw_tick_left) {
390 drawOneLine( scrn_rect.left, scrn_rect.top,
391 scrn_rect.left, height);
392 } // endif draw_tick_left
394 if (draw_tick_right) {
395 drawOneLine( width, scrn_rect.top,
398 } // endif draw_tick_right
400 marker_ys = scrn_rect.top; // Starting point for
401 marker_ye = height; // tick y location calcs
403 marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
406 // glBegin(GL_LINES);
408 // glVertex2f( scrn_rect.left, scrn_rect.top);
409 // glVertex2f( scrn_rect.left, marker_ye);
412 // glVertex2f( marker_xe, scrn_rect.top);
413 // glVertex2f( marker_xe, marker_ye );
416 if( huds_top(options) ) {
417 if (draw_cap_bottom) {
419 drawOneLine( scrn_rect.left,
426 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
428 // drawOneLine( mid_scr.x, marker_ye,
429 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
430 // drawOneLine( mid_scr.x, marker_ye,
431 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
434 if(pointer_type=="fixed") {
435 glBegin(GL_LINE_STRIP);
436 glVertex2f( marker_xs - scrn_rect.bottom / 4, scrn_rect.top);
437 glVertex2f( marker_xs, marker_ye);
438 glVertex2f( marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
441 if(pointer_type=="moving") {
442 // Code for Moving type Pointer to be included.
448 if( huds_bottom(options) ) {
451 drawOneLine( scrn_rect.left, height,
456 marker_ys = height - scrn_rect.bottom / 2;
458 // drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
459 // scrn_rect.top + scrn_rect.bottom,
460 // mid_scr.x, marker_ys );
461 // drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
462 // scrn_rect.top + scrn_rect.bottom,
463 // mid_scr.x , marker_ys );
467 if(pointer_type=="fixed") {
468 glBegin(GL_LINE_STRIP);
469 glVertex2f( marker_xs + scrn_rect.bottom / 4, height);
470 glVertex2f( marker_xs, marker_ys );
471 glVertex2f( marker_xs - scrn_rect.bottom / 4, height);
474 if(pointer_type=="moving") {
475 // Code for Moving Type Pointer to be included.
482 // if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
483 // marker_xe = marker_ys;
484 // marker_ys = marker_ye;
485 // marker_ye = marker_xe;
488 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
490 // last = FloatToInt(vmax)+1;
491 // i = FloatToInt(vmin);
492 last = (int)vmax + 1;
494 for(; i <last ; i++ ) {
495 // for( i = (int)vmin; i <= (int)vmax; i++ ) {
496 // printf("<*> i = %d\n", i);
503 // printf("<**> i = %d\n", i);
505 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
506 marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
508 // if( (i%(int)div_min()) == 0 ) {
509 if( !(i%(int)div_min() )) {
510 // draw in ticks only if they aren't too close to the edge.
511 if((( marker_xs - 5) > scrn_rect.left ) &&
512 (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
514 if( huds_both(options) ) {
515 drawOneLine( marker_xs, scrn_rect.top,
516 marker_xs, marker_ys - 4);
517 drawOneLine( marker_xs, marker_ye + 4,
519 // glBegin(GL_LINES);
520 // glVertex2f( marker_xs, scrn_rect.top);
521 // glVertex2f( marker_xs, marker_ys - 4);
522 // glVertex2f( marker_xs, marker_ye + 4);
523 // glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
526 if( huds_top(options)) {
528 drawOneLine( marker_xs, marker_ys,
529 marker_xs, marker_ye - 4);
531 drawOneLine( marker_xs, marker_ys + 4,
532 marker_xs, marker_ye);
538 // printf("<***> i = %d\n", i);
540 // printf("i = %d\n", i);
541 // if( (i%(int)div_max())==0 ) {
542 if( !(i%(int)div_max()) ) {
546 disp_val += modulo();
548 disp_val = i % (int) modulo(); // ?????????
552 // printf("disp_val = %d\n", disp_val);
553 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
554 lenstr = sprintf( TextScale, "%d",
555 // (int)(disp_val * data_scaling() +.5));
556 FloatToInt(disp_val * data_scaling()/*+.5*/));
557 // Draw major ticks and text only if far enough from the edge.
558 if(( (marker_xs - 10)> scrn_rect.left ) &&
559 ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
560 if( huds_both(options) ) {
561 // drawOneLine( marker_xs, scrn_rect.top,
562 // marker_xs, marker_ys);
563 // drawOneLine( marker_xs, marker_ye,
564 // marker_xs, scrn_rect.top + scrn_rect.bottom);
565 glBegin(GL_LINE_STRIP);
566 glVertex2f( marker_xs, scrn_rect.top);
567 glVertex2f( marker_xs, marker_ye);
568 glVertex2f( marker_xs, height);
570 if( !huds_notext(options) ) {
571 textString ( marker_xs - 4 * lenstr,
573 TextScale, GLUT_BITMAP_8_BY_13 );
576 drawOneLine( marker_xs, marker_ys,
577 marker_xs, marker_ye );
578 if( !huds_notext(options)) {
579 if( huds_top(options) ) {
580 textString ( marker_xs - 4 * lenstr,
582 TextScale, GLUT_BITMAP_8_BY_13 );
584 textString( marker_xs - 4 * lenstr,
586 TextScale, GLUT_BITMAP_8_BY_13 );
593 // printf("<****> i = %d\n", i);