]> git.mxchange.org Git - flightgear.git/blob - Cockpit/hud_inst.cxx
Added Charlie Hotchkiss's HUD updates and improvementes.
[flightgear.git] / Cockpit / hud_inst.cxx
1 // Abstract Base Class instr_item\r
2 //
3 #ifdef HAVE_CONFIG_H
4 #  include <config.h>
5 #endif
6
7 #ifdef HAVE_WINDOWS_H
8 #  include <windows.h>
9 #endif
10 #include <stdlib.h>
11 #include <string.h>
12 #include <Aircraft/aircraft.h>
13 #include <Debug/fg_debug.h>
14 #include <Include/fg_constants.h>
15 #include <Math/fg_random.h>
16 #include <Math/mat3.h>
17 #include <Math/polar3d.h>
18 #include <Scenery/scenery.hxx>
19 #include <Time/fg_timer.hxx>
20 #include <Weather/weather.h>
21
22
23 #include "hud.hxx"
24
25 UINT instr_item :: instances;  // Initial value of zero
26
27 // constructor    ( No default provided )
28 instr_item  ::
29    instr_item( int              x,
30                int              y,
31                UINT             width,
32                UINT             height,
33                DBLFNPTR         data_source,
34                UINT             options,
35                bool             working) :
36                       handle         ( ++instances  ),
37                       load_value_fn  ( data_source  ),
38                       opts           ( options      ),
39                       is_enabled     ( working      ),
40                       broken         ( FALSE        ),
41                       brightness     ( BRT_MEDIUM   )
42 {
43   scrn_pos.left   = x;
44   scrn_pos.top    = y;
45   scrn_pos.right  = width;
46   scrn_pos.bottom = height;
47
48          // Set up convenience values for centroid of the box and
49          // the span values according to orientation
50
51   if( opts & HUDS_VERT) { // Vertical style
52          // Insure that the midpoint marker will fall exactly at the
53          // middle of the bar.
54     if( !(scrn_pos.bottom % 2)) {
55       scrn_pos.bottom++;
56       }
57     scr_span = scrn_pos.bottom;
58     }
59   else {
60          // Insure that the midpoint marker will fall exactly at the
61          // middle of the bar.
62     if( !(scrn_pos.right % 2)) {
63       scrn_pos.right++;
64       }
65     scr_span = scrn_pos.right;
66     }
67          // Here we work out the centroid for the corrected box.
68   mid_span.x = scrn_pos.left   + (scrn_pos.right  >> 1);
69   mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
70 }
71
72
73 // copy constructor
74 instr_item  ::
75      instr_item ( const instr_item & image ):
76                          handle       ( ++instances        ),
77                          scrn_pos     ( image.scrn_pos     ),
78                          load_value_fn( image.load_value_fn),
79                          opts         ( image.opts         ),
80                          is_enabled   ( image.is_enabled   ),
81                          broken       ( image.broken       ),
82                          brightness   ( image.brightness   ),
83                          scr_span     ( image.scr_span     ),
84                          mid_span     ( image.mid_span     )
85 {
86 }
87
88 // assignment operator
89
90 instr_item & instr_item :: operator = ( const instr_item & rhs )
91 {
92   if( !(this == &rhs )) { // Not an identity assignment
93     scrn_pos      = rhs.scrn_pos;
94     load_value_fn = rhs.load_value_fn;
95     opts          = rhs.opts;
96     is_enabled    = rhs.is_enabled;
97     broken        = rhs.broken;
98     brightness    = rhs.brightness;
99     }
100   return *this;
101 }
102
103 // destructor
104
105 instr_item :: ~instr_item ()
106 {
107   if( instances ) {
108     instances--;
109     }
110 }
111
112 void instr_item ::
113     update( void )
114 {
115 }
116
117 // break_display       This is emplaced to provide hooks for making
118 //                     instruments unreliable. The default behavior is
119 // to simply not display, but more sophisticated behavior is available
120 // by over riding the function which is virtual in this class.
121
122 void instr_item ::
123     break_display ( bool bad )
124 {
125   broken = !!bad;
126   is_enabled = FALSE;
127 }
128
129 void instr_item ::
130     SetBrightness  ( int level  )
131 {
132   brightness = level;   // This is all we will do for now. Later the
133                         // brightness levels will be sensitive both to
134                         // the control knob and the outside light levels
135                         // to emulated night vision effects.
136 }
137
138 UINT instr_item :: get_Handle( void )
139 {
140   return handle;
141 }
142