]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud_inst.cxx
Fixed gauge spelling error.
[flightgear.git] / src / Cockpit / hud_inst.cxx
1
2 #include "hud.hxx"
3
4
5 UINT instr_item :: instances = 0;  // Initial value of zero
6 int  instr_item :: brightness = BRT_MEDIUM;
7 glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0};
8
9 // constructor    ( No default provided )
10 instr_item  ::
11    instr_item( int              x,
12                int              y,
13                UINT             width,
14                UINT             height,
15                FLTFNPTR         data_source,
16                float           data_scaling,
17                UINT             options,
18                bool             working) :
19                       handle         ( ++instances  ),
20                       load_value_fn  ( data_source  ),
21                       disp_factor    ( data_scaling ),
22                       opts           ( options      ),
23                       is_enabled     ( working      ),
24                       broken         ( FALSE        )
25 {
26   scrn_pos.left   = x;
27   scrn_pos.top    = y;
28   scrn_pos.right  = width;
29   scrn_pos.bottom = height;
30
31          // Set up convenience values for centroid of the box and
32          // the span values according to orientation
33
34   if( opts & HUDS_VERT) { // Vertical style
35          // Insure that the midpoint marker will fall exactly at the
36          // middle of the bar.
37     if( !(scrn_pos.bottom % 2)) {
38       scrn_pos.bottom++;
39       }
40     scr_span = scrn_pos.bottom;
41     }
42   else {
43          // Insure that the midpoint marker will fall exactly at the
44          // middle of the bar.
45     if( !(scrn_pos.right % 2)) {
46       scrn_pos.right++;
47       }
48     scr_span = scrn_pos.right;
49     }
50          // Here we work out the centroid for the corrected box.
51   mid_span.x = scrn_pos.left   + (scrn_pos.right  >> 1);
52   mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
53 }
54
55
56 // copy constructor
57 instr_item  ::
58      instr_item ( const instr_item & image ):
59                          handle       ( ++instances        ),
60                          scrn_pos     ( image.scrn_pos     ),
61                          load_value_fn( image.load_value_fn),
62                          disp_factor  ( image.disp_factor  ),
63                          opts         ( image.opts         ),
64                          is_enabled   ( image.is_enabled   ),
65                          broken       ( image.broken       ),
66                          scr_span     ( image.scr_span     ),
67                          mid_span     ( image.mid_span     )
68 {
69 }
70
71 // assignment operator
72
73 instr_item & instr_item :: operator = ( const instr_item & rhs )
74 {
75   if( !(this == &rhs )) { // Not an identity assignment
76     scrn_pos      = rhs.scrn_pos;
77     load_value_fn = rhs.load_value_fn;
78     disp_factor   = rhs.disp_factor;
79     opts          = rhs.opts;
80     is_enabled    = rhs.is_enabled;
81     broken        = rhs.broken;
82     }
83   return *this;
84 }
85
86 // destructor
87
88 instr_item :: ~instr_item ()
89 {
90   if( instances ) {
91     instances--;
92     }
93 }
94
95 void instr_item ::
96     update( void )
97 {
98 }
99
100 // break_display       This is emplaced to provide hooks for making
101 //                     instruments unreliable. The default behavior is
102 // to simply not display, but more sophisticated behavior is available
103 // by over riding the function which is virtual in this class.
104
105 void instr_item ::
106     break_display ( bool bad )
107 {
108   broken = !!bad;
109   is_enabled = FALSE;
110 }
111
112 void instr_item ::
113     SetBrightness  ( int level  )
114 {
115   brightness = level;   // This is all we will do for now. Later the
116                         // brightness levels will be sensitive both to
117                         // the control knob and the outside light levels
118                         // to emulated night vision effects.
119 }
120
121 UINT instr_item :: get_Handle( void )
122 {
123   return handle;
124 }
125