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