9 #ifdef USE_HUD_TextList
10 #define textString(x, y, text, digit) TextString(text, x , y ,digit)
12 #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
15 //========== Top of hud_card class member definitions =============
28 float max_value, // 360
48 string type_tick,//hud
49 string length_tick,//hud
54 instr_scale(x,y,width,height,
57 max_value, min_value, disp_scaling,
58 major_divs, minor_divs, modulus,
60 val_span (value_span),
62 draw_tick_bottom (tick_bottom),
63 draw_tick_top (tick_top),
64 draw_tick_right (tick_right),
65 draw_tick_left (tick_left),
66 draw_cap_bottom (cap_bottom),
67 draw_cap_top (cap_top),
68 draw_cap_right (cap_right),
69 draw_cap_left (cap_left),
70 marker_offset (mark_offset),
71 pointer (pointer_enable),
72 pointer_type (type_pointer),
73 tick_type (type_tick), //hud
74 tick_length (length_tick), //hud
79 half_width_units = range_to_show() / 2.0;
86 // UINT options = get_options();
87 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
88 // huds_right = options & HUDS_RIGHT;
89 // huds_left = options & HUDS_LEFT;
90 // huds_vert = options & HUDS_VERT;
91 // huds_notext = options & HUDS_NOTEXT;
92 // huds_top = options & HUDS_TOP;
93 // huds_bottom = options & HUDS_BOTTOM;
97 hud_card::~hud_card() { }
100 hud_card::hud_card(const hud_card & image) :
101 instr_scale((const instr_scale &) image),
102 val_span(image.val_span),
104 half_width_units (image.half_width_units),
105 draw_tick_bottom (image.draw_tick_bottom),
106 draw_tick_top (image.draw_tick_top),
107 draw_tick_right (image.draw_tick_right),
108 draw_tick_left (image.draw_tick_left),
109 draw_cap_bottom (image.draw_cap_bottom),
110 draw_cap_top (image.draw_cap_top),
111 draw_cap_right (image.draw_cap_right),
112 draw_cap_left (image.draw_cap_left),
113 marker_offset (image.marker_offset),
114 pointer (image.pointer),
115 pointer_type (image.pointer_type),
116 tick_type(image.tick_type), //hud
117 tick_length(image.tick_length), //hud
118 Maj_div(image.Maj_div),
119 Min_div(image.Min_div)
122 // UINT options = get_options();
123 // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
124 // huds_right = options & HUDS_RIGHT;
125 // huds_left = options & HUDS_LEFT;
126 // huds_vert = options & HUDS_VERT;
127 // huds_notext = options & HUDS_NOTEXT;
128 // huds_top = options & HUDS_TOP;
129 // huds_bottom = options & HUDS_BOTTOM;
133 hud_card & hud_card::operator=(const hud_card & rhs)
135 if (!(this == &rhs)) {
136 instr_scale::operator = (rhs);
137 val_span = rhs.val_span;
138 half_width_units = rhs.half_width_units;
139 draw_tick_bottom = rhs.draw_tick_bottom;
140 draw_tick_top = rhs.draw_tick_top;
141 draw_tick_right = rhs.draw_tick_right;
142 draw_tick_left = rhs.draw_tick_left;
143 draw_cap_bottom = rhs.draw_cap_bottom;
144 draw_cap_top = rhs.draw_cap_top;
145 draw_cap_right = rhs.draw_cap_right;
146 draw_cap_left = rhs.draw_cap_left;
147 marker_offset = rhs.marker_offset;
149 pointer = rhs.pointer;
150 pointer_type = rhs.pointer_type;
151 tick_type = rhs.tick_type;
152 tick_length = rhs.tick_length;
153 Maj_div = rhs.Maj_div;
154 Min_div = rhs.Min_div;
161 void hud_card::draw(void) // (HUD_scale * pscale)
163 float vmin = 0.0, vmax = 0.0;
168 int text_x = 0, text_y = 0;
175 int oddtype, k; //odd or even values for ticks
177 POINT mid_scr = get_centroid();
178 float cur_value = get_value();
180 if (!((int)maxValue%2))
181 oddtype = 0; //draw ticks at even values
183 oddtype = 1; //draw ticks at odd values
185 RECT scrn_rect = get_location();
186 UINT options = get_options();
188 height = scrn_rect.top + scrn_rect.bottom;
189 width = scrn_rect.left + scrn_rect.right;
191 // if type=gauge then display dial
192 if (type == "gauge") {
195 y = (float)(scrn_rect.top);
196 x = (float)(scrn_rect.left);
197 glEnable(GL_POINT_SMOOTH);
200 float incr = 360.0 / divisions;
201 for (i = 0.0; i < 360.0; i += incr) {
202 float i1 = i * SGD_DEGREES_TO_RADIANS;
203 float x1 = x + radius*cos(i1);
204 float y1 = y + radius*sin(i1);
211 glDisable(GL_POINT_SMOOTH);
214 if (data_available()) {
215 float offset = 90.0 * SGD_DEGREES_TO_RADIANS;
216 float r1 = 10.0; //size of carrot
217 float theta = get_value();
219 float theta1 = -theta*SGD_DEGREES_TO_RADIANS+offset;
220 float x1 = x+radius*cos(theta1);
221 float y1 = y+radius*sin(theta1);
222 float x2 = x1-r1*cos(theta1-30.0*SGD_DEGREES_TO_RADIANS);
223 float y2 = y1-r1*sin(theta1-30.0*SGD_DEGREES_TO_RADIANS);
224 float x3 = x1-r1*cos(theta1+30.0*SGD_DEGREES_TO_RADIANS);
225 float y3 = y1-r1*sin(theta1+30.0*SGD_DEGREES_TO_RADIANS);
228 drawOneLine(x1,y1,x2,y2);
229 drawOneLine(x1,y1,x3,y3);
230 sprintf(TextScale,"%3.1f\n",theta);
233 int l = abs((int)theta);
236 textString(x, y, TextScale, 0);
238 textString(x-1.0, y, TextScale, 0);
240 textString(x-2.0, y, TextScale, 0);
245 // if its not explicitly a gauge default to tape
247 if (pointer_type=="moving") {
253 vmin = cur_value - half_width_units; // width units == needle travel
254 vmax = cur_value + half_width_units; // or picture unit span.
260 vmin = cur_value - half_width_units; // width units == needle travel
261 vmax = cur_value + half_width_units; // or picture unit span.
266 // Draw the basic markings for the scale...
268 if (huds_vert(options)) { // Vertical scale
269 if (draw_tick_bottom) {
270 drawOneLine(scrn_rect.left, // Bottom tick bar
274 } // endif draw_tick_bottom
277 drawOneLine(scrn_rect.left, // Top tick bar
281 } // endif draw_tick_top
283 marker_xs = scrn_rect.left; // x start
284 marker_xe = width; // x extent
287 // glBegin(GL_LINES);
290 // glVertex2f(marker_xs, scrn_rect.top);
291 // glVertex2f(marker_xe, scrn_rect.top);
294 // glVertex2f(marker_xs, marker_ye);
295 // glVertex2f(marker_xe, marker_ye);
299 // We do not use else in the following so that combining the
300 // two options produces a "caged" display with double
301 // carrots. The same is done for horizontal card indicators.
303 // begin vertical/left
304 //First draw capping lines and pointers
305 if (huds_left(options)) { // Calculate x marker offset
307 if (draw_cap_right) {
308 drawOneLine(marker_xe, scrn_rect.top,
309 marker_xe, marker_ye); // Cap right side
312 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
314 // drawOneLine(marker_xs, mid_scr.y,
315 // marker_xe, mid_scr.y + scrn_rect.right / 6);
316 // drawOneLine(marker_xs, mid_scr.y,
317 // marker_xe, mid_scr.y - scrn_rect.right / 6);
321 if (pointer_type=="moving") {
323 //Code for Moving Type Pointer
324 float ycentre, ypoint,xpoint;
326 if (cur_value > maxValue)
327 cur_value = maxValue;
328 if (cur_value < minValue)
329 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);
341 range = scrn_rect.bottom;
342 wth = scrn_rect.left + scrn_rect.right;
345 ypoint = ycentre + ((cur_value-1.0) * range / val_span);
347 ypoint = ycentre + (cur_value * range / val_span);
349 xpoint = wth + marker_offset;
350 drawOneLine(xpoint,ycentre,xpoint,ypoint);
351 drawOneLine(xpoint,ypoint,xpoint-marker_offset,ypoint);
352 drawOneLine(xpoint-marker_offset,ypoint,xpoint-5.0,ypoint+5.0);
353 drawOneLine(xpoint-marker_offset,ypoint,xpoint-5.0,ypoint-5.0);
358 fixed(marker_offset+marker_xe, text_y + scrn_rect.right / 6,
359 marker_offset+marker_xs, text_y,marker_offset+marker_xe,
360 text_y - scrn_rect.right / 6);
363 } //end vertical/left
365 // begin vertical/right
366 //First draw capping lines and pointers
367 if (huds_right(options)) { // We'll default this for now.
369 drawOneLine(scrn_rect.left, scrn_rect.top,
370 scrn_rect.left, marker_ye); // Cap left side
373 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
375 // drawOneLine(scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
376 // marker_xe, mid_scr.y);
377 // drawOneLine(scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
378 // marker_xe, mid_scr.y);
382 if (pointer_type == "moving") {
384 //type-fixed & zoom=1, behaviour to be defined
385 // Code for Moving Type Pointer
386 float ycentre, ypoint,xpoint;
389 if (cur_value > maxValue)
390 cur_value = maxValue;
391 if (cur_value < minValue)
392 cur_value = minValue;
395 ycentre = scrn_rect.top;
396 else if (maxValue + minValue == 0.0)
400 ycentre = scrn_rect.top + (1.0-minValue)*scrn_rect.bottom/(maxValue-minValue);
402 ycentre = scrn_rect.top + minValue*scrn_rect.bottom/(maxValue-minValue);
404 range = scrn_rect.bottom;
407 ypoint = ycentre + ((cur_value-1.0) * range / val_span);
409 ypoint = ycentre + (cur_value * range / val_span);
411 xpoint = scrn_rect.left - marker_offset;
412 drawOneLine(xpoint,ycentre,xpoint,ypoint);
413 drawOneLine(xpoint,ypoint,xpoint+marker_offset,ypoint);
414 drawOneLine(xpoint+marker_offset,ypoint,xpoint+5.0,ypoint+5.0);
415 drawOneLine(xpoint+marker_offset,ypoint,xpoint+5.0,ypoint-5.0);
420 fixed(-marker_offset+scrn_rect.left, text_y + scrn_rect.right / 6,
421 -marker_offset+marker_xe, text_y,-marker_offset+scrn_rect.left,
422 text_y - scrn_rect.right / 6);
425 } //end vertical/right
427 // At this point marker x_start and x_end values are transposed.
428 // To keep this from confusing things they are now interchanged.
429 if (huds_both(options)) {
430 marker_ye = marker_xs;
431 marker_xs = marker_xe;
432 marker_xe = marker_ye;
435 // Work through from bottom to top of scale. Calculating where to put
436 // minor and major ticks.
438 // draw scale or tape
440 // last = FloatToInt(vmax)+1;
441 // i = FloatToInt(vmin);
442 last = (int)vmax + 1; // N
446 zoomed_scale((int)vmin, (int)vmax);
448 for (; i < last; i++) {
456 if (condition) { // Show a tick if necessary
457 // Calculate the location of this tick
458 marker_ys = scrn_rect.top + ((i - vmin) * factor()/*+.5f*/);
459 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
460 // Block calculation artifact from drawing ticks below min coordinate.
461 // Calculation here accounts for text height.
463 if ((marker_ys < (scrn_rect.top + 4))
464 | (marker_ys > (height - 4))) {
470 k = i+1; //enable ticks at odd values
476 // if ((i%div_min()) == 0) {
477 if (!(k%(int)div_min())) {
478 if (((marker_ys - 5) > scrn_rect.top)
479 && ((marker_ys + 5) < (height))) {
481 //vertical/left OR vertical/right
482 if (huds_both(options)) {
483 if (tick_type=="line") {
484 if (tick_length=="variable") {
485 drawOneLine(scrn_rect.left, marker_ys,
486 marker_xs, marker_ys);
487 drawOneLine(marker_xe, marker_ys,
490 drawOneLine(scrn_rect.left, marker_ys,
491 marker_xs, marker_ys);
492 drawOneLine(marker_xe, marker_ys,
495 } else if (tick_type == "circle")
496 circles(scrn_rect.left,(float)marker_ys,3.0);
499 // if neither line nor circle draw default as line
500 drawOneLine(scrn_rect.left, marker_ys,
501 marker_xs, marker_ys);
502 drawOneLine(marker_xe, marker_ys,
505 // glBegin(GL_LINES);
506 // glVertex2f(scrn_rect.left, marker_ys);
507 // glVertex2f(marker_xs, marker_ys);
508 // glVertex2f(marker_xe, marker_ys);
509 // glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
511 // anything other than huds_both
514 if (huds_left(options)) {
515 if (tick_type=="line") {
516 if (tick_length=="variable") {
517 drawOneLine(marker_xs + 4, marker_ys,
518 marker_xe, marker_ys);
520 drawOneLine(marker_xs , marker_ys,
521 marker_xe, marker_ys);
523 } else if (tick_type=="circle")
524 circles((float)marker_xs + 4, (float)marker_ys,3.0);
527 drawOneLine(marker_xs + 4, marker_ys,
528 marker_xe, marker_ys);
531 if (tick_type=="line") {
532 if (tick_length=="variable") {
533 drawOneLine(marker_xs, marker_ys,
534 marker_xe - 4, marker_ys);
536 drawOneLine(marker_xs, marker_ys,
537 marker_xe , marker_ys);
539 } else if (tick_type=="circle")
540 circles((float)marker_xe - 4, (float)marker_ys,3.0);
542 drawOneLine(marker_xs, marker_ys,
543 marker_xe - 4, marker_ys);
548 } //end draw minor ticks
553 if (!(k%(int)div_max())) {
555 disp_val = i % (int) modulo(); // ?????????
558 disp_val += modulo();
564 lenstr = sprintf(TextScale, "%d",
565 FloatToInt(disp_val * data_scaling()/*+.5*/));
566 // (int)(disp_val * data_scaling() +.5));
567 /* if (((marker_ys - 8) > scrn_rect.top) &&
568 ((marker_ys + 8) < (height))){ */
570 if (huds_both(options)) {
571 // drawOneLine(scrn_rect.left, marker_ys,
572 // marker_xs, marker_ys);
573 // drawOneLine(marker_xs, marker_ys,
574 // scrn_rect.left + scrn_rect.right,
576 if (tick_type == "line") {
577 glBegin(GL_LINE_STRIP);
578 glVertex2f(scrn_rect.left, marker_ys);
579 glVertex2f(marker_xs, marker_ys);
580 glVertex2f(width, marker_ys);
582 } else if (tick_type == "circle") {
583 circles(scrn_rect.left, (float)marker_ys,5.0);
585 glBegin(GL_LINE_STRIP);
586 glVertex2f(scrn_rect.left, marker_ys);
587 glVertex2f(marker_xs, marker_ys);
588 glVertex2f(width, marker_ys);
592 if (!huds_notext(options)) {
593 textString (marker_xs + 2, marker_ys,
598 /* Changes are made to draw a circle when tick_type="circle" */
599 // anything other than huds_both
600 if (tick_type=="line") {
601 drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
602 } else if (tick_type=="circle") {
603 circles((float)marker_xs + 4, (float)marker_ys,5.0);
605 drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
608 if (!huds_notext(options)) {
609 if (huds_left(options)) {
610 textString(marker_xs - 8 * lenstr - 2,
614 textString(marker_xe + 3 * lenstr,
618 } //End if !huds_notext
620 } // End if draw major ticks
621 } // End if major ticks
625 // End if VERTICAL SCALE TYPE (tape loop yet to be closed)
628 // Horizontal scale by default
630 if (draw_tick_left) {
631 drawOneLine(scrn_rect.left, scrn_rect.top,
632 scrn_rect.left, height);
633 } // endif draw_tick_left
635 if (draw_tick_right) {
636 drawOneLine(width, scrn_rect.top,
639 } // endif draw_tick_right
641 marker_ys = scrn_rect.top; // Starting point for
642 marker_ye = height; // tick y location calcs
644 marker_xs = scrn_rect.left + ((cur_value - vmin) * factor() /*+ .5f*/);
646 // glBegin(GL_LINES);
648 // glVertex2f(scrn_rect.left, scrn_rect.top);
649 // glVertex2f(scrn_rect.left, marker_ye);
652 // glVertex2f(marker_xe, scrn_rect.top);
653 // glVertex2f(marker_xe, marker_ye);
656 if (huds_top(options)) {
657 if (draw_cap_bottom) {
659 drawOneLine(scrn_rect.left,
666 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
668 // drawOneLine(mid_scr.x, marker_ye,
669 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
670 // drawOneLine(mid_scr.x, marker_ye,
671 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
674 if (pointer_type == "moving") {
676 //Code for Moving Type Pointer
677 // static float xcentre,xpoint,ypoint;
679 if (cur_value > maxValue)
680 cur_value = maxValue;
681 if (cur_value < minValue)
682 cur_value = minValue;
684 float xcentre = mid_scr.x;
685 int range = scrn_rect.right;
686 float xpoint = xcentre + (cur_value * range / val_span);
687 float ypoint = scrn_rect.top - marker_offset;
688 drawOneLine(xcentre, ypoint,xpoint,ypoint);
689 drawOneLine(xpoint,ypoint,xpoint,ypoint+marker_offset);
690 drawOneLine(xpoint,ypoint+marker_offset,xpoint+5.0,ypoint+5.0);
691 drawOneLine(xpoint,ypoint+marker_offset,xpoint-5.0,ypoint+5.0);
695 fixed(marker_xs - scrn_rect.bottom / 4, scrn_rect.top,
696 marker_xs, marker_ye, marker_xs + scrn_rect.bottom / 4,scrn_rect.top);
699 } //End Horizontal scale/top
701 if (huds_bottom(options)) {
704 drawOneLine(scrn_rect.left, height,
709 marker_ys = height - scrn_rect.bottom / 2;
711 // drawOneLine(mid_scr.x + scrn_rect.bottom / 4,
712 // scrn_rect.top + scrn_rect.bottom,
713 // mid_scr.x, marker_ys);
714 // drawOneLine(mid_scr.x - scrn_rect.bottom / 4,
715 // scrn_rect.top + scrn_rect.bottom,
716 // mid_scr.x , marker_ys);
720 if (pointer_type =="moving") {
722 //Code for Moving Type Pointer
723 // static float xcentre,xpoint,ypoint;
724 // static int range,hgt;
725 if (cur_value > maxValue)
726 cur_value = maxValue;
727 if (cur_value < minValue)
728 cur_value = minValue;
730 float xcentre = mid_scr.x ;
731 int range = scrn_rect.right;
732 int hgt = scrn_rect.top + scrn_rect.bottom;
733 float xpoint = xcentre + (cur_value * range / val_span);
734 float ypoint = hgt + marker_offset;
735 drawOneLine(xcentre, ypoint,xpoint,ypoint);
736 drawOneLine(xpoint,ypoint,xpoint,ypoint-marker_offset);
737 drawOneLine(xpoint,ypoint-marker_offset,xpoint+5.0,ypoint-5.0);
738 drawOneLine(xpoint,ypoint-marker_offset,xpoint-5.0,ypoint-5.0);
741 fixed(marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
742 marker_xs - scrn_rect.bottom / 4, height);
745 } //end horizontal scale bottom
747 // if ((options & HUDS_BOTTOM) == HUDS_BOTTOM) {
748 // marker_xe = marker_ys;
749 // marker_ys = marker_ye;
750 // marker_ye = marker_xe;
753 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
755 // last = FloatToInt(vmax)+1;
756 // i = FloatToInt(vmin);
759 zoomed_scale((int)vmin,(int)vmax);
762 last = (int)vmax + 1;
764 for (; i < last; i++) {
765 // for (i = (int)vmin; i <= (int)vmax; i++) {
766 // printf("<*> i = %d\n", i);
773 // printf("<**> i = %d\n", i);
775 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
776 marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
779 k = i+1; //enable ticks at odd values
784 // if ((i%(int)div_min()) == 0) {
786 if (!(k%(int)div_min())) {
787 // draw in ticks only if they aren't too close to the edge.
788 if (((marker_xs - 5) > scrn_rect.left)
789 && ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) {
791 if (huds_both(options)) {
792 if (tick_length == "variable") {
793 drawOneLine(marker_xs, scrn_rect.top,
794 marker_xs, marker_ys - 4);
795 drawOneLine(marker_xs, marker_ye + 4,
798 drawOneLine(marker_xs, scrn_rect.top,
799 marker_xs, marker_ys);
800 drawOneLine(marker_xs, marker_ye,
803 // glBegin(GL_LINES);
804 // glVertex2f(marker_xs, scrn_rect.top);
805 // glVertex2f(marker_xs, marker_ys - 4);
806 // glVertex2f(marker_xs, marker_ye + 4);
807 // glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom);
811 if (huds_top(options)) {
813 if (tick_length=="variable")
814 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye-4);
816 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye);
819 if (tick_length=="variable")
820 drawOneLine(marker_xs,marker_ys+4,marker_xs,marker_ye);
822 drawOneLine(marker_xs,marker_ys,marker_xs,marker_ye);
825 } //end draw minor ticks
830 // printf("i = %d\n", i);
831 // if ((i%(int)div_max())==0) {
834 if (!(k%(int)div_max())) {
836 disp_val = i % (int) modulo(); // ?????????
839 disp_val += modulo();
844 // printf("disp_val = %d\n", disp_val);
845 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
846 lenstr = sprintf(TextScale, "%d",
847 // (int)(disp_val * data_scaling() +.5));
848 FloatToInt(disp_val * data_scaling()/*+.5*/));
850 // Draw major ticks and text only if far enough from the edge.
851 if (((marker_xs - 10)> scrn_rect.left)
852 && ((marker_xs + 10) < (scrn_rect.left + scrn_rect.right))) {
853 if (huds_both(options)) {
854 // drawOneLine(marker_xs, scrn_rect.top,
855 // marker_xs, marker_ys);
856 // drawOneLine(marker_xs, marker_ye,
857 // marker_xs, scrn_rect.top + scrn_rect.bottom);
858 glBegin(GL_LINE_STRIP);
859 glVertex2f(marker_xs, scrn_rect.top);
860 glVertex2f(marker_xs, marker_ye);
861 glVertex2f(marker_xs, height);
864 if (!huds_notext(options)) {
865 textString(marker_xs - 4 * lenstr,
866 marker_ys + 4, TextScale, 0);
869 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
871 if (!huds_notext(options)) {
872 if (huds_top(options)) {
873 textString(marker_xs - 4 * lenstr,
874 height - 10, TextScale, 0);
877 textString(marker_xs - 4 * lenstr,
878 scrn_rect.top, TextScale, 0);
883 } //end draw major ticks
884 } //endif major ticks
888 } //end horizontal/vertical scale
889 } // end of type tape
894 void hud_card::circles(float x,float y,float size)
896 glEnable(GL_POINT_SMOOTH);
904 glDisable(GL_POINT_SMOOTH);
908 void hud_card::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
910 glBegin(GL_LINE_STRIP);
918 void hud_card::zoomed_scale(int first, int last)
920 POINT mid_scr = get_centroid();
921 RECT scrn_rect = get_location();
922 UINT options = get_options();
927 float x,y,w,h,bottom;
928 float cur_value=get_value();
929 if (cur_value > maxValue)
930 cur_value = maxValue;
931 if (cur_value < minValue)
932 cur_value = minValue;
936 while (first <= last) {
937 if ((first % (int)Maj_div) == 0) {
945 if (huds_vert(options)) {
948 w=scrn_rect.left+scrn_rect.right;
949 h=scrn_rect.top+scrn_rect.bottom;
950 bottom=scrn_rect.bottom;
952 float xstart, yfirst, ycentre, ysecond;
954 float hgt = bottom * 20.0 /100.0; // 60% of height should be zoomed
955 yfirst = mid_scr.y - hgt;
957 ysecond = mid_scr.y + hgt;
958 float range = hgt * 2;
961 float factor = range /10.0;
963 float hgt1 = bottom * 30.0 /100.0;
964 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
965 int incr = incrs / 2;
966 float factors = hgt1 / incr;
969 //this is for moving type pointer
970 static float ycent, ypoint,xpoint;
974 wth=scrn_rect.left+scrn_rect.right;
976 if (cur_value <= data[centre+1])
977 if (cur_value > data[centre]) {
978 ypoint = ycent + ((cur_value - data[centre]) * hgt/Maj_div);
981 if (cur_value >= data[centre-1])
982 if (cur_value <= data[centre]) {
983 ypoint = ycent - ((data[centre]-cur_value) * hgt/Maj_div);
986 if (cur_value < data[centre-1])
987 if (cur_value >= minValue) {
988 float diff = minValue - data[centre-1];
989 float diff1 = cur_value - data[centre-1];
990 float val = (diff1 * hgt1) / diff;
992 ypoint = ycent - hgt - val;
995 if (cur_value > data[centre+1])
996 if (cur_value <= maxValue) {
997 float diff = maxValue - data[centre+1];
998 float diff1 = cur_value - data[centre+1];
999 float val = (diff1 * hgt1) / diff;
1001 ypoint = ycent + hgt + val;
1004 if (huds_left(options)) {
1007 drawOneLine(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
1009 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1011 if (!huds_notext(options)) {
1012 textString (x, ycentre, TextScale, 0);
1015 for (i = 1; i < 5; i++) {
1018 circles(xstart-2.5,yfirst, 3.0);
1019 circles(xstart-2.5,ycentre,3.0);
1022 yfirst = mid_scr.y - hgt;
1024 for (i = 0; i <= incr; i++) {
1025 drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
1026 drawOneLine(xstart,ysecond, xstart - 5.0,ysecond);
1028 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1030 if (!huds_notext(options))
1031 textString (x, yfirst, TextScale, 0);
1033 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1035 if (!huds_notext(options))
1036 textString (x, ysecond, TextScale, 0);
1043 //to draw moving type pointer for left option
1045 xpoint = wth + 10.0;
1047 if (pointer_type == "moving") {
1048 drawOneLine(xpoint,ycent,xpoint,ypoint);
1049 drawOneLine(xpoint,ypoint,xpoint-10.0,ypoint);
1050 drawOneLine(xpoint-10.0,ypoint,xpoint-5.0,ypoint+5.0);
1051 drawOneLine(xpoint-10.0,ypoint,xpoint-5.0,ypoint-5.0);
1059 drawOneLine(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
1061 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1063 if (!huds_notext(options)) {
1064 textString (w, ycentre, TextScale, 0);
1067 for (i = 1; i < 5; i++) {
1070 circles(xstart+2.5,yfirst, 3.0);
1071 circles(xstart+2.5,ycentre,3.0);
1074 yfirst = mid_scr.y - hgt;
1076 for (i = 0; i <= incr; i++) {
1077 drawOneLine(xstart, yfirst, xstart + 5.0, yfirst);
1078 drawOneLine(xstart,ysecond, xstart + 5.0,ysecond);
1080 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1082 if (!huds_notext(options))
1083 textString(w, yfirst, TextScale, 0);
1085 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1087 if (!huds_notext(options))
1088 textString(w, ysecond, TextScale, 0);
1095 // to draw moving type pointer for right option
1097 xpoint = scrn_rect.left;
1099 if (pointer_type == "moving") {
1100 drawOneLine(xpoint,ycent,xpoint,ypoint);
1101 drawOneLine(xpoint,ypoint,xpoint+10.0,ypoint);
1102 drawOneLine(xpoint+10.0,ypoint,xpoint+5.0,ypoint+5.0);
1103 drawOneLine(xpoint+10.0,ypoint,xpoint+5.0,ypoint-5.0);
1106 }//end huds_right /left
1107 //end of vertical scale
1113 w=scrn_rect.left+scrn_rect.right;
1114 h=scrn_rect.top+scrn_rect.bottom;
1115 bottom=scrn_rect.right;
1117 float ystart, xfirst, xcentre, xsecond;
1119 float hgt = bottom * 20.0 /100.0; // 60% of height should be zoomed
1120 xfirst = mid_scr.x - hgt;
1121 xcentre = mid_scr.x;
1122 xsecond = mid_scr.x + hgt;
1123 float range = hgt * 2;
1126 float factor = range /10.0;
1128 float hgt1 = bottom * 30.0 /100.0;
1129 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
1130 int incr = incrs / 2;
1131 float factors = hgt1 / incr;
1134 //Code for Moving Type Pointer
1136 static float xcent,xpoint,ypoint;
1140 if (cur_value <= data[centre+1])
1141 if (cur_value > data[centre]) {
1142 xpoint = xcent + ((cur_value - data[centre]) * hgt/Maj_div);
1145 if (cur_value >= data[centre-1])
1146 if (cur_value <= data[centre]) {
1147 xpoint = xcent - ((data[centre]-cur_value) * hgt/Maj_div);
1150 if (cur_value < data[centre-1])
1151 if (cur_value >= minValue) {
1152 float diff = minValue - data[centre-1];
1153 float diff1 = cur_value - data[centre-1];
1154 float val = (diff1 * hgt1) / diff;
1156 xpoint = xcent - hgt - val;
1160 if (cur_value > data[centre+1])
1161 if (cur_value <= maxValue) {
1162 float diff = maxValue - data[centre+1];
1163 float diff1 = cur_value - data[centre+1];
1164 float val = (diff1 * hgt1) / diff;
1166 xpoint = xcent + hgt + val;
1170 if (huds_top(options)) {
1174 drawOneLine(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
1176 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1178 if (!huds_notext(options)) {
1179 textString (xcentre-10.0, y, TextScale, 0);
1182 for (i = 1; i < 5; i++) {
1185 circles(xfirst, ystart-2.5, 3.0);
1186 circles(xcentre, ystart-2.5, 3.0);
1189 xfirst = mid_scr.x - hgt;
1191 for (i = 0; i <= incr; i++) {
1192 drawOneLine(xfirst, ystart, xfirst, ystart - 5.0);
1193 drawOneLine(xsecond, ystart, xsecond, ystart - 5.0);
1195 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1197 if (!huds_notext(options))
1198 textString (xfirst-10.0, y, TextScale, 0);
1200 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1202 if (!huds_notext(options))
1203 textString (xsecond-10.0, y, TextScale, 0);
1209 //this is for moving pointer for top option
1212 ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
1214 if (pointer_type == "moving") {
1215 drawOneLine(xcent, ypoint,xpoint,ypoint);
1216 drawOneLine(xpoint,ypoint,xpoint,ypoint-10.0);
1217 drawOneLine(xpoint,ypoint-10.0,xpoint+5.0,ypoint-5.0);
1218 drawOneLine(xpoint,ypoint-10.0,xpoint-5.0,ypoint-5.0);
1224 ystart = (y + h) / 2;
1226 //drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
1227 drawOneLine(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
1229 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1231 if (!huds_notext(options)) {
1232 textString (xcentre-10.0, h, TextScale, 0);
1235 for (i = 1; i < 5; i++) {
1238 circles(xfirst, ystart+2.5, 3.0);
1239 circles(xcentre, ystart+2.5,3.0);
1242 xfirst = mid_scr.x - hgt;
1244 for (i = 0; i <= incr; i++) {
1245 drawOneLine(xfirst, ystart, xfirst, ystart + 5.0);
1246 drawOneLine(xsecond,ystart, xsecond,ystart + 5.0);
1248 sprintf(TextScale,"%3.0f\n",(float)(data[centre-i-1] * data_scaling()));
1250 if (!huds_notext(options))
1251 textString (xfirst-10.0,h, TextScale, 0);
1253 sprintf(TextScale,"%3.0f\n",(float)(data[centre+i+1] * data_scaling()));
1255 if (!huds_notext(options))
1256 textString (xsecond-10.0,h, TextScale, 0);
1263 //this is for movimg pointer for bottom option
1266 ypoint = scrn_rect.top - 10.0;
1267 if (pointer_type == "moving") {
1268 drawOneLine(xcent, ypoint,xpoint,ypoint);
1269 drawOneLine(xpoint,ypoint,xpoint,ypoint+10.0);
1270 drawOneLine(xpoint,ypoint+10.0,xpoint+5.0,ypoint+5.0);
1271 drawOneLine(xpoint,ypoint+10.0,xpoint-5.0,ypoint+5.0);
1273 }//end hud_top or hud_bottom
1274 } //end of horizontal/vertical scales