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
375 // if ((i % div_min()) == 0) {
376 if (!(k % (int)div_min())) {
377 if (((marker_ys - 5) > scrn_rect.top)
378 && ((marker_ys + 5) < (height))) {
380 //vertical/left OR vertical/right
381 if (huds_both(options)) {
382 if (tick_type == "line") {
383 if (tick_length == "variable") {
384 drawOneLine(scrn_rect.left, marker_ys,
385 marker_xs, marker_ys);
386 drawOneLine(marker_xe, marker_ys,
389 drawOneLine(scrn_rect.left, marker_ys,
390 marker_xs, marker_ys);
391 drawOneLine(marker_xe, marker_ys,
395 } else if (tick_type == "circle") {
396 circles(scrn_rect.left,(float)marker_ys, 3.0);
399 // if neither line nor circle draw default as line
400 drawOneLine(scrn_rect.left, marker_ys,
401 marker_xs, marker_ys);
402 drawOneLine(marker_xe, marker_ys,
405 // glBegin(GL_LINES);
406 // glVertex2f(scrn_rect.left, marker_ys);
407 // glVertex2f(marker_xs, marker_ys);
408 // glVertex2f(marker_xe, marker_ys);
409 // glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
411 // anything other than huds_both
414 if (huds_left(options)) {
415 if (tick_type == "line") {
416 if (tick_length == "variable") {
417 drawOneLine(marker_xs + 4, marker_ys,
418 marker_xe, marker_ys);
420 drawOneLine(marker_xs, marker_ys,
421 marker_xe, marker_ys);
423 } else if (tick_type == "circle") {
424 circles((float)marker_xs + 4, (float)marker_ys, 3.0);
427 drawOneLine(marker_xs + 4, marker_ys,
428 marker_xe, marker_ys);
432 if (tick_type == "line") {
433 if (tick_length == "variable") {
434 drawOneLine(marker_xs, marker_ys,
435 marker_xe - 4, marker_ys);
437 drawOneLine(marker_xs, marker_ys,
438 marker_xe, marker_ys);
441 } else if (tick_type == "circle") {
442 circles((float)marker_xe - 4, (float)marker_ys, 3.0);
444 drawOneLine(marker_xs, marker_ys,
445 marker_xe - 4, marker_ys);
450 } //end draw minor ticks
455 if (!(k % (int)div_max())) {
457 disp_val = i % (int) modulo(); // ?????????
460 disp_val += modulo();
466 lenstr = sprintf(TextScale, "%d",
467 float_to_int(disp_val * data_scaling()/*+.5*/));
468 // (int)(disp_val * data_scaling() +.5));
469 /* if (((marker_ys - 8) > scrn_rect.top) &&
470 ((marker_ys + 8) < (height))){ */
472 if (huds_both(options)) {
473 // drawOneLine(scrn_rect.left, marker_ys,
474 // marker_xs, marker_ys);
475 // drawOneLine(marker_xs, marker_ys,
476 // scrn_rect.left + scrn_rect.right,
478 if (tick_type == "line") {
479 glBegin(GL_LINE_STRIP);
480 glVertex2f(scrn_rect.left, marker_ys);
481 glVertex2f(marker_xs, marker_ys);
482 glVertex2f(width, marker_ys);
485 } else if (tick_type == "circle") {
486 circles(scrn_rect.left, (float)marker_ys, 5.0);
489 glBegin(GL_LINE_STRIP);
490 glVertex2f(scrn_rect.left, marker_ys);
491 glVertex2f(marker_xs, marker_ys);
492 glVertex2f(width, marker_ys);
496 if (!huds_notext(options))
497 textString (marker_xs + 2, marker_ys, TextScale, 0);
500 /* Changes are made to draw a circle when tick_type="circle" */
501 // anything other than huds_both
502 if (tick_type == "line")
503 drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
504 else if (tick_type == "circle")
505 circles((float)marker_xs + 4, (float)marker_ys, 5.0);
507 drawOneLine(marker_xs, marker_ys, marker_xe, marker_ys);
509 if (!huds_notext(options)) {
510 if (huds_left(options)) {
511 textString(marker_xs - 8 * lenstr - 2,
512 marker_ys - 4, TextScale, 0);
514 textString(marker_xe + 3 * lenstr,
515 marker_ys - 4, TextScale, 0);
517 } //End if !huds_notext
519 } // End if draw major ticks
520 } // End if major ticks
524 // End if VERTICAL SCALE TYPE (tape loop yet to be closed)
527 // Horizontal scale by default
530 drawOneLine(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
534 drawOneLine(width, scrn_rect.top, width, height);
536 marker_ys = scrn_rect.top; // Starting point for
537 marker_ye = height; // tick y location calcs
539 marker_xs = scrn_rect.left + ((cur_value - vmin) * factor() /*+ .5f*/);
541 // glBegin(GL_LINES);
543 // glVertex2f(scrn_rect.left, scrn_rect.top);
544 // glVertex2f(scrn_rect.left, marker_ye);
547 // glVertex2f(marker_xe, scrn_rect.top);
548 // glVertex2f(marker_xe, marker_ye);
551 if (huds_top(options)) {
554 drawOneLine(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
557 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
559 // drawOneLine(mid_scr.x, marker_ye,
560 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
561 // drawOneLine(mid_scr.x, marker_ye,
562 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
565 if (pointer_type == "moving") {
567 //Code for Moving Type Pointer
568 // static float xcentre, xpoint, ypoint;
570 if (cur_value > maxValue)
571 cur_value = maxValue;
572 if (cur_value < minValue)
573 cur_value = minValue;
575 float xcentre = mid_scr.x;
576 int range = scrn_rect.right;
577 float xpoint = xcentre + (cur_value * range / val_span);
578 float ypoint = scrn_rect.top - marker_offset;
579 drawOneLine(xcentre, ypoint, xpoint, ypoint);
580 drawOneLine(xpoint, ypoint, xpoint, ypoint + marker_offset);
581 drawOneLine(xpoint, ypoint + marker_offset, xpoint + 5.0, ypoint + 5.0);
582 drawOneLine(xpoint, ypoint + marker_offset, xpoint - 5.0, ypoint + 5.0);
587 fixed(marker_xs - scrn_rect.bottom / 4, scrn_rect.top, marker_xs,
588 marker_ye, marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
591 } //End Horizontal scale/top
593 if (huds_bottom(options)) {
596 drawOneLine(scrn_rect.left, height, width, height);
599 marker_ys = height - scrn_rect.bottom / 2;
601 // drawOneLine(mid_scr.x + scrn_rect.bottom / 4,
602 // scrn_rect.top + scrn_rect.bottom,
603 // mid_scr.x, marker_ys);
604 // drawOneLine(mid_scr.x - scrn_rect.bottom / 4,
605 // scrn_rect.top + scrn_rect.bottom,
606 // mid_scr.x , marker_ys);
610 if (pointer_type == "moving") {
612 //Code for Moving Type Pointer
613 // static float xcentre, xpoint, ypoint;
614 // static int range, hgt;
615 if (cur_value > maxValue)
616 cur_value = maxValue;
617 if (cur_value < minValue)
618 cur_value = minValue;
620 float xcentre = mid_scr.x ;
621 int range = scrn_rect.right;
622 int hgt = scrn_rect.top + scrn_rect.bottom;
623 float xpoint = xcentre + (cur_value * range / val_span);
624 float ypoint = hgt + marker_offset;
625 drawOneLine(xcentre, ypoint, xpoint, ypoint);
626 drawOneLine(xpoint, ypoint, xpoint, ypoint - marker_offset);
627 drawOneLine(xpoint, ypoint - marker_offset, xpoint + 5.0, ypoint - 5.0);
628 drawOneLine(xpoint, ypoint - marker_offset, xpoint - 5.0, ypoint - 5.0);
631 fixed(marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
632 marker_xs - scrn_rect.bottom / 4, height);
635 } //end horizontal scale bottom
637 // if ((options & HUDS_BOTTOM) == HUDS_BOTTOM) {
638 // marker_xe = marker_ys;
639 // marker_ys = marker_ye;
640 // marker_ye = marker_xe;
643 // printf("vmin = %d vmax = %d\n", (int)vmin, (int)vmax);
645 // last = float_to_int(vmax)+1;
646 // i = float_to_int(vmin);
649 zoomed_scale((int)vmin,(int)vmax);
652 last = (int)vmax + 1;
654 for (; i < last; i++) {
655 // for (i = (int)vmin; i <= (int)vmax; i++) {
656 // printf("<*> i = %d\n", i);
658 if (!modulo() && i < min_val())
661 // printf("<**> i = %d\n", i);
663 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
664 marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
667 k = i + 1; //enable ticks at odd values
672 // if ((i % (int)div_min()) == 0) {
674 if (!(k % (int)div_min())) {
675 // draw in ticks only if they aren't too close to the edge.
676 if (((marker_xs - 5) > scrn_rect.left)
677 && ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) {
679 if (huds_both(options)) {
680 if (tick_length == "variable") {
681 drawOneLine(marker_xs, scrn_rect.top,
682 marker_xs, marker_ys - 4);
683 drawOneLine(marker_xs, marker_ye + 4,
686 drawOneLine(marker_xs, scrn_rect.top,
687 marker_xs, marker_ys);
688 drawOneLine(marker_xs, marker_ye,
691 // glBegin(GL_LINES);
692 // glVertex2f(marker_xs, scrn_rect.top);
693 // glVertex2f(marker_xs, marker_ys - 4);
694 // glVertex2f(marker_xs, marker_ye + 4);
695 // glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom);
699 if (huds_top(options)) {
701 if (tick_length == "variable")
702 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye - 4);
704 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
706 } else if (tick_length == "variable") {
707 drawOneLine(marker_xs, marker_ys + 4, marker_xs, marker_ye);
709 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
713 } //end draw minor ticks
718 // printf("i = %d\n", i);
719 // if ((i % (int)div_max())==0) {
722 if (!(k % (int)div_max())) {
724 disp_val = i % (int) modulo(); // ?????????
727 disp_val += modulo();
732 // printf("disp_val = %d\n", disp_val);
733 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
734 lenstr = sprintf(TextScale, "%d",
735 // (int)(disp_val * data_scaling() +.5));
736 float_to_int(disp_val * data_scaling()/*+.5*/));
738 // Draw major ticks and text only if far enough from the edge.
739 if (((marker_xs - 10)> scrn_rect.left)
740 && ((marker_xs + 10) < (scrn_rect.left + scrn_rect.right))) {
741 if (huds_both(options)) {
742 // drawOneLine(marker_xs, scrn_rect.top,
743 // marker_xs, marker_ys);
744 // drawOneLine(marker_xs, marker_ye,
745 // marker_xs, scrn_rect.top + scrn_rect.bottom);
746 glBegin(GL_LINE_STRIP);
747 glVertex2f(marker_xs, scrn_rect.top);
748 glVertex2f(marker_xs, marker_ye);
749 glVertex2f(marker_xs, height);
752 if (!huds_notext(options)) {
753 textString(marker_xs - 4 * lenstr,
754 marker_ys + 4, TextScale, 0);
757 drawOneLine(marker_xs, marker_ys, marker_xs, marker_ye);
759 if (!huds_notext(options)) {
760 if (huds_top(options)) {
761 textString(marker_xs - 4 * lenstr,
762 height - 10, TextScale, 0);
765 textString(marker_xs - 4 * lenstr,
766 scrn_rect.top, TextScale, 0);
771 } //end draw major ticks
772 } //endif major ticks
776 } //end horizontal/vertical scale
777 } // end of type tape
782 void hud_card::circles(float x, float y, float size)
784 glEnable(GL_POINT_SMOOTH);
792 glDisable(GL_POINT_SMOOTH);
796 void hud_card::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
798 glBegin(GL_LINE_STRIP);
806 void hud_card::zoomed_scale(int first, int last)
808 POINT mid_scr = get_centroid();
809 RECT scrn_rect = get_location();
810 UINT options = get_options();
814 float x, y, w, h, bottom;
815 float cur_value = get_value();
816 if (cur_value > maxValue)
817 cur_value = maxValue;
818 if (cur_value < minValue)
819 cur_value = minValue;
823 while (first <= last) {
824 if ((first % (int)Maj_div) == 0) {
832 if (huds_vert(options)) {
835 w = scrn_rect.left + scrn_rect.right;
836 h = scrn_rect.top + scrn_rect.bottom;
837 bottom = scrn_rect.bottom;
839 float xstart, yfirst, ycentre, ysecond;
841 float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
842 yfirst = mid_scr.y - hgt;
844 ysecond = mid_scr.y + hgt;
845 float range = hgt * 2;
848 float factor = range / 10.0;
850 float hgt1 = bottom * 30.0 / 100.0;
851 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
852 int incr = incrs / 2;
853 float factors = hgt1 / incr;
856 //this is for moving type pointer
857 static float ycent, ypoint, xpoint;
861 wth = scrn_rect.left + scrn_rect.right;
863 if (cur_value <= data[centre + 1])
864 if (cur_value > data[centre]) {
865 ypoint = ycent + ((cur_value - data[centre]) * hgt / Maj_div);
868 if (cur_value >= data[centre - 1])
869 if (cur_value <= data[centre]) {
870 ypoint = ycent - ((data[centre]-cur_value) * hgt / Maj_div);
873 if (cur_value < data[centre - 1])
874 if (cur_value >= minValue) {
875 float diff = minValue - data[centre - 1];
876 float diff1 = cur_value - data[centre - 1];
877 float val = (diff1 * hgt1) / diff;
879 ypoint = ycent - hgt - val;
882 if (cur_value > data[centre + 1])
883 if (cur_value <= maxValue) {
884 float diff = maxValue - data[centre + 1];
885 float diff1 = cur_value - data[centre + 1];
886 float val = (diff1 * hgt1) / diff;
888 ypoint = ycent + hgt + val;
891 if (huds_left(options)) {
894 drawOneLine(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
896 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
898 if (!huds_notext(options))
899 textString(x, ycentre, TextScale, 0);
901 for (i = 1; i < 5; i++) {
904 circles(xstart - 2.5, yfirst, 3.0);
905 circles(xstart - 2.5, ycentre, 3.0);
908 yfirst = mid_scr.y - hgt;
910 for (i = 0; i <= incr; i++) {
911 drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
912 drawOneLine(xstart, ysecond, xstart - 5.0, ysecond);
914 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
916 if (!huds_notext(options))
917 textString (x, yfirst, TextScale, 0);
919 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
921 if (!huds_notext(options))
922 textString (x, ysecond, TextScale, 0);
929 //to draw moving type pointer for left option
933 if (pointer_type == "moving") {
934 drawOneLine(xpoint, ycent, xpoint, ypoint);
935 drawOneLine(xpoint, ypoint, xpoint - 10.0, ypoint);
936 drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint + 5.0);
937 drawOneLine(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint - 5.0);
943 xstart = (x + w) / 2;
945 drawOneLine(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
947 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
949 if (!huds_notext(options))
950 textString(w, ycentre, TextScale, 0);
952 for (i = 1; i < 5; i++) {
955 circles(xstart + 2.5, yfirst, 3.0);
956 circles(xstart + 2.5, ycentre, 3.0);
959 yfirst = mid_scr.y - hgt;
961 for (i = 0; i <= incr; i++) {
962 drawOneLine(xstart, yfirst, xstart + 5.0, yfirst);
963 drawOneLine(xstart, ysecond, xstart + 5.0, ysecond);
965 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
967 if (!huds_notext(options))
968 textString(w, yfirst, TextScale, 0);
970 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
972 if (!huds_notext(options))
973 textString(w, ysecond, TextScale, 0);
980 // to draw moving type pointer for right option
982 xpoint = scrn_rect.left;
984 if (pointer_type == "moving") {
985 drawOneLine(xpoint, ycent, xpoint, ypoint);
986 drawOneLine(xpoint, ypoint, xpoint + 10.0, ypoint);
987 drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint + 5.0);
988 drawOneLine(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint - 5.0);
991 }//end huds_right /left
992 //end of vertical scale
998 w = scrn_rect.left + scrn_rect.right;
999 h = scrn_rect.top + scrn_rect.bottom;
1000 bottom = scrn_rect.right;
1002 float ystart, xfirst, xcentre, xsecond;
1004 float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
1005 xfirst = mid_scr.x - hgt;
1006 xcentre = mid_scr.x;
1007 xsecond = mid_scr.x + hgt;
1008 float range = hgt * 2;
1011 float factor = range / 10.0;
1013 float hgt1 = bottom * 30.0 / 100.0;
1014 int incrs = ((int)val_span - (Maj_div * 2)) / Maj_div ;
1015 int incr = incrs / 2;
1016 float factors = hgt1 / incr;
1019 //Code for Moving Type Pointer
1021 static float xcent, xpoint, ypoint;
1025 if (cur_value <= data[centre + 1])
1026 if (cur_value > data[centre]) {
1027 xpoint = xcent + ((cur_value - data[centre]) * hgt / Maj_div);
1030 if (cur_value >= data[centre - 1])
1031 if (cur_value <= data[centre]) {
1032 xpoint = xcent - ((data[centre]-cur_value) * hgt / Maj_div);
1035 if (cur_value < data[centre - 1])
1036 if (cur_value >= minValue) {
1037 float diff = minValue - data[centre - 1];
1038 float diff1 = cur_value - data[centre - 1];
1039 float val = (diff1 * hgt1) / diff;
1041 xpoint = xcent - hgt - val;
1045 if (cur_value > data[centre + 1])
1046 if (cur_value <= maxValue) {
1047 float diff = maxValue - data[centre + 1];
1048 float diff1 = cur_value - data[centre + 1];
1049 float val = (diff1 * hgt1) / diff;
1051 xpoint = xcent + hgt + val;
1055 if (huds_top(options)) {
1057 drawOneLine(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
1059 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1061 if (!huds_notext(options))
1062 textString (xcentre - 10.0, y, TextScale, 0);
1064 for (i = 1; i < 5; i++) {
1067 circles(xfirst, ystart - 2.5, 3.0);
1068 circles(xcentre, ystart - 2.5, 3.0);
1071 xfirst = mid_scr.x - hgt;
1073 for (i = 0; i <= incr; i++) {
1074 drawOneLine(xfirst, ystart, xfirst, ystart - 5.0);
1075 drawOneLine(xsecond, ystart, xsecond, ystart - 5.0);
1077 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
1079 if (!huds_notext(options))
1080 textString (xfirst - 10.0, y, TextScale, 0);
1082 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
1084 if (!huds_notext(options))
1085 textString (xsecond - 10.0, y, TextScale, 0);
1091 //this is for moving pointer for top option
1094 ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
1096 if (pointer_type == "moving") {
1097 drawOneLine(xcent, ypoint, xpoint, ypoint);
1098 drawOneLine(xpoint, ypoint, xpoint, ypoint - 10.0);
1099 drawOneLine(xpoint, ypoint - 10.0, xpoint + 5.0, ypoint - 5.0);
1100 drawOneLine(xpoint, ypoint - 10.0, xpoint - 5.0, ypoint - 5.0);
1106 ystart = (y + h) / 2;
1108 //drawOneLine(xstart, yfirst, xstart - 5.0, yfirst);
1109 drawOneLine(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
1111 sprintf(TextScale,"%3.0f\n",(float)(data[centre] * data_scaling()));
1113 if (!huds_notext(options))
1114 textString (xcentre - 10.0, h, TextScale, 0);
1116 for (i = 1; i < 5; i++) {
1119 circles(xfirst, ystart + 2.5, 3.0);
1120 circles(xcentre, ystart + 2.5, 3.0);
1123 xfirst = mid_scr.x - hgt;
1125 for (i = 0; i <= incr; i++) {
1126 drawOneLine(xfirst, ystart, xfirst, ystart + 5.0);
1127 drawOneLine(xsecond, ystart, xsecond, ystart + 5.0);
1129 sprintf(TextScale,"%3.0f\n",(float)(data[centre - i - 1] * data_scaling()));
1131 if (!huds_notext(options))
1132 textString (xfirst - 10.0, h, TextScale, 0);
1134 sprintf(TextScale,"%3.0f\n",(float)(data[centre + i + 1] * data_scaling()));
1136 if (!huds_notext(options))
1137 textString (xsecond - 10.0, h, TextScale, 0);
1142 //this is for movimg pointer for bottom option
1145 ypoint = scrn_rect.top - 10.0;
1146 if (pointer_type == "moving") {
1147 drawOneLine(xcent, ypoint, xpoint, ypoint);
1148 drawOneLine(xpoint, ypoint, xpoint, ypoint + 10.0);
1149 drawOneLine(xpoint, ypoint + 10.0, xpoint + 5.0, ypoint + 5.0);
1150 drawOneLine(xpoint, ypoint + 10.0, xpoint - 5.0, ypoint + 5.0);
1152 }//end hud_top or hud_bottom
1153 } //end of horizontal/vertical scales