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