1 // Abstract Base Class instr_item
13 #include <Aircraft/aircraft.h>
14 #include <Debug/fg_debug.h>
15 #include <Include/fg_constants.h>
16 #include <Math/fg_random.h>
17 #include <Math/mat3.h>
18 #include <Math/polar3d.hxx>
19 #include <Scenery/scenery.hxx>
20 #include <Time/fg_timer.hxx>
21 #include <Weather/weather.h>
26 UINT instr_item :: instances = 0; // Initial value of zero
27 int instr_item :: brightness = BRT_MEDIUM;
28 glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0};
30 // constructor ( No default provided )
40 handle ( ++instances ),
41 load_value_fn ( data_source ),
42 disp_factor ( data_scaling ),
44 is_enabled ( working ),
49 scrn_pos.right = width;
50 scrn_pos.bottom = height;
52 // Set up convenience values for centroid of the box and
53 // the span values according to orientation
55 if( opts & HUDS_VERT) { // Vertical style
56 // Insure that the midpoint marker will fall exactly at the
58 if( !(scrn_pos.bottom % 2)) {
61 scr_span = scrn_pos.bottom;
64 // Insure that the midpoint marker will fall exactly at the
66 if( !(scrn_pos.right % 2)) {
69 scr_span = scrn_pos.right;
71 // Here we work out the centroid for the corrected box.
72 mid_span.x = scrn_pos.left + (scrn_pos.right >> 1);
73 mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
79 instr_item ( const instr_item & image ):
80 handle ( ++instances ),
81 scrn_pos ( image.scrn_pos ),
82 load_value_fn( image.load_value_fn),
83 disp_factor ( image.disp_factor ),
85 is_enabled ( image.is_enabled ),
86 broken ( image.broken ),
87 scr_span ( image.scr_span ),
88 mid_span ( image.mid_span )
92 // assignment operator
94 instr_item & instr_item :: operator = ( const instr_item & rhs )
96 if( !(this == &rhs )) { // Not an identity assignment
97 scrn_pos = rhs.scrn_pos;
98 load_value_fn = rhs.load_value_fn;
99 disp_factor = rhs.disp_factor;
101 is_enabled = rhs.is_enabled;
109 instr_item :: ~instr_item ()
121 // break_display This is emplaced to provide hooks for making
122 // instruments unreliable. The default behavior is
123 // to simply not display, but more sophisticated behavior is available
124 // by over riding the function which is virtual in this class.
127 break_display ( bool bad )
134 SetBrightness ( int level )
136 brightness = level; // This is all we will do for now. Later the
137 // brightness levels will be sensitive both to
138 // the control knob and the outside light levels
139 // to emulated night vision effects.
142 UINT instr_item :: get_Handle( void )