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;
157 text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
162 vmin = cur_value - half_width_units; // width units == needle travel
163 vmax = cur_value + half_width_units; // or picture unit span.
169 // Draw the basic markings for the scale...
171 if( huds_vert(options) ) { // Vertical scale
172 if (draw_tick_bottom) {
173 drawOneLine( scrn_rect.left, // Bottom tick bar
177 } // endif draw_tick_bottom
179 drawOneLine( scrn_rect.left, // Top tick bar
183 } // endif draw_tick_top
185 marker_xs = scrn_rect.left; // x start
186 marker_xe = width; // x extent
189 // glBegin(GL_LINES);
192 // glVertex2f( marker_xs, scrn_rect.top);
193 // glVertex2f( marker_xe, scrn_rect.top);
196 // glVertex2f( marker_xs, marker_ye);
197 // glVertex2f( marker_xe, marker_ye );
201 // We do not use else in the following so that combining the
202 // two options produces a "caged" display with double
203 // carrots. The same is done for horizontal card indicators.
205 if( huds_left(options) ) { // Calculate x marker offset
207 if (draw_cap_right) {
209 drawOneLine( marker_xe, scrn_rect.top,
210 marker_xe, marker_ye); // Cap right side
213 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
215 // drawOneLine( marker_xs, mid_scr.y,
216 // marker_xe, mid_scr.y + scrn_rect.right / 6);
217 // drawOneLine( marker_xs, mid_scr.y,
218 // marker_xe, mid_scr.y - scrn_rect.right / 6);
222 if(pointer_type=="fixed") {
223 glBegin(GL_LINE_STRIP);
224 glVertex2f( marker_offset+marker_xe, text_y + scrn_rect.right / 6);
225 glVertex2f( marker_offset+marker_xs, text_y);
226 glVertex2f( marker_offset+marker_xe, text_y - scrn_rect.right / 6);
229 if(pointer_type=="moving") {
230 //Code for Moving Type Pointer to be included.
236 if( huds_right(options) ) { // We'll default this for now.
238 drawOneLine( scrn_rect.left, scrn_rect.top,
239 scrn_rect.left, marker_ye ); // Cap left side
242 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
244 // drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
245 // marker_xe, mid_scr.y );
246 // drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
247 // marker_xe, mid_scr.y);
251 if(pointer_type=="fixed") {
252 glBegin(GL_LINE_STRIP);
253 glVertex2f( -marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6);
254 glVertex2f( -marker_offset+marker_xe, text_y );
255 glVertex2f( -marker_offset+scrn_rect.left, text_y - scrn_rect.right / 6);
259 if(pointer_type=="moving") {
260 // Code for Moving Type Pointer to be included.
266 // At this point marker x_start and x_end values are transposed.
267 // To keep this from confusing things they are now interchanged.
268 if(huds_both(options)) {
269 marker_ye = marker_xs;
270 marker_xs = marker_xe;
271 marker_xe = marker_ye;
274 // Work through from bottom to top of scale. Calculating where to put
275 // minor and major ticks.
277 // draw scale or tape
278 // last = FloatToInt(vmax)+1;
279 // i = FloatToInt(vmin);
280 last = (int)vmax + 1;
282 for( ; i <last ; i++ ) {
290 if( condition ) { // Show a tick if necessary
291 // Calculate the location of this tick
292 marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
293 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
294 // Block calculation artifact from drawing ticks below min coordinate.
295 // Calculation here accounts for text height.
297 if(( marker_ys < (scrn_rect.top + 4)) |
298 ( marker_ys > (height - 4)))
304 // if( (i%div_min()) == 0) {
305 if( !(i%(int)div_min())) {
306 if((( marker_ys - 5) > scrn_rect.top ) &&
307 (( marker_ys + 5) < (height))){
308 if( huds_both(options) ) {
309 drawOneLine( scrn_rect.left, marker_ys,
310 marker_xs, marker_ys );
311 drawOneLine( marker_xe, marker_ys,
313 // glBegin(GL_LINES);
314 // glVertex2f( scrn_rect.left, marker_ys );
315 // glVertex2f( marker_xs, marker_ys );
316 // glVertex2f( marker_xe, marker_ys);
317 // glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
320 if( huds_left(options) ) {
321 drawOneLine( marker_xs + 4, marker_ys,
322 marker_xe, marker_ys );
324 drawOneLine( marker_xs, marker_ys,
325 marker_xe - 4, marker_ys );
333 if( !(i%(int)div_max()) ) {
337 disp_val += modulo();
339 // disp_val = i % (int)modulo();
341 disp_val = i % (int) modulo(); // ?????????
346 lenstr = sprintf( TextScale, "%d",
347 FloatToInt(disp_val * data_scaling()/*+.5*/));
348 // (int)(disp_val * data_scaling() +.5));
349 if(( (marker_ys - 8 ) > scrn_rect.top ) &&
350 ( (marker_ys + 8) < (height))){
351 if( huds_both(options) ) {
352 // drawOneLine( scrn_rect.left, marker_ys,
353 // marker_xs, marker_ys);
354 // drawOneLine( marker_xs, marker_ys,
355 // scrn_rect.left + scrn_rect.right,
357 glBegin(GL_LINE_STRIP);
358 glVertex2f( scrn_rect.left, marker_ys );
359 glVertex2f( marker_xs, marker_ys);
360 glVertex2f( width, marker_ys);
362 if( !huds_notext(options)) {
363 textString ( marker_xs + 2, marker_ys,
364 TextScale, GLUT_BITMAP_8_BY_13 );
367 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
368 if( !huds_notext(options) ) {
369 if( huds_left(options) ) {
370 textString( marker_xs - 8 * lenstr - 2,
372 TextScale, GLUT_BITMAP_8_BY_13 );
374 textString( marker_xe + 3 * lenstr,
376 TextScale, GLUT_BITMAP_8_BY_13 );
380 } // Else read oriented right
381 } // End if modulo division by major interval is zero
382 } // End if major interval divisor non-zero
383 } // End if condition
384 } // End for range of i from vmin to vmax
385 } // End if VERTICAL SCALE TYPE
386 else { // Horizontal scale by default
388 if (draw_tick_left) {
389 drawOneLine( scrn_rect.left, scrn_rect.top,
390 scrn_rect.left, height);
391 } // endif draw_tick_left
393 if (draw_tick_right) {
394 drawOneLine( width, scrn_rect.top,
397 } // endif draw_tick_right
399 marker_ys = scrn_rect.top; // Starting point for
400 marker_ye = height; // tick y location calcs
402 marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
405 // glBegin(GL_LINES);
407 // glVertex2f( scrn_rect.left, scrn_rect.top);
408 // glVertex2f( scrn_rect.left, marker_ye);
411 // glVertex2f( marker_xe, scrn_rect.top);
412 // glVertex2f( marker_xe, marker_ye );
415 if( huds_top(options) ) {
416 if (draw_cap_bottom) {
418 drawOneLine( scrn_rect.left,
425 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
427 // drawOneLine( mid_scr.x, marker_ye,
428 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
429 // drawOneLine( mid_scr.x, marker_ye,
430 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
433 if(pointer_type=="fixed") {
434 glBegin(GL_LINE_STRIP);
435 glVertex2f( marker_xs - scrn_rect.bottom / 4, scrn_rect.top);
436 glVertex2f( marker_xs, marker_ye);
437 glVertex2f( marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
440 if(pointer_type=="moving") {
441 // Code for Moving type Pointer to be included.
447 if( huds_bottom(options) ) {
450 drawOneLine( scrn_rect.left, height,
455 marker_ys = height - scrn_rect.bottom / 2;
457 // drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
458 // scrn_rect.top + scrn_rect.bottom,
459 // mid_scr.x, marker_ys );
460 // drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
461 // scrn_rect.top + scrn_rect.bottom,
462 // mid_scr.x , marker_ys );
466 if(pointer_type=="fixed") {
467 glBegin(GL_LINE_STRIP);
468 glVertex2f( marker_xs + scrn_rect.bottom / 4, height);
469 glVertex2f( marker_xs, marker_ys );
470 glVertex2f( marker_xs - scrn_rect.bottom / 4, height);
473 if(pointer_type=="moving") {
474 // Code for Moving Type Pointer to be included.
481 // if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
482 // marker_xe = marker_ys;
483 // marker_ys = marker_ye;
484 // marker_ye = marker_xe;
487 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
489 // last = FloatToInt(vmax)+1;
490 // i = FloatToInt(vmin);
491 last = (int)vmax + 1;
493 for(; i <last ; i++ ) {
494 // for( i = (int)vmin; i <= (int)vmax; i++ ) {
495 // printf("<*> i = %d\n", i);
502 // printf("<**> i = %d\n", i);
504 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
505 marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
507 // if( (i%(int)div_min()) == 0 ) {
508 if( !(i%(int)div_min() )) {
509 // draw in ticks only if they aren't too close to the edge.
510 if((( marker_xs - 5) > scrn_rect.left ) &&
511 (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
513 if( huds_both(options) ) {
514 drawOneLine( marker_xs, scrn_rect.top,
515 marker_xs, marker_ys - 4);
516 drawOneLine( marker_xs, marker_ye + 4,
518 // glBegin(GL_LINES);
519 // glVertex2f( marker_xs, scrn_rect.top);
520 // glVertex2f( marker_xs, marker_ys - 4);
521 // glVertex2f( marker_xs, marker_ye + 4);
522 // glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
525 if( huds_top(options)) {
527 drawOneLine( marker_xs, marker_ys,
528 marker_xs, marker_ye - 4);
530 drawOneLine( marker_xs, marker_ys + 4,
531 marker_xs, marker_ye);
537 // printf("<***> i = %d\n", i);
539 // printf("i = %d\n", i);
540 // if( (i%(int)div_max())==0 ) {
541 if( !(i%(int)div_max()) ) {
545 disp_val += modulo();
547 disp_val = i % (int) modulo(); // ?????????
551 // printf("disp_val = %d\n", disp_val);
552 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
553 lenstr = sprintf( TextScale, "%d",
554 // (int)(disp_val * data_scaling() +.5));
555 FloatToInt(disp_val * data_scaling()/*+.5*/));
556 // Draw major ticks and text only if far enough from the edge.
557 if(( (marker_xs - 10)> scrn_rect.left ) &&
558 ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
559 if( huds_both(options) ) {
560 // drawOneLine( marker_xs, scrn_rect.top,
561 // marker_xs, marker_ys);
562 // drawOneLine( marker_xs, marker_ye,
563 // marker_xs, scrn_rect.top + scrn_rect.bottom);
564 glBegin(GL_LINE_STRIP);
565 glVertex2f( marker_xs, scrn_rect.top);
566 glVertex2f( marker_xs, marker_ye);
567 glVertex2f( marker_xs, height);
569 if( !huds_notext(options) ) {
570 textString ( marker_xs - 4 * lenstr,
572 TextScale, GLUT_BITMAP_8_BY_13 );
575 drawOneLine( marker_xs, marker_ys,
576 marker_xs, marker_ye );
577 if( !huds_notext(options)) {
578 if( huds_top(options) ) {
579 textString ( marker_xs - 4 * lenstr,
581 TextScale, GLUT_BITMAP_8_BY_13 );
583 textString( marker_xs - 4 * lenstr,
585 TextScale, GLUT_BITMAP_8_BY_13 );
592 // printf("<****> i = %d\n", i);