1 // Abstract Base Class instr_item
14 #include <simgear/constants.h>
15 #include <simgear/math/fg_random.h>
16 #include <simgear/math/polar3d.hxx>
18 #include <Aircraft/aircraft.hxx>
19 #include <Scenery/scenery.hxx>
20 #include <Time/fg_timer.hxx>
25 UINT instr_item :: instances = 0; // Initial value of zero
26 int instr_item :: brightness = BRT_MEDIUM;
27 glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0};
29 // constructor ( No default provided )
39 handle ( ++instances ),
40 load_value_fn ( data_source ),
41 disp_factor ( data_scaling ),
43 is_enabled ( working ),
48 scrn_pos.right = width;
49 scrn_pos.bottom = height;
51 // Set up convenience values for centroid of the box and
52 // the span values according to orientation
54 if( opts & HUDS_VERT) { // Vertical style
55 // Insure that the midpoint marker will fall exactly at the
57 if( !(scrn_pos.bottom % 2)) {
60 scr_span = scrn_pos.bottom;
63 // Insure that the midpoint marker will fall exactly at the
65 if( !(scrn_pos.right % 2)) {
68 scr_span = scrn_pos.right;
70 // Here we work out the centroid for the corrected box.
71 mid_span.x = scrn_pos.left + (scrn_pos.right >> 1);
72 mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
78 instr_item ( const instr_item & image ):
79 handle ( ++instances ),
80 scrn_pos ( image.scrn_pos ),
81 load_value_fn( image.load_value_fn),
82 disp_factor ( image.disp_factor ),
84 is_enabled ( image.is_enabled ),
85 broken ( image.broken ),
86 scr_span ( image.scr_span ),
87 mid_span ( image.mid_span )
91 // assignment operator
93 instr_item & instr_item :: operator = ( const instr_item & rhs )
95 if( !(this == &rhs )) { // Not an identity assignment
96 scrn_pos = rhs.scrn_pos;
97 load_value_fn = rhs.load_value_fn;
98 disp_factor = rhs.disp_factor;
100 is_enabled = rhs.is_enabled;
108 instr_item :: ~instr_item ()
120 // break_display This is emplaced to provide hooks for making
121 // instruments unreliable. The default behavior is
122 // to simply not display, but more sophisticated behavior is available
123 // by over riding the function which is virtual in this class.
126 break_display ( bool bad )
133 SetBrightness ( int level )
135 brightness = level; // This is all we will do for now. Later the
136 // brightness levels will be sensitive both to
137 // the control knob and the outside light levels
138 // to emulated night vision effects.
141 UINT instr_item :: get_Handle( void )