]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud_card.cxx
67ae34a7b14abc4cc6ba42814d4f444eaf6ff932
[flightgear.git] / src / Cockpit / hud_card.cxx
1
2 #include "hud.hxx"
3
4 #ifdef USE_HUD_TextList
5 #define textString( x , y, text, font )  TextString( text, x , y )
6 #else
7 #define textString( x , y, text, font )  puDrawString ( guiFnt, text, x, y );
8 #endif
9
10 //========== Top of hud_card class member definitions =============
11
12 hud_card ::
13 hud_card( int       x,
14           int       y,
15           UINT      width,
16           UINT      height,
17           FLTFNPTR  data_source,
18           UINT      options,
19           float    max_value, // 360
20           float    min_value, // 0
21           float    disp_scaling,
22           UINT      major_divs,
23           UINT      minor_divs,
24           UINT      modulus,  // 360
25           int       dp_showing,
26           float    value_span,
27           bool      working) :
28                 instr_scale( x,y,width,height,
29                              data_source, options,
30                              value_span,
31                              max_value, min_value, disp_scaling,
32                              major_divs, minor_divs, modulus,
33                              working),
34                 val_span   ( value_span)
35 {
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;
45 }
46
47 hud_card ::
48 ~hud_card() { }
49
50 hud_card ::
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)
55 {
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;
64 }
65
66 hud_card & hud_card ::
67 operator = (const hud_card & rhs )
68 {
69   if( !( this == &rhs)){
70     instr_scale::operator = (rhs);
71     val_span = rhs.val_span;
72     half_width_units = rhs.half_width_units;
73     }
74   return *this;
75 }
76
77 // $$$ begin - added, VS Renganathan, 13 Oct 2K
78 #ifdef FIGHTER_HUD
79 void hud_card ::
80 draw( void ) //  (HUD_scale * pscale )
81 {
82   float vmin, vmax;
83   int marker_xs;
84   int marker_xe;
85   int marker_ys;
86   int marker_ye;
87   int lenstr;
88   int height, width;
89   int i, last;
90   char TextScale[80];
91   bool condition;
92   int disp_val = 0;
93   POINT mid_scr    = get_centroid();
94   float cur_value  = get_value();
95   RECT   scrn_rect = get_location();
96   UINT options     = get_options();
97
98   height = scrn_rect.top  + scrn_rect.bottom;
99   width = scrn_rect.left + scrn_rect.right;
100
101   vmin = cur_value - half_width_units; // width units == needle travel
102   vmax = cur_value + half_width_units; // or picture unit span.
103   
104   // Draw the basic markings for the scale...
105   
106   if( huds_vert(options) ) { // Vertical scale
107 //    drawOneLine( scrn_rect.left,     // Bottom tick bar
108 //                 scrn_rect.top,
109 //                 width,
110 //                 scrn_rect.top);
111
112 //    drawOneLine( scrn_rect.left,    // Top tick bar
113 //                 height,
114 //                 width,
115 //                 height );
116       
117       marker_xs = scrn_rect.left;  // x start
118       marker_xe = width;  // x extent
119       marker_ye = height;
120
121 //    glBegin(GL_LINES);
122       
123       // Bottom tick bar
124 //    glVertex2f( marker_xs, scrn_rect.top);
125 //    glVertex2f( marker_xe, scrn_rect.top);
126
127       // Top tick bar
128 //    glVertex2f( marker_xs, marker_ye);
129 //    glVertex2f( marker_xe, marker_ye );
130 //    glEnd();
131
132     // We do not use else in the following so that combining the two
133     // options produces a "caged" display with double carrots. The
134     // same is done for horizontal card indicators.
135
136       if( huds_left(options) ) {    // Calculate x marker offset
137 //          drawOneLine( marker_xe, scrn_rect.top,
138 //                       marker_xe, marker_ye); // Cap right side
139
140         marker_xs  = marker_xe - scrn_rect.right / 3;   // Adjust tick xs
141                                                       // Indicator carrot
142 //      drawOneLine( marker_xs, mid_scr.y,
143 //                   marker_xe, mid_scr.y + scrn_rect.right / 6);
144 //      drawOneLine( marker_xs, mid_scr.y,
145 //                   marker_xe, mid_scr.y - scrn_rect.right / 6);
146
147         glBegin(GL_LINE_STRIP);
148         glVertex2f( 10+marker_xe, mid_scr.y + scrn_rect.right / 6);
149         glVertex2f( 10+marker_xs, mid_scr.y);
150         glVertex2f( 10+marker_xe, mid_scr.y - scrn_rect.right / 6);
151         glEnd();
152     }
153     if( huds_right(options) ) {  // We'll default this for now.
154 //        drawOneLine( scrn_rect.left, scrn_rect.top,
155 //                     scrn_rect.left, marker_ye );  // Cap left side
156
157         marker_xe = scrn_rect.left + scrn_rect.right / 3;     // Adjust tick xe
158                                                        // Indicator carrot
159 //      drawOneLine( scrn_rect.left, mid_scr.y +  scrn_rect.right / 6,
160 //                   marker_xe, mid_scr.y );
161 //      drawOneLine( scrn_rect.left, mid_scr.y -  scrn_rect.right / 6,
162 //                   marker_xe, mid_scr.y);
163         glBegin(GL_LINE_STRIP);
164         glVertex2f( -10+scrn_rect.left, mid_scr.y +  scrn_rect.right / 6);
165         glVertex2f( -10+marker_xe, mid_scr.y );
166         glVertex2f( -10+scrn_rect.left, mid_scr.y -  scrn_rect.right / 6);
167         glEnd();
168     }
169
170     // At this point marker x_start and x_end values are transposed.
171     // To keep this from confusing things they are now interchanged.
172     if(huds_both(options)) {
173       marker_ye = marker_xs;
174       marker_xs = marker_xe;
175       marker_xe = marker_ye;
176       }
177
178     // Work through from bottom to top of scale. Calculating where to put
179     // minor and major ticks.
180
181 //  last = FloatToInt(vmax)+1;
182 //  i = FloatToInt(vmin);
183     last = (int)vmax + 1;
184     i = (int)vmin;
185     for( ; i <last ; i++ )
186     {
187
188       condition = true;
189       if( !modulo()) {
190         if( i < min_val()) {
191           condition = false;
192           }
193         }
194
195       if( condition ) {  // Show a tick if necessary
196                          // Calculate the location of this tick
197         marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
198 //        marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
199         // Block calculation artifact from drawing ticks below min coordinate.
200         // Calculation here accounts for text height.
201
202         if(( marker_ys < (scrn_rect.top + 4)) |
203            ( marker_ys > (height - 4))) {
204             // Magic numbers!!!
205           continue;
206           }
207         if( div_min()) {
208 //          if( (i%div_min()) == 0) {
209           if( !(i%(int)div_min())) {            
210             if((( marker_ys - 5) > scrn_rect.top ) &&
211                (( marker_ys + 5) < (height))){
212               if( huds_both(options) ) {
213                 drawOneLine( scrn_rect.left, marker_ys,
214                              marker_xs,      marker_ys );
215                 drawOneLine( marker_xe,      marker_ys,
216                              width,  marker_ys );
217 //                glBegin(GL_LINES);
218 //                glVertex2f( scrn_rect.left, marker_ys );
219 //                glVertex2f( marker_xs,      marker_ys );
220 //                glVertex2f( marker_xe,      marker_ys);
221 //                glVertex2f( scrn_rect.left + scrn_rect.right,  marker_ys );
222 //                glEnd();
223                   }
224               else {
225                 if( huds_left(options) ) {
226                   drawOneLine( marker_xs + 4, marker_ys,
227                                marker_xe,     marker_ys );
228                   }
229                 else {
230                   drawOneLine( marker_xs,     marker_ys,
231                                marker_xe - 4, marker_ys );
232                   }
233                 }
234               }
235             }
236           }
237         if( div_max() ) {
238           if( !(i%(int)div_max()) )         
239           {
240             if(modulo()) {
241                 if( disp_val < 0) {
242                     while(disp_val < 0)
243                         disp_val += modulo();
244 //              } else {
245 //                  disp_val = i % (int)modulo();
246                 }
247                 disp_val = i % (int) modulo(); // ?????????
248             } else {
249                 disp_val = i;
250             }
251
252             lenstr = sprintf( TextScale, "%d",
253                               FloatToInt(disp_val * data_scaling()/*+.5*/));
254 //                            (int)(disp_val  * data_scaling() +.5));
255             if(( (marker_ys - 8 ) > scrn_rect.top ) &&
256                ( (marker_ys + 8) < (height))){
257               if( huds_both(options) ) {
258 //                drawOneLine( scrn_rect.left, marker_ys,
259 //                             marker_xs,      marker_ys);
260 //                drawOneLine( marker_xs, marker_ys,
261 //                             scrn_rect.left + scrn_rect.right,
262 //                             marker_ys);
263                   glBegin(GL_LINE_STRIP);
264                   glVertex2f( scrn_rect.left, marker_ys );
265                   glVertex2f( marker_xs, marker_ys);
266                   glVertex2f( width, marker_ys);
267                   glEnd();
268                   if( !huds_notext(options)) {
269                       textString ( marker_xs + 2,  marker_ys,
270                                    TextScale,  GLUT_BITMAP_8_BY_13 );
271                   }
272               }
273               else {
274                 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
275                 if( !huds_notext(options) ) {
276                   if( huds_left(options) )              {
277                       textString( marker_xs -  8 * lenstr - 2,
278                                   marker_ys - 4,
279                                   TextScale, GLUT_BITMAP_8_BY_13 );
280                     }
281                   else  {
282                       textString( marker_xe + 3 * lenstr,
283                                   marker_ys - 4,
284                                   TextScale, GLUT_BITMAP_8_BY_13 );
285                   }
286                   }
287                 }
288               } // Else read oriented right
289             } // End if modulo division by major interval is zero
290           }  // End if major interval divisor non-zero
291         } // End if condition
292       } // End for range of i from vmin to vmax
293     }  // End if VERTICAL SCALE TYPE
294   else {                                // Horizontal scale by default
295 // commented
296       // left tick bar
297 //      drawOneLine( scrn_rect.left, scrn_rect.top,
298 //                   scrn_rect.left, height);
299
300       // right tick bar
301 //      drawOneLine( width, scrn_rect.top,
302 //                 width,
303 //                 height );
304       
305       marker_ys = scrn_rect.top;           // Starting point for
306       marker_ye = height;                  // tick y location calcs
307       marker_xe = width;
308
309 //    glBegin(GL_LINES);
310       // left tick bar
311 //    glVertex2f( scrn_rect.left, scrn_rect.top);
312 //    glVertex2f( scrn_rect.left, marker_ye);
313
314       // right tick bar
315 //    glVertex2f( marker_xe, scrn_rect.top);
316 //    glVertex2f( marker_xe, marker_ye );
317 //    glEnd();
318
319     if( huds_top(options) ) {
320         // Bottom box line
321 // commented 
322 //        drawOneLine( scrn_rect.left,
323 //                     scrn_rect.top,
324 //                     width,
325 //                     scrn_rect.top);
326
327         // Tick point adjust
328         marker_ye  = scrn_rect.top + scrn_rect.bottom / 2;
329         
330         // Bottom arrow
331 //      drawOneLine( mid_scr.x, marker_ye,
332 //                   mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
333 //      drawOneLine( mid_scr.x, marker_ye,
334 //                   mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
335
336 // commented
337 //        glBegin(GL_LINE_STRIP);
338 //        glVertex2f( mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
339 //        glVertex2f( mid_scr.x, marker_ye);
340 //        glVertex2f( mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
341 //        glEnd();
342
343     }
344     if( huds_bottom(options) ) {
345         // Top box line
346         drawOneLine( scrn_rect.left, height,
347                      width, height);
348         // Tick point adjust
349         marker_ys = height - scrn_rect.bottom  / 2;
350         
351         // Top arrow
352 //      drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
353 //                   scrn_rect.top + scrn_rect.bottom,
354 //                   mid_scr.x, marker_ys );
355 //      drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
356 //                   scrn_rect.top + scrn_rect.bottom,
357 //                   mid_scr.x , marker_ys );
358         glBegin(GL_LINE_STRIP);
359         glVertex2f( mid_scr.x + scrn_rect.bottom / 4,
360                     height);
361         glVertex2f( mid_scr.x , marker_ys );
362         glVertex2f( mid_scr.x - scrn_rect.bottom / 4,
363                     height);
364         glEnd();
365     }
366
367 //    if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
368 //      marker_xe = marker_ys;
369 //      marker_ys = marker_ye;
370 //      marker_ye = marker_xe;
371 //      }
372
373     // printf("vmin = %d  vmax = %d\n", (int)vmin, (int)vmax);
374
375 //  last = FloatToInt(vmax)+1;
376 //  i    = FloatToInt(vmin);
377     last = (int)vmax + 1;
378     i = (int)vmin;
379     for(; i <last ; i++ )      {
380 //    for( i = (int)vmin; i <= (int)vmax; i++ )     {
381       // printf("<*> i = %d\n", i);
382       condition = true;
383       if( !modulo()) {
384         if( i < min_val()) {
385           condition = false;
386           }
387         }
388       // printf("<**> i = %d\n", i);
389       if( condition )        {
390 //        marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
391         marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
392         if( div_min()){
393 //          if( (i%(int)div_min()) == 0 ) {
394           if( !(i%(int)div_min() )) {           
395             // draw in ticks only if they aren't too close to the edge.
396             if((( marker_xs - 5) > scrn_rect.left ) &&
397                (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
398
399               if( huds_both(options) ) {
400                 drawOneLine( marker_xs, scrn_rect.top,
401                              marker_xs, marker_ys - 4);
402                 drawOneLine( marker_xs, marker_ye + 4,
403                              marker_xs, height);
404 //                glBegin(GL_LINES);
405 //                glVertex2f( marker_xs, scrn_rect.top);
406 //                glVertex2f( marker_xs, marker_ys - 4);
407 //                glVertex2f( marker_xs, marker_ye + 4);
408 //                glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
409 //                glEnd();
410               }
411               else {
412                 if( huds_top(options)) {
413                 // draw minor ticks
414                   drawOneLine( marker_xs, marker_ys,
415                                marker_xs, marker_ye - 4);
416 //  patch for  angled deck heading
417                     if (i == 352) {
418                        glBegin(GL_POLYGON);
419                          glVertex2f( marker_xs, marker_ys+16);
420                          glVertex2f( marker_xs+2, marker_ys+13);
421                          glVertex2f( marker_xs, marker_ys+10);
422                          glVertex2f( marker_xs-2, marker_ys+13);
423                        glEnd();
424                     }
425                   }
426                 else {
427                   drawOneLine( marker_xs, marker_ys + 4,
428                                marker_xs, marker_ye);
429                   }
430                 }
431               }
432             }
433           }
434     // printf("<***> i = %d\n", i);
435         if( div_max()) {
436       // printf("i = %d\n", i);
437 //          if( (i%(int)div_max())==0 ) {
438           if( !(i%(int)div_max()) ) {           
439             if(modulo()) {
440               if( disp_val < 0) {
441                   while(disp_val<0)
442                       disp_val += modulo();
443               }
444               disp_val = i % (int) modulo(); // ?????????
445             } else {
446               disp_val = i;
447             }
448         // printf("disp_val = %d\n", disp_val);
449         // printf("%d\n", (int)(disp_val  * (double)data_scaling() + 0.5));
450             lenstr = sprintf( TextScale, "%d",
451 //                            (int)(disp_val  * data_scaling() +.5));
452                               FloatToInt(disp_val * data_scaling()/*+.5*/));
453             // Draw major ticks and text only if far enough from the edge.
454             if(( (marker_xs - 10)> scrn_rect.left ) &&
455                ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
456               if( huds_both(options) ) {
457 //                drawOneLine( marker_xs, scrn_rect.top,
458 //                             marker_xs, marker_ys);
459 //                drawOneLine( marker_xs, marker_ye,
460 //                             marker_xs, scrn_rect.top + scrn_rect.bottom);
461                   glBegin(GL_LINE_STRIP);
462                   glVertex2f( marker_xs, scrn_rect.top);
463                   glVertex2f( marker_xs, marker_ye);
464                   glVertex2f( marker_xs, height);
465                   glEnd();
466                 if( !huds_notext(options) ) {
467                   textString ( marker_xs - 4 * lenstr,
468                                marker_ys + 4,
469                                TextScale,  GLUT_BITMAP_8_BY_13 );
470                   }
471                 }
472               else {
473                 // draw major ticks
474                 drawOneLine( marker_xs, marker_ys,
475                              marker_xs, marker_ye );
476                 if( !huds_notext(options)) {
477                   if( huds_top(options) )              {
478                     textString ( marker_xs - 4 * lenstr,
479                                  height - 10,
480                                  TextScale, GLUT_BITMAP_8_BY_13 );
481                     }
482                   else  {
483                     textString( marker_xs - 4 * lenstr,
484                                 scrn_rect.top,
485                                 TextScale, GLUT_BITMAP_8_BY_13 );
486                     }
487                   }
488                 }
489               }
490             }
491       }//if(condition)  
492     // printf("<****> i = %d\n", i);
493           } //if(divmax)
494       } //if(!modulo)
495     } //for
496 } //draw
497
498 #else
499 //$$$ end - VS Renganathan, 13 Oct 2K
500
501 void hud_card ::
502 draw( void ) //  (HUD_scale * pscale )
503 {
504   float vmin, vmax;
505   int marker_xs;
506   int marker_xe;
507   int marker_ys;
508   int marker_ye;
509   int lenstr;
510   int height, width;
511   int i, last;
512   char TextScale[80];
513   bool condition;
514   int disp_val = 0;
515   POINT mid_scr    = get_centroid();
516   float cur_value  = get_value();
517   RECT   scrn_rect = get_location();
518   UINT options     = get_options();
519
520   height = scrn_rect.top  + scrn_rect.bottom;
521   width = scrn_rect.left + scrn_rect.right;
522
523   vmin = cur_value - half_width_units; // width units == needle travel
524   vmax = cur_value + half_width_units; // or picture unit span.
525   
526   // Draw the basic markings for the scale...
527   
528   if( huds_vert(options) ) { // Vertical scale
529     drawOneLine( scrn_rect.left,     // Bottom tick bar
530                  scrn_rect.top,
531                  width,
532                  scrn_rect.top);
533
534     drawOneLine( scrn_rect.left,    // Top tick bar
535                  height,
536                  width,
537                  height );
538       
539       marker_xs = scrn_rect.left;  // x start
540       marker_xe = width;  // x extent
541       marker_ye = height;
542
543 //    glBegin(GL_LINES);
544       
545       // Bottom tick bar
546 //    glVertex2f( marker_xs, scrn_rect.top);
547 //    glVertex2f( marker_xe, scrn_rect.top);
548
549       // Top tick bar
550 //    glVertex2f( marker_xs, marker_ye);
551 //    glVertex2f( marker_xe, marker_ye );
552 //    glEnd();
553
554     // We do not use else in the following so that combining the two
555     // options produces a "caged" display with double carrots. The
556     // same is done for horizontal card indicators.
557
558       if( huds_left(options) ) {    // Calculate x marker offset
559           drawOneLine( marker_xe, scrn_rect.top,
560                        marker_xe, marker_ye); // Cap right side
561
562         marker_xs  = marker_xe - scrn_rect.right / 3;   // Adjust tick xs
563                                                       // Indicator carrot
564 //      drawOneLine( marker_xs, mid_scr.y,
565 //                   marker_xe, mid_scr.y + scrn_rect.right / 6);
566 //      drawOneLine( marker_xs, mid_scr.y,
567 //                   marker_xe, mid_scr.y - scrn_rect.right / 6);
568
569         glBegin(GL_LINE_STRIP);
570         glVertex2f( marker_xe, mid_scr.y + scrn_rect.right / 6);
571         glVertex2f( marker_xs, mid_scr.y);
572         glVertex2f( marker_xe, mid_scr.y - scrn_rect.right / 6);
573         glEnd();
574     }
575     if( huds_right(options) ) {  // We'll default this for now.
576         drawOneLine( scrn_rect.left, scrn_rect.top,
577                      scrn_rect.left, marker_ye );  // Cap left side
578
579         marker_xe = scrn_rect.left + scrn_rect.right / 3;     // Adjust tick xe
580                                                        // Indicator carrot
581 //      drawOneLine( scrn_rect.left, mid_scr.y +  scrn_rect.right / 6,
582 //                   marker_xe, mid_scr.y );
583 //      drawOneLine( scrn_rect.left, mid_scr.y -  scrn_rect.right / 6,
584 //                   marker_xe, mid_scr.y);
585         glBegin(GL_LINE_STRIP);
586         glVertex2f( scrn_rect.left, mid_scr.y +  scrn_rect.right / 6);
587         glVertex2f( marker_xe, mid_scr.y );
588         glVertex2f( scrn_rect.left, mid_scr.y -  scrn_rect.right / 6);
589         glEnd();
590     }
591
592     // At this point marker x_start and x_end values are transposed.
593     // To keep this from confusing things they are now interchanged.
594     if(huds_both(options)) {
595       marker_ye = marker_xs;
596       marker_xs = marker_xe;
597       marker_xe = marker_ye;
598       }
599
600     // Work through from bottom to top of scale. Calculating where to put
601     // minor and major ticks.
602
603 //  last = FloatToInt(vmax)+1;
604 //  i = FloatToInt(vmin);
605     last = (int)vmax + 1;
606     i = (int)vmin;
607     for( ; i <last ; i++ )
608     {
609       condition = true;
610       if( !modulo()) {
611         if( i < min_val()) {
612           condition = false;
613           }
614         }
615
616       if( condition ) {  // Show a tick if necessary
617                          // Calculate the location of this tick
618         marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
619 //        marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
620         // Block calculation artifact from drawing ticks below min coordinate.
621         // Calculation here accounts for text height.
622
623         if(( marker_ys < (scrn_rect.top + 4)) |
624            ( marker_ys > (height - 4))) {
625             // Magic numbers!!!
626           continue;
627           }
628         if( div_min()) {
629 //          if( (i%div_min()) == 0) {
630           if( !(i%(int)div_min())) {            
631             if((( marker_ys - 5) > scrn_rect.top ) &&
632                (( marker_ys + 5) < (height))){
633               if( huds_both(options) ) {
634                 drawOneLine( scrn_rect.left, marker_ys,
635                              marker_xs,      marker_ys );
636                 drawOneLine( marker_xe,      marker_ys,
637                              width,  marker_ys );
638 //                glBegin(GL_LINES);
639 //                glVertex2f( scrn_rect.left, marker_ys );
640 //                glVertex2f( marker_xs,      marker_ys );
641 //                glVertex2f( marker_xe,      marker_ys);
642 //                glVertex2f( scrn_rect.left + scrn_rect.right,  marker_ys );
643 //                glEnd();
644                   }
645               else {
646                 if( huds_left(options) ) {
647                   drawOneLine( marker_xs + 4, marker_ys,
648                                marker_xe,     marker_ys );
649                   }
650                 else {
651                   drawOneLine( marker_xs,     marker_ys,
652                                marker_xe - 4, marker_ys );
653                   }
654                 }
655               }
656             }
657           }
658         if( div_max() ) {
659           if( !(i%(int)div_max()) )         
660           {
661             if(modulo()) {
662                 if( disp_val < 0) {
663                     while(disp_val < 0)
664                         disp_val += modulo();
665 //              } else {
666 //                  disp_val = i % (int)modulo();
667                 }
668                 disp_val = i % (int) modulo(); // ?????????
669             } else {
670                 disp_val = i;
671             }
672
673             lenstr = sprintf( TextScale, "%d",
674                               FloatToInt(disp_val * data_scaling()/*+.5*/));
675 //                            (int)(disp_val  * data_scaling() +.5));
676             if(( (marker_ys - 8 ) > scrn_rect.top ) &&
677                ( (marker_ys + 8) < (height))){
678               if( huds_both(options) ) {
679 //                drawOneLine( scrn_rect.left, marker_ys,
680 //                             marker_xs,      marker_ys);
681 //                drawOneLine( marker_xs, marker_ys,
682 //                             scrn_rect.left + scrn_rect.right,
683 //                             marker_ys);
684                   glBegin(GL_LINE_STRIP);
685                   glVertex2f( scrn_rect.left, marker_ys );
686                   glVertex2f( marker_xs, marker_ys);
687                   glVertex2f( width, marker_ys);
688                   glEnd();
689                   if( !huds_notext(options)) {
690                       textString ( marker_xs + 2,  marker_ys,
691                                    TextScale,  GLUT_BITMAP_8_BY_13 );
692                   }
693               }
694               else {
695                 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
696                 if( !huds_notext(options) ) {
697                   if( huds_left(options) )              {
698                       textString( marker_xs -  8 * lenstr - 2,
699                                   marker_ys - 4,
700                                   TextScale, GLUT_BITMAP_8_BY_13 );
701                     }
702                   else  {
703                       textString( marker_xe + 3 * lenstr,
704                                   marker_ys - 4,
705                                   TextScale, GLUT_BITMAP_8_BY_13 );
706                   }
707                   }
708                 }
709               } // Else read oriented right
710             } // End if modulo division by major interval is zero
711           }  // End if major interval divisor non-zero
712         } // End if condition
713       } // End for range of i from vmin to vmax
714     }  // End if VERTICAL SCALE TYPE
715   else {                                // Horizontal scale by default
716       // left tick bar
717       drawOneLine( scrn_rect.left, scrn_rect.top,
718                    scrn_rect.left, height);
719
720       // right tick bar
721       drawOneLine( width, scrn_rect.top,
722                  width,
723                  height );
724       
725       marker_ys = scrn_rect.top;           // Starting point for
726       marker_ye = height;                  // tick y location calcs
727       marker_xe = width;
728
729 //    glBegin(GL_LINES);
730       // left tick bar
731 //    glVertex2f( scrn_rect.left, scrn_rect.top);
732 //    glVertex2f( scrn_rect.left, marker_ye);
733
734       // right tick bar
735 //    glVertex2f( marker_xe, scrn_rect.top);
736 //    glVertex2f( marker_xe, marker_ye );
737 //    glEnd();
738
739     if( huds_top(options) ) {
740         // Bottom box line
741         drawOneLine( scrn_rect.left,
742                      scrn_rect.top,
743                      width,
744                      scrn_rect.top);
745
746         // Tick point adjust
747         marker_ye  = scrn_rect.top + scrn_rect.bottom / 2;
748         
749         // Bottom arrow
750 //      drawOneLine( mid_scr.x, marker_ye,
751 //                   mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
752 //      drawOneLine( mid_scr.x, marker_ye,
753 //                   mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
754
755         glBegin(GL_LINE_STRIP);
756         glVertex2f( mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
757         glVertex2f( mid_scr.x, marker_ye);
758         glVertex2f( mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
759         glEnd();
760     }
761     if( huds_bottom(options) ) {
762         // Top box line
763         drawOneLine( scrn_rect.left, height,
764                      width, height);
765         // Tick point adjust
766         marker_ys = height - scrn_rect.bottom  / 2;
767         
768         // Top arrow
769 //      drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
770 //                   scrn_rect.top + scrn_rect.bottom,
771 //                   mid_scr.x, marker_ys );
772 //      drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
773 //                   scrn_rect.top + scrn_rect.bottom,
774 //                   mid_scr.x , marker_ys );
775         glBegin(GL_LINE_STRIP);
776         glVertex2f( mid_scr.x + scrn_rect.bottom / 4,
777                     height);
778         glVertex2f( mid_scr.x , marker_ys );
779         glVertex2f( mid_scr.x - scrn_rect.bottom / 4,
780                     height);
781         glEnd();
782     }
783
784 //    if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
785 //      marker_xe = marker_ys;
786 //      marker_ys = marker_ye;
787 //      marker_ye = marker_xe;
788 //      }
789
790     // printf("vmin = %d  vmax = %d\n", (int)vmin, (int)vmax);
791
792 //  last = FloatToInt(vmax)+1;
793 //  i    = FloatToInt(vmin);
794     last = (int)vmax + 1;
795     i = (int)vmin;
796     for(; i <last ; i++ )      {
797 //    for( i = (int)vmin; i <= (int)vmax; i++ )     {
798       // printf("<*> i = %d\n", i);
799       condition = true;
800       if( !modulo()) {
801         if( i < min_val()) {
802           condition = false;
803           }
804         }
805       // printf("<**> i = %d\n", i);
806       if( condition )        {
807 //        marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
808         marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
809         if( div_min()){
810 //          if( (i%(int)div_min()) == 0 ) {
811           if( !(i%(int)div_min() )) {           
812             // draw in ticks only if they aren't too close to the edge.
813             if((( marker_xs - 5) > scrn_rect.left ) &&
814                (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
815
816               if( huds_both(options) ) {
817                 drawOneLine( marker_xs, scrn_rect.top,
818                              marker_xs, marker_ys - 4);
819                 drawOneLine( marker_xs, marker_ye + 4,
820                              marker_xs, height);
821 //                glBegin(GL_LINES);
822 //                glVertex2f( marker_xs, scrn_rect.top);
823 //                glVertex2f( marker_xs, marker_ys - 4);
824 //                glVertex2f( marker_xs, marker_ye + 4);
825 //                glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
826 //                glEnd();
827               }
828               else {
829                 if( huds_top(options)) {
830                   drawOneLine( marker_xs, marker_ys,
831                                marker_xs, marker_ye - 4);
832                   }
833                 else {
834                   drawOneLine( marker_xs, marker_ys + 4,
835                                marker_xs, marker_ye);
836                   }
837                 }
838               }
839             }
840           }
841     // printf("<***> i = %d\n", i);
842         if( div_max()) {
843       // printf("i = %d\n", i);
844 //          if( (i%(int)div_max())==0 ) {
845           if( !(i%(int)div_max()) ) {           
846             if(modulo()) {
847               if( disp_val < 0) {
848                   while(disp_val<0)
849                       disp_val += modulo();
850               }
851               disp_val = i % (int) modulo(); // ?????????
852             } else {
853               disp_val = i;
854             }
855         // printf("disp_val = %d\n", disp_val);
856         // printf("%d\n", (int)(disp_val  * (double)data_scaling() + 0.5));
857             lenstr = sprintf( TextScale, "%d",
858 //                            (int)(disp_val  * data_scaling() +.5));
859                               FloatToInt(disp_val * data_scaling()/*+.5*/));
860             // Draw major ticks and text only if far enough from the edge.
861             if(( (marker_xs - 10)> scrn_rect.left ) &&
862                ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
863               if( huds_both(options) ) {
864 //                drawOneLine( marker_xs, scrn_rect.top,
865 //                             marker_xs, marker_ys);
866 //                drawOneLine( marker_xs, marker_ye,
867 //                             marker_xs, scrn_rect.top + scrn_rect.bottom);
868                   glBegin(GL_LINE_STRIP);
869                   glVertex2f( marker_xs, scrn_rect.top);
870                   glVertex2f( marker_xs, marker_ye);
871                   glVertex2f( marker_xs, height);
872                   glEnd();
873                 if( !huds_notext(options) ) {
874                   textString ( marker_xs - 4 * lenstr,
875                                marker_ys + 4,
876                                TextScale,  GLUT_BITMAP_8_BY_13 );
877                   }
878                 }
879               else {
880                 drawOneLine( marker_xs, marker_ys,
881                              marker_xs, marker_ye );
882                 if( !huds_notext(options)) {
883                   if( huds_top(options) )              {
884                     textString ( marker_xs - 4 * lenstr,
885                                  height - 10,
886                                  TextScale, GLUT_BITMAP_8_BY_13 );
887                     }
888                   else  {
889                     textString( marker_xs - 4 * lenstr,
890                                 scrn_rect.top,
891                                 TextScale, GLUT_BITMAP_8_BY_13 );
892                     }
893                   }
894                 }
895               }
896             }
897       }
898     // printf("<****> i = %d\n", i);
899         }
900       }
901     }
902 }
903
904 #endif