]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/HUD/HUD_scale.cxx
Win32 fix
[flightgear.git] / src / Instrumentation / HUD / HUD_scale.cxx
1 // HUD_scale.cxx -- HUD Common Scale Base (inherited from Gauge/Tape/Dial)
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 //============== Scale class memeber definitions ===============
26 //
27 // Notes:
28 // 1. Scales divide the specified location into half and then
29 //    the half opposite the read direction in half again. A bar is
30 //    then drawn along the second divider. Scale ticks are drawn
31 //    between the middle and quarter section lines (minor division
32 //    markers) or just over the middle line.
33 //
34 // 2.  This class was not intended to be instanciated. See moving_scale
35 //     and gauge_instr classes.
36 //==============================================================
37 HUD::Scale::Scale( HUD *hud, const SGPropertyNode *n, float x, float y) :
38     Item(hud, n, x, y),
39     _input(n->getNode("input", false)),
40     _major_divs(n->getFloatValue("major-divisions")),
41     _minor_divs(n->getFloatValue("minor-divisions")),
42     _modulo(n->getIntValue("modulo"))
43 {
44     if (n->hasValue("display-span"))
45         _range_shown = n->getFloatValue("display-span");
46     else
47         _range_shown = _input.max() - _input.min();
48
49     _display_factor = get_span() / _range_shown;
50     if (_range_shown < 0)
51         _range_shown = -_range_shown;
52
53 //    float temp = (_input.max() - _input.min()) / 100;         // FIXME huh?
54 //    if (_range_shown < temp)
55 //        _range_shown = temp;
56 }
57
58