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),
79 half_width_units (image.half_width_units),
80 draw_tick_bottom (image.draw_tick_bottom),
81 draw_tick_top (image.draw_tick_top),
82 draw_tick_right (image.draw_tick_right),
83 draw_tick_left (image.draw_tick_left),
84 draw_cap_bottom (image.draw_cap_bottom),
85 draw_cap_top (image.draw_cap_top),
86 draw_cap_right (image.draw_cap_right),
87 draw_cap_left (image.draw_cap_left),
88 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 )
146 POINT mid_scr = get_centroid();
147 float cur_value = get_value();
148 RECT scrn_rect = get_location();
149 UINT options = get_options();
151 height = scrn_rect.top + scrn_rect.bottom;
152 width = scrn_rect.left + scrn_rect.right;
160 text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
166 vmin = cur_value - half_width_units; // width units == needle travel
167 vmax = cur_value + half_width_units; // or picture unit span.
173 // Draw the basic markings for the scale...
175 if( huds_vert(options) ) { // Vertical scale
176 if (draw_tick_bottom) {
177 drawOneLine( scrn_rect.left, // Bottom tick bar
181 } // endif draw_tick_bottom
183 drawOneLine( scrn_rect.left, // Top tick bar
187 } // endif draw_tick_top
189 marker_xs = scrn_rect.left; // x start
190 marker_xe = width; // x extent
193 // glBegin(GL_LINES);
196 // glVertex2f( marker_xs, scrn_rect.top);
197 // glVertex2f( marker_xe, scrn_rect.top);
200 // glVertex2f( marker_xs, marker_ye);
201 // glVertex2f( marker_xe, marker_ye );
205 // We do not use else in the following so that combining the two
206 // options produces a "caged" display with double carrots. The
207 // same is done for horizontal card indicators.
209 if( huds_left(options) ) { // Calculate x marker offset
211 if (draw_cap_right) {
213 drawOneLine( marker_xe, scrn_rect.top,
214 marker_xe, marker_ye); // Cap right side
217 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
219 // drawOneLine( marker_xs, mid_scr.y,
220 // marker_xe, mid_scr.y + scrn_rect.right / 6);
221 // drawOneLine( marker_xs, mid_scr.y,
222 // marker_xe, mid_scr.y - scrn_rect.right / 6);
226 if(pointer_type=="fixed") {
227 glBegin(GL_LINE_STRIP);
228 glVertex2f( marker_offset+marker_xe, text_y + scrn_rect.right / 6);
229 glVertex2f( marker_offset+marker_xs, text_y);
230 glVertex2f( marker_offset+marker_xe, text_y - scrn_rect.right / 6);
234 if(pointer_type=="moving") {
235 //Code for Moving Type Pointer to be included.
241 if( huds_right(options) ) { // We'll default this for now.
243 drawOneLine( scrn_rect.left, scrn_rect.top,
244 scrn_rect.left, marker_ye ); // Cap left side
247 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
249 // drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
250 // marker_xe, mid_scr.y );
251 // drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
252 // marker_xe, mid_scr.y);
256 if(pointer_type=="fixed") {
257 glBegin(GL_LINE_STRIP);
258 glVertex2f( -marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6);
259 glVertex2f( -marker_offset+marker_xe, text_y );
260 glVertex2f( -marker_offset+scrn_rect.left, text_y - scrn_rect.right / 6);
264 if(pointer_type=="moving") {
265 // Code for Moving Type Pointer to be included.
270 // At this point marker x_start and x_end values are transposed.
271 // To keep this from confusing things they are now interchanged.
272 if(huds_both(options)) {
273 marker_ye = marker_xs;
274 marker_xs = marker_xe;
275 marker_xe = marker_ye;
278 // Work through from bottom to top of scale. Calculating where to put
279 // minor and major ticks.
281 // draw scale or tape
282 // last = FloatToInt(vmax)+1;
283 // i = FloatToInt(vmin);
284 last = (int)vmax + 1;
286 for( ; i <last ; i++ )
295 if( condition ) { // Show a tick if necessary
296 // Calculate the location of this tick
297 marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
298 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
299 // Block calculation artifact from drawing ticks below min coordinate.
300 // Calculation here accounts for text height.
302 if(( marker_ys < (scrn_rect.top + 4)) |
303 ( marker_ys > (height - 4))) {
308 // if( (i%div_min()) == 0) {
309 if( !(i%(int)div_min())) {
310 if((( marker_ys - 5) > scrn_rect.top ) &&
311 (( marker_ys + 5) < (height))){
312 if( huds_both(options) ) {
313 drawOneLine( scrn_rect.left, marker_ys,
314 marker_xs, marker_ys );
315 drawOneLine( marker_xe, marker_ys,
317 // glBegin(GL_LINES);
318 // glVertex2f( scrn_rect.left, marker_ys );
319 // glVertex2f( marker_xs, marker_ys );
320 // glVertex2f( marker_xe, marker_ys);
321 // glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
325 if( huds_left(options) ) {
326 drawOneLine( marker_xs + 4, marker_ys,
327 marker_xe, marker_ys );
330 drawOneLine( marker_xs, marker_ys,
331 marker_xe - 4, marker_ys );
338 if( !(i%(int)div_max()) )
343 disp_val += modulo();
345 // disp_val = i % (int)modulo();
347 disp_val = i % (int) modulo(); // ?????????
352 lenstr = sprintf( TextScale, "%d",
353 FloatToInt(disp_val * data_scaling()/*+.5*/));
354 // (int)(disp_val * data_scaling() +.5));
355 if(( (marker_ys - 8 ) > scrn_rect.top ) &&
356 ( (marker_ys + 8) < (height))){
357 if( huds_both(options) ) {
358 // drawOneLine( scrn_rect.left, marker_ys,
359 // marker_xs, marker_ys);
360 // drawOneLine( marker_xs, marker_ys,
361 // scrn_rect.left + scrn_rect.right,
363 glBegin(GL_LINE_STRIP);
364 glVertex2f( scrn_rect.left, marker_ys );
365 glVertex2f( marker_xs, marker_ys);
366 glVertex2f( width, marker_ys);
368 if( !huds_notext(options)) {
369 textString ( marker_xs + 2, marker_ys,
370 TextScale, GLUT_BITMAP_8_BY_13 );
374 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
375 if( !huds_notext(options) ) {
376 if( huds_left(options) ) {
377 textString( marker_xs - 8 * lenstr - 2,
379 TextScale, GLUT_BITMAP_8_BY_13 );
382 textString( marker_xe + 3 * lenstr,
384 TextScale, GLUT_BITMAP_8_BY_13 );
388 } // Else read oriented right
389 } // End if modulo division by major interval is zero
390 } // End if major interval divisor non-zero
391 } // End if condition
392 } // End for range of i from vmin to vmax
393 } // End if VERTICAL SCALE TYPE
394 else { // Horizontal scale by default
396 if (draw_tick_left) {
397 drawOneLine( scrn_rect.left, scrn_rect.top,
398 scrn_rect.left, height);
399 } // endif draw_tick_left
401 if (draw_tick_right) {
402 drawOneLine( width, scrn_rect.top,
405 } // endif draw_tick_right
407 marker_ys = scrn_rect.top; // Starting point for
408 marker_ye = height; // tick y location calcs
410 marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
413 // glBegin(GL_LINES);
415 // glVertex2f( scrn_rect.left, scrn_rect.top);
416 // glVertex2f( scrn_rect.left, marker_ye);
419 // glVertex2f( marker_xe, scrn_rect.top);
420 // glVertex2f( marker_xe, marker_ye );
423 if( huds_top(options) ) {
424 if (draw_cap_bottom) {
426 drawOneLine( scrn_rect.left,
433 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
435 // drawOneLine( mid_scr.x, marker_ye,
436 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
437 // drawOneLine( mid_scr.x, marker_ye,
438 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
441 if(pointer_type=="fixed") {
442 glBegin(GL_LINE_STRIP);
443 glVertex2f( marker_xs - scrn_rect.bottom / 4, scrn_rect.top);
444 glVertex2f( marker_xs, marker_ye);
445 glVertex2f( marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
449 if(pointer_type=="moving") {
450 // Code for Moving type Pointer to be included.
455 if( huds_bottom(options) ) {
458 drawOneLine( scrn_rect.left, height,
463 marker_ys = height - scrn_rect.bottom / 2;
465 // drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
466 // scrn_rect.top + scrn_rect.bottom,
467 // mid_scr.x, marker_ys );
468 // drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
469 // scrn_rect.top + scrn_rect.bottom,
470 // mid_scr.x , marker_ys );
474 if(pointer_type=="fixed") {
475 glBegin(GL_LINE_STRIP);
476 glVertex2f( marker_xs + scrn_rect.bottom / 4, height);
477 glVertex2f( marker_xs, marker_ys );
478 glVertex2f( marker_xs - scrn_rect.bottom / 4, height);
482 if(pointer_type=="moving") {
483 // Code for Moving Type Pointer to be included.
490 // if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
491 // marker_xe = marker_ys;
492 // marker_ys = marker_ye;
493 // marker_ye = marker_xe;
496 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
498 // last = FloatToInt(vmax)+1;
499 // i = FloatToInt(vmin);
500 last = (int)vmax + 1;
502 for(; i <last ; i++ ) {
503 // for( i = (int)vmin; i <= (int)vmax; i++ ) {
504 // printf("<*> i = %d\n", i);
511 // printf("<**> i = %d\n", i);
513 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
514 marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
516 // if( (i%(int)div_min()) == 0 ) {
517 if( !(i%(int)div_min() )) {
518 // draw in ticks only if they aren't too close to the edge.
519 if((( marker_xs - 5) > scrn_rect.left ) &&
520 (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
522 if( huds_both(options) ) {
523 drawOneLine( marker_xs, scrn_rect.top,
524 marker_xs, marker_ys - 4);
525 drawOneLine( marker_xs, marker_ye + 4,
527 // glBegin(GL_LINES);
528 // glVertex2f( marker_xs, scrn_rect.top);
529 // glVertex2f( marker_xs, marker_ys - 4);
530 // glVertex2f( marker_xs, marker_ye + 4);
531 // glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
535 if( huds_top(options)) {
537 drawOneLine( marker_xs, marker_ys,
538 marker_xs, marker_ye - 4);
541 drawOneLine( marker_xs, marker_ys + 4,
542 marker_xs, marker_ye);
548 // printf("<***> i = %d\n", i);
550 // printf("i = %d\n", i);
551 // if( (i%(int)div_max())==0 ) {
552 if( !(i%(int)div_max()) ) {
556 disp_val += modulo();
558 disp_val = i % (int) modulo(); // ?????????
562 // printf("disp_val = %d\n", disp_val);
563 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
564 lenstr = sprintf( TextScale, "%d",
565 // (int)(disp_val * data_scaling() +.5));
566 FloatToInt(disp_val * data_scaling()/*+.5*/));
567 // Draw major ticks and text only if far enough from the edge.
568 if(( (marker_xs - 10)> scrn_rect.left ) &&
569 ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
570 if( huds_both(options) ) {
571 // drawOneLine( marker_xs, scrn_rect.top,
572 // marker_xs, marker_ys);
573 // drawOneLine( marker_xs, marker_ye,
574 // marker_xs, scrn_rect.top + scrn_rect.bottom);
575 glBegin(GL_LINE_STRIP);
576 glVertex2f( marker_xs, scrn_rect.top);
577 glVertex2f( marker_xs, marker_ye);
578 glVertex2f( marker_xs, height);
580 if( !huds_notext(options) ) {
581 textString ( marker_xs - 4 * lenstr,
583 TextScale, GLUT_BITMAP_8_BY_13 );
587 drawOneLine( marker_xs, marker_ys,
588 marker_xs, marker_ye );
589 if( !huds_notext(options)) {
590 if( huds_top(options) ) {
591 textString ( marker_xs - 4 * lenstr,
593 TextScale, GLUT_BITMAP_8_BY_13 );
596 textString( marker_xs - 4 * lenstr,
598 TextScale, GLUT_BITMAP_8_BY_13 );
605 // printf("<****> i = %d\n", i);