]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/HUD/HUD_tape.cxx
cleanup
[flightgear.git] / src / Instrumentation / HUD / HUD_tape.cxx
1 // HUD_tape.cxx -- HUD Tape Instrument
2 //
3 // Written by Michele America, started September 1997.
4 //
5 // Copyright (C) 1997  Michele F. America  [micheleamerica#geocities:com]
6 // Copyright (C) 2006  Melchior FRANZ  [mfranz#aon:at]
7 //
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.
12 //
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.
17 //
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.
21
22 #include "HUD.hxx"
23
24
25 HUD::Tape::Tape(HUD *hud, const SGPropertyNode *n, float x, float y) :
26     Scale(hud, n, x, 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     _label_gap(n->getFloatValue("label-gap-width", 0.0)),
37     _pointer(n->getBoolValue("enable-pointer", true)),
38     _zoom(n->getIntValue("zoom"))
39 {
40     _half_width_units = range_to_show() / 2.0;
41
42     const char *s;
43     s = n->getStringValue("pointer-type");
44     _pointer_type = strcmp(s, "moving") ? FIXED : MOVING;    // "fixed", "moving"
45
46     s = n->getStringValue("tick-type");
47     _tick_type = strcmp(s, "circle") ? LINE : CIRCLE;        // "circle", "line"
48
49     s = n->getStringValue("tick-length");                    // "variable", "constant"
50     _tick_length = strcmp(s, "constant") ? VARIABLE : CONSTANT;
51 }
52
53
54 void HUD::Tape::draw(void) //  (HUD_scale * pscale)
55 {
56     if (!_input.isValid())
57         return;
58
59     float vmin = 0.0, vmax = 0.0;
60     float marker_xs;
61     float marker_xe;
62     float marker_ys;
63     float marker_ye;
64     float text_y = 0.0;
65     const int BUFSIZE = 80;
66     char buf[BUFSIZE];
67     int oddtype;
68 //    int k; //odd or even values for ticks             // FIXME odd scale
69
70     float cur_value = _input.getFloatValue();
71
72     if (int(floorf(_input.max() + 0.5)) & 1)
73         oddtype = 1; //draw ticks at odd values
74     else
75         oddtype = 0; //draw ticks at even values
76
77     float top = _y + _h;
78     float right = _x + _w;
79
80
81     if (!_pointer) {
82         vmin = cur_value - _half_width_units; // width units == needle travel
83         vmax = cur_value + _half_width_units; // or picture unit span.
84         text_y = _center_y;
85
86     } else if (_pointer_type == MOVING) {
87         vmin = _input.min();
88         vmax = _input.max();
89
90     } else { // FIXED
91         vmin = cur_value - _half_width_units; // width units == needle travel
92         vmax = cur_value + _half_width_units; // or picture unit span.
93         text_y = _center_y;
94     }
95
96
97 ///////////////////////////////////////////////////////////////////////////////
98 // VERTICAL SCALE
99 ///////////////////////////////////////////////////////////////////////////////
100
101     // Draw the basic markings for the scale...
102
103     if (option_vert()) { // Vertical scale
104         // Bottom tick bar
105         if (_draw_tick_bottom)
106             draw_line(_x, _y, right, _y);
107
108         // Top tick bar
109         if (_draw_tick_top)
110             draw_line(_x, top, right, top);
111
112         marker_xs = _x;       // x start
113         marker_xe = right;    // x extent
114         marker_ye = top;
115
116         // We do not use else in the following so that combining the
117         // two options produces a "caged" display with double
118         // carrots. The same is done for horizontal card indicators.
119
120         // begin vertical/left
121         //First draw capping lines and pointers
122         if (option_left()) {    // Calculate x marker offset
123
124             if (_draw_cap_right)
125                 draw_line(marker_xe, _y, marker_xe, marker_ye);
126
127             marker_xs = marker_xe - _w / 3.0;
128
129             // draw_line(marker_xs, _center_y, marker_xe, _center_y + _w / 6);
130             // draw_line(marker_xs, _center_y, marker_xe, _center_y - _w / 6);
131
132             // draw pointer
133             if (_pointer) {
134                 if (_pointer_type == MOVING) {
135                     if (!_zoom) {
136                         //Code for Moving Type Pointer
137                         float ycentre, ypoint, xpoint;
138                         float range, right;
139
140                         if (_input.min() >= 0.0)
141                             ycentre = _y;
142                         else if (_input.max() + _input.min() == 0.0)
143                             ycentre = _center_y;
144                         else if (oddtype)
145                             ycentre = _y + (1.0 - _input.min()) * _h / (_input.max() - _input.min());
146                         else
147                             ycentre = _y + _input.min() * _h / (_input.max() - _input.min());
148
149                         range = _h;
150                         right = _x + _w;
151
152                         if (oddtype)
153                             ypoint = ycentre + ((cur_value - 1.0) * range / _val_span);
154                         else
155                             ypoint = ycentre + (cur_value * range / _val_span);
156
157                         xpoint = right + _marker_offset;
158                         draw_line(xpoint, ycentre, xpoint, ypoint);
159                         draw_line(xpoint, ypoint, xpoint - _marker_offset, ypoint);
160                         draw_line(xpoint - _marker_offset, ypoint, xpoint - 5.0, ypoint + 5.0);
161                         draw_line(xpoint - _marker_offset, ypoint, xpoint - 5.0, ypoint - 5.0);
162                     } // !_zoom
163
164                 } else {
165                     // default to fixed
166                     draw_fixed_pointer(_marker_offset + marker_xe, text_y + _w / 6,
167                             _marker_offset + marker_xs, text_y, _marker_offset + marker_xe,
168                             text_y - _w / 6);
169                 } // end pointer type
170             } // if pointer
171         } // end vertical/left
172
173
174         // begin vertical/right
175         // First draw capping lines and pointers
176         if (option_right()) {
177
178             if (_draw_cap_left)
179                 draw_line(_x, _y, _x, marker_ye);
180
181             marker_xe = _x + _w / 3.0;
182             // Indicator carrot
183             // draw_line(_x, _center_y +  _w / 6, marker_xe, _center_y);
184             // draw_line(_x, _center_y -  _w / 6, marker_xe, _center_y);
185
186             // draw pointer
187             if (_pointer) {
188                 if (_pointer_type == MOVING) {
189                     if (!_zoom) {
190                         // type-fixed & _zoom=1, behaviour to be defined
191                         // Code for Moving Type Pointer
192                         float ycentre, ypoint, xpoint;
193                         float range;
194
195                         if (_input.min() >= 0.0)
196                             ycentre = _y;
197                         else if (_input.max() + _input.min() == 0.0)
198                             ycentre = _center_y;
199                         else if (oddtype)
200                             ycentre = _y + (1.0 - _input.min()) * _h / (_input.max() - _input.min());
201                         else
202                             ycentre = _y + _input.min() * _h / (_input.max() - _input.min());
203
204                         range = _h;
205
206                         if (oddtype)
207                             ypoint = ycentre + ((cur_value - 1.0) * range / _val_span);
208                         else
209                             ypoint = ycentre + (cur_value * range / _val_span);
210
211                         xpoint = _x - _marker_offset;
212                         draw_line(xpoint, ycentre, xpoint, ypoint);
213                         draw_line(xpoint, ypoint, xpoint + _marker_offset, ypoint);
214                         draw_line(xpoint + _marker_offset, ypoint, xpoint + 5.0, ypoint + 5.0);
215                         draw_line(xpoint + _marker_offset, ypoint, xpoint + 5.0, ypoint - 5.0);
216                     }
217
218                 } else {
219                     // default to fixed
220                     draw_fixed_pointer(-_marker_offset + _x, text_y +  _w / 6,
221                             -_marker_offset + marker_xe, text_y, -_marker_offset + _x,
222                             text_y - _w / 6);
223                 }
224             } // if pointer
225         } // end vertical/right
226
227
228         // At this point marker x_start and x_end values are transposed.
229         // To keep this from confusing things they are now swapped.
230         if (option_both())
231             marker_ye = marker_xs, marker_xs = marker_xe, marker_xe = marker_ye;
232
233
234
235         // Work through from bottom to top of scale. Calculating where to put
236         // minor and major ticks.
237
238         // draw scale or tape
239         if (_zoom) {
240             zoomed_scale((int)vmin, (int)vmax);
241         } else {
242
243             int div_ratio;
244             if (_minor_divs != 0.0f)
245                 div_ratio = int(_major_divs / _minor_divs + 0.5f);
246             else
247                 div_ratio = 0, _minor_divs = _major_divs;               // FIXME move that into Scale/Constructor ?
248
249             float vstart = floorf(vmin / _major_divs) * _major_divs;
250             float min_diff = _w / 6.0;    // length difference between major & minor tick
251
252             // FIXME consider oddtype
253             for (int i = 0; ; i++) {
254                 float v = vstart + i * _minor_divs;
255
256                 if (!_modulo)
257                     if (v < _input.min())
258                         continue;
259                     else if (v > _input.max())
260                         break;
261
262                 float y = _y + (v - vmin) * factor();
263
264                 if (y < _y + 4)
265                     continue;
266                 if (y > top - 4)
267                     break;
268
269                 if (div_ratio && i % div_ratio) { // minor div
270                     if (option_both()) {
271                         if (_tick_type == LINE) {
272                             if (_tick_length == VARIABLE) {
273                                 draw_line(_x, y, marker_xs, y);
274                                 draw_line(marker_xe, y, right, y);
275                             } else {
276                                 draw_line(_x, y, marker_xs, y);
277                                 draw_line(marker_xe, y, right, y);
278                             }
279
280                         } else { // _tick_type == CIRCLE
281                             draw_bullet(_x, y, 3.0);
282                         }
283
284                     } else if (option_left()) {
285                         if (_tick_type == LINE) {
286                             if (_tick_length == VARIABLE) {
287                                 draw_line(marker_xs + min_diff, y, marker_xe, y);
288                             } else {
289                                 draw_line(marker_xs, y, marker_xe, y);
290                             }
291                         } else { // _tick_type == CIRCLE
292                             draw_bullet(marker_xs + 4, y, 3.0);
293                         }
294
295                     } else { // if (option_right())
296                         if (_tick_type == LINE) {
297                             if (_tick_length == VARIABLE) {
298                                 draw_line(marker_xs, y, marker_xe - min_diff, y);
299                             } else {
300                                 draw_line(marker_xs, y, marker_xe, y);
301                             }
302
303                         } else { // _tick_type == CIRCLE
304                             draw_bullet(marker_xe - 4, y, 3.0);
305                         }
306                     } // end huds both
307
308                 } else { // major div
309                     int display_value = int(v);
310                     if (_modulo)
311                         display_value %= _modulo;
312
313                     snprintf(buf, BUFSIZE, "%d", display_value);
314
315                     if (option_both()) {
316                         if (_tick_type == LINE) {
317                             draw_line(_x, y, marker_xs, y);
318                             draw_line(marker_xs, y, right, y);
319
320                         } else { // _tick_type == CIRCLE
321                             draw_bullet(_x, y, 5.0);
322                         }
323
324                         if (!option_notext())
325                             draw_text(marker_xs, y, buf, HUDText::CENTER);
326
327                     } else {
328                         if (_tick_type == LINE)
329                             draw_line(marker_xs, y, marker_xe, y);
330                         else // _tick_type == CIRCLE
331                             draw_bullet(marker_xs + 4, y, 5.0);
332
333                         if (!option_notext()) {
334                             if (option_left())
335                                 draw_text(marker_xs, y, buf, HUDText::RIGHT|HUDText::VCENTER);
336                             else
337                                 draw_text(marker_xe + 1.0, y, buf, HUDText::LEFT|HUDText::VCENTER);
338                         }
339                     } // End if huds-both
340                 }
341             }
342         } // end of zoom
343
344
345 ///////////////////////////////////////////////////////////////////////////////
346 // HORIZONTAL SCALE
347 ///////////////////////////////////////////////////////////////////////////////
348
349
350     } else {
351         // left tick bar
352         if (_draw_tick_left)
353             draw_line(_x, _y, _x, top);
354
355         // right tick bar
356         if (_draw_tick_right)
357             draw_line(right, _y, right, top);
358
359         marker_ys = _y;    // Starting point for
360         marker_ye = top;           // tick y location calcs
361         marker_xe = right;
362         marker_xs = _x + ((cur_value - vmin) * factor());
363
364         if (option_top()) {
365             if (_draw_cap_bottom)
366                 draw_line(_x, _y, right, _y);
367
368             // Tick point adjust
369             marker_ye  = _y + _h / 2;
370             // Bottom arrow
371             // draw_line(_center_x, marker_ye, _center_x - _h / 4, _y);
372             // draw_line(_center_x, marker_ye, _center_x + _h / 4, _y);
373             // draw pointer
374             if (_pointer) {
375                 if (_pointer_type == MOVING) {
376                     if (!_zoom) {
377                         //Code for Moving Type Pointer
378
379                         float xcentre = _center_x;
380                         float range = _w;
381                         float xpoint = xcentre + (cur_value * range / _val_span);
382                         float ypoint = _y - _marker_offset;
383                         draw_line(xcentre, ypoint, xpoint, ypoint);
384                         draw_line(xpoint, ypoint, xpoint, ypoint + _marker_offset);
385                         draw_line(xpoint, ypoint + _marker_offset, xpoint + 5.0, ypoint + 5.0);
386                         draw_line(xpoint, ypoint + _marker_offset, xpoint - 5.0, ypoint + 5.0);
387                     }
388
389                 } else {
390                     //default to fixed
391                     draw_fixed_pointer(marker_xs - _h / 4, _y, marker_xs,
392                             marker_ye, marker_xs + _h / 4, _y);
393                 }
394             }
395         } // End Horizontal scale/top
396
397         if (option_bottom()) {
398             if (_draw_cap_top)
399                 draw_line(_x, top, right, top);
400
401             // Tick point adjust
402             marker_ys = top - _h / 2;
403             // Top arrow
404             // draw_line(_center_x + _h / 4, _y + _h, _center_x, marker_ys);
405             // draw_line(_center_x - _h / 4, _y + _h, _center_x , marker_ys);
406
407             // draw pointer
408             if (_pointer) {
409                 if (_pointer_type == MOVING) {
410                     if (!_zoom) {
411                         //Code for Moving Type Pointer
412
413                         float xcentre = _center_x;
414                         float range = _w;
415                         float hgt = _y + _h;
416                         float xpoint = xcentre + (cur_value * range / _val_span);
417                         float ypoint = hgt + _marker_offset;
418                         draw_line(xcentre, ypoint, xpoint, ypoint);
419                         draw_line(xpoint, ypoint, xpoint, ypoint - _marker_offset);
420                         draw_line(xpoint, ypoint - _marker_offset, xpoint + 5.0, ypoint - 5.0);
421                         draw_line(xpoint, ypoint - _marker_offset, xpoint - 5.0, ypoint - 5.0);
422                     }
423                 } else {
424                     draw_fixed_pointer(marker_xs + _h / 4, top, marker_xs, marker_ys,
425                             marker_xs - _h / 4, top);
426                 }
427             }
428         } //end horizontal scale bottom
429
430
431         if (_zoom) {
432             zoomed_scale((int)vmin,(int)vmax);
433         } else {
434             int div_ratio;                                      // FIXME abstract that out of hor/vert
435             if (_minor_divs != 0.0f)
436                 div_ratio = int(_major_divs / _minor_divs + 0.5f);
437             else
438                 div_ratio = 0, _minor_divs = _major_divs;                       // FIXME move that into Scale/Constructor ?
439
440             float vstart = floorf(vmin / _major_divs) * _major_divs;
441             float min_diff = _h / 6.0;    // length difference between major & minor tick
442
443             // FIXME consider oddtype
444             for (int i = 0; ; i++) {
445                 float v = vstart + i * _minor_divs;
446
447                 if (!_modulo)
448                     if (v < _input.min())
449                         continue;
450                     else if (v > _input.max())
451                         break;
452
453                 float x = _x + (v - vmin) * factor();
454
455                 if (x < _x + 4)
456                     continue;
457                 if (x > right - 4)
458                     break;
459
460                 if (div_ratio && i % div_ratio) { // minor div
461                     if (option_both()) {
462                         if (_tick_length == VARIABLE) {
463                             draw_line(x, _y, x, marker_ys - 4);
464                             draw_line(x, marker_ye + 4, x, top);
465                         } else {
466                             draw_line(x, _y, x, marker_ys);
467                             draw_line(x, marker_ye, x, top);
468                         }
469
470                     } else {
471                         if (option_top()) {
472                             // draw minor ticks
473                             if (_tick_length == VARIABLE)
474                                 draw_line(x, marker_ys, x, marker_ye - min_diff);
475                             else
476                                 draw_line(x, marker_ys, x, marker_ye);
477
478                         } else if (_tick_length == VARIABLE) {
479                             draw_line(x, marker_ys + 4, x, marker_ye);
480                         } else {
481                             draw_line(x, marker_ys, x, marker_ye);
482                         }
483                     }
484
485                 } else { // major divs
486                     int display_value = int(v);
487                     if (_modulo)
488                         display_value %= _modulo;
489
490                     snprintf(buf, BUFSIZE, "%d", display_value);
491
492                     // Draw major ticks and text only if far enough from the edge.                      // FIXME
493                     if (x < _x + 10 || x + 10 > _x + _w)
494                         continue;
495
496                     if (option_both()) {
497                         draw_line(x, _y, x, marker_ye);
498                         draw_line(x, marker_ye, x, _y + _h);
499
500                         if (!option_notext())
501                             draw_text(x, marker_ys, buf, HUDText::CENTER);
502
503                     } else {
504                         draw_line(x, marker_ys, x, marker_ye);
505
506                         if (!option_notext()) {
507                             if (option_top())
508                                 draw_text(x, top, buf, HUDText::TOP|HUDText::HCENTER);
509                             else
510                                 draw_text(x, _y, buf, HUDText::BOTTOM|HUDText::HCENTER);
511                         }
512                     }
513                 }
514             } // end for
515         } // end zoom
516     } // end horizontal/vertical scale
517 }
518
519
520 void HUD::Tape::draw_fixed_pointer(float x1, float y1, float x2, float y2, float x3, float y3)
521 {
522     glBegin(GL_LINE_STRIP);
523     glVertex2f(x1, y1);
524     glVertex2f(x2, y2);
525     glVertex2f(x3, y3);
526     glEnd();
527 }
528
529
530 void HUD::Tape::zoomed_scale(int first, int last)
531 {
532     const int BUFSIZE = 80;
533     char buf[BUFSIZE];
534     int data[80];
535
536     float x, y, w, h, bottom;
537     float cur_value = _input.getFloatValue();
538     int a = 0;
539
540     while (first <= last) {
541         if ((first % (int)_major_divs) == 0) {
542             data[a] = first;
543             a++;
544         }
545         first++;
546     }
547     int centre = a / 2;
548
549     if (option_vert()) {
550         x = _x;
551         y = _y;
552         w = _x + _w;
553         h = _y + _h;
554         bottom = _h;
555
556         float xstart, yfirst, ycentre, ysecond;
557
558         float hgt = bottom * 20.0 / 100.0;  // 60% of height should be zoomed
559         yfirst = _center_y - hgt;
560         ycentre = _center_y;
561         ysecond = _center_y + hgt;
562         float range = hgt * 2;
563
564         int i;
565         float factor = range / 10.0;
566
567         float hgt1 = bottom * 30.0 / 100.0;
568         int  incrs = int((_val_span - _major_divs * 2.0) / _major_divs);
569         int  incr = incrs / 2;
570         float factors = hgt1 / incr;
571
572         // moving type pointer
573         float ypoint, xpoint;
574         float ycent = _center_y;
575         float right = _x + _w;
576
577         if (cur_value <= data[centre + 1])
578             if (cur_value > data[centre]) {
579                 ypoint = ycent + ((cur_value - data[centre]) * hgt / _major_divs);
580             }
581
582         if (cur_value >= data[centre - 1])
583             if (cur_value <= data[centre]) {
584                 ypoint = ycent - ((data[centre] - cur_value) * hgt / _major_divs);
585             }
586
587         if (cur_value < data[centre - 1])
588             if (cur_value >= _input.min()) {
589                 float diff  = _input.min() - data[centre - 1];
590                 float diff1 = cur_value - data[centre - 1];
591                 float val = (diff1 * hgt1) / diff;
592
593                 ypoint = ycent - hgt - val;
594             }
595
596         if (cur_value > data[centre + 1])
597             if (cur_value <= _input.max()) {
598                 float diff  = _input.max() - data[centre + 1];
599                 float diff1 = cur_value - data[centre + 1];
600                 float val = (diff1 * hgt1) / diff;
601
602                 ypoint = ycent + hgt + val;
603             }
604
605         if (option_left()) {
606             xstart = w;
607
608             draw_line(xstart, ycentre, xstart - 5.0, ycentre); //centre tick
609
610             snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre] * _input.factor())); // was data_scaling() ... makes not sense at all
611
612             if (!option_notext())
613                 draw_text(x, ycentre, buf, 0);
614
615             for (i = 1; i < 5; i++) {
616                 yfirst += factor;
617                 ycentre += factor;
618                 draw_bullet(xstart - 2.5, yfirst, 3.0);
619                 draw_bullet(xstart - 2.5, ycentre, 3.0);
620             }
621
622             yfirst = _center_y - hgt;
623
624             for (i = 0; i <= incr; i++) {
625                 draw_line(xstart, yfirst, xstart - 5.0, yfirst);
626                 draw_line(xstart, ysecond, xstart - 5.0, ysecond);
627
628                 snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre - i - 1] * _input.factor()));  // was data_scaling() ... makes no sense at all
629
630                 if (!option_notext())
631                     draw_text(x, yfirst, buf, 0);
632
633                 snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
634
635                 if (!option_notext())
636                     draw_text(x, ysecond, buf, 0);
637
638                 yfirst -= factors;
639                 ysecond += factors;
640
641             }
642
643             //to draw moving type pointer for left option
644             //begin
645             xpoint = right + 10.0;
646
647             if (_pointer_type == MOVING) {
648                 draw_line(xpoint, ycent, xpoint, ypoint);
649                 draw_line(xpoint, ypoint, xpoint - 10.0, ypoint);
650                 draw_line(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint + 5.0);
651                 draw_line(xpoint - 10.0, ypoint, xpoint - 5.0, ypoint - 5.0);
652             }
653             //end
654
655         } else {
656             //option_right
657             xstart = (x + w) / 2;
658
659             draw_line(xstart, ycentre, xstart + 5.0, ycentre); //centre tick
660
661             snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
662
663             if (!option_notext())
664                 draw_text(w, ycentre, buf, 0);
665
666             for (i = 1; i < 5; i++) {
667                 yfirst += factor;
668                 ycentre += factor;
669                 draw_bullet(xstart + 2.5, yfirst, 3.0);
670                 draw_bullet(xstart + 2.5, ycentre, 3.0);
671             }
672
673             yfirst = _center_y - hgt;
674
675             for (i = 0; i <= incr; i++) {
676                 draw_line(xstart, yfirst, xstart + 5.0, yfirst);
677                 draw_line(xstart, ysecond, xstart + 5.0, ysecond);
678
679                 snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
680
681                 if (!option_notext())
682                     draw_text(w, yfirst, buf, 0);
683
684                 snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre + i + 1] * _input.factor()));
685
686                 if (!option_notext())
687                     draw_text(w, ysecond, buf, 0);
688
689                 yfirst -= factors;
690                 ysecond += factors;
691
692             }
693
694             // to draw moving type pointer for right option
695             //begin
696             xpoint = _x;
697
698             if (_pointer_type == MOVING) {
699                 draw_line(xpoint, ycent, xpoint, ypoint);
700                 draw_line(xpoint, ypoint, xpoint + 10.0, ypoint);
701                 draw_line(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint + 5.0);
702                 draw_line(xpoint + 10.0, ypoint, xpoint + 5.0, ypoint - 5.0);
703             }
704             //end
705         }//end option_right /left
706         //end of vertical scale
707
708     } else {
709         //horizontal scale
710         x = _x;
711         y = _y;
712         w = _x + _w;
713         h = _y + _h;
714         bottom = _w;
715
716         float ystart, xfirst, xcentre, xsecond;
717
718         float hgt = bottom * 20.0 / 100.0;  // 60% of height should be zoomed
719         xfirst = _center_x - hgt;
720         xcentre = _center_x;
721         xsecond = _center_x + hgt;
722         float range = hgt * 2;
723
724         int i;
725         float factor = range / 10.0;
726
727         float hgt1 = bottom * 30.0 / 100.0;
728         int  incrs = int((_val_span - _major_divs * 2.0) / _major_divs);
729         int  incr = incrs / 2;
730         float factors = hgt1 / incr;
731
732
733         // Code for Moving Type Pointer
734         float, xpoint, ypoint;
735         float xcent = _center_x;
736
737         if (cur_value <= data[centre + 1]) {
738             if (cur_value > data[centre]) {
739                 xpoint = xcent + ((cur_value - data[centre]) * hgt / _major_divs);
740             }
741         }
742
743         if (cur_value >= data[centre - 1]) {
744             if (cur_value <= data[centre]) {
745                 xpoint = xcent - ((data[centre] - cur_value) * hgt / _major_divs);
746             }
747         }
748
749         if (cur_value < data[centre - 1]) {
750             if (cur_value >= _input.min()) {
751                 float diff = _input.min() - data[centre - 1];
752                 float diff1 = cur_value - data[centre - 1];
753                 float val = (diff1 * hgt1) / diff;
754
755                 xpoint = xcent - hgt - val;
756             }
757         }
758
759         if (cur_value > data[centre + 1]) {
760             if (cur_value <= _input.max()) {
761                 float diff = _input.max() - data[centre + 1];
762                 float diff1 = cur_value - data[centre + 1];
763                 float val = (diff1 * hgt1) / diff;
764
765                 xpoint = xcent + hgt + val;
766             }
767         }
768         // end moving pointer
769
770         if (option_top()) {
771             ystart = h;
772             draw_line(xcentre, ystart, xcentre, ystart - 5.0); //centre tick
773
774             snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre] * _input.factor()));  // was data_scaling() ... makes no sense at all
775
776             if (!option_notext())
777                 draw_text(xcentre - 10.0, y, buf, 0);
778
779             for (i = 1; i < 5; i++) {
780                 xfirst += factor;
781                 xcentre += factor;
782                 draw_bullet(xfirst, ystart - 2.5, 3.0);
783                 draw_bullet(xcentre, ystart - 2.5, 3.0);
784             }
785
786             xfirst = _center_x - hgt;
787
788             for (i = 0; i <= incr; i++) {
789                 draw_line(xfirst, ystart, xfirst,  ystart - 5.0);
790                 draw_line(xsecond, ystart, xsecond, ystart - 5.0);
791
792                 snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
793
794                 if (!option_notext())
795                     draw_text(xfirst - 10.0, y, buf, 0);
796
797                 snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
798
799                 if (!option_notext())
800                     draw_text(xsecond - 10.0, y, buf, 0);
801
802
803                 xfirst -= factors;
804                 xsecond += factors;
805             }
806
807             // moving pointer for top option
808             ypoint = _y + _h + 10.0;
809
810             if (_pointer_type == MOVING) {
811                 draw_line(xcent, ypoint, xpoint, ypoint);
812                 draw_line(xpoint, ypoint, xpoint, ypoint - 10.0);
813                 draw_line(xpoint, ypoint - 10.0, xpoint + 5.0, ypoint - 5.0);
814                 draw_line(xpoint, ypoint - 10.0, xpoint - 5.0, ypoint - 5.0);
815             }
816             //end of top option
817
818         } else {
819             //else option_bottom
820             ystart = (y + h) / 2;
821
822             //draw_line(xstart, yfirst,  xstart - 5.0, yfirst);
823             draw_line(xcentre, ystart, xcentre, ystart + 5.0); //centre tick
824
825             snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre] * _input.factor())); // was data_scaling() ... makes no sense at all
826
827             if (!option_notext())
828                 draw_text(xcentre - 10.0, h, buf, 0);
829
830             for (i = 1; i < 5; i++) {
831                 xfirst += factor;
832                 xcentre += factor;
833                 draw_bullet(xfirst, ystart + 2.5, 3.0);
834                 draw_bullet(xcentre, ystart + 2.5, 3.0);
835             }
836
837             xfirst = _center_x - hgt;
838
839             for (i = 0; i <= incr; i++) {
840                 draw_line(xfirst, ystart, xfirst, ystart + 5.0);
841                 draw_line(xsecond, ystart, xsecond, ystart + 5.0);
842
843                 snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre - i - 1] * _input.factor())); // was data_scaling() ... makes no sense at all
844
845                 if (!option_notext())
846                     draw_text(xfirst - 10.0, h, buf, 0);
847
848                 snprintf(buf, BUFSIZE, "%3.0f\n", float(data[centre + i + 1] * _input.factor())); // was data_scaling() ... makes no sense at all
849
850                 if (!option_notext())
851                     draw_text(xsecond - 10.0, h, buf, 0);
852
853                 xfirst -= factors;
854                 xsecond   += factors;
855             }
856
857             // movimg pointer for bottom option
858             ypoint = _y - 10.0;
859             if (_pointer_type == MOVING) {
860                 draw_line(xcent, ypoint, xpoint, ypoint);
861                 draw_line(xpoint, ypoint, xpoint, ypoint + 10.0);
862                 draw_line(xpoint, ypoint + 10.0, xpoint + 5.0, ypoint + 5.0);
863                 draw_line(xpoint, ypoint + 10.0, xpoint - 5.0, ypoint + 5.0);
864             }
865         }//end hud_top or hud_bottom
866     }  //end of horizontal/vertical scales
867 }//end draw
868
869