1 /**************************************************************************
2 * hud.hxx -- hud defines and prototypes (initial draft)
4 * Written by Michele America, started September 1997.
6 * Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * (Log is kept at end of this file)
24 **************************************************************************/
32 # error This library requires C++
39 #include <fg_typedefs.h>
40 #include <fg_constants.h>
41 #include <Aircraft/aircraft.h>
42 #include <Flight/flight.h>
43 #include <Controls/controls.h>
45 //using namespace std;
47 #include <deque.h> // STL
57 int top, bottom, left, right;
63 // View mode definitions
65 enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
67 // DAY, NIGHT and brightness levels need to be visible where dialogs and
68 // controls can be used to set intensity and appropriate color. This will
70 // Hud general constants
86 enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
91 #define UPPER_CENTER 3
93 #define CENTER_RIGHT 5
95 #define LOWER_CENTER 7
98 #define SOLID_LINES 10
99 #define DASHED_LINES 11
100 #define DASHED_NEG_LINES 12
103 #define HORIZON_FIXED 1
104 #define HORIZON_MOVING 2
105 #define LABEL_COUNTER 1
106 #define LABEL_WARNING 2
109 // #define HUD_VERTICAL 1
110 // #define HUD_HORIZONTAL 2
111 // #define HUD_FREEFLOAT 3
113 // Ladder orientation modes
114 // #define HUD_LEFT 1
115 // #define HUD_RIGHT 2
117 // #define HUD_BOTTOM 2
118 // #define HUD_V_LEFT 1
119 // #define HUD_V_RIGHT 2
120 // #define HUD_H_TOP 1
121 // #define HUD_H_BOTTOM 2
126 // #define HUD_NOLIM 2
127 // #define HUD_CIRC 3
129 // #define HUD_INSTR_LADDER 1
130 // #define HUD_INSTR_CLADDER 2
131 // #define HUD_INSTR_HORIZON 3
132 // #define HUD_INSTR_LABEL 4
134 extern double get_throttleval ( void );
135 extern double get_aileronval ( void );
136 extern double get_elevatorval ( void );
137 extern double get_elev_trimval( void );
138 extern double get_rudderval ( void );
139 extern double get_speed ( void );
140 extern double get_aoa ( void );
141 extern double get_roll ( void );
142 extern double get_pitch ( void );
143 extern double get_heading ( void );
144 extern double get_altitude ( void );
145 extern double get_sideslip ( void );
146 extern double get_frame_rate ( void );
147 extern double get_fov ( void );
149 enum hudinstype{ HUDno_instr,
161 enum ReadOriented{ ReadRIGHT, ReadLEFT, ReadTOP, ReadBOTTOM };
163 class instr_item { // An Abstract Base Class (ABC)
165 static UINT instances; // More than 64K instruments? Nah!
167 RECT scrn_pos; // Framing - affects scale dimensions
168 // and orientation. Vert vs Horz, etc.
169 DBLFNPTR load_value_fn;
170 ReadOriented oriented;
174 UINT scr_span; // Working values for draw;
178 instr_item( RECT scrn_pos,
179 DBLFNPTR data_source,
181 bool working = true);
183 instr_item( const instr_item & image );
185 instr_item & operator = ( const instr_item & rhs );
186 virtual ~instr_item ();
188 int get_brightness ( void ) { return brightness;}
189 RECT get_location ( void ) { return scrn_pos; }
190 bool is_broken ( void ) { return broken; }
191 bool enabled ( void ) { return is_enabled;}
192 double get_value ( void ) { return load_value_fn();}
193 UINT get_span ( void ) { return scr_span; }
194 POINT get_centroid ( void ) { return mid_span; }
195 ReadOriented get_orientation ( void ) { return oriented; }
197 virtual void display_enable( bool working ) { is_enabled = !! working;}
200 virtual void update( void );
201 virtual void break_display ( bool bad );
202 virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
203 UINT get_Handle( void );
204 virtual void draw( void ) = 0; // Required method in derived classes
207 typedef instr_item *HIptr;
208 extern deque< instr_item *> HUD_deque;
210 // instr_item This class has no other purpose than to maintain
211 // a linked list of instrument and derived class
215 class instr_label : public instr_item {
219 const char *post_str;
225 instr_label( RECT the_box,
226 DBLFNPTR data_source,
227 const char *label_format,
228 const char *pre_label_string = 0,
229 const char *post_label_string = 0,
230 ReadOriented orientation = ReadTOP,
231 fgLabelJust justification = CENTER_JUST,
232 int font_size = SMALL,
233 int blinking = NOBLINK,
234 bool working = true);
238 instr_label( const instr_label & image);
239 instr_label & operator = (const instr_label & rhs );
241 virtual void draw( void ); // Required method in base class
244 typedef instr_label * pInstlabel;
247 // instr_scale This class is an abstract base class for both moving
248 // scale and moving needle (fixed scale) indicators. It
249 // does not draw itself, but is not instanciable.
252 class instr_scale : public instr_item {
254 int range_shown; // Width Units.
255 int Maximum_value; // ceiling.
256 int Minimum_value; // Representation floor.
257 UINT Maj_div; // major division marker units
258 UINT Min_div; // minor division marker units
259 UINT Modulo; // Roll over point
260 double scale_factor; // factor => screen units/range values.
263 instr_scale( RECT the_box,
269 UINT major_divs = 10,
272 bool working = true);
274 virtual ~instr_scale();
275 instr_scale( const instr_scale & image);
276 instr_scale & operator = (const instr_scale & rhs);
278 virtual void draw ( void ) {}; // No-op here. Defined in derived classes.
279 UINT div_min ( void ) { return Min_div;}
280 UINT div_max ( void ) { return Maj_div;}
281 int min_val ( void ) { return Minimum_value;}
282 int max_val ( void ) { return Maximum_value;}
283 UINT modulo ( void ) { return Modulo; }
284 double factor ( void ) { return scale_factor;}
285 double range_to_show( void ) { return range_shown;}
288 // moving_scale_instr This class displays the indicated quantity on
289 // a scale that moves past the pointer. It may be
290 // horizontal or vertical, read above(left) or below(right) of the base
293 class moving_scale : public instr_scale {
296 double half_width_units;
299 moving_scale( RECT box,
301 ReadOriented readway,
308 bool working = true);
311 moving_scale( const moving_scale & image);
312 moving_scale & operator = (const moving_scale & rhs );
313 // virtual void display_enable( bool setting );
314 virtual void draw( void ); // Required method in base class
317 typedef moving_scale * pMoveScale;
319 class guage_instr : public instr_scale {
323 guage_instr( RECT box,
325 ReadOriented readway,
331 bool working = true);
334 guage_instr( const guage_instr & image);
335 guage_instr & operator = (const guage_instr & rhs );
336 virtual void draw( void ); // Required method in base class
339 typedef guage_instr * pGuageInst;
341 // dual_instr_item This class was created to form the base class
342 // for both panel and HUD Turn Bank Indicators.
344 class dual_instr_item : public instr_item {
346 DBLFNPTR alt_data_source;
349 dual_instr_item ( RECT the_box,
350 DBLFNPTR chn1_source,
351 DBLFNPTR chn2_source,
353 ReadOriented readway = ReadTOP);
355 virtual ~dual_instr_item() {};
356 dual_instr_item( const dual_instr_item & image);
357 dual_instr_item & operator = (const dual_instr_item & rhs );
359 double current_ch1( void ) { return alt_data_source();}
360 double current_ch2( void ) { return get_value();}
361 virtual void draw ( void ) { }
364 class fgTBI_instr : public dual_instr_item {
371 fgTBI_instr( RECT the_box,
372 DBLFNPTR chn1_source = get_roll,
373 DBLFNPTR chn2_source = get_sideslip,
374 UINT maxBankAngle = 45,
375 UINT maxSlipAngle = 5,
377 bool working = true);
379 fgTBI_instr( const fgTBI_instr & image);
380 fgTBI_instr & operator = (const fgTBI_instr & rhs );
384 UINT bank_limit( void ) { return BankLimit;}
385 UINT slew_limit( void ) { return SlewLimit;}
387 virtual void draw( void ); // Required method in base class
390 typedef fgTBI_instr * pTBI;
392 class HudLadder : public dual_instr_item {
404 HudLadder( RECT the_box,
405 DBLFNPTR ptch_source = get_roll,
406 DBLFNPTR roll_source = get_pitch,
407 UINT span_units = 45,
408 int division_units = 10,
409 UINT minor_division = 0,
410 UINT screen_hole = 70,
412 bool working = true );
416 HudLadder( const HudLadder & image );
417 HudLadder & operator = ( const HudLadder & rhs );
418 virtual void draw( void );
422 //using namespace std;
423 //deque <instr_item> * Hdeque_ptr;
425 extern int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
426 extern void fgUpdateHUD( void );
429 bool AddHUDInstrument( instr_item *pBlackBox );
430 void DrawHUD ( void );
431 bool DamageInstrument( INSTR_HANDLE unit );
432 bool RepairInstrument( INSTR_HANDLE unit );
435 void fgUpdateHUD ( Hptr hud );
436 void fgUpdateHUD2( Hptr hud ); // Future use?
437 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
443 /* Revision 1.3 1998/05/13 18:27:55 curt
444 /* Added an fov to hud display.
446 * Revision 1.2 1998/05/11 18:13:12 curt
447 * Complete C++ rewrite of all cockpit code by Charlie Hotchkiss.
449 * Revision 1.15 1998/02/23 19:07:57 curt
450 * Incorporated Durk's Astro/ tweaks. Includes unifying the sun position
451 * calculation code between sun display, and other FG sections that use this
452 * for things like lighting.
454 * Revision 1.14 1998/02/21 14:53:14 curt
455 * Added Charlie's HUD changes.
457 * Revision 1.13 1998/02/20 00:16:22 curt
460 * Revision 1.12 1998/02/19 13:05:52 curt
461 * Incorporated some HUD tweaks from Michelle America.
462 * Tweaked the sky's sunset/rise colors.
463 * Other misc. tweaks.
465 * Revision 1.11 1998/02/16 13:38:42 curt
466 * Integrated changes from Charlie Hotchkiss.
468 * Revision 1.11 1998/02/16 13:38:42 curt
469 * Integrated changes from Charlie Hotchkiss.
471 * Revision 1.10 1998/02/12 21:59:42 curt
472 * Incorporated code changes contributed by Charlie Hotchkiss
473 * <chotchkiss@namg.us.anritsu.com>
475 * Revision 1.8 1998/02/07 15:29:35 curt
476 * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
477 * <chotchkiss@namg.us.anritsu.com>
479 * Revision 1.7 1998/02/03 23:20:15 curt
480 * Lots of little tweaks to fix various consistency problems discovered by
481 * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
482 * passed arguments along to the real printf(). Also incorporated HUD changes
483 * by Michele America.
485 * Revision 1.6 1998/01/22 02:59:30 curt
486 * Changed #ifdef FILE_H to #ifdef _FILE_H
488 * Revision 1.5 1998/01/19 19:27:01 curt
489 * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
490 * This should simplify things tremendously.
492 * Revision 1.4 1998/01/19 18:40:21 curt
493 * Tons of little changes to clean up the code and to remove fatal errors
494 * when building with the c++ compiler.
496 * Revision 1.3 1997/12/30 16:36:41 curt
497 * Merged in Durk's changes ...
499 * Revision 1.2 1997/12/10 22:37:40 curt
500 * Prepended "fg" on the name of all global structures that didn't have it yet.
501 * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
503 * Revision 1.1 1997/08/29 18:03:22 curt