]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud_scal.cxx
Update from JSBSim
[flightgear.git] / src / Cockpit / hud_scal.cxx
1
2 #include "hud.hxx"
3
4
5 //============== Top of instr_scale class memeber definitions ===============
6 //
7 // Notes:
8 // 1. instr_scales divide the specified location into half and then
9 //    the half opposite the read direction in half again. A bar is
10 //    then drawn along the second divider. Scale ticks are drawn
11 //    between the middle and quarter section lines (minor division
12 //    markers) or just over the middle line.
13 //
14 // 2.  This class was not intended to be instanciated. See moving_scale
15 //     and gauge_instr classes.
16 //============================================================================
17 instr_scale ::
18 instr_scale ( int       x,
19               int       y,
20               UINT      width,
21               UINT      height,
22               FLTFNPTR  load_fn,
23               UINT      options,
24               float    show_range,
25               float    maxValue,
26               float    minValue,
27               float    disp_scale,
28               UINT      major_divs,
29               UINT      minor_divs,
30               UINT      rollover,
31               int       dp_showing,
32               bool      working ) :
33                 instr_item( x, y, width, height,
34                             load_fn, disp_scale, options, working),
35                 range_shown  ( show_range ),
36                 Maximum_value( maxValue   ),
37                 Minimum_value( minValue   ),
38                 Maj_div      ( major_divs ),
39                 Min_div      ( minor_divs ),
40                 Modulo       ( rollover   ),
41                 signif_digits( dp_showing )
42 {
43 int temp;
44
45   scale_factor   = (float)get_span() / range_shown;
46   if( show_range < 0 ) {
47     range_shown = -range_shown;
48     }
49   temp = FloatToInt(Maximum_value - Minimum_value) / 100;
50   if( range_shown < temp ) {
51     range_shown = temp;
52     }
53 }
54
55 instr_scale ::
56   instr_scale( const instr_scale & image ) :
57             instr_item( (const instr_item &) image),
58             range_shown  ( image.range_shown   ),
59             Maximum_value( image.Maximum_value ),
60             Minimum_value( image.Minimum_value ),
61             scale_factor ( image.scale_factor  ),
62             Maj_div      ( image.Maj_div       ),
63             Min_div      ( image.Min_div       ),
64             Modulo       ( image.Modulo        ),
65             signif_digits( image.signif_digits )
66 {
67 }
68
69 instr_scale & instr_scale :: operator = (const instr_scale & rhs )
70 {
71   if( !(this == &rhs)) {
72     instr_item::operator = (rhs);
73     range_shown   = rhs.range_shown;
74     scale_factor  = rhs.scale_factor;
75     Maximum_value = rhs.Maximum_value;
76     Minimum_value = rhs.Minimum_value;
77     Maj_div       = rhs.Maj_div;
78     Min_div       = rhs.Min_div;
79     Modulo        = rhs.Modulo;
80     signif_digits = rhs.signif_digits;
81     }
82   return *this;
83 }
84
85 instr_scale :: ~ instr_scale () {}
86