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
28 instr_scale( x,y,width,height,
31 max_value, min_value, disp_scaling,
32 major_divs, minor_divs, modulus,
34 val_span ( value_span)
36 half_width_units = range_to_show() / 2.0;
37 // UINT options = get_options();
38 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
39 // huds_right = options & HUDS_RIGHT;
40 // huds_left = options & HUDS_LEFT;
41 // huds_vert = options & HUDS_VERT;
42 // huds_notext = options & HUDS_NOTEXT;
43 // huds_top = options & HUDS_TOP;
44 // huds_bottom = options & HUDS_BOTTOM;
51 hud_card( const hud_card & image):
52 instr_scale( (const instr_scale & ) image),
53 val_span( image.val_span),
54 half_width_units (image.half_width_units)
56 // UINT options = get_options();
57 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
58 // huds_right = options & HUDS_RIGHT;
59 // huds_left = options & HUDS_LEFT;
60 // huds_vert = options & HUDS_VERT;
61 // huds_notext = options & HUDS_NOTEXT;
62 // huds_top = options & HUDS_TOP;
63 // huds_bottom = options & HUDS_BOTTOM;
66 hud_card & hud_card ::
67 operator = (const hud_card & rhs )
69 if( !( this == &rhs)){
70 instr_scale::operator = (rhs);
71 val_span = rhs.val_span;
72 half_width_units = rhs.half_width_units;
78 draw( void ) // (HUD_scale * pscale )
91 POINT mid_scr = get_centroid();
92 float cur_value = get_value();
93 RECT scrn_rect = get_location();
94 UINT options = get_options();
96 height = scrn_rect.top + scrn_rect.bottom;
97 width = scrn_rect.left + scrn_rect.right;
99 vmin = cur_value - half_width_units; // width units == needle travel
100 vmax = cur_value + half_width_units; // or picture unit span.
102 // Draw the basic markings for the scale...
104 if( huds_vert(options) ) { // Vertical scale
105 drawOneLine( scrn_rect.left, // Bottom tick bar
110 drawOneLine( scrn_rect.left, // Top tick bar
115 marker_xs = scrn_rect.left; // x start
116 marker_xe = width; // x extent
119 // glBegin(GL_LINES);
122 // glVertex2f( marker_xs, scrn_rect.top);
123 // glVertex2f( marker_xe, scrn_rect.top);
126 // glVertex2f( marker_xs, marker_ye);
127 // glVertex2f( marker_xe, marker_ye );
130 // We do not use else in the following so that combining the two
131 // options produces a "caged" display with double carrots. The
132 // same is done for horizontal card indicators.
134 if( huds_left(options) ) { // Calculate x marker offset
135 drawOneLine( marker_xe, scrn_rect.top,
136 marker_xe, marker_ye); // Cap right side
138 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
140 // drawOneLine( marker_xs, mid_scr.y,
141 // marker_xe, mid_scr.y + scrn_rect.right / 6);
142 // drawOneLine( marker_xs, mid_scr.y,
143 // marker_xe, mid_scr.y - scrn_rect.right / 6);
145 glBegin(GL_LINE_STRIP);
146 glVertex2f( marker_xe, mid_scr.y + scrn_rect.right / 6);
147 glVertex2f( marker_xs, mid_scr.y);
148 glVertex2f( marker_xe, mid_scr.y - scrn_rect.right / 6);
151 if( huds_right(options) ) { // We'll default this for now.
152 drawOneLine( scrn_rect.left, scrn_rect.top,
153 scrn_rect.left, marker_ye ); // Cap left side
155 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
157 // drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
158 // marker_xe, mid_scr.y );
159 // drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
160 // marker_xe, mid_scr.y);
161 glBegin(GL_LINE_STRIP);
162 glVertex2f( scrn_rect.left, mid_scr.y + scrn_rect.right / 6);
163 glVertex2f( marker_xe, mid_scr.y );
164 glVertex2f( scrn_rect.left, mid_scr.y - scrn_rect.right / 6);
168 // At this point marker x_start and x_end values are transposed.
169 // To keep this from confusing things they are now interchanged.
170 if(huds_both(options)) {
171 marker_ye = marker_xs;
172 marker_xs = marker_xe;
173 marker_xe = marker_ye;
176 // Work through from bottom to top of scale. Calculating where to put
177 // minor and major ticks.
179 // last = FloatToInt(vmax)+1;
180 // i = FloatToInt(vmin);
181 last = (int)vmax + 1;
183 for( ; i <last ; i++ )
192 if( condition ) { // Show a tick if necessary
193 // Calculate the location of this tick
194 marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
195 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
196 // Block calculation artifact from drawing ticks below min coordinate.
197 // Calculation here accounts for text height.
199 if(( marker_ys < (scrn_rect.top + 4)) |
200 ( marker_ys > (height - 4))) {
205 // if( (i%div_min()) == 0) {
206 if( !(i%(int)div_min())) {
207 if((( marker_ys - 5) > scrn_rect.top ) &&
208 (( marker_ys + 5) < (height))){
209 if( huds_both(options) ) {
210 drawOneLine( scrn_rect.left, marker_ys,
211 marker_xs, marker_ys );
212 drawOneLine( marker_xe, marker_ys,
214 // glBegin(GL_LINES);
215 // glVertex2f( scrn_rect.left, marker_ys );
216 // glVertex2f( marker_xs, marker_ys );
217 // glVertex2f( marker_xe, marker_ys);
218 // glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
222 if( huds_left(options) ) {
223 drawOneLine( marker_xs + 4, marker_ys,
224 marker_xe, marker_ys );
227 drawOneLine( marker_xs, marker_ys,
228 marker_xe - 4, marker_ys );
235 if( !(i%(int)div_max()) )
240 disp_val += modulo();
242 // disp_val = i % (int)modulo();
244 disp_val = i % (int) modulo(); // ?????????
249 lenstr = sprintf( TextScale, "%d",
250 FloatToInt(disp_val * data_scaling()/*+.5*/));
251 // (int)(disp_val * data_scaling() +.5));
252 if(( (marker_ys - 8 ) > scrn_rect.top ) &&
253 ( (marker_ys + 8) < (height))){
254 if( huds_both(options) ) {
255 // drawOneLine( scrn_rect.left, marker_ys,
256 // marker_xs, marker_ys);
257 // drawOneLine( marker_xs, marker_ys,
258 // scrn_rect.left + scrn_rect.right,
260 glBegin(GL_LINE_STRIP);
261 glVertex2f( scrn_rect.left, marker_ys );
262 glVertex2f( marker_xs, marker_ys);
263 glVertex2f( width, marker_ys);
265 if( !huds_notext(options)) {
266 textString ( marker_xs + 2, marker_ys,
267 TextScale, GLUT_BITMAP_8_BY_13 );
271 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
272 if( !huds_notext(options) ) {
273 if( huds_left(options) ) {
274 textString( marker_xs - 8 * lenstr - 2,
276 TextScale, GLUT_BITMAP_8_BY_13 );
279 textString( marker_xe + 3 * lenstr,
281 TextScale, GLUT_BITMAP_8_BY_13 );
285 } // Else read oriented right
286 } // End if modulo division by major interval is zero
287 } // End if major interval divisor non-zero
288 } // End if condition
289 } // End for range of i from vmin to vmax
290 } // End if VERTICAL SCALE TYPE
291 else { // Horizontal scale by default
293 drawOneLine( scrn_rect.left, scrn_rect.top,
294 scrn_rect.left, height);
297 drawOneLine( width, scrn_rect.top,
301 marker_ys = scrn_rect.top; // Starting point for
302 marker_ye = height; // tick y location calcs
305 // glBegin(GL_LINES);
307 // glVertex2f( scrn_rect.left, scrn_rect.top);
308 // glVertex2f( scrn_rect.left, marker_ye);
311 // glVertex2f( marker_xe, scrn_rect.top);
312 // glVertex2f( marker_xe, marker_ye );
315 if( huds_top(options) ) {
317 drawOneLine( scrn_rect.left,
323 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
326 // drawOneLine( mid_scr.x, marker_ye,
327 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
328 // drawOneLine( mid_scr.x, marker_ye,
329 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
331 glBegin(GL_LINE_STRIP);
332 glVertex2f( mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
333 glVertex2f( mid_scr.x, marker_ye);
334 glVertex2f( mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
337 if( huds_bottom(options) ) {
339 drawOneLine( scrn_rect.left, height,
342 marker_ys = height - scrn_rect.bottom / 2;
345 // drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
346 // scrn_rect.top + scrn_rect.bottom,
347 // mid_scr.x, marker_ys );
348 // drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
349 // scrn_rect.top + scrn_rect.bottom,
350 // mid_scr.x , marker_ys );
351 glBegin(GL_LINE_STRIP);
352 glVertex2f( mid_scr.x + scrn_rect.bottom / 4,
354 glVertex2f( mid_scr.x , marker_ys );
355 glVertex2f( mid_scr.x - scrn_rect.bottom / 4,
360 // if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
361 // marker_xe = marker_ys;
362 // marker_ys = marker_ye;
363 // marker_ye = marker_xe;
366 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
368 // last = FloatToInt(vmax)+1;
369 // i = FloatToInt(vmin);
370 last = (int)vmax + 1;
372 for(; i <last ; i++ ) {
373 // for( i = (int)vmin; i <= (int)vmax; i++ ) {
374 // printf("<*> i = %d\n", i);
381 // printf("<**> i = %d\n", i);
383 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
384 marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
386 // if( (i%(int)div_min()) == 0 ) {
387 if( !(i%(int)div_min() )) {
388 // draw in ticks only if they aren't too close to the edge.
389 if((( marker_xs - 5) > scrn_rect.left ) &&
390 (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
392 if( huds_both(options) ) {
393 drawOneLine( marker_xs, scrn_rect.top,
394 marker_xs, marker_ys - 4);
395 drawOneLine( marker_xs, marker_ye + 4,
397 // glBegin(GL_LINES);
398 // glVertex2f( marker_xs, scrn_rect.top);
399 // glVertex2f( marker_xs, marker_ys - 4);
400 // glVertex2f( marker_xs, marker_ye + 4);
401 // glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
405 if( huds_top(options)) {
406 drawOneLine( marker_xs, marker_ys,
407 marker_xs, marker_ye - 4);
410 drawOneLine( marker_xs, marker_ys + 4,
411 marker_xs, marker_ye);
417 // printf("<***> i = %d\n", i);
419 // printf("i = %d\n", i);
420 // if( (i%(int)div_max())==0 ) {
421 if( !(i%(int)div_max()) ) {
425 disp_val += modulo();
427 disp_val = i % (int) modulo(); // ?????????
431 // printf("disp_val = %d\n", disp_val);
432 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
433 lenstr = sprintf( TextScale, "%d",
434 // (int)(disp_val * data_scaling() +.5));
435 FloatToInt(disp_val * data_scaling()/*+.5*/));
436 // Draw major ticks and text only if far enough from the edge.
437 if(( (marker_xs - 10)> scrn_rect.left ) &&
438 ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
439 if( huds_both(options) ) {
440 // drawOneLine( marker_xs, scrn_rect.top,
441 // marker_xs, marker_ys);
442 // drawOneLine( marker_xs, marker_ye,
443 // marker_xs, scrn_rect.top + scrn_rect.bottom);
444 glBegin(GL_LINE_STRIP);
445 glVertex2f( marker_xs, scrn_rect.top);
446 glVertex2f( marker_xs, marker_ye);
447 glVertex2f( marker_xs, height);
449 if( !huds_notext(options) ) {
450 textString ( marker_xs - 4 * lenstr,
452 TextScale, GLUT_BITMAP_8_BY_13 );
456 drawOneLine( marker_xs, marker_ys,
457 marker_xs, marker_ye );
458 if( !huds_notext(options)) {
459 if( huds_top(options) ) {
460 textString ( marker_xs - 4 * lenstr,
462 TextScale, GLUT_BITMAP_8_BY_13 );
465 textString( marker_xs - 4 * lenstr,
467 TextScale, GLUT_BITMAP_8_BY_13 );
474 // printf("<****> i = %d\n", i);