12 #ifdef USE_HUD_TextList
13 #define textString(x, y, text, digit) TextString(text, x , y , digit)
15 #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
18 FLTFNPTR get_func(const char *name); // FIXME
20 hud_card::hud_card(const SGPropertyNode *node) :
22 node->getIntValue("x"),
23 node->getIntValue("y"),
24 node->getIntValue("width"),
25 node->getIntValue("height"),
26 0 /*data_source*/, // FIXME
27 node->getIntValue("options"),
28 node->getFloatValue("value_span"),
29 node->getFloatValue("maxValue"),
30 node->getFloatValue("minValue"),
31 node->getFloatValue("disp_scaling"),
32 node->getIntValue("major_divs"),
33 node->getIntValue("minor_divs"),
34 node->getIntValue("modulator"),
35 node->getBoolValue("working", true)),
36 val_span(node->getFloatValue("value_span")), // FIXME
37 type(node->getStringValue("type")),
38 draw_tick_bottom(node->getBoolValue("tick_bottom", false)),
39 draw_tick_top(node->getBoolValue("tick_top", false)),
40 draw_tick_right(node->getBoolValue("tick_right", false)),
41 draw_tick_left(node->getBoolValue("tick_left", false)),
42 draw_cap_bottom(node->getBoolValue("cap_bottom", false)),
43 draw_cap_top(node->getBoolValue("cap_top", false)),
44 draw_cap_right(node->getBoolValue("cap_right", false)),
45 draw_cap_left(node->getBoolValue("cap_left", false)),
46 marker_offset(node->getFloatValue("marker_offset", 0.0)),
47 pointer(node->getBoolValue("enable_pointer", true)),
48 pointer_type(node->getStringValue("pointer_type")),
49 tick_type(node->getStringValue("tick_type")), // 'circle' or 'line'
50 tick_length(node->getStringValue("tick_length")), // for variable length
51 radius(node->getFloatValue("radius")),
52 maxValue(node->getFloatValue("maxValue")), // FIXME dup
53 minValue(node->getFloatValue("minValue")), // FIXME dup
54 divisions(node->getIntValue("divisions")),
55 zoom(node->getIntValue("zoom")),
56 Maj_div(node->getIntValue("major_divs")), // FIXME dup
57 Min_div(node->getIntValue("minor_divs")) // FIXME dup
59 SG_LOG(SG_INPUT, SG_INFO, "Done reading dial/tape instrument "
60 << node->getStringValue("name", "[unnamed]"));
62 set_data_source(get_func(node->getStringValue("loadfn")));
63 half_width_units = range_to_show() / 2.0;
67 void hud_card::draw(void) // (HUD_scale * pscale)
69 float vmin = 0.0, vmax = 0.0;
74 int text_x = 0, text_y = 0;
81 int oddtype, k; //odd or even values for ticks
83 POINT mid_scr = get_centroid();
84 float cur_value = get_value();
86 if (!((int)maxValue % 2))
87 oddtype = 0; //draw ticks at even values
89 oddtype = 1; //draw ticks at odd values
91 RECT scrn_rect = get_location();
92 UINT options = get_options();
94 height = scrn_rect.top + scrn_rect.bottom;
95 width = scrn_rect.left + scrn_rect.right;
97 // if type=gauge then display dial
98 if (type == "gauge") {
101 y = (float)(scrn_rect.top);
102 x = (float)(scrn_rect.left);
103 glEnable(GL_POINT_SMOOTH);
106 float incr = 360.0 / divisions;
107 for (i = 0.0; i < 360.0; i += incr) {
108 float i1 = i * SGD_DEGREES_TO_RADIANS;
109 float x1 = x + radius * cos(i1);
110 float y1 = y + radius * sin(i1);
117 glDisable(GL_POINT_SMOOTH);
120 if (data_available()) {
121 float offset = 90.0 * SGD_DEGREES_TO_RADIANS;
122 float r1 = 10.0; //size of carrot
123 float theta = get_value();
125 float theta1 = -theta * SGD_DEGREES_TO_RADIANS + offset;
126 float x1 = x + radius * cos(theta1);
127 float y1 = y + radius * sin(theta1);
128 float x2 = x1 - r1 * cos(theta1 - 30.0 * SGD_DEGREES_TO_RADIANS);
129 float y2 = y1 - r1 * sin(theta1 - 30.0 * SGD_DEGREES_TO_RADIANS);
130 float x3 = x1 - r1 * cos(theta1 + 30.0 * SGD_DEGREES_TO_RADIANS);
131 float y3 = y1 - r1 * sin(theta1 + 30.0 * SGD_DEGREES_TO_RADIANS);
134 drawOneLine(x1, y1, x2, y2);
135 drawOneLine(x1, y1, x3, y3);
136 sprintf(TextScale,"%3.1f\n", theta);
139 int l = abs((int)theta);
142 textString(x, y, TextScale, 0);
144 textString(x - 1.0, y, TextScale, 0);
146 textString(x - 2.0, y, TextScale, 0);
152 // if its not explicitly a gauge default to tape
154 if (pointer_type == "moving") {
160 vmin = cur_value - half_width_units; // width units == needle travel
161 vmax = cur_value + half_width_units; // or picture unit span.
167 vmin = cur_value - half_width_units; // width units == needle travel
168 vmax = cur_value + half_width_units; // or picture unit span.
173 // Draw the basic markings for the scale...
175 if (huds_vert(options)) { // Vertical scale
177 if (draw_tick_bottom)
178 drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
182 drawOneLine(scrn_rect.left, height, width, height);
184 marker_xs = scrn_rect.left; // x start
185 marker_xe = width; // x extent
188 // glBegin(GL_LINES);
191 // glVertex2f(marker_xs, scrn_rect.top);
192 // glVertex2f(marker_xe, scrn_rect.top);
195 // glVertex2f(marker_xs, marker_ye);
196 // glVertex2f(marker_xe, marker_ye);
200 // We do not use else in the following so that combining the
201 // two options produces a "caged" display with double
202 // carrots. The same is done for horizontal card indicators.
204 // begin vertical/left
205 //First draw capping lines and pointers
206 if (huds_left(options)) { // Calculate x marker offset
208 if (draw_cap_right) {
210 drawOneLine(marker_xe, scrn_rect.top, marker_xe, marker_ye);
213 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
215 // drawOneLine(marker_xs, mid_scr.y,
216 // marker_xe, mid_scr.y + scrn_rect.right / 6);
217 // drawOneLine(marker_xs, mid_scr.y,
218 // marker_xe, mid_scr.y - scrn_rect.right / 6);
222 if (pointer_type == "moving") {
224 //Code for Moving Type Pointer
225 float ycentre, ypoint, xpoint;
227 if (cur_value > maxValue)
228 cur_value = maxValue;
229 if (cur_value < minValue)
230 cur_value = minValue;
233 ycentre = scrn_rect.top;
234 else if (maxValue + minValue == 0.0)
236 else if (oddtype == 1)
237 ycentre = scrn_rect.top + (1.0 - minValue)*scrn_rect.bottom
238 / (maxValue - minValue);
240 ycentre = scrn_rect.top + minValue * scrn_rect.bottom
241 / (maxValue - minValue);
243 range = scrn_rect.bottom;
244 wth = scrn_rect.left + scrn_rect.right;
247 ypoint = ycentre + ((cur_value - 1.0) * range / val_span);
249 ypoint = ycentre + (cur_value * range / val_span);
251 xpoint = wth + marker_offset;
252 drawOneLine(xpoint, ycentre, xpoint, ypoint);
253 drawOneLine(xpoint, ypoint, xpoint - marker_offset, ypoint);
254 drawOneLine(xpoint - marker_offset, ypoint, xpoint - 5.0, ypoint + 5.0);
255 drawOneLine(xpoint - marker_offset, ypoint, xpoint - 5.0, ypoint - 5.0);
260 fixed(marker_offset + marker_xe, text_y + scrn_rect.right / 6,
261 marker_offset + marker_xs, text_y, marker_offset + marker_xe,
262 text_y - scrn_rect.right / 6);
265 } //end vertical/left
267 // begin vertical/right
268 //First draw capping lines and pointers
269 if (huds_right(options)) { // We'll default this for now.
272 drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, marker_ye);
275 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
277 // drawOneLine(scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
278 // marker_xe, mid_scr.y);
279 // drawOneLine(scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
280 // marker_xe, mid_scr.y);
284 if (pointer_type == "moving") {
286 //type-fixed & zoom=1, behaviour to be defined
287 // Code for Moving Type Pointer
288 float ycentre, ypoint, xpoint;
291 if (cur_value > maxValue)
292 cur_value = maxValue;
293 if (cur_value < minValue)
294 cur_value = minValue;
297 ycentre = scrn_rect.top;
298 else if (maxValue + minValue == 0.0)
300 else if (oddtype == 1)
301 ycentre = scrn_rect.top + (1.0 - minValue)*scrn_rect.bottom / (maxValue - minValue);
303 ycentre = scrn_rect.top + minValue * scrn_rect.bottom / (maxValue - minValue);
305 range = scrn_rect.bottom;
308 ypoint = ycentre + ((cur_value - 1.0) * range / val_span);
310 ypoint = ycentre + (cur_value * range / val_span);
312 xpoint = scrn_rect.left - marker_offset;
313 drawOneLine(xpoint, ycentre, xpoint, ypoint);
314 drawOneLine(xpoint, ypoint, xpoint + marker_offset, ypoint);
315 drawOneLine(xpoint + marker_offset, ypoint, xpoint + 5.0, ypoint + 5.0);
316 drawOneLine(xpoint + marker_offset, ypoint, xpoint + 5.0, ypoint - 5.0);
321 fixed(-marker_offset + scrn_rect.left, text_y + scrn_rect.right / 6,
322 -marker_offset + marker_xe, text_y,-marker_offset + scrn_rect.left,
323 text_y - scrn_rect.right / 6);
326 } //end vertical/right
328 // At this point marker x_start and x_end values are transposed.
329 // To keep this from confusing things they are now interchanged.
330 if (huds_both(options)) {
331 marker_ye = marker_xs;
332 marker_xs = marker_xe;
333 marker_xe = marker_ye;
336 // Work through from bottom to top of scale. Calculating where to put
337 // minor and major ticks.
339 // draw scale or tape
341 // last = float_to_int(vmax)+1;
342 // i = float_to_int(vmin);
343 last = (int)vmax + 1; // N
347 zoomed_scale((int)vmin, (int)vmax);
349 for (; i < last; i++) {
351 if (!modulo() && i < min_val())
354 if (condition) { // Show a tick if necessary
355 // Calculate the location of this tick
356 marker_ys = scrn_rect.top + ((i - vmin) * factor()/*+.5f*/);
357 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
358 // Block calculation artifact from drawing ticks below min coordinate.
359 // Calculation here accounts for text height.
361 if ((marker_ys < (scrn_rect.top + 4))
362 || (marker_ys > (height - 4))) {
368 k = i + 1; //enable ticks at odd values
372 bool major_tick_drawn = false;
376 if (!(k % (int)div_max())) {
377 major_tick_drawn = true;
379 disp_val = i % (int) modulo(); // ?????????
382 disp_val += modulo();
388 lenstr = sprintf(TextScale, "%d",
389 float_to_int(disp_val * data_scaling()/*+.5*/));
390 // (int)(disp_val * data_scaling() +.5));
391 /* if (((marker_ys - 8) > scrn_rect.top) &&
392 ((marker_ys + 8) < (height))){ */
394 if (huds_both(options)) {
395 // drawOneLine(scrn_rect.left, marker_ys,
396 // marker_xs, marker_ys);
397 // drawOneLine(marker_xs, marker_ys,
398 // scrn_rect.left + scrn_rect.right,
400 if (tick_type == "line") {
401 glBegin(GL_LINE_STRIP);
402 glVertex2f(scrn_rect.left, marker_ys);
403 glVertex2f(marker_xs, marker_ys);
404 glVertex2f(width, marker_ys);
407 } else if (tick_type == "circle") {
408 circles(scrn_rect.left, (float)marker_ys, 5.0);
411 glBegin(GL_LINE_STRIP);
412 glVertex2f(scrn_rect.left, marker_ys);
413 glVertex2f(marker_xs, marker_ys);
414 glVertex2f(width, marker_ys);
418 if (!huds_notext(options))
419 textString (marker_xs + 2, marker_ys, TextScale, 0);
422 /* Changes are made to draw a circle when tick_type="circle" */
423 // anything other than huds_both
424 if (tick_type == "line")
425 drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
426 else if (tick_type == "circle")
427 circles((float)marker_xs + 4, (float)marker_ys, 5.0);
429 drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
431 if (!huds_notext(options)) {
432 if (huds_left(options)) {
433 textString(marker_xs - 8 * lenstr - 2,
434 marker_ys - 4, TextScale, 0);
436 textString(marker_xe + 3 * lenstr,
437 marker_ys - 4, TextScale, 0);
439 } //End if !huds_notext
441 } // End if draw major ticks
442 } // End if major ticks
445 if (div_min() && !major_tick_drawn) {
446 // if ((i % div_min()) == 0) {
447 if (!(k % (int)div_min())) {
448 if (((marker_ys - 5) > scrn_rect.top)
449 && ((marker_ys + 5) < (height))) {
451 //vertical/left OR vertical/right
452 if (huds_both(options)) {
453 if (tick_type == "line") {
454 if (tick_length == "variable") {
455 drawOneLine(scrn_rect.left, marker_ys,
456 marker_xs, marker_ys);
457 drawOneLine(marker_xe, marker_ys,
460 drawOneLine(scrn_rect.left, marker_ys,
461 marker_xs, marker_ys);
462 drawOneLine(marker_xe, marker_ys,
466 } else if (tick_type == "circle") {
467 circles(scrn_rect.left,(float)marker_ys, 3.0);
470 // if neither line nor circle draw default as line
471 drawOneLine(scrn_rect.left, marker_ys,
472 marker_xs, marker_ys);
473 drawOneLine(marker_xe, marker_ys,
476 // glBegin(GL_LINES);
477 // glVertex2f(scrn_rect.left, marker_ys);
478 // glVertex2f(marker_xs, marker_ys);
479 // glVertex2f(marker_xe, marker_ys);
480 // glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
482 // anything other than huds_both
485 if (huds_left(options)) {
486 if (tick_type == "line") {
487 if (tick_length == "variable") {
488 drawOneLine(marker_xs + 4, marker_ys,
489 marker_xe, marker_ys);
491 drawOneLine(marker_xs, marker_ys,
492 marker_xe, marker_ys);
494 } else if (tick_type == "circle") {
495 circles((float)marker_xs + 4, (float)marker_ys, 3.0);
498 drawOneLine(marker_xs + 4, marker_ys,
499 marker_xe, marker_ys);
503 if (tick_type == "line") {
504 if (tick_length == "variable") {
505 drawOneLine(marker_xs, marker_ys,
506 marker_xe - 4, marker_ys);
508 drawOneLine(marker_xs, marker_ys,
509 marker_xe, marker_ys);
512 } else if (tick_type == "circle") {
513 circles((float)marker_xe - 4, (float)marker_ys, 3.0);
515 drawOneLine(marker_xs, marker_ys,
516 marker_xe - 4, marker_ys);
521 } //end draw minor ticks
527 // End if VERTICAL SCALE TYPE (tape loop yet to be closed)
530 // Horizontal scale by default
533 drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
537 drawOneLine(width, scrn_rect.top, width, height);
539 marker_ys = scrn_rect.top; // Starting point for
540 marker_ye = height; // tick y location calcs
542 marker_xs = scrn_rect.left + ((cur_value - vmin) * factor() /*+ .5f*/);
544 // glBegin(GL_LINES);
546 // glVertex2f(scrn_rect.left, scrn_rect.top);
547 // glVertex2f(scrn_rect.left, marker_ye);
550 // glVertex2f(marker_xe, scrn_rect.top);
551 // glVertex2f(marker_xe, marker_ye);
554 if (huds_top(options)) {
557 drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
560 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
562 // drawOneLine(mid_scr.x, marker_ye,
563 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
564 // drawOneLine(mid_scr.x, marker_ye,
565 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
568 if (pointer_type == "moving") {
570 //Code for Moving Type Pointer
571 // static float xcentre, xpoint, ypoint;
573 if (cur_value > maxValue)
574 cur_value = maxValue;
575 if (cur_value < minValue)
576 cur_value = minValue;
578 float xcentre = mid_scr.x;
579 int range = scrn_rect.right;
580 float xpoint = xcentre + (cur_value * range / val_span);
581 float ypoint = scrn_rect.top - marker_offset;
582 drawOneLine(xcentre, ypoint, xpoint, ypoint);
583 drawOneLine(xpoint, ypoint, xpoint, ypoint + marker_offset);
584 drawOneLine(xpoint, ypoint + marker_offset, xpoint + 5.0, ypoint + 5.0);
585 drawOneLine(xpoint, ypoint + marker_offset, xpoint - 5.0, ypoint + 5.0);
590 fixed(marker_xs - scrn_rect.bottom / 4, scrn_rect.top, marker_xs,
591 marker_ye, marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
594 } //End Horizontal scale/top
596 if (huds_bottom(options)) {
599 drawOneLine(scrn_rect.left, height, width, height);
602 marker_ys = height - scrn_rect.bottom / 2;
604 // drawOneLine(mid_scr.x + scrn_rect.bottom / 4,
605 // scrn_rect.top + scrn_rect.bottom,
606 // mid_scr.x, marker_ys);
607 // drawOneLine(mid_scr.x - scrn_rect.bottom / 4,
608 // scrn_rect.top + scrn_rect.bottom,
609 // mid_scr.x , marker_ys);
613 if (pointer_type == "moving") {
615 //Code for Moving Type Pointer
616 // static float xcentre, xpoint, ypoint;
617 // static int range, hgt;
618 if (cur_value > maxValue)
619 cur_value = maxValue;
620 if (cur_value < minValue)
621 cur_value = minValue;
623 float xcentre = mid_scr.x ;
624 int range = scrn_rect.right;
625 int hgt = scrn_rect.top + scrn_rect.bottom;
626 float xpoint = xcentre + (cur_value * range / val_span);
627 float ypoint = hgt + marker_offset;
628 drawOneLine(xcentre, ypoint, xpoint, ypoint);
629 drawOneLine(xpoint, ypoint, xpoint, ypoint - marker_offset);
630 drawOneLine(xpoint, ypoint - marker_offset, xpoint + 5.0, ypoint - 5.0);
631 drawOneLine(xpoint, ypoint - marker_offset, xpoint - 5.0, ypoint - 5.0);
634 fixed(marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
635 marker_xs - scrn_rect.bottom / 4, height);
638 } //end horizontal scale bottom
640 // if ((options & HUDS_BOTTOM) == HUDS_BOTTOM) {
641 // marker_xe = marker_ys;
642 // marker_ys = marker_ye;
643 // marker_ye = marker_xe;
646 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
648 // last = float_to_int(vmax)+1;
649 // i = float_to_int(vmin);
652 zoomed_scale((int)vmin,(int)vmax);
655 last = (int)vmax + 1;
657 for (; i < last; i++) {
658 // for (i = (int)vmin; i <= (int)vmax; i++) {
659 // printf("<*> i = %d\n", i);
661 if (!modulo() && i < min_val())
664 // printf("<**> i = %d\n", i);
666 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
667 marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
670 k = i + 1; //enable ticks at odd values
674 bool major_tick_drawn = false;
678 // printf("i = %d\n", i);
679 // if ((i % (int)div_max())==0) {
682 if (!(k % (int)div_max())) {
683 major_tick_drawn = true;
685 disp_val = i % (int) modulo(); // ?????????
688 disp_val += modulo();
693 // printf("disp_val = %d\n", disp_val);
694 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
695 lenstr = sprintf(TextScale, "%d",
696 // (int)(disp_val * data_scaling() +.5));
697 float_to_int(disp_val * data_scaling()/*+.5*/));
699 // Draw major ticks and text only if far enough from the edge.
700 if (((marker_xs - 10)> scrn_rect.left)
701 && ((marker_xs + 10) < (scrn_rect.left + scrn_rect.right))) {
702 if (huds_both(options)) {
703 // drawOneLine(marker_xs, scrn_rect.top,
704 // marker_xs, marker_ys);
705 // drawOneLine(marker_xs, marker_ye,
706 // marker_xs, scrn_rect.top + scrn_rect.bottom);
707 glBegin(GL_LINE_STRIP);
708 glVertex2f(marker_xs, scrn_rect.top);
709 glVertex2f(marker_xs, marker_ye);
710 glVertex2f(marker_xs, height);
713 if (!huds_notext(options)) {
714 textString(marker_xs - 4 * lenstr,
715 marker_ys + 4, TextScale, 0);
718 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
720 if (!huds_notext(options)) {
721 if (huds_top(options)) {
722 textString(marker_xs - 4 * lenstr,
723 height - 10, TextScale, 0);
726 textString(marker_xs - 4 * lenstr,
727 scrn_rect.top, TextScale, 0);
732 } //end draw major ticks
733 } //endif major ticks
735 if (div_min() && !major_tick_drawn) {
736 // if ((i % (int)div_min()) == 0) {
738 if (!(k % (int)div_min())) {
739 // draw in ticks only if they aren't too close to the edge.
740 if (((marker_xs - 5) > scrn_rect.left)
741 && ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) {
743 if (huds_both(options)) {
744 if (tick_length == "variable") {
745 drawOneLine(marker_xs, scrn_rect.top,
746 marker_xs, marker_ys - 4);
747 drawOneLine(marker_xs, marker_ye + 4,
750 drawOneLine(marker_xs, scrn_rect.top,
751 marker_xs, marker_ys);
752 drawOneLine(marker_xs, marker_ye,
755 // glBegin(GL_LINES);
756 // glVertex2f(marker_xs, scrn_rect.top);
757 // glVertex2f(marker_xs, marker_ys - 4);
758 // glVertex2f(marker_xs, marker_ye + 4);
759 // glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom);
763 if (huds_top(options)) {
765 if (tick_length == "variable")
766 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4);
768 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
770 } else if (tick_length == "variable") {
771 drawOneLine(marker_xs, marker_ys + 4, marker_xs, marker_ye);
773 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
777 } //end draw minor ticks
783 } //end horizontal/vertical scale
784 } // end of type tape
789 void hud_card::circles(float x, float y, float size)
791 glEnable(GL_POINT_SMOOTH);
799 glDisable(GL_POINT_SMOOTH);
803 void hud_card::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
805 glBegin(GL_LINE_STRIP);
813 void hud_card::zoomed_scale(int first, int last)
815 POINT mid_scr = get_centroid();
816 RECT scrn_rect = get_location();
817 UINT options = get_options();
821 float x, y, w, h, bottom;
822 float cur_value = get_value();
823 if (cur_value > maxValue)
824 cur_value = maxValue;
825 if (cur_value < minValue)
826 cur_value = minValue;
830 while (first <= last) {
831 if ((first % (int)Maj_div) == 0) {
839 if (huds_vert(options)) {
842 w = scrn_rect.left + scrn_rect.right;
843 h = scrn_rect.top + scrn_rect.bottom;
844 bottom = scrn_rect.bottom;
846 float xstart, yfirst, ycentre, ysecond;
848 float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
849 yfirst = mid_scr.y - hgt;
851 ysecond = mid_scr.y + hgt;
852 float range = hgt * 2;
855 float factor = range / 10.0;
857 float hgt1 = bottom * 30.0 / 100.0;
858 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
859 int incr = incrs / 2;
860 float factors = hgt1 / incr;
863 //this is for moving type pointer
864 static float ycent, ypoint, xpoint;
868 wth = scrn_rect.left + scrn_rect.right;
870 if (cur_value <= data[centre + 1])
871 if (cur_value > data[centre]) {
872 ypoint = ycent + ((cur_value - data[centre]) * hgt / Maj_div);
875 if (cur_value >= data[centre - 1])
876 if (cur_value <= data[centre]) {
877 ypoint = ycent - ((data[centre]-cur_value) * hgt / Maj_div);
880 if (cur_value < data[centre - 1])
881 if (cur_value >= minValue) {
882 float diff = minValue - data[centre - 1];
883 float diff1 = cur_value - data[centre - 1];
884 float val = (diff1 * hgt1) / diff;
886 ypoint = ycent - hgt - val;
889 if (cur_value > data[centre + 1])
890 if (cur_value <= maxValue) {
891 float diff = maxValue - data[centre + 1];
892 float diff1 = cur_value - data[centre + 1];
893 float val = (diff1 * hgt1) / diff;
895 ypoint = ycent + hgt + val;
898 if (huds_left(options)) {
901 drawOneLine(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
903 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
905 if (!huds_notext(options))
906 textString(x, ycentre, TextScale, 0);
908 for (i = 1; i < 5; i++) {
911 circles(xstart - 2.5, yfirst, 3.0);
912 circles(xstart - 2.5, ycentre, 3.0);
915 yfirst = mid_scr.y - hgt;
917 for (i = 0; i <= incr; i++) {
918 drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
919 drawOneLine(xstart, ysecond, xstart - 5.0, ysecond);
921 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
923 if (!huds_notext(options))
924 textString (x, yfirst, TextScale, 0);
926 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
928 if (!huds_notext(options))
929 textString (x, ysecond, TextScale, 0);
936 //to draw moving type pointer for left option
940 if (pointer_type == "moving") {
941 drawOneLine(xpoint, ycent, xpoint, ypoint);
942 drawOneLine(xpoint, ypoint, xpoint - 10.0, ypoint);
943 drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint + 5.0);
944 drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint - 5.0);
950 xstart = (x + w) / 2;
952 drawOneLine(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
954 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
956 if (!huds_notext(options))
957 textString(w, ycentre, TextScale, 0);
959 for (i = 1; i < 5; i++) {
962 circles(xstart + 2.5, yfirst, 3.0);
963 circles(xstart + 2.5, ycentre, 3.0);
966 yfirst = mid_scr.y - hgt;
968 for (i = 0; i <= incr; i++) {
969 drawOneLine(xstart, yfirst, xstart + 5.0, yfirst);
970 drawOneLine(xstart, ysecond, xstart + 5.0, ysecond);
972 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
974 if (!huds_notext(options))
975 textString(w, yfirst, TextScale, 0);
977 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
979 if (!huds_notext(options))
980 textString(w, ysecond, TextScale, 0);
987 // to draw moving type pointer for right option
989 xpoint = scrn_rect.left;
991 if (pointer_type == "moving") {
992 drawOneLine(xpoint, ycent, xpoint, ypoint);
993 drawOneLine(xpoint, ypoint, xpoint + 10.0, ypoint);
994 drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint + 5.0);
995 drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint - 5.0);
998 }//end huds_right /left
999 //end of vertical scale
1005 w = scrn_rect.left + scrn_rect.right;
1006 h = scrn_rect.top + scrn_rect.bottom;
1007 bottom = scrn_rect.right;
1009 float ystart, xfirst, xcentre, xsecond;
1011 float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
1012 xfirst = mid_scr.x - hgt;
1013 xcentre = mid_scr.x;
1014 xsecond = mid_scr.x + hgt;
1015 float range = hgt * 2;
1018 float factor = range / 10.0;
1020 float hgt1 = bottom * 30.0 / 100.0;
1021 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
1022 int incr = incrs / 2;
1023 float factors = hgt1 / incr;
1026 //Code for Moving Type Pointer
1028 static float xcent, xpoint, ypoint;
1032 if (cur_value <= data[centre + 1])
1033 if (cur_value > data[centre]) {
1034 xpoint = xcent + ((cur_value - data[centre]) * hgt / Maj_div);
1037 if (cur_value >= data[centre - 1])
1038 if (cur_value <= data[centre]) {
1039 xpoint = xcent - ((data[centre]-cur_value) * hgt / Maj_div);
1042 if (cur_value < data[centre - 1])
1043 if (cur_value >= minValue) {
1044 float diff = minValue - data[centre - 1];
1045 float diff1 = cur_value - data[centre - 1];
1046 float val = (diff1 * hgt1) / diff;
1048 xpoint = xcent - hgt - val;
1052 if (cur_value > data[centre + 1])
1053 if (cur_value <= maxValue) {
1054 float diff = maxValue - data[centre + 1];
1055 float diff1 = cur_value - data[centre + 1];
1056 float val = (diff1 * hgt1) / diff;
1058 xpoint = xcent + hgt + val;
1062 if (huds_top(options)) {
1064 drawOneLine(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
1066 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1068 if (!huds_notext(options))
1069 textString (xcentre - 10.0, y, TextScale, 0);
1071 for (i = 1; i < 5; i++) {
1074 circles(xfirst, ystart - 2.5, 3.0);
1075 circles(xcentre, ystart - 2.5, 3.0);
1078 xfirst = mid_scr.x - hgt;
1080 for (i = 0; i <= incr; i++) {
1081 drawOneLine(xfirst, ystart, xfirst, ystart - 5.0);
1082 drawOneLine(xsecond, ystart, xsecond, ystart - 5.0);
1084 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
1086 if (!huds_notext(options))
1087 textString (xfirst - 10.0, y, TextScale, 0);
1089 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
1091 if (!huds_notext(options))
1092 textString (xsecond - 10.0, y, TextScale, 0);
1098 //this is for moving pointer for top option
1101 ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
1103 if (pointer_type == "moving") {
1104 drawOneLine(xcent, ypoint, xpoint, ypoint);
1105 drawOneLine(xpoint, ypoint, xpoint, ypoint - 10.0);
1106 drawOneLine(xpoint, ypoint - 10.0, xpoint + 5.0, ypoint - 5.0);
1107 drawOneLine(xpoint, ypoint - 10.0, xpoint - 5.0, ypoint - 5.0);
1113 ystart = (y + h) / 2;
1115 //drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
1116 drawOneLine(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
1118 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1120 if (!huds_notext(options))
1121 textString (xcentre - 10.0, h, TextScale, 0);
1123 for (i = 1; i < 5; i++) {
1126 circles(xfirst, ystart + 2.5, 3.0);
1127 circles(xcentre, ystart + 2.5, 3.0);
1130 xfirst = mid_scr.x - hgt;
1132 for (i = 0; i <= incr; i++) {
1133 drawOneLine(xfirst, ystart, xfirst, ystart + 5.0);
1134 drawOneLine(xsecond, ystart, xsecond, ystart + 5.0);
1136 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
1138 if (!huds_notext(options))
1139 textString (xfirst - 10.0, h, TextScale, 0);
1141 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
1143 if (!huds_notext(options))
1144 textString (xsecond - 10.0, h, TextScale, 0);
1149 //this is for movimg pointer for bottom option
1152 ypoint = scrn_rect.top - 10.0;
1153 if (pointer_type == "moving") {
1154 drawOneLine(xcent, ypoint, xpoint, ypoint);
1155 drawOneLine(xpoint, ypoint, xpoint, ypoint + 10.0);
1156 drawOneLine(xpoint, ypoint + 10.0, xpoint + 5.0, ypoint + 5.0);
1157 drawOneLine(xpoint, ypoint + 10.0, xpoint - 5.0, ypoint + 5.0);
1159 }//end hud_top or hud_bottom
1160 } //end of horizontal/vertical scales