13 #ifdef USE_HUD_TextList
14 #define textString(x, y, text, digit) TextString(text, x , y , digit)
16 #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
19 FLTFNPTR get_func(const char *name); // FIXME
21 hud_card::hud_card(const SGPropertyNode *node) :
23 node->getIntValue("x"),
24 node->getIntValue("y"),
25 node->getIntValue("width"),
26 node->getIntValue("height"),
27 0 /*data_source*/, // FIXME
28 node->getIntValue("options"),
29 node->getFloatValue("value_span"),
30 node->getFloatValue("maxValue"),
31 node->getFloatValue("minValue"),
32 node->getFloatValue("disp_scaling"),
33 node->getIntValue("major_divs"),
34 node->getIntValue("minor_divs"),
35 node->getIntValue("modulator"),
36 node->getBoolValue("working", true)),
37 val_span(node->getFloatValue("value_span")), // FIXME
38 type(node->getStringValue("type")),
39 draw_tick_bottom(node->getBoolValue("tick_bottom", false)),
40 draw_tick_top(node->getBoolValue("tick_top", false)),
41 draw_tick_right(node->getBoolValue("tick_right", false)),
42 draw_tick_left(node->getBoolValue("tick_left", false)),
43 draw_cap_bottom(node->getBoolValue("cap_bottom", false)),
44 draw_cap_top(node->getBoolValue("cap_top", false)),
45 draw_cap_right(node->getBoolValue("cap_right", false)),
46 draw_cap_left(node->getBoolValue("cap_left", false)),
47 marker_offset(node->getFloatValue("marker_offset", 0.0)),
48 pointer(node->getBoolValue("enable_pointer", true)),
49 pointer_type(node->getStringValue("pointer_type")),
50 tick_type(node->getStringValue("tick_type")), // 'circle' or 'line'
51 tick_length(node->getStringValue("tick_length")), // for variable length
52 radius(node->getFloatValue("radius")),
53 maxValue(node->getFloatValue("maxValue")), // FIXME dup
54 minValue(node->getFloatValue("minValue")), // FIXME dup
55 divisions(node->getIntValue("divisions")),
56 zoom(node->getIntValue("zoom")),
57 Maj_div(node->getIntValue("major_divs")), // FIXME dup
58 Min_div(node->getIntValue("minor_divs")) // FIXME dup
60 SG_LOG(SG_INPUT, SG_INFO, "Done reading dial/tape instrument "
61 << node->getStringValue("name", "[unnamed]"));
63 set_data_source(get_func(node->getStringValue("loadfn")));
64 half_width_units = range_to_show() / 2.0;
68 void hud_card::draw(void) // (HUD_scale * pscale)
70 float vmin = 0.0, vmax = 0.0;
75 int text_x = 0, text_y = 0;
82 int oddtype, k; //odd or even values for ticks
84 POINT mid_scr = get_centroid();
85 float cur_value = get_value();
87 if (!((int)maxValue % 2))
88 oddtype = 0; //draw ticks at even values
90 oddtype = 1; //draw ticks at odd values
92 RECT scrn_rect = get_location();
93 UINT options = get_options();
95 height = scrn_rect.top + scrn_rect.bottom;
96 width = scrn_rect.left + scrn_rect.right;
98 // if type=gauge then display dial
99 if (type == "gauge") {
102 y = (float)(scrn_rect.top);
103 x = (float)(scrn_rect.left);
104 glEnable(GL_POINT_SMOOTH);
107 float incr = 360.0 / divisions;
108 for (i = 0.0; i < 360.0; i += incr) {
109 float i1 = i * SGD_DEGREES_TO_RADIANS;
110 float x1 = x + radius * cos(i1);
111 float y1 = y + radius * sin(i1);
118 glDisable(GL_POINT_SMOOTH);
121 if (data_available()) {
122 float offset = 90.0 * SGD_DEGREES_TO_RADIANS;
123 float r1 = 10.0; //size of carrot
124 float theta = get_value();
126 float theta1 = -theta * SGD_DEGREES_TO_RADIANS + offset;
127 float x1 = x + radius * cos(theta1);
128 float y1 = y + radius * sin(theta1);
129 float x2 = x1 - r1 * cos(theta1 - 30.0 * SGD_DEGREES_TO_RADIANS);
130 float y2 = y1 - r1 * sin(theta1 - 30.0 * SGD_DEGREES_TO_RADIANS);
131 float x3 = x1 - r1 * cos(theta1 + 30.0 * SGD_DEGREES_TO_RADIANS);
132 float y3 = y1 - r1 * sin(theta1 + 30.0 * SGD_DEGREES_TO_RADIANS);
135 drawOneLine(x1, y1, x2, y2);
136 drawOneLine(x1, y1, x3, y3);
137 sprintf(TextScale,"%3.1f\n", theta);
140 int l = abs((int)theta);
143 textString(x, y, TextScale, 0);
145 textString(x - 1.0, y, TextScale, 0);
147 textString(x - 2.0, y, TextScale, 0);
153 // if its not explicitly a gauge default to tape
155 if (pointer_type == "moving") {
161 vmin = cur_value - half_width_units; // width units == needle travel
162 vmax = cur_value + half_width_units; // or picture unit span.
168 vmin = cur_value - half_width_units; // width units == needle travel
169 vmax = cur_value + half_width_units; // or picture unit span.
174 // Draw the basic markings for the scale...
176 if (huds_vert(options)) { // Vertical scale
178 if (draw_tick_bottom)
179 drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
183 drawOneLine(scrn_rect.left, height, width, height);
185 marker_xs = scrn_rect.left; // x start
186 marker_xe = width; // x extent
189 // glBegin(GL_LINES);
192 // glVertex2f(marker_xs, scrn_rect.top);
193 // glVertex2f(marker_xe, scrn_rect.top);
196 // glVertex2f(marker_xs, marker_ye);
197 // glVertex2f(marker_xe, marker_ye);
201 // We do not use else in the following so that combining the
202 // two options produces a "caged" display with double
203 // carrots. The same is done for horizontal card indicators.
205 // begin vertical/left
206 //First draw capping lines and pointers
207 if (huds_left(options)) { // Calculate x marker offset
209 if (draw_cap_right) {
211 drawOneLine(marker_xe, scrn_rect.top, marker_xe, marker_ye);
214 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
216 // drawOneLine(marker_xs, mid_scr.y,
217 // marker_xe, mid_scr.y + scrn_rect.right / 6);
218 // drawOneLine(marker_xs, mid_scr.y,
219 // marker_xe, mid_scr.y - scrn_rect.right / 6);
223 if (pointer_type == "moving") {
225 //Code for Moving Type Pointer
226 float ycentre, ypoint, xpoint;
228 if (cur_value > maxValue)
229 cur_value = maxValue;
230 if (cur_value < minValue)
231 cur_value = minValue;
234 ycentre = scrn_rect.top;
235 else if (maxValue + minValue == 0.0)
237 else if (oddtype == 1)
238 ycentre = scrn_rect.top + (1.0 - minValue)*scrn_rect.bottom
239 / (maxValue - minValue);
241 ycentre = scrn_rect.top + minValue * scrn_rect.bottom
242 / (maxValue - minValue);
244 range = scrn_rect.bottom;
245 wth = scrn_rect.left + scrn_rect.right;
248 ypoint = ycentre + ((cur_value - 1.0) * range / val_span);
250 ypoint = ycentre + (cur_value * range / val_span);
252 xpoint = wth + marker_offset;
253 drawOneLine(xpoint, ycentre, xpoint, ypoint);
254 drawOneLine(xpoint, ypoint, xpoint - marker_offset, ypoint);
255 drawOneLine(xpoint - marker_offset, ypoint, xpoint - 5.0, ypoint + 5.0);
256 drawOneLine(xpoint - marker_offset, ypoint, xpoint - 5.0, ypoint - 5.0);
261 fixed(marker_offset + marker_xe, text_y + scrn_rect.right / 6,
262 marker_offset + marker_xs, text_y, marker_offset + marker_xe,
263 text_y - scrn_rect.right / 6);
266 } //end vertical/left
268 // begin vertical/right
269 //First draw capping lines and pointers
270 if (huds_right(options)) { // We'll default this for now.
273 drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, marker_ye);
276 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
278 // drawOneLine(scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
279 // marker_xe, mid_scr.y);
280 // drawOneLine(scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
281 // marker_xe, mid_scr.y);
285 if (pointer_type == "moving") {
287 //type-fixed & zoom=1, behaviour to be defined
288 // Code for Moving Type Pointer
289 float ycentre, ypoint, xpoint;
292 if (cur_value > maxValue)
293 cur_value = maxValue;
294 if (cur_value < minValue)
295 cur_value = minValue;
298 ycentre = scrn_rect.top;
299 else if (maxValue + minValue == 0.0)
301 else if (oddtype == 1)
302 ycentre = scrn_rect.top + (1.0 - minValue)*scrn_rect.bottom / (maxValue - minValue);
304 ycentre = scrn_rect.top + minValue * scrn_rect.bottom / (maxValue - minValue);
306 range = scrn_rect.bottom;
309 ypoint = ycentre + ((cur_value - 1.0) * range / val_span);
311 ypoint = ycentre + (cur_value * range / val_span);
313 xpoint = scrn_rect.left - marker_offset;
314 drawOneLine(xpoint, ycentre, xpoint, ypoint);
315 drawOneLine(xpoint, ypoint, xpoint + marker_offset, ypoint);
316 drawOneLine(xpoint + marker_offset, ypoint, xpoint + 5.0, ypoint + 5.0);
317 drawOneLine(xpoint + marker_offset, ypoint, xpoint + 5.0, ypoint - 5.0);
322 fixed(-marker_offset + scrn_rect.left, text_y + scrn_rect.right / 6,
323 -marker_offset + marker_xe, text_y,-marker_offset + scrn_rect.left,
324 text_y - scrn_rect.right / 6);
327 } //end vertical/right
329 // At this point marker x_start and x_end values are transposed.
330 // To keep this from confusing things they are now interchanged.
331 if (huds_both(options)) {
332 marker_ye = marker_xs;
333 marker_xs = marker_xe;
334 marker_xe = marker_ye;
337 // Work through from bottom to top of scale. Calculating where to put
338 // minor and major ticks.
340 // draw scale or tape
342 // last = float_to_int(vmax)+1;
343 // i = float_to_int(vmin);
344 last = (int)vmax + 1; // N
348 zoomed_scale((int)vmin, (int)vmax);
350 for (; i < last; i++) {
352 if (!modulo() && i < min_val())
355 if (condition) { // Show a tick if necessary
356 // Calculate the location of this tick
357 marker_ys = scrn_rect.top + ((i - vmin) * factor()/*+.5f*/);
358 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
359 // Block calculation artifact from drawing ticks below min coordinate.
360 // Calculation here accounts for text height.
362 if ((marker_ys < (scrn_rect.top + 4))
363 || (marker_ys > (height - 4))) {
369 k = i + 1; //enable ticks at odd values
373 bool major_tick_drawn = false;
377 if (!(k % (int)div_max())) {
378 major_tick_drawn = true;
380 disp_val = i % (int) modulo(); // ?????????
383 disp_val += modulo();
389 lenstr = sprintf(TextScale, "%d",
390 float_to_int(disp_val * data_scaling()/*+.5*/));
391 // (int)(disp_val * data_scaling() +.5));
392 /* if (((marker_ys - 8) > scrn_rect.top) &&
393 ((marker_ys + 8) < (height))){ */
395 if (huds_both(options)) {
396 // drawOneLine(scrn_rect.left, marker_ys,
397 // marker_xs, marker_ys);
398 // drawOneLine(marker_xs, marker_ys,
399 // scrn_rect.left + scrn_rect.right,
401 if (tick_type == "line") {
402 glBegin(GL_LINE_STRIP);
403 glVertex2f(scrn_rect.left, marker_ys);
404 glVertex2f(marker_xs, marker_ys);
405 glVertex2f(width, marker_ys);
408 } else if (tick_type == "circle") {
409 circles(scrn_rect.left, (float)marker_ys, 5.0);
412 glBegin(GL_LINE_STRIP);
413 glVertex2f(scrn_rect.left, marker_ys);
414 glVertex2f(marker_xs, marker_ys);
415 glVertex2f(width, marker_ys);
419 if (!huds_notext(options))
420 textString (marker_xs + 2, marker_ys, TextScale, 0);
423 /* Changes are made to draw a circle when tick_type="circle" */
424 // anything other than huds_both
425 if (tick_type == "line")
426 drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
427 else if (tick_type == "circle")
428 circles((float)marker_xs + 4, (float)marker_ys, 5.0);
430 drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
432 if (!huds_notext(options)) {
433 if (huds_left(options)) {
434 textString(marker_xs - 8 * lenstr - 2,
435 marker_ys - 4, TextScale, 0);
437 textString(marker_xe + 3 * lenstr,
438 marker_ys - 4, TextScale, 0);
440 } //End if !huds_notext
442 } // End if draw major ticks
443 } // End if major ticks
446 if (div_min() && !major_tick_drawn) {
447 // if ((i % div_min()) == 0) {
448 if (!(k % (int)div_min())) {
449 if (((marker_ys - 5) > scrn_rect.top)
450 && ((marker_ys + 5) < (height))) {
452 //vertical/left OR vertical/right
453 if (huds_both(options)) {
454 if (tick_type == "line") {
455 if (tick_length == "variable") {
456 drawOneLine(scrn_rect.left, marker_ys,
457 marker_xs, marker_ys);
458 drawOneLine(marker_xe, marker_ys,
461 drawOneLine(scrn_rect.left, marker_ys,
462 marker_xs, marker_ys);
463 drawOneLine(marker_xe, marker_ys,
467 } else if (tick_type == "circle") {
468 circles(scrn_rect.left,(float)marker_ys, 3.0);
471 // if neither line nor circle draw default as line
472 drawOneLine(scrn_rect.left, marker_ys,
473 marker_xs, marker_ys);
474 drawOneLine(marker_xe, marker_ys,
477 // glBegin(GL_LINES);
478 // glVertex2f(scrn_rect.left, marker_ys);
479 // glVertex2f(marker_xs, marker_ys);
480 // glVertex2f(marker_xe, marker_ys);
481 // glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
483 // anything other than huds_both
486 if (huds_left(options)) {
487 if (tick_type == "line") {
488 if (tick_length == "variable") {
489 drawOneLine(marker_xs + 4, marker_ys,
490 marker_xe, marker_ys);
492 drawOneLine(marker_xs, marker_ys,
493 marker_xe, marker_ys);
495 } else if (tick_type == "circle") {
496 circles((float)marker_xs + 4, (float)marker_ys, 3.0);
499 drawOneLine(marker_xs + 4, marker_ys,
500 marker_xe, marker_ys);
504 if (tick_type == "line") {
505 if (tick_length == "variable") {
506 drawOneLine(marker_xs, marker_ys,
507 marker_xe - 4, marker_ys);
509 drawOneLine(marker_xs, marker_ys,
510 marker_xe, marker_ys);
513 } else if (tick_type == "circle") {
514 circles((float)marker_xe - 4, (float)marker_ys, 3.0);
516 drawOneLine(marker_xs, marker_ys,
517 marker_xe - 4, marker_ys);
522 } //end draw minor ticks
528 // End if VERTICAL SCALE TYPE (tape loop yet to be closed)
531 // Horizontal scale by default
534 drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
538 drawOneLine(width, scrn_rect.top, width, height);
540 marker_ys = scrn_rect.top; // Starting point for
541 marker_ye = height; // tick y location calcs
543 marker_xs = scrn_rect.left + ((cur_value - vmin) * factor() /*+ .5f*/);
545 // glBegin(GL_LINES);
547 // glVertex2f(scrn_rect.left, scrn_rect.top);
548 // glVertex2f(scrn_rect.left, marker_ye);
551 // glVertex2f(marker_xe, scrn_rect.top);
552 // glVertex2f(marker_xe, marker_ye);
555 if (huds_top(options)) {
558 drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
561 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
563 // drawOneLine(mid_scr.x, marker_ye,
564 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
565 // drawOneLine(mid_scr.x, marker_ye,
566 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
569 if (pointer_type == "moving") {
571 //Code for Moving Type Pointer
572 // static float xcentre, xpoint, ypoint;
574 if (cur_value > maxValue)
575 cur_value = maxValue;
576 if (cur_value < minValue)
577 cur_value = minValue;
579 float xcentre = mid_scr.x;
580 int range = scrn_rect.right;
581 float xpoint = xcentre + (cur_value * range / val_span);
582 float ypoint = scrn_rect.top - marker_offset;
583 drawOneLine(xcentre, ypoint, xpoint, ypoint);
584 drawOneLine(xpoint, ypoint, xpoint, ypoint + marker_offset);
585 drawOneLine(xpoint, ypoint + marker_offset, xpoint + 5.0, ypoint + 5.0);
586 drawOneLine(xpoint, ypoint + marker_offset, xpoint - 5.0, ypoint + 5.0);
591 fixed(marker_xs - scrn_rect.bottom / 4, scrn_rect.top, marker_xs,
592 marker_ye, marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
595 } //End Horizontal scale/top
597 if (huds_bottom(options)) {
600 drawOneLine(scrn_rect.left, height, width, height);
603 marker_ys = height - scrn_rect.bottom / 2;
605 // drawOneLine(mid_scr.x + scrn_rect.bottom / 4,
606 // scrn_rect.top + scrn_rect.bottom,
607 // mid_scr.x, marker_ys);
608 // drawOneLine(mid_scr.x - scrn_rect.bottom / 4,
609 // scrn_rect.top + scrn_rect.bottom,
610 // mid_scr.x , marker_ys);
614 if (pointer_type == "moving") {
616 //Code for Moving Type Pointer
617 // static float xcentre, xpoint, ypoint;
618 // static int range, hgt;
619 if (cur_value > maxValue)
620 cur_value = maxValue;
621 if (cur_value < minValue)
622 cur_value = minValue;
624 float xcentre = mid_scr.x ;
625 int range = scrn_rect.right;
626 int hgt = scrn_rect.top + scrn_rect.bottom;
627 float xpoint = xcentre + (cur_value * range / val_span);
628 float ypoint = hgt + marker_offset;
629 drawOneLine(xcentre, ypoint, xpoint, ypoint);
630 drawOneLine(xpoint, ypoint, xpoint, ypoint - marker_offset);
631 drawOneLine(xpoint, ypoint - marker_offset, xpoint + 5.0, ypoint - 5.0);
632 drawOneLine(xpoint, ypoint - marker_offset, xpoint - 5.0, ypoint - 5.0);
635 fixed(marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
636 marker_xs - scrn_rect.bottom / 4, height);
639 } //end horizontal scale bottom
641 // if ((options & HUDS_BOTTOM) == HUDS_BOTTOM) {
642 // marker_xe = marker_ys;
643 // marker_ys = marker_ye;
644 // marker_ye = marker_xe;
647 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
649 // last = float_to_int(vmax)+1;
650 // i = float_to_int(vmin);
653 zoomed_scale((int)vmin,(int)vmax);
656 last = (int)vmax + 1;
658 for (; i < last; i++) {
659 // for (i = (int)vmin; i <= (int)vmax; i++) {
660 // printf("<*> i = %d\n", i);
662 if (!modulo() && i < min_val())
665 // printf("<**> i = %d\n", i);
667 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
668 marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
671 k = i + 1; //enable ticks at odd values
675 bool major_tick_drawn = false;
679 // printf("i = %d\n", i);
680 // if ((i % (int)div_max())==0) {
683 if (!(k % (int)div_max())) {
684 major_tick_drawn = true;
686 disp_val = i % (int) modulo(); // ?????????
689 disp_val += modulo();
694 // printf("disp_val = %d\n", disp_val);
695 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
696 lenstr = sprintf(TextScale, "%d",
697 // (int)(disp_val * data_scaling() +.5));
698 float_to_int(disp_val * data_scaling()/*+.5*/));
700 // Draw major ticks and text only if far enough from the edge.
701 if (((marker_xs - 10)> scrn_rect.left)
702 && ((marker_xs + 10) < (scrn_rect.left + scrn_rect.right))) {
703 if (huds_both(options)) {
704 // drawOneLine(marker_xs, scrn_rect.top,
705 // marker_xs, marker_ys);
706 // drawOneLine(marker_xs, marker_ye,
707 // marker_xs, scrn_rect.top + scrn_rect.bottom);
708 glBegin(GL_LINE_STRIP);
709 glVertex2f(marker_xs, scrn_rect.top);
710 glVertex2f(marker_xs, marker_ye);
711 glVertex2f(marker_xs, height);
714 if (!huds_notext(options)) {
715 textString(marker_xs - 4 * lenstr,
716 marker_ys + 4, TextScale, 0);
719 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
721 if (!huds_notext(options)) {
722 if (huds_top(options)) {
723 textString(marker_xs - 4 * lenstr,
724 height - 10, TextScale, 0);
727 textString(marker_xs - 4 * lenstr,
728 scrn_rect.top, TextScale, 0);
733 } //end draw major ticks
734 } //endif major ticks
736 if (div_min() && !major_tick_drawn) {
737 // if ((i % (int)div_min()) == 0) {
739 if (!(k % (int)div_min())) {
740 // draw in ticks only if they aren't too close to the edge.
741 if (((marker_xs - 5) > scrn_rect.left)
742 && ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) {
744 if (huds_both(options)) {
745 if (tick_length == "variable") {
746 drawOneLine(marker_xs, scrn_rect.top,
747 marker_xs, marker_ys - 4);
748 drawOneLine(marker_xs, marker_ye + 4,
751 drawOneLine(marker_xs, scrn_rect.top,
752 marker_xs, marker_ys);
753 drawOneLine(marker_xs, marker_ye,
756 // glBegin(GL_LINES);
757 // glVertex2f(marker_xs, scrn_rect.top);
758 // glVertex2f(marker_xs, marker_ys - 4);
759 // glVertex2f(marker_xs, marker_ye + 4);
760 // glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom);
764 if (huds_top(options)) {
766 if (tick_length == "variable")
767 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4);
769 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
771 } else if (tick_length == "variable") {
772 drawOneLine(marker_xs, marker_ys + 4, marker_xs, marker_ye);
774 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
778 } //end draw minor ticks
784 } //end horizontal/vertical scale
785 } // end of type tape
790 void hud_card::circles(float x, float y, float size)
792 glEnable(GL_POINT_SMOOTH);
800 glDisable(GL_POINT_SMOOTH);
804 void hud_card::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
806 glBegin(GL_LINE_STRIP);
814 void hud_card::zoomed_scale(int first, int last)
816 POINT mid_scr = get_centroid();
817 RECT scrn_rect = get_location();
818 UINT options = get_options();
822 float x, y, w, h, bottom;
823 float cur_value = get_value();
824 if (cur_value > maxValue)
825 cur_value = maxValue;
826 if (cur_value < minValue)
827 cur_value = minValue;
831 while (first <= last) {
832 if ((first % (int)Maj_div) == 0) {
840 if (huds_vert(options)) {
843 w = scrn_rect.left + scrn_rect.right;
844 h = scrn_rect.top + scrn_rect.bottom;
845 bottom = scrn_rect.bottom;
847 float xstart, yfirst, ycentre, ysecond;
849 float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
850 yfirst = mid_scr.y - hgt;
852 ysecond = mid_scr.y + hgt;
853 float range = hgt * 2;
856 float factor = range / 10.0;
858 float hgt1 = bottom * 30.0 / 100.0;
859 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
860 int incr = incrs / 2;
861 float factors = hgt1 / incr;
864 //this is for moving type pointer
865 static float ycent, ypoint, xpoint;
869 wth = scrn_rect.left + scrn_rect.right;
871 if (cur_value <= data[centre + 1])
872 if (cur_value > data[centre]) {
873 ypoint = ycent + ((cur_value - data[centre]) * hgt / Maj_div);
876 if (cur_value >= data[centre - 1])
877 if (cur_value <= data[centre]) {
878 ypoint = ycent - ((data[centre]-cur_value) * hgt / Maj_div);
881 if (cur_value < data[centre - 1])
882 if (cur_value >= minValue) {
883 float diff = minValue - data[centre - 1];
884 float diff1 = cur_value - data[centre - 1];
885 float val = (diff1 * hgt1) / diff;
887 ypoint = ycent - hgt - val;
890 if (cur_value > data[centre + 1])
891 if (cur_value <= maxValue) {
892 float diff = maxValue - data[centre + 1];
893 float diff1 = cur_value - data[centre + 1];
894 float val = (diff1 * hgt1) / diff;
896 ypoint = ycent + hgt + val;
899 if (huds_left(options)) {
902 drawOneLine(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
904 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
906 if (!huds_notext(options))
907 textString(x, ycentre, TextScale, 0);
909 for (i = 1; i < 5; i++) {
912 circles(xstart - 2.5, yfirst, 3.0);
913 circles(xstart - 2.5, ycentre, 3.0);
916 yfirst = mid_scr.y - hgt;
918 for (i = 0; i <= incr; i++) {
919 drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
920 drawOneLine(xstart, ysecond, xstart - 5.0, ysecond);
922 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
924 if (!huds_notext(options))
925 textString (x, yfirst, TextScale, 0);
927 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
929 if (!huds_notext(options))
930 textString (x, ysecond, TextScale, 0);
937 //to draw moving type pointer for left option
941 if (pointer_type == "moving") {
942 drawOneLine(xpoint, ycent, xpoint, ypoint);
943 drawOneLine(xpoint, ypoint, xpoint - 10.0, ypoint);
944 drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint + 5.0);
945 drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint - 5.0);
951 xstart = (x + w) / 2;
953 drawOneLine(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
955 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
957 if (!huds_notext(options))
958 textString(w, ycentre, TextScale, 0);
960 for (i = 1; i < 5; i++) {
963 circles(xstart + 2.5, yfirst, 3.0);
964 circles(xstart + 2.5, ycentre, 3.0);
967 yfirst = mid_scr.y - hgt;
969 for (i = 0; i <= incr; i++) {
970 drawOneLine(xstart, yfirst, xstart + 5.0, yfirst);
971 drawOneLine(xstart, ysecond, xstart + 5.0, ysecond);
973 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
975 if (!huds_notext(options))
976 textString(w, yfirst, TextScale, 0);
978 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
980 if (!huds_notext(options))
981 textString(w, ysecond, TextScale, 0);
988 // to draw moving type pointer for right option
990 xpoint = scrn_rect.left;
992 if (pointer_type == "moving") {
993 drawOneLine(xpoint, ycent, xpoint, ypoint);
994 drawOneLine(xpoint, ypoint, xpoint + 10.0, ypoint);
995 drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint + 5.0);
996 drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint - 5.0);
999 }//end huds_right /left
1000 //end of vertical scale
1006 w = scrn_rect.left + scrn_rect.right;
1007 h = scrn_rect.top + scrn_rect.bottom;
1008 bottom = scrn_rect.right;
1010 float ystart, xfirst, xcentre, xsecond;
1012 float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
1013 xfirst = mid_scr.x - hgt;
1014 xcentre = mid_scr.x;
1015 xsecond = mid_scr.x + hgt;
1016 float range = hgt * 2;
1019 float factor = range / 10.0;
1021 float hgt1 = bottom * 30.0 / 100.0;
1022 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
1023 int incr = incrs / 2;
1024 float factors = hgt1 / incr;
1027 //Code for Moving Type Pointer
1029 static float xcent, xpoint, ypoint;
1033 if (cur_value <= data[centre + 1])
1034 if (cur_value > data[centre]) {
1035 xpoint = xcent + ((cur_value - data[centre]) * hgt / Maj_div);
1038 if (cur_value >= data[centre - 1])
1039 if (cur_value <= data[centre]) {
1040 xpoint = xcent - ((data[centre]-cur_value) * hgt / Maj_div);
1043 if (cur_value < data[centre - 1])
1044 if (cur_value >= minValue) {
1045 float diff = minValue - data[centre - 1];
1046 float diff1 = cur_value - data[centre - 1];
1047 float val = (diff1 * hgt1) / diff;
1049 xpoint = xcent - hgt - val;
1053 if (cur_value > data[centre + 1])
1054 if (cur_value <= maxValue) {
1055 float diff = maxValue - data[centre + 1];
1056 float diff1 = cur_value - data[centre + 1];
1057 float val = (diff1 * hgt1) / diff;
1059 xpoint = xcent + hgt + val;
1063 if (huds_top(options)) {
1065 drawOneLine(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
1067 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1069 if (!huds_notext(options))
1070 textString (xcentre - 10.0, y, TextScale, 0);
1072 for (i = 1; i < 5; i++) {
1075 circles(xfirst, ystart - 2.5, 3.0);
1076 circles(xcentre, ystart - 2.5, 3.0);
1079 xfirst = mid_scr.x - hgt;
1081 for (i = 0; i <= incr; i++) {
1082 drawOneLine(xfirst, ystart, xfirst, ystart - 5.0);
1083 drawOneLine(xsecond, ystart, xsecond, ystart - 5.0);
1085 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
1087 if (!huds_notext(options))
1088 textString (xfirst - 10.0, y, TextScale, 0);
1090 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
1092 if (!huds_notext(options))
1093 textString (xsecond - 10.0, y, TextScale, 0);
1099 //this is for moving pointer for top option
1102 ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
1104 if (pointer_type == "moving") {
1105 drawOneLine(xcent, ypoint, xpoint, ypoint);
1106 drawOneLine(xpoint, ypoint, xpoint, ypoint - 10.0);
1107 drawOneLine(xpoint, ypoint - 10.0, xpoint + 5.0, ypoint - 5.0);
1108 drawOneLine(xpoint, ypoint - 10.0, xpoint - 5.0, ypoint - 5.0);
1114 ystart = (y + h) / 2;
1116 //drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
1117 drawOneLine(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
1119 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1121 if (!huds_notext(options))
1122 textString (xcentre - 10.0, h, TextScale, 0);
1124 for (i = 1; i < 5; i++) {
1127 circles(xfirst, ystart + 2.5, 3.0);
1128 circles(xcentre, ystart + 2.5, 3.0);
1131 xfirst = mid_scr.x - hgt;
1133 for (i = 0; i <= incr; i++) {
1134 drawOneLine(xfirst, ystart, xfirst, ystart + 5.0);
1135 drawOneLine(xsecond, ystart, xsecond, ystart + 5.0);
1137 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
1139 if (!huds_notext(options))
1140 textString (xfirst - 10.0, h, TextScale, 0);
1142 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
1144 if (!huds_notext(options))
1145 textString (xsecond - 10.0, h, TextScale, 0);
1150 //this is for movimg pointer for bottom option
1153 ypoint = scrn_rect.top - 10.0;
1154 if (pointer_type == "moving") {
1155 drawOneLine(xcent, ypoint, xpoint, ypoint);
1156 drawOneLine(xpoint, ypoint, xpoint, ypoint + 10.0);
1157 drawOneLine(xpoint, ypoint + 10.0, xpoint + 5.0, ypoint + 5.0);
1158 drawOneLine(xpoint, ypoint + 10.0, xpoint - 5.0, ypoint + 5.0);
1160 }//end hud_top or hud_bottom
1161 } //end of horizontal/vertical scales