1 // HUD_tape.cxx -- HUD Tape Instrument
3 // Written by Michele America, started September 1997.
5 // Copyright (C) 1997 Michele F. America [micheleamerica#geocities:com]
6 // Copyright (C) 2006 Melchior FRANZ [mfranz#aon:at]
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 HUD::Tape::Tape(HUD *hud, const SGPropertyNode *n, float x, float y) :
27 _draw_tick_bottom(n->getBoolValue("tick-bottom", false)),
28 _draw_tick_top(n->getBoolValue("tick-top", false)),
29 _draw_tick_right(n->getBoolValue("tick-right", false)),
30 _draw_tick_left(n->getBoolValue("tick-left", false)),
31 _draw_cap_bottom(n->getBoolValue("cap-bottom", false)),
32 _draw_cap_top(n->getBoolValue("cap-top", false)),
33 _draw_cap_right(n->getBoolValue("cap-right", false)),
34 _draw_cap_left(n->getBoolValue("cap-left", false)),
35 _marker_offset(n->getFloatValue("marker-offset", 0.0)),
36 _pointer(n->getBoolValue("enable-pointer", true)),
37 _zoom(n->getIntValue("zoom"))
39 _half_width_units = range_to_show() / 2.0;
41 const char *s = n->getStringValue("pointer-type");
42 _pointer_type = strcmp(s, "moving") ? FIXED : MOVING; // "fixed", "moving"
44 s = n->getStringValue("tick-type");
45 _tick_type = strcmp(s, "circle") ? LINE : CIRCLE; // "circle", "line"
47 s = n->getStringValue("tick-length"); // "variable", "constant"
48 _tick_length = strcmp(s, "constant") ? VARIABLE : CONSTANT;
52 void HUD::Tape::draw(void) // (HUD_scale * pscale)
54 if (!_input.isValid())
57 float vmin = 0.0, vmax = 0.0;
62 float text_x = 0.0, text_y = 0.0;
66 const int BUFSIZE = 80;
70 int oddtype, k; //odd or even values for ticks
72 Point mid_scr = get_centroid();
73 float cur_value = _input.getFloatValue();
75 if ((int)_input.max() & 1)
76 oddtype = 1; //draw ticks at odd values
78 oddtype = 0; //draw ticks at even values
80 Rect scrn_rect = get_location();
82 height = scrn_rect.top + scrn_rect.bottom;
83 width = scrn_rect.left + scrn_rect.right;
87 if (_pointer_type == MOVING) {
93 vmin = cur_value - _half_width_units; // width units == needle travel
94 vmax = cur_value + _half_width_units; // or picture unit span.
100 vmin = cur_value - _half_width_units; // width units == needle travel
101 vmax = cur_value + _half_width_units; // or picture unit span.
106 // Draw the basic markings for the scale...
108 if (option_vert()) { // Vertical scale
110 if (_draw_tick_bottom)
111 draw_line(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
115 draw_line(scrn_rect.left, height, width, height);
117 marker_xs = scrn_rect.left; // x start
118 marker_xe = width; // x extent
121 // glBegin(GL_LINES);
124 // glVertex2f(marker_xs, scrn_rect.top);
125 // glVertex2f(marker_xe, scrn_rect.top);
128 // glVertex2f(marker_xs, marker_ye);
129 // glVertex2f(marker_xe, marker_ye);
133 // We do not use else in the following so that combining the
134 // two options produces a "caged" display with double
135 // carrots. The same is done for horizontal card indicators.
137 // begin vertical/left
138 //First draw capping lines and pointers
139 if (option_left()) { // Calculate x marker offset
141 if (_draw_cap_right) {
143 draw_line(marker_xe, scrn_rect.top, marker_xe, marker_ye);
146 marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
148 // draw_line(marker_xs, mid_scr.y,
149 // marker_xe, mid_scr.y + scrn_rect.right / 6);
150 // draw_line(marker_xs, mid_scr.y,
151 // marker_xe, mid_scr.y - scrn_rect.right / 6);
155 if (_pointer_type == MOVING) {
157 //Code for Moving Type Pointer
158 float ycentre, ypoint, xpoint;
160 if (cur_value > _input.max())
161 cur_value = _input.max();
162 if (cur_value < _input.min())
163 cur_value = _input.min();
165 if (_input.min() >= 0.0)
166 ycentre = scrn_rect.top;
167 else if (_input.max() + _input.min() == 0.0)
169 else if (oddtype == 1)
170 ycentre = scrn_rect.top + (1.0 - _input.min()) * scrn_rect.bottom
171 / (_input.max() - _input.min());
173 ycentre = scrn_rect.top + _input.min() * scrn_rect.bottom
174 / (_input.max() - _input.min());
176 range = scrn_rect.bottom;
177 wth = scrn_rect.left + scrn_rect.right;
180 ypoint = ycentre + ((cur_value - 1.0) * range / _val_span);
182 ypoint = ycentre + (cur_value * range / _val_span);
184 xpoint = wth + _marker_offset;
185 draw_line(xpoint, ycentre, xpoint, ypoint);
186 draw_line(xpoint, ypoint, xpoint - _marker_offset, ypoint);
187 draw_line(xpoint - _marker_offset, ypoint, xpoint - 5.0, ypoint + 5.0);
188 draw_line(xpoint - _marker_offset, ypoint, xpoint - 5.0, ypoint - 5.0);
193 fixed(_marker_offset + marker_xe, text_y + scrn_rect.right / 6,
194 _marker_offset + marker_xs, text_y, _marker_offset + marker_xe,
195 text_y - scrn_rect.right / 6);
198 } //end vertical/left
200 // begin vertical/right
201 //First draw capping lines and pointers
202 if (option_right()) { // We'll default this for now.
203 if (_draw_cap_left) {
205 draw_line(scrn_rect.left, scrn_rect.top, scrn_rect.left, marker_ye);
208 marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
210 // draw_line(scrn_rect.left, mid_scr.y + scrn_rect.right / 6,
211 // marker_xe, mid_scr.y);
212 // draw_line(scrn_rect.left, mid_scr.y - scrn_rect.right / 6,
213 // marker_xe, mid_scr.y);
217 if (_pointer_type == MOVING) {
219 //type-fixed & _zoom=1, behaviour to be defined
220 // Code for Moving Type Pointer
221 float ycentre, ypoint, xpoint;
224 if (cur_value > _input.max())
225 cur_value = _input.max();
226 if (cur_value < _input.min())
227 cur_value = _input.min();
229 if (_input.min() >= 0.0)
230 ycentre = scrn_rect.top;
231 else if (_input.max() + _input.min() == 0.0)
233 else if (oddtype == 1)
234 ycentre = scrn_rect.top + (1.0 - _input.min()) * scrn_rect.bottom / (_input.max() - _input.min());
236 ycentre = scrn_rect.top + _input.min() * scrn_rect.bottom / (_input.max() - _input.min());
238 range = scrn_rect.bottom;
241 ypoint = ycentre + ((cur_value - 1.0) * range / _val_span);
243 ypoint = ycentre + (cur_value * range / _val_span);
245 xpoint = scrn_rect.left - _marker_offset;
246 draw_line(xpoint, ycentre, xpoint, ypoint);
247 draw_line(xpoint, ypoint, xpoint + _marker_offset, ypoint);
248 draw_line(xpoint + _marker_offset, ypoint, xpoint + 5.0, ypoint + 5.0);
249 draw_line(xpoint + _marker_offset, ypoint, xpoint + 5.0, ypoint - 5.0);
254 fixed(-_marker_offset + scrn_rect.left, text_y + scrn_rect.right / 6,
255 -_marker_offset + marker_xe, text_y, -_marker_offset + scrn_rect.left,
256 text_y - scrn_rect.right / 6);
259 } //end vertical/right
261 // At this point marker x_start and x_end values are transposed.
262 // To keep this from confusing things they are now interchanged.
264 marker_ye = marker_xs;
265 marker_xs = marker_xe;
266 marker_xe = marker_ye;
269 // Work through from bottom to top of scale. Calculating where to put
270 // minor and major ticks.
272 // draw scale or tape
273 last = (int)vmax + 1; // N
277 zoomed_scale((int)vmin, (int)vmax);
279 for (; i < last; i++) {
281 if (!modulo() && i < _input.min())
284 if (condition) { // Show a tick if necessary
285 // Calculate the location of this tick
286 marker_ys = scrn_rect.top + ((i - vmin) * factor()/*+.5f*/);
287 // marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
288 // Block calculation artifact from drawing ticks below min coordinate.
289 // Calculation here accounts for text height.
291 if ((marker_ys < (scrn_rect.top + 4))
292 || (marker_ys > (height - 4))) {
298 k = i + 1; //enable ticks at odd values
304 // if ((i % _minor_divs) == 0) {
305 if (!(k % (int)_minor_divs)) {
306 if (((marker_ys - 5) > scrn_rect.top)
307 && ((marker_ys + 5) < (height))) {
309 //vertical/left OR vertical/right
311 if (_tick_type == LINE) {
312 if (_tick_length == VARIABLE) {
313 draw_line(scrn_rect.left, marker_ys,
314 marker_xs, marker_ys);
315 draw_line(marker_xe, marker_ys,
318 draw_line(scrn_rect.left, marker_ys,
319 marker_xs, marker_ys);
320 draw_line(marker_xe, marker_ys,
324 } else if (_tick_type == CIRCLE) {
325 draw_bullet(scrn_rect.left,(float)marker_ys, 3.0);
328 // if neither line nor circle draw default as line
329 draw_line(scrn_rect.left, marker_ys,
330 marker_xs, marker_ys);
331 draw_line(marker_xe, marker_ys,
334 // glBegin(GL_LINES);
335 // glVertex2f(scrn_rect.left, marker_ys);
336 // glVertex2f(marker_xs, marker_ys);
337 // glVertex2f(marker_xe, marker_ys);
338 // glVertex2f(scrn_rect.left + scrn_rect.right, marker_ys);
340 // anything other than option_both
344 if (_tick_type == LINE) {
345 if (_tick_length == VARIABLE) {
346 draw_line(marker_xs + 4, marker_ys,
347 marker_xe, marker_ys);
349 draw_line(marker_xs, marker_ys,
350 marker_xe, marker_ys);
352 } else if (_tick_type == CIRCLE) {
353 draw_bullet((float)marker_xs + 4, (float)marker_ys, 3.0);
356 draw_line(marker_xs + 4, marker_ys,
357 marker_xe, marker_ys);
361 if (_tick_type == LINE) {
362 if (_tick_length == VARIABLE) {
363 draw_line(marker_xs, marker_ys,
364 marker_xe - 4, marker_ys);
366 draw_line(marker_xs, marker_ys,
367 marker_xe, marker_ys);
370 } else if (_tick_type == CIRCLE) {
371 draw_bullet((float)marker_xe - 4, (float)marker_ys, 3.0);
373 draw_line(marker_xs, marker_ys,
374 marker_xe - 4, marker_ys);
379 } //end draw minor ticks
384 if (!(k % (int)_major_divs)) {
387 disp_val = i % (int) modulo(); // ?????????
390 disp_val += modulo();
396 // FIXME what nonsense is this?!?
397 lenstr = snprintf(buf, BUFSIZE, "%d", int(disp_val * _input.factor()/*+.5*/)); // was data_scaling ... makes no sense at all
398 // (int)(disp_val * data_scaling() +.5));
399 /* if (((marker_ys - 8) > scrn_rect.top) &&
400 ((marker_ys + 8) < (height))){ */
403 // draw_line(scrn_rect.left, marker_ys,
404 // marker_xs, marker_ys);
405 // draw_line(marker_xs, marker_ys,
406 // scrn_rect.left + scrn_rect.right,
408 if (_tick_type == LINE) {
409 glBegin(GL_LINE_STRIP);
410 glVertex2f(scrn_rect.left, marker_ys);
411 glVertex2f(marker_xs, marker_ys);
412 glVertex2f(width, marker_ys);
415 } else if (_tick_type == CIRCLE) {
416 draw_bullet(scrn_rect.left, (float)marker_ys, 5.0);
419 glBegin(GL_LINE_STRIP);
420 glVertex2f(scrn_rect.left, marker_ys);
421 glVertex2f(marker_xs, marker_ys);
422 glVertex2f(width, marker_ys);
426 if (!option_notext())
427 draw_text(marker_xs + 2, marker_ys, buf, 0);
430 /* Changes are made to draw a circle when tick_type=CIRCLE */
431 // anything other than option_both
432 if (_tick_type == LINE)
433 draw_line(marker_xs, marker_ys, marker_xe, marker_ys);
434 else if (_tick_type == CIRCLE)
435 draw_bullet((float)marker_xs + 4, (float)marker_ys, 5.0);
437 draw_line(marker_xs, marker_ys, marker_xe, marker_ys);
439 if (!option_notext()) {
441 draw_text(marker_xs - 8 * lenstr - 2,
442 marker_ys - 4, buf, 0);
444 draw_text(marker_xe + 3 * lenstr,
445 marker_ys - 4, buf, 0);
446 } //End if option_left
447 } //End if !option_notext
449 } // End if draw major ticks
450 } // End if major ticks
454 // End if VERTICAL SCALE TYPE (tape loop yet to be closed)
457 // Horizontal scale by default
460 draw_line(scrn_rect.left, scrn_rect.top, scrn_rect.left, height);
463 if (_draw_tick_right)
464 draw_line(width, scrn_rect.top, width, height);
466 marker_ys = scrn_rect.top; // Starting point for
467 marker_ye = height; // tick y location calcs
469 marker_xs = scrn_rect.left + ((cur_value - vmin) * factor() /*+ .5f*/);
471 // glBegin(GL_LINES);
473 // glVertex2f(scrn_rect.left, scrn_rect.top);
474 // glVertex2f(scrn_rect.left, marker_ye);
477 // glVertex2f(marker_xe, scrn_rect.top);
478 // glVertex2f(marker_xe, marker_ye);
483 if (_draw_cap_bottom)
484 draw_line(scrn_rect.left, scrn_rect.top, width, scrn_rect.top);
487 marker_ye = scrn_rect.top + scrn_rect.bottom / 2;
489 // draw_line(mid_scr.x, marker_ye,
490 // mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
491 // draw_line(mid_scr.x, marker_ye,
492 // mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
495 if (_pointer_type == MOVING) {
497 //Code for Moving Type Pointer
498 // static float xcentre, xpoint, ypoint;
500 if (cur_value > _input.max())
501 cur_value = _input.max();
502 if (cur_value < _input.min())
503 cur_value = _input.min();
505 float xcentre = mid_scr.x;
506 float range = scrn_rect.right;
507 float xpoint = xcentre + (cur_value * range / _val_span);
508 float ypoint = scrn_rect.top - _marker_offset;
509 draw_line(xcentre, ypoint, xpoint, ypoint);
510 draw_line(xpoint, ypoint, xpoint, ypoint + _marker_offset);
511 draw_line(xpoint, ypoint + _marker_offset, xpoint + 5.0, ypoint + 5.0);
512 draw_line(xpoint, ypoint + _marker_offset, xpoint - 5.0, ypoint + 5.0);
517 fixed(marker_xs - scrn_rect.bottom / 4, scrn_rect.top, marker_xs,
518 marker_ye, marker_xs + scrn_rect.bottom / 4, scrn_rect.top);
521 } //End Horizontal scale/top
523 if (option_bottom()) {
526 draw_line(scrn_rect.left, height, width, height);
529 marker_ys = height - scrn_rect.bottom / 2;
531 // draw_line(mid_scr.x + scrn_rect.bottom / 4,
532 // scrn_rect.top + scrn_rect.bottom,
533 // mid_scr.x, marker_ys);
534 // draw_line(mid_scr.x - scrn_rect.bottom / 4,
535 // scrn_rect.top + scrn_rect.bottom,
536 // mid_scr.x , marker_ys);
540 if (_pointer_type == MOVING) {
542 //Code for Moving Type Pointer
543 // static float xcentre, xpoint, ypoint;
544 // static int range, hgt;
545 if (cur_value > _input.max())
546 cur_value = _input.max();
547 if (cur_value < _input.min())
548 cur_value = _input.min();
550 float xcentre = mid_scr.x ;
551 float range = scrn_rect.right;
552 float hgt = scrn_rect.top + scrn_rect.bottom;
553 float xpoint = xcentre + (cur_value * range / _val_span);
554 float ypoint = hgt + _marker_offset;
555 draw_line(xcentre, ypoint, xpoint, ypoint);
556 draw_line(xpoint, ypoint, xpoint, ypoint - _marker_offset);
557 draw_line(xpoint, ypoint - _marker_offset, xpoint + 5.0, ypoint - 5.0);
558 draw_line(xpoint, ypoint - _marker_offset, xpoint - 5.0, ypoint - 5.0);
561 fixed(marker_xs + scrn_rect.bottom / 4, height, marker_xs, marker_ys,
562 marker_xs - scrn_rect.bottom / 4, height);
565 } //end horizontal scale bottom
569 zoomed_scale((int)vmin,(int)vmax);
572 last = (int)vmax + 1;
574 for (; i < last; i++) {
575 // for (i = (int)vmin; i <= (int)vmax; i++) {
576 // printf("<*> i = %d\n", i);
578 if (!modulo() && i < _input.min())
581 // printf("<**> i = %d\n", i);
583 // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
584 marker_xs = scrn_rect.left + (((i - vmin) * factor()/*+ .5f*/));
587 k = i + 1; //enable ticks at odd values
592 // if ((i % (int)_minor_divs) == 0) {
594 if (!(k % (int)_minor_divs)) {
595 // draw in ticks only if they aren't too close to the edge.
596 if (((marker_xs - 5) > scrn_rect.left)
597 && ((marker_xs + 5)< (scrn_rect.left + scrn_rect.right))) {
600 if (_tick_length == VARIABLE) {
601 draw_line(marker_xs, scrn_rect.top,
602 marker_xs, marker_ys - 4);
603 draw_line(marker_xs, marker_ye + 4,
606 draw_line(marker_xs, scrn_rect.top,
607 marker_xs, marker_ys);
608 draw_line(marker_xs, marker_ye,
611 // glBegin(GL_LINES);
612 // glVertex2f(marker_xs, scrn_rect.top);
613 // glVertex2f(marker_xs, marker_ys - 4);
614 // glVertex2f(marker_xs, marker_ye + 4);
615 // glVertex2f(marker_xs, scrn_rect.top + scrn_rect.bottom);
621 if (_tick_length == VARIABLE)
622 draw_line(marker_xs, marker_ys, marker_xs, marker_ye - 4);
624 draw_line(marker_xs, marker_ys, marker_xs, marker_ye);
626 } else if (_tick_length == VARIABLE) {
627 draw_line(marker_xs, marker_ys + 4, marker_xs, marker_ye);
629 draw_line(marker_xs, marker_ys, marker_xs, marker_ye);
633 } //end draw minor ticks
638 // printf("i = %d\n", i);
639 // if ((i % (int)_major_divs)==0) {
642 if (!(k % (int)_major_divs)) {
644 disp_val = i % (int) modulo(); // ?????????
647 disp_val += modulo();
652 // printf("disp_val = %d\n", disp_val);
653 // printf("%d\n", (int)(disp_val * (double)data_scaling() + 0.5));
654 lenstr = snprintf(buf, BUFSIZE, "%d",
655 // (int)(disp_val * data_scaling() +.5));
656 int(disp_val * _input.factor() /*+.5*/)); // was data_scaling() ... makes no sense at all
658 // Draw major ticks and text only if far enough from the edge.
659 if (((marker_xs - 10)> scrn_rect.left)
660 && ((marker_xs + 10) < (scrn_rect.left + scrn_rect.right))) {
662 // draw_line(marker_xs, scrn_rect.top,
663 // marker_xs, marker_ys);
664 // draw_line(marker_xs, marker_ye,
665 // marker_xs, scrn_rect.top + scrn_rect.bottom);
666 glBegin(GL_LINE_STRIP);
667 glVertex2f(marker_xs, scrn_rect.top);
668 glVertex2f(marker_xs, marker_ye);
669 glVertex2f(marker_xs, height);
672 if (!option_notext()) {
673 draw_text(marker_xs - 4 * lenstr,
674 marker_ys + 4, buf, 0);
677 draw_line(marker_xs, marker_ys, marker_xs, marker_ye);
679 if (!option_notext()) {
681 draw_text(marker_xs - 4 * lenstr,
682 height - 10, buf, 0);
685 draw_text(marker_xs - 4 * lenstr,
686 scrn_rect.top, buf, 0);
691 } //end draw major ticks
692 } //endif major ticks
696 } //end horizontal/vertical scale
701 void HUD::Tape::fixed(float x1, float y1, float x2, float y2, float x3, float y3)
703 glBegin(GL_LINE_STRIP);
711 void HUD::Tape::zoomed_scale(int first, int last)
713 Point mid_scr = get_centroid();
714 Rect scrn_rect = get_location();
715 const int BUFSIZE = 80;
719 float x, y, w, h, bottom;
720 float cur_value = _input.getFloatValue();
721 if (cur_value > _input.max())
722 cur_value = _input.max();
723 if (cur_value < _input.min())
724 cur_value = _input.min();
728 while (first <= last) {
729 if ((first % (int)_major_divs) == 0) {
740 w = scrn_rect.left + scrn_rect.right;
741 h = scrn_rect.top + scrn_rect.bottom;
742 bottom = scrn_rect.bottom;
744 float xstart, yfirst, ycentre, ysecond;
746 float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
747 yfirst = mid_scr.y - hgt;
749 ysecond = mid_scr.y + hgt;
750 float range = hgt * 2;
753 float factor = range / 10.0;
755 float hgt1 = bottom * 30.0 / 100.0;
756 int incrs = ((int)_val_span - (_major_divs * 2)) / _major_divs ;
757 int incr = incrs / 2;
758 float factors = hgt1 / incr;
761 //this is for moving type pointer
762 static float ycent, ypoint, xpoint;
766 wth = scrn_rect.left + scrn_rect.right;
768 if (cur_value <= data[centre + 1])
769 if (cur_value > data[centre]) {
770 ypoint = ycent + ((cur_value - data[centre]) * hgt / _major_divs);
773 if (cur_value >= data[centre - 1])
774 if (cur_value <= data[centre]) {
775 ypoint = ycent - ((data[centre] - cur_value) * hgt / _major_divs);
778 if (cur_value < data[centre - 1])
779 if (cur_value >= _input.min()) {
780 float diff = _input.min() - data[centre - 1];
781 float diff1 = cur_value - data[centre - 1];
782 float val = (diff1 * hgt1) / diff;
784 ypoint = ycent - hgt - val;
787 if (cur_value > data[centre + 1])
788 if (cur_value <= _input.max()) {
789 float diff = _input.max() - data[centre + 1];
790 float diff1 = cur_value - data[centre + 1];
791 float val = (diff1 * hgt1) / diff;
793 ypoint = ycent + hgt + val;
799 draw_line(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
801 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre] * _input.factor())); // was data_scaling() ... makes not sense at all
803 if (!option_notext())
804 draw_text(x, ycentre, buf, 0);
806 for (i = 1; i < 5; i++) {
809 draw_bullet(xstart - 2.5, yfirst, 3.0);
810 draw_bullet(xstart - 2.5, ycentre, 3.0);
813 yfirst = mid_scr.y - hgt;
815 for (i = 0; i <= incr; i++) {
816 draw_line(xstart, yfirst, xstart - 5.0, yfirst);
817 draw_line(xstart, ysecond, xstart - 5.0, ysecond);
819 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
821 if (!option_notext())
822 draw_text(x, yfirst, buf, 0);
824 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
826 if (!option_notext())
827 draw_text(x, ysecond, buf, 0);
834 //to draw moving type pointer for left option
838 if (_pointer_type == MOVING) {
839 draw_line(xpoint, ycent, xpoint, ypoint);
840 draw_line(xpoint, ypoint, xpoint - 10.0, ypoint);
841 draw_line(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint + 5.0);
842 draw_line(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint - 5.0);
848 xstart = (x + w) / 2;
850 draw_line(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
852 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
854 if (!option_notext())
855 draw_text(w, ycentre, buf, 0);
857 for (i = 1; i < 5; i++) {
860 draw_bullet(xstart + 2.5, yfirst, 3.0);
861 draw_bullet(xstart + 2.5, ycentre, 3.0);
864 yfirst = mid_scr.y - hgt;
866 for (i = 0; i <= incr; i++) {
867 draw_line(xstart, yfirst, xstart + 5.0, yfirst);
868 draw_line(xstart, ysecond, xstart + 5.0, ysecond);
870 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
872 if (!option_notext())
873 draw_text(w, yfirst, buf, 0);
875 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre + i + 1] * _input.factor()));
877 if (!option_notext())
878 draw_text(w, ysecond, buf, 0);
885 // to draw moving type pointer for right option
887 xpoint = scrn_rect.left;
889 if (_pointer_type == MOVING) {
890 draw_line(xpoint, ycent, xpoint, ypoint);
891 draw_line(xpoint, ypoint, xpoint + 10.0, ypoint);
892 draw_line(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint + 5.0);
893 draw_line(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint - 5.0);
896 }//end option_right /left
897 //end of vertical scale
903 w = scrn_rect.left + scrn_rect.right;
904 h = scrn_rect.top + scrn_rect.bottom;
905 bottom = scrn_rect.right;
907 float ystart, xfirst, xcentre, xsecond;
909 float hgt = bottom * 20.0 / 100.0; // 60% of height should be zoomed
910 xfirst = mid_scr.x - hgt;
912 xsecond = mid_scr.x + hgt;
913 float range = hgt * 2;
916 float factor = range / 10.0;
918 float hgt1 = bottom * 30.0 / 100.0;
919 int incrs = ((int)_val_span - (_major_divs * 2)) / _major_divs ;
920 int incr = incrs / 2;
921 float factors = hgt1 / incr;
924 //Code for Moving Type Pointer
926 static float xcent, xpoint, ypoint;
930 if (cur_value <= data[centre + 1])
931 if (cur_value > data[centre]) {
932 xpoint = xcent + ((cur_value - data[centre]) * hgt / _major_divs);
935 if (cur_value >= data[centre - 1])
936 if (cur_value <= data[centre]) {
937 xpoint = xcent - ((data[centre] - cur_value) * hgt / _major_divs);
940 if (cur_value < data[centre - 1])
941 if (cur_value >= _input.min()) {
942 float diff = _input.min() - data[centre - 1];
943 float diff1 = cur_value - data[centre - 1];
944 float val = (diff1 * hgt1) / diff;
946 xpoint = xcent - hgt - val;
950 if (cur_value > data[centre + 1])
951 if (cur_value <= _input.max()) {
952 float diff = _input.max() - data[centre + 1];
953 float diff1 = cur_value - data[centre + 1];
954 float val = (diff1 * hgt1) / diff;
956 xpoint = xcent + hgt + val;
962 draw_line(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
964 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
966 if (!option_notext())
967 draw_text(xcentre - 10.0, y, buf, 0);
969 for (i = 1; i < 5; i++) {
972 draw_bullet(xfirst, ystart - 2.5, 3.0);
973 draw_bullet(xcentre, ystart - 2.5, 3.0);
976 xfirst = mid_scr.x - hgt;
978 for (i = 0; i <= incr; i++) {
979 draw_line(xfirst, ystart, xfirst, ystart - 5.0);
980 draw_line(xsecond, ystart, xsecond, ystart - 5.0);
982 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
984 if (!option_notext())
985 draw_text(xfirst - 10.0, y, buf, 0);
987 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
989 if (!option_notext())
990 draw_text(xsecond - 10.0, y, buf, 0);
996 //this is for moving pointer for top option
999 ypoint = scrn_rect.top + scrn_rect.bottom + 10.0;
1001 if (_pointer_type == MOVING) {
1002 draw_line(xcent, ypoint, xpoint, ypoint);
1003 draw_line(xpoint, ypoint, xpoint, ypoint - 10.0);
1004 draw_line(xpoint, ypoint - 10.0, xpoint + 5.0, ypoint - 5.0);
1005 draw_line(xpoint, ypoint - 10.0, xpoint - 5.0, ypoint - 5.0);
1010 //else option_bottom
1011 ystart = (y + h) / 2;
1013 //draw_line(xstart, yfirst, xstart - 5.0, yfirst);
1014 draw_line(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
1016 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
1018 if (!option_notext())
1019 draw_text(xcentre - 10.0, h, buf, 0);
1021 for (i = 1; i < 5; i++) {
1024 draw_bullet(xfirst, ystart + 2.5, 3.0);
1025 draw_bullet(xcentre, ystart + 2.5, 3.0);
1028 xfirst = mid_scr.x - hgt;
1030 for (i = 0; i <= incr; i++) {
1031 draw_line(xfirst, ystart, xfirst, ystart + 5.0);
1032 draw_line(xsecond, ystart, xsecond, ystart + 5.0);
1034 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
1036 if (!option_notext())
1037 draw_text(xfirst - 10.0, h, buf, 0);
1039 snprintf(buf, BUFSIZE, "%3.0f\n", (float)(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
1041 if (!option_notext())
1042 draw_text(xsecond - 10.0, h, buf, 0);
1047 //this is for movimg pointer for bottom option
1050 ypoint = scrn_rect.top - 10.0;
1051 if (_pointer_type == MOVING) {
1052 draw_line(xcent, ypoint, xpoint, ypoint);
1053 draw_line(xpoint, ypoint, xpoint, ypoint + 10.0);
1054 draw_line(xpoint, ypoint + 10.0, xpoint + 5.0, ypoint + 5.0);
1055 draw_line(xpoint, ypoint + 10.0, xpoint - 5.0, ypoint + 5.0);
1057 }//end hud_top or hud_bottom
1058 } //end of horizontal/vertical scales