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
197 y=(float)(scrn_rect.top);
198 x=(float)(scrn_rect.left);
199 glEnable(GL_POINT_SMOOTH);
202 float incr= 360.0/divisions;
203 for(i=0.0;i<360.0;i+=incr) {
204 float i1=i*SGD_DEGREES_TO_RADIANS;
205 float x1=x+radius*cos(i1);
206 float y1=y+radius*sin(i1);
213 glDisable(GL_POINT_SMOOTH);
216 if(data_available()) {
217 float offset = 90.0*SGD_DEGREES_TO_RADIANS;
218 float r1=10.0; //size of carrot
219 float theta= get_value();
221 float theta1= -theta*SGD_DEGREES_TO_RADIANS+offset;
222 float x1=x+radius*cos(theta1);
223 float y1=y+radius*sin(theta1);
224 float x2=x1-r1*cos(theta1-30.0*SGD_DEGREES_TO_RADIANS);
225 float y2=y1-r1*sin(theta1-30.0*SGD_DEGREES_TO_RADIANS);
226 float x3=x1-r1*cos(theta1+30.0*SGD_DEGREES_TO_RADIANS);
227 float y3=y1-r1*sin(theta1+30.0*SGD_DEGREES_TO_RADIANS);
230 drawOneLine(x1,y1,x2,y2);
231 drawOneLine(x1,y1,x3,y3);
232 sprintf(TextScale,"%3.1f\n",theta);
235 int l = abs((int)theta);
238 textString (x,y,TextScale,GLUT_BITMAP_8_BY_13,0 );
240 textString (x-1.0,y,TextScale,GLUT_BITMAP_8_BY_13,0 );
242 textString (x-2.0,y,TextScale,GLUT_BITMAP_8_BY_13,0 );
249 // if its not explicitly a gauge default to tape
251 if(pointer_type=="moving") {
256 vmin = cur_value - half_width_units; // width units == needle travel
257 vmax = cur_value + half_width_units; // or picture unit span.
262 vmin = cur_value - half_width_units; // width units == needle travel
263 vmax = cur_value + half_width_units; // or picture unit span.
268 // Draw the basic markings for the scale...
270 if( huds_vert(options) ) { // Vertical scale
271 if (draw_tick_bottom) {
272 drawOneLine( scrn_rect.left, // Bottom tick bar
276 } // endif draw_tick_bottom
278 drawOneLine( scrn_rect.left, // Top tick bar
282 } // endif draw_tick_top
284 marker_xs = scrn_rect.left; // x start
285 marker_xe = width; // x extent
288 // glBegin(GL_LINES);
291 // glVertex2f( marker_xs, scrn_rect.top);
292 // glVertex2f( marker_xe, scrn_rect.top);
295 // glVertex2f( marker_xs, marker_ye);
296 // glVertex2f( marker_xe, marker_ye );
300 // We do not use else in the following so that combining the
301 // two options produces a "caged" display with double
302 // carrots. The same is done for horizontal card indicators.
304 // begin vertical/left
305 //First draw capping lines and pointers
306 if( huds_left(options) ) { // Calculate x marker offset
308 if (draw_cap_right) {
310 drawOneLine( marker_xe, scrn_rect.top,
311 marker_xe, marker_ye); // Cap right side
314 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
316 // drawOneLine( marker_xs, mid_scr.y,
317 // marker_xe, mid_scr.y + scrn_rect.right / 6);
318 // drawOneLine( marker_xs, mid_scr.y,
319 // marker_xe, mid_scr.y - scrn_rect.right / 6);
323 if(pointer_type=="moving") {
325 //Code for Moving Type Pointer included by suma.
326 float ycentre, ypoint,xpoint;
328 if(cur_value > maxValue) cur_value = maxValue;
329 if(cur_value < minValue) cur_value = minValue;
331 ycentre = scrn_rect.top;
332 else if (maxValue + minValue == 0.0)
336 ycentre = scrn_rect.top + (1.0-minValue)*scrn_rect.bottom/(maxValue-minValue);
338 ycentre = scrn_rect.top + minValue*scrn_rect.bottom/(maxValue-minValue);
339 range = scrn_rect.bottom;
340 wth = scrn_rect.left + scrn_rect.right;
342 ypoint = ycentre + ((cur_value-1.0) * range / val_span);
344 ypoint = ycentre + (cur_value * range / val_span);
345 xpoint = wth + marker_offset;
346 drawOneLine(xpoint,ycentre,xpoint,ypoint);
347 drawOneLine(xpoint,ypoint,xpoint-marker_offset,ypoint);
348 drawOneLine(xpoint-marker_offset,ypoint,xpoint-5.0,ypoint+5.0);
349 drawOneLine(xpoint-marker_offset,ypoint,xpoint-5.0,ypoint-5.0);
353 fixed(marker_offset+marker_xe, text_y + scrn_rect.right / 6,
354 marker_offset+marker_xs, text_y,marker_offset+marker_xe,
355 text_y - scrn_rect.right / 6);
359 } //end vertical/left
361 // begin vertical/right
362 //First draw capping lines and pointers
363 if( huds_right(options) ) { // We'll default this for now.
365 drawOneLine( scrn_rect.left, scrn_rect.top,
366 scrn_rect.left, marker_ye ); // Cap left side
369 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
371 // drawOneLine( scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
372 // marker_xe, mid_scr.y );
373 // drawOneLine( scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
374 // marker_xe, mid_scr.y);
378 if(pointer_type=="moving") {
380 //type-fixed & zoom=1, behaviour to be defined
381 // Code for Moving Type Pointer included by suma.
382 float ycentre, ypoint,xpoint;
385 if(cur_value > maxValue)
386 cur_value = maxValue;
387 if(cur_value < minValue)
388 cur_value = minValue;
391 ycentre = scrn_rect.top;
392 else if (maxValue + minValue == 0.0)
396 ycentre = scrn_rect.top + (1.0-minValue)*scrn_rect.bottom/(maxValue-minValue);
398 ycentre = scrn_rect.top + minValue*scrn_rect.bottom/(maxValue-minValue);
399 range = scrn_rect.bottom;
402 ypoint = ycentre + ((cur_value-1.0) * range / val_span);
404 ypoint = ycentre + (cur_value * range / val_span);
405 xpoint = scrn_rect.left - marker_offset;
406 drawOneLine(xpoint,ycentre,xpoint,ypoint);
407 drawOneLine(xpoint,ypoint,xpoint+marker_offset,ypoint);
408 drawOneLine(xpoint+marker_offset,ypoint,xpoint+5.0,ypoint+5.0);
409 drawOneLine(xpoint+marker_offset,ypoint,xpoint+5.0,ypoint-5.0);
413 fixed( -marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6,
414 -marker_offset+marker_xe, text_y,-marker_offset+scrn_rect.left,
415 text_y - scrn_rect.right / 6);
418 } //end vertical/right
420 // At this point marker x_start and x_end values are transposed.
421 // To keep this from confusing things they are now interchanged.
422 if(huds_both(options)) {
423 marker_ye = marker_xs;
424 marker_xs = marker_xe;
425 marker_xe = marker_ye;
428 // Work through from bottom to top of scale. Calculating where to put
429 // minor and major ticks.
431 // draw scale or tape
433 // last = FloatToInt(vmax)+1;
434 // i = FloatToInt(vmin);
435 last = (int)vmax + 1; // N
439 zoomed_scale(vmin,vmax); //suma
441 for( ; i <last ; i++ ) {
449 if( condition ) { // Show a tick if necessary
450 // Calculate the location of this tick
451 marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
452 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
453 // Block calculation artifact from drawing ticks below min coordinate.
454 // Calculation here accounts for text height.
456 if(( marker_ys < (scrn_rect.top + 4)) |
457 ( marker_ys > (height - 4)))
464 k = i+1; //enable ticks at odd values
470 // if( (i%div_min()) == 0) {
471 if( !(k%(int)div_min())) {
472 if((( marker_ys - 5) > scrn_rect.top ) &&
473 (( marker_ys + 5) < (height))) {
475 //vertical/left OR vertical/right
476 if( huds_both(options) ) {
477 if(tick_type=="line") {
478 if(tick_length=="variable") {
479 drawOneLine( scrn_rect.left, marker_ys,
480 marker_xs, marker_ys );
481 drawOneLine( marker_xe, marker_ys,
484 drawOneLine( scrn_rect.left, marker_ys,
485 marker_xs, marker_ys );
486 drawOneLine( marker_xe, marker_ys,
489 } else if(tick_type=="circle") // begin suma this func. is written below
490 circles(scrn_rect.left,(float)marker_ys,3.0); //end suma
493 // if neither line nor circle draw default as line
494 drawOneLine( scrn_rect.left, marker_ys,
495 marker_xs, marker_ys );
496 drawOneLine( marker_xe, marker_ys,
499 // glBegin(GL_LINES);
500 // glVertex2f( scrn_rect.left, marker_ys );
501 // glVertex2f( marker_xs, marker_ys );
502 // glVertex2f( marker_xe, marker_ys);
503 // glVertex2f( scrn_rect.left + scrn_rect.right, marker_ys );
505 // anything other than huds_both
507 if( huds_left(options) ) {
508 if(tick_type=="line") {
509 if(tick_length=="variable") {
510 drawOneLine( marker_xs + 4, marker_ys,
511 marker_xe, marker_ys );
513 drawOneLine( marker_xs , marker_ys,
514 marker_xe, marker_ys );
516 } else if(tick_type=="circle") // begin suma
517 circles((float)marker_xs + 4, (float)marker_ys,3.0); //end suma
520 drawOneLine( marker_xs + 4, marker_ys,
521 marker_xe, marker_ys );
524 if(tick_type=="line") {
525 if(tick_length=="variable") {
526 drawOneLine( marker_xs, marker_ys,
527 marker_xe - 4, marker_ys );
529 drawOneLine( marker_xs, marker_ys,
530 marker_xe , marker_ys );
532 } else if(tick_type=="circle") //begin suma
533 circles((float)marker_xe - 4, (float)marker_ys,3.0); //end suma
535 drawOneLine( marker_xs, marker_ys,
536 marker_xe - 4, marker_ys );
541 } //end draw minor ticks
547 if( !(k%(int)div_max()) ) {
549 disp_val = i % (int) modulo(); // ?????????
552 disp_val += modulo();
558 lenstr = sprintf( TextScale, "%d",
559 FloatToInt(disp_val * data_scaling()/*+.5*/));
560 // (int)(disp_val * data_scaling() +.5));
561 /* if(( (marker_ys - 8 ) > scrn_rect.top ) &&
562 ( (marker_ys + 8) < (height))){ */ //suma
564 if( huds_both(options) ) {
565 // drawOneLine( scrn_rect.left, marker_ys,
566 // marker_xs, marker_ys);
567 // drawOneLine( marker_xs, marker_ys,
568 // scrn_rect.left + scrn_rect.right,
570 if(tick_type=="line") {
571 glBegin(GL_LINE_STRIP);
572 glVertex2f( scrn_rect.left, marker_ys );
573 glVertex2f( marker_xs, marker_ys);
574 glVertex2f( width, marker_ys);
576 } else if(tick_type=="circle") //begin suma
577 circles(scrn_rect.left, (float)marker_ys,5.0); //end suma
579 glBegin(GL_LINE_STRIP);
580 glVertex2f( scrn_rect.left, marker_ys );
581 glVertex2f( marker_xs, marker_ys);
582 glVertex2f( width, marker_ys);
586 if( !huds_notext(options)) {
587 textString ( marker_xs + 2, marker_ys,
588 TextScale, GLUT_BITMAP_8_BY_13,0 );
592 /* Changes are made to draw a circle when tick_type="circle" */
593 // anything other than huds_both
594 if(tick_type=="line") {
595 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
596 } else if(tick_type=="circle")
597 circles((float)marker_xs + 4, (float)marker_ys,5.0);//end suma
599 drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
601 if( !huds_notext(options) ) {
602 if( huds_left(options) ) {
603 textString( marker_xs - 8 * lenstr - 2,
605 TextScale, GLUT_BITMAP_8_BY_13,0 );
607 textString( marker_xe + 3 * lenstr,
609 TextScale, GLUT_BITMAP_8_BY_13,0 );
611 } //End if !huds_notext
613 } // End if draw major ticks
614 } // End if major ticks
618 // End if VERTICAL SCALE TYPE (tape loop yet to be closed)
620 // Horizontal scale by default
622 if (draw_tick_left) {
623 drawOneLine( scrn_rect.left, scrn_rect.top,
624 scrn_rect.left, height);
625 } // endif draw_tick_left
627 if (draw_tick_right) {
628 drawOneLine( width, scrn_rect.top,
631 } // endif draw_tick_right
633 marker_ys = scrn_rect.top; // Starting point for
634 marker_ye = height; // tick y location calcs
636 marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
639 // glBegin(GL_LINES);
641 // glVertex2f( scrn_rect.left, scrn_rect.top);
642 // glVertex2f( scrn_rect.left, marker_ye);
645 // glVertex2f( marker_xe, scrn_rect.top);
646 // glVertex2f( marker_xe, marker_ye );
649 if( huds_top(options) ) {
650 if (draw_cap_bottom) {
652 drawOneLine( scrn_rect.left,
659 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
661 // drawOneLine( mid_scr.x, marker_ye,
662 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
663 // drawOneLine( mid_scr.x, marker_ye,
664 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
667 if(pointer_type=="moving") {
669 //Code for Moving Type Pointer included by suma.
670 // static float xcentre,xpoint,ypoint;
672 if(cur_value > maxValue) cur_value = maxValue;
673 if(cur_value < minValue) cur_value = minValue;
674 float xcentre = mid_scr.x;
675 int range = scrn_rect.right;
676 float xpoint = xcentre + (cur_value * range / val_span);
677 float ypoint = scrn_rect.top - marker_offset;
678 drawOneLine(xcentre, ypoint,xpoint,ypoint);
679 drawOneLine(xpoint,ypoint,xpoint,ypoint+marker_offset);
680 drawOneLine(xpoint,ypoint+marker_offset,xpoint+5.0,ypoint+5.0);
681 drawOneLine(xpoint,ypoint+marker_offset,xpoint-5.0,ypoint+5.0);
685 fixed( marker_xs - scrn_rect.bottom / 4, scrn_rect.top,
686 marker_xs, marker_ye, marker_xs + scrn_rect.bottom / 4,scrn_rect.top);
689 } //End Horizontal scale/top
691 if( huds_bottom(options) ) {
694 drawOneLine( scrn_rect.left, height,
699 marker_ys = height - scrn_rect.bottom / 2;
701 // drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
702 // scrn_rect.top + scrn_rect.bottom,
703 // mid_scr.x, marker_ys );
704 // drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
705 // scrn_rect.top + scrn_rect.bottom,
706 // mid_scr.x , marker_ys );
710 if(pointer_type=="moving") {
712 //Code for Moving Type Pointer included by suma.
713 // static float xcentre,xpoint,ypoint;
714 // static int range,hgt;
715 if(cur_value > maxValue) cur_value = maxValue;
716 if(cur_value < minValue) cur_value = minValue;
717 float xcentre = mid_scr.x ;
718 int range = scrn_rect.right;
719 int hgt = scrn_rect.top + scrn_rect.bottom;
720 float xpoint = xcentre + (cur_value * range / val_span);
721 float ypoint = hgt + marker_offset;
722 drawOneLine(xcentre, ypoint,xpoint,ypoint);
723 drawOneLine(xpoint,ypoint,xpoint,ypoint-marker_offset);
724 drawOneLine(xpoint,ypoint-marker_offset,xpoint+5.0,ypoint-5.0);
725 drawOneLine(xpoint,ypoint-marker_offset,xpoint-5.0,ypoint-5.0);
728 fixed( marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
729 marker_xs - scrn_rect.bottom / 4, height);
732 } //end horizontal scale bottom
734 // if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
735 // marker_xe = marker_ys;
736 // marker_ys = marker_ye;
737 // marker_ye = marker_xe;
740 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
742 // last = FloatToInt(vmax)+1;
743 // i = FloatToInt(vmin);
746 zoomed_scale(vmin,vmax); //suma
749 last = (int)vmax + 1;
751 for(; i <last ; i++ ) {
752 // for( i = (int)vmin; i <= (int)vmax; i++ ) {
753 // printf("<*> i = %d\n", i);
760 // printf("<**> i = %d\n", i);
762 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
763 marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
766 k = i+1; //enable ticks at odd values
771 // if( (i%(int)div_min()) == 0 ) {
773 if( !(k%(int)div_min() )) {
774 // draw in ticks only if they aren't too close to the edge.
775 if((( marker_xs - 5) > scrn_rect.left ) &&
776 (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
778 if( huds_both(options) ) {
779 if(tick_length=="variable") {
780 drawOneLine( marker_xs, scrn_rect.top,
781 marker_xs, marker_ys - 4);
782 drawOneLine( marker_xs, marker_ye + 4,
785 drawOneLine( marker_xs, scrn_rect.top,
786 marker_xs, marker_ys);
787 drawOneLine( marker_xs, marker_ye,
790 // glBegin(GL_LINES);
791 // glVertex2f( marker_xs, scrn_rect.top);
792 // glVertex2f( marker_xs, marker_ys - 4);
793 // glVertex2f( marker_xs, marker_ye + 4);
794 // glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
797 if( huds_top(options)) {
799 if(tick_length=="variable")
800 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye-4);
802 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye);
804 if(tick_length=="variable")
805 drawOneLine(marker_xs,marker_ys+4,marker_xs,marker_ye);
807 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye);
810 } //end draw minor ticks
814 // printf("i = %d\n", i);
815 // if( (i%(int)div_max())==0 ) {
817 if( !(k%(int)div_max()) ) {
819 disp_val = i % (int) modulo(); // ?????????
822 disp_val += modulo();
827 // printf("disp_val = %d\n", disp_val);
828 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
829 lenstr = sprintf( TextScale, "%d",
830 // (int)(disp_val * data_scaling() +.5));
831 FloatToInt(disp_val * data_scaling()/*+.5*/));
832 // Draw major ticks and text only if far enough from the edge.
833 if(( (marker_xs - 10)> scrn_rect.left ) &&
834 ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
835 if( huds_both(options) ) {
836 // drawOneLine( marker_xs, scrn_rect.top,
837 // marker_xs, marker_ys);
838 // drawOneLine( marker_xs, marker_ye,
839 // marker_xs, scrn_rect.top + scrn_rect.bottom);
840 glBegin(GL_LINE_STRIP);
841 glVertex2f( marker_xs, scrn_rect.top);
842 glVertex2f( marker_xs, marker_ye);
843 glVertex2f( marker_xs, height);
845 if( !huds_notext(options) ) {
846 textString ( marker_xs - 4 * lenstr,
848 TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
851 drawOneLine( marker_xs, marker_ys,
852 marker_xs, marker_ye );
853 if( !huds_notext(options)) {
854 if( huds_top(options) ) {
855 textString ( marker_xs - 4 * lenstr,
857 TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
859 textString( marker_xs - 4 * lenstr,
861 TextScale, GLUT_BITMAP_8_BY_13,0 ); //suma
866 } //end draw major ticks
867 } //endif major ticks
871 } //end horizontal/vertical scale
872 } // end of type tape
879 circles(float x,float y,float size)
881 glEnable(GL_POINT_SMOOTH);
889 glDisable(GL_POINT_SMOOTH);
895 fixed(float x1, float y1, float x2, float y2, float x3, float y3)
897 glBegin(GL_LINE_STRIP);
906 zoomed_scale(int first, int last)
909 POINT mid_scr = get_centroid();
910 RECT scrn_rect = get_location();
911 UINT options = get_options();
916 float x,y,w,h,bottom;
917 float cur_value=get_value();
918 if(cur_value > maxValue) cur_value = maxValue;
919 if(cur_value < minValue) cur_value = minValue;
923 while(first <= last) {
924 if((first % (int)Maj_div) == 0) {
933 if( huds_vert(options) ) {
937 w=scrn_rect.left+scrn_rect.right;
938 h=scrn_rect.top+scrn_rect.bottom;
939 bottom=scrn_rect.bottom;
941 float xstart, yfirst, ycentre, ysecond;
943 float hgt = bottom * 20.0 /100.0; // 60% of height should be zoomed
944 yfirst = mid_scr.y - hgt;
946 ysecond = mid_scr.y + hgt;
947 float range = hgt * 2;
950 float factor = range /10.0;
952 float hgt1 = bottom * 30.0 /100.0;
953 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
954 int incr = incrs / 2;
955 float factors = hgt1 / incr;
960 //this is for moving type pointer
961 static float ycent, ypoint,xpoint;
965 wth=scrn_rect.left+scrn_rect.right;
967 if(cur_value <= data[centre+1])
968 if(cur_value > data[centre]) {
969 ypoint = ycent + ((cur_value - data[centre]) * hgt/Maj_div);
972 if(cur_value >= data[centre-1])
973 if(cur_value <= data[centre]) {
974 ypoint = ycent - ((data[centre]-cur_value) * hgt/Maj_div);
977 if(cur_value < data[centre-1])
978 if(cur_value >= minValue) {
979 float diff = minValue - data[centre-1];
980 float diff1 = cur_value - data[centre-1];
981 float val = (diff1 * hgt1) / diff;
983 ypoint = ycent - hgt - val;
987 if(cur_value > data[centre+1])
988 if(cur_value <= maxValue) {
989 float diff = maxValue - data[centre+1];
990 float diff1 = cur_value - data[centre+1];
991 float val = (diff1 * hgt1) / diff;
993 ypoint = ycent + hgt + val;
996 if(huds_left(options)) {
999 drawOneLine( xstart, ycentre, xstart - 5.0, ycentre); //centre tick
1001 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1003 if( !huds_notext(options)) {
1004 textString (x, ycentre, TextScale, GLUT_BITMAP_8_BY_13,0 );
1010 circles(xstart-2.5,yfirst, 3.0);
1011 circles(xstart-2.5,ycentre,3.0);
1014 yfirst = mid_scr.y - hgt;
1016 for(i=0;i<=incr;i++) {
1017 drawOneLine( xstart, yfirst, xstart - 5.0, yfirst);
1018 drawOneLine( xstart,ysecond, xstart - 5.0,ysecond);
1020 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1022 if( !huds_notext(options))
1023 textString (x, yfirst, TextScale, GLUT_BITMAP_8_BY_13,0 );
1025 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1027 if( !huds_notext(options))
1028 textString (x, ysecond, TextScale, GLUT_BITMAP_8_BY_13,0 );
1035 //to draw moving type pointer for left option
1037 xpoint = wth + 10.0;
1039 if(pointer_type == "moving") {
1040 drawOneLine(xpoint,ycent,xpoint,ypoint);
1041 drawOneLine(xpoint,ypoint,xpoint-10.0,ypoint);
1042 drawOneLine(xpoint-10.0,ypoint,xpoint-5.0,ypoint+5.0);
1043 drawOneLine(xpoint-10.0,ypoint,xpoint-5.0,ypoint-5.0);
1051 drawOneLine( xstart, ycentre, xstart + 5.0, ycentre); //centre tick
1053 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1055 if( !huds_notext(options)) {
1056 textString (w, ycentre, TextScale, GLUT_BITMAP_8_BY_13,0 );
1062 circles(xstart+2.5,yfirst, 3.0);
1063 circles(xstart+2.5,ycentre,3.0);
1066 yfirst = mid_scr.y - hgt;
1068 for(i=0;i<=incr;i++) {
1069 drawOneLine( xstart, yfirst, xstart + 5.0, yfirst);
1070 drawOneLine( xstart,ysecond, xstart + 5.0,ysecond);
1072 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1074 if( !huds_notext(options))
1075 textString (w, yfirst, TextScale, GLUT_BITMAP_8_BY_13,0 );
1077 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1079 if( !huds_notext(options))
1080 textString (w, ysecond, TextScale, GLUT_BITMAP_8_BY_13,0 );
1087 // to draw moving type pointer for right option
1089 xpoint = scrn_rect.left;
1091 if(pointer_type == "moving") {
1092 drawOneLine(xpoint,ycent,xpoint,ypoint);
1093 drawOneLine(xpoint,ypoint,xpoint+10.0,ypoint);
1094 drawOneLine(xpoint+10.0,ypoint,xpoint+5.0,ypoint+5.0);
1095 drawOneLine(xpoint+10.0,ypoint,xpoint+5.0,ypoint-5.0);
1098 }//end huds_right /left
1099 //end of vertical scale
1104 w=scrn_rect.left+scrn_rect.right;
1105 h=scrn_rect.top+scrn_rect.bottom;
1106 bottom=scrn_rect.right;
1108 float ystart, xfirst, xcentre, xsecond;
1110 float hgt = bottom * 20.0 /100.0; // 60% of height should be zoomed
1111 xfirst = mid_scr.x - hgt;
1112 xcentre = mid_scr.x;
1113 xsecond = mid_scr.x + hgt;
1114 float range = hgt * 2;
1117 float factor = range /10.0;
1119 float hgt1 = bottom * 30.0 /100.0;
1120 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
1121 int incr = incrs / 2;
1122 float factors = hgt1 / incr;
1125 //Code for Moving Type Pointer
1127 static float xcent,xpoint,ypoint;
1131 if(cur_value <= data[centre+1])
1132 if(cur_value > data[centre]) {
1133 xpoint = xcent + ((cur_value - data[centre]) * hgt/Maj_div);
1136 if(cur_value >= data[centre-1])
1137 if(cur_value <= data[centre]) {
1138 xpoint = xcent - ((data[centre]-cur_value) * hgt/Maj_div);
1141 if(cur_value < data[centre-1])
1142 if(cur_value >= minValue) {
1143 float diff = minValue - data[centre-1];
1144 float diff1 = cur_value - data[centre-1];
1145 float val = (diff1 * hgt1) / diff;
1147 xpoint = xcent - hgt - val;
1151 if(cur_value > data[centre+1])
1152 if(cur_value <= maxValue) {
1153 float diff = maxValue - data[centre+1];
1154 float diff1 = cur_value - data[centre+1];
1155 float val = (diff1 * hgt1) / diff;
1157 xpoint = xcent + hgt + val;
1161 if(huds_top(options)) {
1165 drawOneLine( xcentre, ystart, xcentre, ystart - 5.0); //centre tick
1167 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1169 if( !huds_notext(options)) {
1170 textString (xcentre-10.0, y, TextScale, GLUT_BITMAP_8_BY_13,0 );
1176 circles(xfirst, ystart-2.5, 3.0);
1177 circles(xcentre, ystart-2.5, 3.0);
1180 xfirst = mid_scr.x - hgt;
1182 for(i=0;i<=incr;i++) {
1183 drawOneLine( xfirst, ystart, xfirst, ystart - 5.0);
1184 drawOneLine( xsecond, ystart, xsecond, ystart - 5.0);
1186 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1188 if( !huds_notext(options))
1189 textString (xfirst-10.0, y, TextScale, GLUT_BITMAP_8_BY_13,0 );
1191 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1193 if( !huds_notext(options))
1194 textString (xsecond-10.0, y, TextScale, GLUT_BITMAP_8_BY_13,0 );
1201 //this is for moving pointer for top option
1204 ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
1206 if(pointer_type == "moving") {
1207 drawOneLine(xcent, ypoint,xpoint,ypoint);
1208 drawOneLine(xpoint,ypoint,xpoint,ypoint-10.0);
1209 drawOneLine(xpoint,ypoint-10.0,xpoint+5.0,ypoint-5.0);
1210 drawOneLine(xpoint,ypoint-10.0,xpoint-5.0,ypoint-5.0);
1217 //drawOneLine( xstart, yfirst, xstart - 5.0, yfirst );
1218 drawOneLine( xcentre, ystart, xcentre, ystart + 5.0); //centre tick
1220 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1222 if( !huds_notext(options)) {
1223 textString (xcentre-10.0, h, TextScale, GLUT_BITMAP_8_BY_13,0 );
1229 circles(xfirst, ystart+2.5, 3.0);
1230 circles(xcentre, ystart+2.5,3.0);
1233 xfirst = mid_scr.x - hgt;
1235 for(i=0;i<=incr;i++) {
1236 drawOneLine( xfirst, ystart, xfirst, ystart + 5.0);
1237 drawOneLine( xsecond,ystart, xsecond,ystart + 5.0);
1239 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1241 if( !huds_notext(options))
1242 textString (xfirst-10.0,h, TextScale, GLUT_BITMAP_8_BY_13,0 );
1244 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1246 if( !huds_notext(options))
1247 textString (xsecond-10.0,h, TextScale, GLUT_BITMAP_8_BY_13,0 );
1254 //this is for movimg pointer for bottom option
1257 ypoint = scrn_rect.top - 10.0;
1258 if(pointer_type == "moving") {
1259 drawOneLine(xcent, ypoint,xpoint,ypoint);
1260 drawOneLine(xpoint,ypoint,xpoint,ypoint+10.0);
1261 drawOneLine(xpoint,ypoint+10.0,xpoint+5.0,ypoint+5.0);
1262 drawOneLine(xpoint,ypoint+10.0,xpoint-5.0,ypoint+5.0);
1267 }//end hud_top or hud_bottom
1269 } //end of horizontal/vertical scales