4 #ifdef USE_HUD_TextList
5 #define textString( x , y, text, font,digit) TextString( text, x , y ,digit ) //suma
7 #define textString( x , y, text, font,digit ) puDrawString ( guiFnt, text, x, y ); //suma
10 //========== Top of hud_card class member definitions =============
26 float max_value, // 360
46 string type_tick,//hud
47 string length_tick,//hud
53 instr_scale( x,y,width,height,
56 max_value, min_value, disp_scaling,
57 major_divs, minor_divs, modulus,
59 val_span ( value_span),
61 draw_tick_bottom (tick_bottom),
62 draw_tick_top (tick_top),
63 draw_tick_right (tick_right),
64 draw_tick_left (tick_left),
65 draw_cap_bottom (cap_bottom),
66 draw_cap_top (cap_top),
67 draw_cap_right (cap_right),
68 draw_cap_left (cap_left),
69 marker_offset (mark_offset),
70 pointer (pointer_enable),
71 pointer_type (type_pointer),
72 tick_type (type_tick), //hud
73 tick_length (length_tick), //hud
74 Maj_div (major_divs), //suma
75 Min_div (minor_divs) //suma
78 half_width_units = range_to_show() / 2.0;
80 maxValue=max_value; //suma
81 minValue=min_value; //suma
82 divisions=divs; //suma
85 // UINT options = get_options();
86 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
87 // huds_right = options & HUDS_RIGHT;
88 // huds_left = options & HUDS_LEFT;
89 // huds_vert = options & HUDS_VERT;
90 // huds_notext = options & HUDS_NOTEXT;
91 // huds_top = options & HUDS_TOP;
92 // huds_bottom = options & HUDS_BOTTOM;
99 hud_card( const hud_card & image):
100 instr_scale( (const instr_scale & ) image),
101 val_span( image.val_span),
103 half_width_units (image.half_width_units),
104 draw_tick_bottom (image.draw_tick_bottom),
105 draw_tick_top (image.draw_tick_top),
106 draw_tick_right (image.draw_tick_right),
107 draw_tick_left (image.draw_tick_left),
108 draw_cap_bottom (image.draw_cap_bottom),
109 draw_cap_top (image.draw_cap_top),
110 draw_cap_right (image.draw_cap_right),
111 draw_cap_left (image.draw_cap_left),
112 marker_offset (image.marker_offset),
113 pointer (image.pointer),
114 pointer_type (image.pointer_type),
115 tick_type(image.tick_type), //hud
116 tick_length(image.tick_length), //hud
117 Maj_div(image.Maj_div), //suma
118 Min_div(image.Min_div)//suma
121 // UINT options = get_options();
122 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
123 // huds_right = options & HUDS_RIGHT;
124 // huds_left = options & HUDS_LEFT;
125 // huds_vert = options & HUDS_VERT;
126 // huds_notext = options & HUDS_NOTEXT;
127 // huds_top = options & HUDS_TOP;
128 // huds_bottom = options & HUDS_BOTTOM;
131 hud_card & hud_card ::
132 operator = (const hud_card & rhs )
134 if( !( this == &rhs)){
135 instr_scale::operator = (rhs);
136 val_span = rhs.val_span;
137 half_width_units = rhs.half_width_units;
138 draw_tick_bottom = rhs.draw_tick_bottom;
139 draw_tick_top = rhs.draw_tick_top;
140 draw_tick_right = rhs.draw_tick_right;
141 draw_tick_left = rhs.draw_tick_left;
142 draw_cap_bottom = rhs.draw_cap_bottom;
143 draw_cap_top = rhs.draw_cap_top;
144 draw_cap_right = rhs.draw_cap_right;
145 draw_cap_left = rhs.draw_cap_left;
146 marker_offset = rhs.marker_offset;
148 pointer = rhs.pointer;
149 pointer_type = rhs.pointer_type;
150 tick_type = rhs.tick_type;
151 tick_length = rhs.tick_length;
152 Maj_div = rhs.Maj_div; //suma
153 Min_div = rhs.Min_div; //suma
161 draw( void ) // (HUD_scale * pscale )
164 float vmin = 0.0, vmax = 0.0;
169 int text_x = 0, text_y = 0;
176 int oddtype, k; //odd or even values for ticks
178 POINT mid_scr = get_centroid();
179 float cur_value = get_value();
181 if (!((int)maxValue%2) )
182 oddtype =0; //draw ticks at even values
184 oddtype = 1;//draw ticks at odd values
186 RECT scrn_rect = get_location();
187 UINT options = get_options();
189 height = scrn_rect.top + scrn_rect.bottom;
190 width = scrn_rect.left + scrn_rect.right;
193 // if type=gauge then display dial
198 y=(float)(scrn_rect.top);
199 x=(float)(scrn_rect.left);
200 glEnable(GL_POINT_SMOOTH);
203 float incr= 360.0/divisions;
204 for(i=0.0;i<360.0;i+=incr) {
205 float i1=i*SGD_DEGREES_TO_RADIANS;
206 float x1=x+radius*cos(i1);
207 float y1=y+radius*sin(i1);
214 glDisable(GL_POINT_SMOOTH);
217 if(data_available()) {
218 float offset = 90.0*SGD_DEGREES_TO_RADIANS;
219 float r1=10.0; //size of carrot
220 float theta= get_value();
222 float theta1= -theta*SGD_DEGREES_TO_RADIANS+offset;
223 float x1=x+radius*cos(theta1);
224 float y1=y+radius*sin(theta1);
225 float x2=x1-r1*cos(theta1-30.0*SGD_DEGREES_TO_RADIANS);
226 float y2=y1-r1*sin(theta1-30.0*SGD_DEGREES_TO_RADIANS);
227 float x3=x1-r1*cos(theta1+30.0*SGD_DEGREES_TO_RADIANS);
228 float y3=y1-r1*sin(theta1+30.0*SGD_DEGREES_TO_RADIANS);
231 drawOneLine(x1,y1,x2,y2);
232 drawOneLine(x1,y1,x3,y3);
233 sprintf(TextScale,"%3.1f\n",theta);
236 int l = abs((int)theta);
239 textString (x,y,TextScale,GLUT_BITMAP_8_BY_13,0 );
241 textString (x-1.0,y,TextScale,GLUT_BITMAP_8_BY_13,0 );
243 textString (x-2.0,y,TextScale,GLUT_BITMAP_8_BY_13,0 );
250 // if its not explicitly a gauge default to tape
252 if(pointer_type=="moving") {
257 vmin = cur_value - half_width_units; // width units == needle travel
258 vmax = cur_value + half_width_units; // or picture unit span.
263 vmin = cur_value - half_width_units; // width units == needle travel
264 vmax = cur_value + half_width_units; // or picture unit span.
269 // Draw the basic markings for the scale...
271 if( huds_vert(options) ) { // Vertical scale
272 if (draw_tick_bottom) {
273 drawOneLine( scrn_rect.left, // Bottom tick bar
277 } // endif draw_tick_bottom
279 drawOneLine( scrn_rect.left, // Top tick bar
283 } // endif draw_tick_top
285 marker_xs = scrn_rect.left; // x start
286 marker_xe = width; // x extent
289 // glBegin(GL_LINES);
292 // glVertex2f( marker_xs, scrn_rect.top);
293 // glVertex2f( marker_xe, scrn_rect.top);
296 // glVertex2f( marker_xs, marker_ye);
297 // glVertex2f( marker_xe, marker_ye );
301 // We do not use else in the following so that combining the
302 // two options produces a "caged" display with double
303 // carrots. The same is done for horizontal card indicators.
305 // begin vertical/left
306 //First draw capping lines and pointers
307 if( huds_left(options) ) { // Calculate x marker offset
309 if (draw_cap_right) {
311 drawOneLine( marker_xe, scrn_rect.top,
312 marker_xe, marker_ye); // Cap right side
315 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
317 // drawOneLine( marker_xs, mid_scr.y,
318 // marker_xe, mid_scr.y + scrn_rect.right / 6);
319 // drawOneLine( marker_xs, mid_scr.y,
320 // marker_xe, mid_scr.y - scrn_rect.right / 6);
324 if(pointer_type=="moving") {
326 //Code for Moving Type Pointer included by suma.
327 float ycentre, ypoint,xpoint;
329 if(cur_value > maxValue) cur_value = maxValue;
330 if(cur_value < minValue) cur_value = minValue;
332 ycentre = scrn_rect.top;
333 else if (maxValue + minValue == 0.0)
337 ycentre = scrn_rect.top + (1.0-minValue)*scrn_rect.bottom/(maxValue-minValue);
339 ycentre = scrn_rect.top + minValue*scrn_rect.bottom/(maxValue-minValue);
340 range = scrn_rect.bottom;
341 wth = scrn_rect.left + scrn_rect.right;
343 ypoint = ycentre + ((cur_value-1.0) * range / val_span);
345 ypoint = ycentre + (cur_value * range / val_span);
346 xpoint = wth + marker_offset;
347 drawOneLine(xpoint,ycentre,xpoint,ypoint);
348 drawOneLine(xpoint,ypoint,xpoint-marker_offset,ypoint);
349 drawOneLine(xpoint-marker_offset,ypoint,xpoint-5.0,ypoint+5.0);
350 drawOneLine(xpoint-marker_offset,ypoint,xpoint-5.0,ypoint-5.0);
354 fixed(marker_offset+marker_xe, text_y + scrn_rect.right / 6,
355 marker_offset+marker_xs, text_y,marker_offset+marker_xe,
356 text_y - scrn_rect.right / 6);
360 } //end vertical/left
362 // begin vertical/right
363 //First draw capping lines and pointers
364 if( huds_right(options) ) { // We'll default this for now.
366 drawOneLine( scrn_rect.left, scrn_rect.top,
367 scrn_rect.left, marker_ye ); // Cap left side
370 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
372 // drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
373 // marker_xe, mid_scr.y );
374 // drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
375 // marker_xe, mid_scr.y);
379 if(pointer_type=="moving") {
381 //type-fixed & zoom=1, behaviour to be defined
382 // Code for Moving Type Pointer included by suma.
383 float ycentre, ypoint,xpoint;
386 if(cur_value > maxValue)
387 cur_value = maxValue;
388 if(cur_value < minValue)
389 cur_value = minValue;
392 ycentre = scrn_rect.top;
393 else if (maxValue + minValue == 0.0)
397 ycentre = scrn_rect.top + (1.0-minValue)*scrn_rect.bottom/(maxValue-minValue);
399 ycentre = scrn_rect.top + minValue*scrn_rect.bottom/(maxValue-minValue);
400 range = scrn_rect.bottom;
403 ypoint = ycentre + ((cur_value-1.0) * range / val_span);
405 ypoint = ycentre + (cur_value * range / val_span);
406 xpoint = scrn_rect.left - marker_offset;
407 drawOneLine(xpoint,ycentre,xpoint,ypoint);
408 drawOneLine(xpoint,ypoint,xpoint+marker_offset,ypoint);
409 drawOneLine(xpoint+marker_offset,ypoint,xpoint+5.0,ypoint+5.0);
410 drawOneLine(xpoint+marker_offset,ypoint,xpoint+5.0,ypoint-5.0);
414 fixed( -marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6,
415 -marker_offset+marker_xe, text_y,-marker_offset+scrn_rect.left,
416 text_y - scrn_rect.right / 6);
419 } //end vertical/right
421 // At this point marker x_start and x_end values are transposed.
422 // To keep this from confusing things they are now interchanged.
423 if(huds_both(options)) {
424 marker_ye = marker_xs;
425 marker_xs = marker_xe;
426 marker_xe = marker_ye;
429 // Work through from bottom to top of scale. Calculating where to put
430 // minor and major ticks.
432 // draw scale or tape
434 // last = FloatToInt(vmax)+1;
435 // i = FloatToInt(vmin);
436 last = (int)vmax + 1; // N
440 zoomed_scale(vmin,vmax); //suma
442 for( ; i <last ; i++ ) {
450 if( condition ) { // Show a tick if necessary
451 // Calculate the location of this tick
452 marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
453 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
454 // Block calculation artifact from drawing ticks below min coordinate.
455 // Calculation here accounts for text height.
457 if(( marker_ys < (scrn_rect.top + 4)) |
458 ( marker_ys > (height - 4)))
465 k = i+1; //enable ticks at odd values
471 // if( (i%div_min()) == 0) {
472 if( !(k%(int)div_min())) {
473 if((( marker_ys - 5) > scrn_rect.top ) &&
474 (( marker_ys + 5) < (height))) {
476 //vertical/left OR vertical/right
477 if( huds_both(options) ) {
478 if(tick_type=="line") {
479 if(tick_length=="variable") {
480 drawOneLine( scrn_rect.left, marker_ys,
481 marker_xs, marker_ys );
482 drawOneLine( marker_xe, marker_ys,
485 drawOneLine( scrn_rect.left, marker_ys,
486 marker_xs, marker_ys );
487 drawOneLine( marker_xe, marker_ys,
490 } else if(tick_type=="circle") // begin suma this func. is written below
491 circles(scrn_rect.left,(float)marker_ys,3.0); //end suma
494 // if neither line nor circle draw default as line
495 drawOneLine( scrn_rect.left, marker_ys,
496 marker_xs, marker_ys );
497 drawOneLine( marker_xe, marker_ys,
500 // glBegin(GL_LINES);
501 // glVertex2f( scrn_rect.left, marker_ys );
502 // glVertex2f( marker_xs, marker_ys );
503 // glVertex2f( marker_xe, marker_ys);
504 // glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
506 // anything other than huds_both
508 if( huds_left(options) ) {
509 if(tick_type=="line") {
510 if(tick_length=="variable") {
511 drawOneLine( marker_xs + 4, marker_ys,
512 marker_xe, marker_ys );
514 drawOneLine( marker_xs , marker_ys,
515 marker_xe, marker_ys );
517 } else if(tick_type=="circle") // begin suma
518 circles((float)marker_xs + 4, (float)marker_ys,3.0); //end suma
521 drawOneLine( marker_xs + 4, marker_ys,
522 marker_xe, marker_ys );
525 if(tick_type=="line") {
526 if(tick_length=="variable") {
527 drawOneLine( marker_xs, marker_ys,
528 marker_xe - 4, marker_ys );
530 drawOneLine( marker_xs, marker_ys,
531 marker_xe , marker_ys );
533 } else if(tick_type=="circle") //begin suma
534 circles((float)marker_xe - 4, (float)marker_ys,3.0); //end suma
536 drawOneLine( marker_xs, marker_ys,
537 marker_xe - 4, marker_ys );
542 } //end draw minor ticks
548 if( !(k%(int)div_max()) ) {
550 disp_val = i % (int) modulo(); // ?????????
553 disp_val += modulo();
559 lenstr = sprintf( TextScale, "%d",
560 FloatToInt(disp_val * data_scaling()/*+.5*/));
561 // (int)(disp_val * data_scaling() +.5));
562 /* if(( (marker_ys - 8 ) > scrn_rect.top ) &&
563 ( (marker_ys + 8) < (height))){ */ //suma
565 if( huds_both(options) ) {
566 // drawOneLine( scrn_rect.left, marker_ys,
567 // marker_xs, marker_ys);
568 // drawOneLine( marker_xs, marker_ys,
569 // scrn_rect.left + scrn_rect.right,
571 if(tick_type=="line") {
572 glBegin(GL_LINE_STRIP);
573 glVertex2f( scrn_rect.left, marker_ys );
574 glVertex2f( marker_xs, marker_ys);
575 glVertex2f( width, marker_ys);
577 } else if(tick_type=="circle") //begin suma
578 circles(scrn_rect.left, (float)marker_ys,5.0); //end suma
580 glBegin(GL_LINE_STRIP);
581 glVertex2f( scrn_rect.left, marker_ys );
582 glVertex2f( marker_xs, marker_ys);
583 glVertex2f( width, marker_ys);
587 if( !huds_notext(options)) {
588 textString ( marker_xs + 2, marker_ys,
589 TextScale, GLUT_BITMAP_8_BY_13,0 );
593 /* Changes are made to draw a circle when tick_type="circle" */
594 // anything other than huds_both
595 if(tick_type=="line") {
596 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
597 } else if(tick_type=="circle")
598 circles((float)marker_xs + 4, (float)marker_ys,5.0);//end suma
600 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
602 if( !huds_notext(options) ) {
603 if( huds_left(options) ) {
604 textString( marker_xs - 8 * lenstr - 2,
606 TextScale, GLUT_BITMAP_8_BY_13,0 );
608 textString( marker_xe + 3 * lenstr,
610 TextScale, GLUT_BITMAP_8_BY_13,0 );
612 } //End if !huds_notext
614 } // End if draw major ticks
615 } // End if major ticks
619 // End if VERTICAL SCALE TYPE (tape loop yet to be closed)
621 // Horizontal scale by default
623 if (draw_tick_left) {
624 drawOneLine( scrn_rect.left, scrn_rect.top,
625 scrn_rect.left, height);
626 } // endif draw_tick_left
628 if (draw_tick_right) {
629 drawOneLine( width, scrn_rect.top,
632 } // endif draw_tick_right
634 marker_ys = scrn_rect.top; // Starting point for
635 marker_ye = height; // tick y location calcs
637 marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
640 // glBegin(GL_LINES);
642 // glVertex2f( scrn_rect.left, scrn_rect.top);
643 // glVertex2f( scrn_rect.left, marker_ye);
646 // glVertex2f( marker_xe, scrn_rect.top);
647 // glVertex2f( marker_xe, marker_ye );
650 if( huds_top(options) ) {
651 if (draw_cap_bottom) {
653 drawOneLine( scrn_rect.left,
660 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
662 // drawOneLine( mid_scr.x, marker_ye,
663 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
664 // drawOneLine( mid_scr.x, marker_ye,
665 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
668 if(pointer_type=="moving") {
670 //Code for Moving Type Pointer included by suma.
671 // static float xcentre,xpoint,ypoint;
673 if(cur_value > maxValue) cur_value = maxValue;
674 if(cur_value < minValue) cur_value = minValue;
675 float xcentre = mid_scr.x;
676 int range = scrn_rect.right;
677 float xpoint = xcentre + (cur_value * range / val_span);
678 float ypoint = scrn_rect.top - marker_offset;
679 drawOneLine(xcentre, ypoint,xpoint,ypoint);
680 drawOneLine(xpoint,ypoint,xpoint,ypoint+marker_offset);
681 drawOneLine(xpoint,ypoint+marker_offset,xpoint+5.0,ypoint+5.0);
682 drawOneLine(xpoint,ypoint+marker_offset,xpoint-5.0,ypoint+5.0);
686 fixed( marker_xs - scrn_rect.bottom / 4, scrn_rect.top,
687 marker_xs, marker_ye, marker_xs + scrn_rect.bottom / 4,scrn_rect.top);
690 } //End Horizontal scale/top
692 if( huds_bottom(options) ) {
695 drawOneLine( scrn_rect.left, height,
700 marker_ys = height - scrn_rect.bottom / 2;
702 // drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
703 // scrn_rect.top + scrn_rect.bottom,
704 // mid_scr.x, marker_ys );
705 // drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
706 // scrn_rect.top + scrn_rect.bottom,
707 // mid_scr.x , marker_ys );
711 if(pointer_type=="moving") {
713 //Code for Moving Type Pointer included by suma.
714 // static float xcentre,xpoint,ypoint;
715 // static int range,hgt;
716 if(cur_value > maxValue) cur_value = maxValue;
717 if(cur_value < minValue) cur_value = minValue;
718 float xcentre = mid_scr.x ;
719 int range = scrn_rect.right;
720 int hgt = scrn_rect.top + scrn_rect.bottom;
721 float xpoint = xcentre + (cur_value * range / val_span);
722 float ypoint = hgt + marker_offset;
723 drawOneLine(xcentre, ypoint,xpoint,ypoint);
724 drawOneLine(xpoint,ypoint,xpoint,ypoint-marker_offset);
725 drawOneLine(xpoint,ypoint-marker_offset,xpoint+5.0,ypoint-5.0);
726 drawOneLine(xpoint,ypoint-marker_offset,xpoint-5.0,ypoint-5.0);
729 fixed( marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
730 marker_xs - scrn_rect.bottom / 4, height);
733 } //end horizontal scale bottom
735 // if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
736 // marker_xe = marker_ys;
737 // marker_ys = marker_ye;
738 // marker_ye = marker_xe;
741 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
743 // last = FloatToInt(vmax)+1;
744 // i = FloatToInt(vmin);
747 zoomed_scale(vmin,vmax); //suma
750 last = (int)vmax + 1;
752 for(; i <last ; i++ ) {
753 // for( i = (int)vmin; i <= (int)vmax; i++ ) {
754 // printf("<*> i = %d\n", i);
761 // printf("<**> i = %d\n", i);
763 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
764 marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
767 k = i+1; //enable ticks at odd values
772 // if( (i%(int)div_min()) == 0 ) {
774 if( !(k%(int)div_min() )) {
775 // draw in ticks only if they aren't too close to the edge.
776 if((( marker_xs - 5) > scrn_rect.left ) &&
777 (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
779 if( huds_both(options) ) {
780 if(tick_length=="variable") {
781 drawOneLine( marker_xs, scrn_rect.top,
782 marker_xs, marker_ys - 4);
783 drawOneLine( marker_xs, marker_ye + 4,
786 drawOneLine( marker_xs, scrn_rect.top,
787 marker_xs, marker_ys);
788 drawOneLine( marker_xs, marker_ye,
791 // glBegin(GL_LINES);
792 // glVertex2f( marker_xs, scrn_rect.top);
793 // glVertex2f( marker_xs, marker_ys - 4);
794 // glVertex2f( marker_xs, marker_ye + 4);
795 // glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
798 if( huds_top(options)) {
800 if(tick_length=="variable")
801 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye-4);
803 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye);
805 if(tick_length=="variable")
806 drawOneLine(marker_xs,marker_ys+4,marker_xs,marker_ye);
808 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye);
811 } //end draw minor ticks
815 // printf("i = %d\n", i);
816 // if( (i%(int)div_max())==0 ) {
818 if( !(k%(int)div_max()) ) {
820 disp_val = i % (int) modulo(); // ?????????
823 disp_val += modulo();
828 // printf("disp_val = %d\n", disp_val);
829 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
830 lenstr = sprintf( TextScale, "%d",
831 // (int)(disp_val * data_scaling() +.5));
832 FloatToInt(disp_val * data_scaling()/*+.5*/));
833 // Draw major ticks and text only if far enough from the edge.
834 if(( (marker_xs - 10)> scrn_rect.left ) &&
835 ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
836 if( huds_both(options) ) {
837 // drawOneLine( marker_xs, scrn_rect.top,
838 // marker_xs, marker_ys);
839 // drawOneLine( marker_xs, marker_ye,
840 // marker_xs, scrn_rect.top + scrn_rect.bottom);
841 glBegin(GL_LINE_STRIP);
842 glVertex2f( marker_xs, scrn_rect.top);
843 glVertex2f( marker_xs, marker_ye);
844 glVertex2f( marker_xs, height);
846 if( !huds_notext(options) ) {
847 textString ( marker_xs - 4 * lenstr,
849 TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
852 drawOneLine( marker_xs, marker_ys,
853 marker_xs, marker_ye );
854 if( !huds_notext(options)) {
855 if( huds_top(options) ) {
856 textString ( marker_xs - 4 * lenstr,
858 TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
860 textString( marker_xs - 4 * lenstr,
862 TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
867 } //end draw major ticks
868 } //endif major ticks
872 } //end horizontal/vertical scale
873 } // end of type tape
880 circles(float x,float y,float size)
882 glEnable(GL_POINT_SMOOTH);
890 glDisable(GL_POINT_SMOOTH);
896 fixed(float x1, float y1, float x2, float y2, float x3, float y3)
898 glBegin(GL_LINE_STRIP);
907 zoomed_scale(int first, int last)
910 POINT mid_scr = get_centroid();
911 RECT scrn_rect = get_location();
912 UINT options = get_options();
917 float x,y,w,h,bottom;
918 float cur_value=get_value();
919 if(cur_value > maxValue) cur_value = maxValue;
920 if(cur_value < minValue) cur_value = minValue;
924 while(first <= last) {
925 if((first % (int)Maj_div) == 0) {
934 if( huds_vert(options) ) {
938 w=scrn_rect.left+scrn_rect.right;
939 h=scrn_rect.top+scrn_rect.bottom;
940 bottom=scrn_rect.bottom;
942 float xstart, yfirst, ycentre, ysecond;
944 float hgt = bottom * 20.0 /100.0; // 60% of height should be zoomed
945 yfirst = mid_scr.y - hgt;
947 ysecond = mid_scr.y + hgt;
948 float range = hgt * 2;
951 float factor = range /10.0;
953 float hgt1 = bottom * 30.0 /100.0;
954 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
955 int incr = incrs / 2;
956 float factors = hgt1 / incr;
961 //this is for moving type pointer
962 static float ycent, ypoint,xpoint;
966 wth=scrn_rect.left+scrn_rect.right;
968 if(cur_value <= data[centre+1])
969 if(cur_value > data[centre]) {
970 ypoint = ycent + ((cur_value - data[centre]) * hgt/Maj_div);
973 if(cur_value >= data[centre-1])
974 if(cur_value <= data[centre]) {
975 ypoint = ycent - ((data[centre]-cur_value) * hgt/Maj_div);
978 if(cur_value < data[centre-1])
979 if(cur_value >= minValue) {
980 float diff = minValue - data[centre-1];
981 float diff1 = cur_value - data[centre-1];
982 float val = (diff1 * hgt1) / diff;
984 ypoint = ycent - hgt - val;
988 if(cur_value > data[centre+1])
989 if(cur_value <= maxValue) {
990 float diff = maxValue - data[centre+1];
991 float diff1 = cur_value - data[centre+1];
992 float val = (diff1 * hgt1) / diff;
994 ypoint = ycent + hgt + val;
997 if(huds_left(options)) {
1000 drawOneLine( xstart, ycentre, xstart - 5.0, ycentre); //centre tick
1002 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1004 if( !huds_notext(options)) {
1005 textString (x, ycentre, TextScale, GLUT_BITMAP_8_BY_13,0 );
1011 circles(xstart-2.5,yfirst, 3.0);
1012 circles(xstart-2.5,ycentre,3.0);
1015 yfirst = mid_scr.y - hgt;
1017 for(i=0;i<=incr;i++) {
1018 drawOneLine( xstart, yfirst, xstart - 5.0, yfirst);
1019 drawOneLine( xstart,ysecond, xstart - 5.0,ysecond);
1021 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1023 if( !huds_notext(options))
1024 textString (x, yfirst, TextScale, GLUT_BITMAP_8_BY_13,0 );
1026 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1028 if( !huds_notext(options))
1029 textString (x, ysecond, TextScale, GLUT_BITMAP_8_BY_13,0 );
1036 //to draw moving type pointer for left option
1038 xpoint = wth + 10.0;
1040 if(pointer_type == "moving") {
1041 drawOneLine(xpoint,ycent,xpoint,ypoint);
1042 drawOneLine(xpoint,ypoint,xpoint-10.0,ypoint);
1043 drawOneLine(xpoint-10.0,ypoint,xpoint-5.0,ypoint+5.0);
1044 drawOneLine(xpoint-10.0,ypoint,xpoint-5.0,ypoint-5.0);
1052 drawOneLine( xstart, ycentre, xstart + 5.0, ycentre); //centre tick
1054 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1056 if( !huds_notext(options)) {
1057 textString (w, ycentre, TextScale, GLUT_BITMAP_8_BY_13,0 );
1063 circles(xstart+2.5,yfirst, 3.0);
1064 circles(xstart+2.5,ycentre,3.0);
1067 yfirst = mid_scr.y - hgt;
1069 for(i=0;i<=incr;i++) {
1070 drawOneLine( xstart, yfirst, xstart + 5.0, yfirst);
1071 drawOneLine( xstart,ysecond, xstart + 5.0,ysecond);
1073 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1075 if( !huds_notext(options))
1076 textString (w, yfirst, TextScale, GLUT_BITMAP_8_BY_13,0 );
1078 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1080 if( !huds_notext(options))
1081 textString (w, ysecond, TextScale, GLUT_BITMAP_8_BY_13,0 );
1088 // to draw moving type pointer for right option
1090 xpoint = scrn_rect.left;
1092 if(pointer_type == "moving") {
1093 drawOneLine(xpoint,ycent,xpoint,ypoint);
1094 drawOneLine(xpoint,ypoint,xpoint+10.0,ypoint);
1095 drawOneLine(xpoint+10.0,ypoint,xpoint+5.0,ypoint+5.0);
1096 drawOneLine(xpoint+10.0,ypoint,xpoint+5.0,ypoint-5.0);
1099 }//end huds_right /left
1100 //end of vertical scale
1105 w=scrn_rect.left+scrn_rect.right;
1106 h=scrn_rect.top+scrn_rect.bottom;
1107 bottom=scrn_rect.right;
1109 float ystart, xfirst, xcentre, xsecond;
1111 float hgt = bottom * 20.0 /100.0; // 60% of height should be zoomed
1112 xfirst = mid_scr.x - hgt;
1113 xcentre = mid_scr.x;
1114 xsecond = mid_scr.x + hgt;
1115 float range = hgt * 2;
1118 float factor = range /10.0;
1120 float hgt1 = bottom * 30.0 /100.0;
1121 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
1122 int incr = incrs / 2;
1123 float factors = hgt1 / incr;
1126 //Code for Moving Type Pointer
1128 static float xcent,xpoint,ypoint;
1132 if(cur_value <= data[centre+1])
1133 if(cur_value > data[centre]) {
1134 xpoint = xcent + ((cur_value - data[centre]) * hgt/Maj_div);
1137 if(cur_value >= data[centre-1])
1138 if(cur_value <= data[centre]) {
1139 xpoint = xcent - ((data[centre]-cur_value) * hgt/Maj_div);
1142 if(cur_value < data[centre-1])
1143 if(cur_value >= minValue) {
1144 float diff = minValue - data[centre-1];
1145 float diff1 = cur_value - data[centre-1];
1146 float val = (diff1 * hgt1) / diff;
1148 xpoint = xcent - hgt - val;
1152 if(cur_value > data[centre+1])
1153 if(cur_value <= maxValue) {
1154 float diff = maxValue - data[centre+1];
1155 float diff1 = cur_value - data[centre+1];
1156 float val = (diff1 * hgt1) / diff;
1158 xpoint = xcent + hgt + val;
1162 if(huds_top(options)) {
1166 drawOneLine( xcentre, ystart, xcentre, ystart - 5.0); //centre tick
1168 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1170 if( !huds_notext(options)) {
1171 textString (xcentre-10.0, y, TextScale, GLUT_BITMAP_8_BY_13,0 );
1177 circles(xfirst, ystart-2.5, 3.0);
1178 circles(xcentre, ystart-2.5, 3.0);
1181 xfirst = mid_scr.x - hgt;
1183 for(i=0;i<=incr;i++) {
1184 drawOneLine( xfirst, ystart, xfirst, ystart - 5.0);
1185 drawOneLine( xsecond, ystart, xsecond, ystart - 5.0);
1187 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1189 if( !huds_notext(options))
1190 textString (xfirst-10.0, y, TextScale, GLUT_BITMAP_8_BY_13,0 );
1192 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1194 if( !huds_notext(options))
1195 textString (xsecond-10.0, y, TextScale, GLUT_BITMAP_8_BY_13,0 );
1202 //this is for moving pointer for top option
1205 ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
1207 if(pointer_type == "moving") {
1208 drawOneLine(xcent, ypoint,xpoint,ypoint);
1209 drawOneLine(xpoint,ypoint,xpoint,ypoint-10.0);
1210 drawOneLine(xpoint,ypoint-10.0,xpoint+5.0,ypoint-5.0);
1211 drawOneLine(xpoint,ypoint-10.0,xpoint-5.0,ypoint-5.0);
1218 //drawOneLine( xstart, yfirst, xstart - 5.0, yfirst );
1219 drawOneLine( xcentre, ystart, xcentre, ystart + 5.0); //centre tick
1221 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1223 if( !huds_notext(options)) {
1224 textString (xcentre-10.0, h, TextScale, GLUT_BITMAP_8_BY_13,0 );
1230 circles(xfirst, ystart+2.5, 3.0);
1231 circles(xcentre, ystart+2.5,3.0);
1234 xfirst = mid_scr.x - hgt;
1236 for(i=0;i<=incr;i++) {
1237 drawOneLine( xfirst, ystart, xfirst, ystart + 5.0);
1238 drawOneLine( xsecond,ystart, xsecond,ystart + 5.0);
1240 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1242 if( !huds_notext(options))
1243 textString (xfirst-10.0,h, TextScale, GLUT_BITMAP_8_BY_13,0 );
1245 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1247 if( !huds_notext(options))
1248 textString (xsecond-10.0,h, TextScale, GLUT_BITMAP_8_BY_13,0 );
1255 //this is for movimg pointer for bottom option
1258 ypoint = scrn_rect.top - 10.0;
1259 if(pointer_type == "moving") {
1260 drawOneLine(xcent, ypoint,xpoint,ypoint);
1261 drawOneLine(xpoint,ypoint,xpoint,ypoint+10.0);
1262 drawOneLine(xpoint,ypoint+10.0,xpoint+5.0,ypoint+5.0);
1263 drawOneLine(xpoint,ypoint+10.0,xpoint-5.0,ypoint+5.0);
1268 }//end hud_top or hud_bottom
1270 } //end of horizontal/vertical scales