1 // Abstract Base Class instr_item
13 #include <Aircraft/aircraft.hxx>
14 #include <Include/fg_constants.h>
15 #include <Math/fg_random.h>
16 #include <Math/mat3.h>
17 #include <Math/polar3d.hxx>
18 #include <Scenery/scenery.hxx>
19 #include <Time/fg_timer.hxx>
24 UINT instr_item :: instances = 0; // Initial value of zero
25 int instr_item :: brightness = BRT_MEDIUM;
26 glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0};
28 // constructor ( No default provided )
38 handle ( ++instances ),
39 load_value_fn ( data_source ),
40 disp_factor ( data_scaling ),
42 is_enabled ( working ),
47 scrn_pos.right = width;
48 scrn_pos.bottom = height;
50 // Set up convenience values for centroid of the box and
51 // the span values according to orientation
53 if( opts & HUDS_VERT) { // Vertical style
54 // Insure that the midpoint marker will fall exactly at the
56 if( !(scrn_pos.bottom % 2)) {
59 scr_span = scrn_pos.bottom;
62 // Insure that the midpoint marker will fall exactly at the
64 if( !(scrn_pos.right % 2)) {
67 scr_span = scrn_pos.right;
69 // Here we work out the centroid for the corrected box.
70 mid_span.x = scrn_pos.left + (scrn_pos.right >> 1);
71 mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
77 instr_item ( const instr_item & image ):
78 handle ( ++instances ),
79 scrn_pos ( image.scrn_pos ),
80 load_value_fn( image.load_value_fn),
81 disp_factor ( image.disp_factor ),
83 is_enabled ( image.is_enabled ),
84 broken ( image.broken ),
85 scr_span ( image.scr_span ),
86 mid_span ( image.mid_span )
90 // assignment operator
92 instr_item & instr_item :: operator = ( const instr_item & rhs )
94 if( !(this == &rhs )) { // Not an identity assignment
95 scrn_pos = rhs.scrn_pos;
96 load_value_fn = rhs.load_value_fn;
97 disp_factor = rhs.disp_factor;
99 is_enabled = rhs.is_enabled;
107 instr_item :: ~instr_item ()
119 // break_display This is emplaced to provide hooks for making
120 // instruments unreliable. The default behavior is
121 // to simply not display, but more sophisticated behavior is available
122 // by over riding the function which is virtual in this class.
125 break_display ( bool bad )
132 SetBrightness ( int level )
134 brightness = level; // This is all we will do for now. Later the
135 // brightness levels will be sensitive both to
136 // the control knob and the outside light levels
137 // to emulated night vision effects.
140 UINT instr_item :: get_Handle( void )