]> git.mxchange.org Git - flightgear.git/blob - Cockpit/hud.hxx
C++-ifing the code a bit.
[flightgear.git] / Cockpit / hud.hxx
1 /**************************************************************************
2  * hud.hxx -- hud defines and prototypes (initial draft)
3  *
4  * Written by Michele America, started September 1997.
5  *
6  * Copyright (C) 1997  Michele F. America  - nomimarketing@mail.telepac.pt
7  *
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.
12  *
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.
17  *
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.
21  *
22  * $Id$
23  * (Log is kept at end of this file)
24  **************************************************************************/
25
26
27 #ifndef _HUD_HXX
28 #define _HUD_HXX
29
30
31 #ifndef __cplusplus                                                          
32 # error This library requires C++
33 #endif                                   
34
35
36 #include <Aircraft/aircraft.h>
37 #include <Flight/flight.h>
38 #include <Controls/controls.h>
39
40 // View mode definitions
41
42 enum VIEW_MODES { HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
43
44 // Hud general constants
45 #define DAY                1
46 #define NIGHT              2
47 #define BRT_DARK           3
48 #define BRT_MEDIUM         4
49 #define BRT_LIGHT          5
50 #define SIZE_SMALL         6
51 #define SIZE_LARGE         7
52
53 // Instrument types
54 #define ARTIFICIAL_HORIZON      1
55 #define SCALE              2
56 #define LADDER             3
57 #define LABEL              4
58
59 // Scale constants
60 #define HORIZONTAL         1
61 #define TOP                2
62 #define BOTTOM             3
63 #define VERTICAL           4
64 #define LEFT               5
65 #define RIGHT              6
66 #define LIMIT              7
67 #define NOLIMIT            8
68 #define ROUNDROB           9
69
70 // Label constants
71 #define SMALL              1
72 #define LARGE              2
73 #define BLINK              3
74 #define NOBLINK            4
75 #define LEFT_JUST          5
76 #define CENTER_JUST        6
77 #define RIGHT_JUST         7
78
79 // Ladder constants
80 #define NONE               1
81 #define UPPER_LEFT         2
82 #define UPPER_CENTER       3
83 #define UPPER_RIGHT        4
84 #define CENTER_RIGHT       5
85 #define LOWER_RIGHT        6
86 #define LOWER_CENTER       7
87 #define LOWER_LEFT         8
88 #define CENTER_LEFT        9
89 #define SOLID_LINES       10
90 #define DASHED_LINES      11
91 #define DASHED_NEG_LINES  12
92
93 // Ladder orientaion
94 // #define HUD_VERTICAL        1
95 // #define HUD_HORIZONTAL               2
96 // #define HUD_FREEFLOAT                3
97
98 // Ladder orientation modes
99 // #define HUD_LEFT             1
100 // #define HUD_RIGHT            2
101 // #define HUD_TOP              1
102 // #define HUD_BOTTOM           2
103 // #define HUD_V_LEFT                   1
104 // #define HUD_V_RIGHT          2
105 // #define HUD_H_TOP            1
106 // #define HUD_H_BOTTOM         2
107
108
109 // Ladder sub-types
110 // #define HUD_LIM                              1
111 // #define HUD_NOLIM                    2
112 // #define HUD_CIRC                     3
113
114 // #define HUD_INSTR_LADDER     1
115 // #define HUD_INSTR_CLADDER    2
116 // #define HUD_INSTR_HORIZON    3
117 // #define HUD_INSTR_LABEL              4
118
119 // The following structs will become classes with a derivation from
120 // an ABC instrument_pack. Eventually the instruments may well become
121 // dll's. This would open the instrumentation issue to all commers.
122 //
123 // Methods Needed:
124 //    Constructor()
125 //    Initialization();  // For dynamic scenario settups?
126 //    Update();          // Follow the data changes.
127 //    Repaint();         // Respond to uncover/panel repaints.
128 //    Break();           // Show a frown.
129 //    Fix();             // Return to normal appearance and function.
130 //    Night_Day();       // Illumination changes appearance/bitmaps.
131 //
132
133 // CLO 2/21/98 - added to fix compile error
134 typedef struct  {
135   int x;
136   int y;
137 } FG_POINT;
138
139 // CLO 2/21/98 - added to fix compile error
140 typedef struct  {
141   int left;
142   int right;
143   int top;
144   int bottom;
145 } FG_RECT;
146
147 typedef struct  {
148        // Parametric defined members
149   int  type;
150   int  sub_type;
151   int  div_min;
152   int  div_max;
153   int  orientation;
154   int  minimum_value;
155   int  maximum_value;
156   int  width_units;
157   int  modulo;    // for compass, etc. Set to 0 for non_modulo scales.
158
159   double (*load_value)( void );
160
161   // Pre-calculated members.
162   int scr_span;
163   int mid_scr;
164   FG_RECT scrn_pos; // Screen rectangle for inicator
165                  //  Replaces previous parameters as:
166                  //  scr_pos -> left,bottom
167                  //  scr_max -> top, right
168                  //  scr_min -> left,bottom
169   double factor;
170   double half_width_units;
171 }HUD_scale,  *pHUDscale;
172
173 typedef struct  {
174         int type;
175   FG_RECT  position;
176         int div_min;
177         int div_max;
178         int orientation;
179         int label_position;
180         int width_units;
181   int  modulo;  // for compass, etc. Set to 0 for non_modulo scales.
182         double (*load_value)( void );
183 }HUD_circular_scale, *pHUD_circscale;
184
185 typedef struct  {
186         int type;
187   FG_POINT scrn_pos;
188         int scr_width;
189         int scr_height;
190         int scr_hole;
191         int div_units;
192         int label_position;
193         int width_units;
194         double (*load_roll)( void );
195         double (*load_pitch)( void );
196 }HUD_ladder, *pHUDladder;
197
198 typedef struct {
199         int scr_min;
200         int scr_max;
201         int div_min;
202         int div_max;
203         int orientation;
204         int label_position;
205         int width_units;
206         double (*load_value)( void );
207 } HUD_circular_ladder, *pHUDcircladder;
208
209 #define HORIZON_FIXED   1
210 #define HORIZON_MOVING  2
211
212 typedef struct{
213         int type;
214   FG_POINT scrn_pos;
215         int scr_width;
216         int scr_hole;
217         int tee_height;
218         double (*load_roll)( void );
219         double (*load_sideslip)( void );
220 } HUD_horizon, *pHUDhorizon;
221
222 typedef struct {
223   FG_POINT scrn_pos;
224   double(*load_value)(void);
225 } HUD_control_surfaces, *pHUDControlSurfaces;
226
227 typedef struct {
228   FG_POINT scrn_pos;    // ctrl_x, ctrl_y
229   int ctrl_length;
230   int orientation;
231   int alignment;
232   int min_value;
233   int max_value;
234   int width_units;
235   double (*load_value)(void);
236 } HUD_control, *pHUDControl;
237 #define LABEL_COUNTER   1
238 #define LABEL_WARNING   2
239
240 typedef struct {
241         int type;
242   FG_POINT scrn_pos;
243         int size;
244         int blink;
245         int justify;
246         char *pre_str;
247         char *post_str;
248         char *format;
249         double (*load_value)( void ); // pointer to routine to get the data
250 } HUD_label, *pHUDlabel;
251
252 // Removed union HUD_instr_data to evolve this to oop code.
253
254 typedef enum{ HUDno_instr,
255               HUDscale,
256               HUDcirc_scale,
257               HUDladder,
258               HUDcirc_ladder,
259               HUDhorizon,
260               HUDlabel,
261               HUDcontrol_surfaces,
262               HUDcontrol
263               } hudinstype;
264
265 typedef struct HUD_INSTR_STRUCT{
266   hudinstype  type;
267   int sub_type;
268   int orientation;
269   void *instr;   // For now we will cast this pointer accoring to the value
270                  // of the type member.
271   struct HUD_INSTR_STRUCT *next;
272 } HUD_instr, *HIptr;
273
274 typedef struct  {
275         int code;
276         HIptr instruments;
277         int status;
278         int time_of_day;
279         int brightness;
280         int size; // possibly another name for this ? (michele)
281 }HUD, *Hptr;
282
283 Hptr fgHUDInit      ( fgAIRCRAFT *cur_aircraft );
284
285 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
286 void fgHUDSetBrightness( Hptr hud, int brightness );
287
288 Hptr fgHUDAddHorizon( Hptr hud,
289                       int x_pos,
290                       int y_pos,
291                       int length,
292                       int hole_len,
293                       int tee_height,
294                       double (*load_roll)( void ),
295                       double (*load_sideslip)( void ) );
296
297 Hptr fgHUDAddScale  ( Hptr hud,                    \
298                       int type,                    \
299                       int subtype,                 \
300                       int scr_pos,                 \
301                       int scr_min,                 \
302                       int scr_max,                 \
303                       int div_min,                 \
304                       int div_max,                 \
305                       int orientation,             \
306                       int min_value,               \
307                       int max_value,               \
308                       int width_units,             \
309                       int modulus,                 \
310                       double (*load_value)( void ) );
311
312 Hptr fgHUDAddLabel  ( Hptr hud,                    \
313                       int x_pos,                   \
314                       int y_pos,                   \
315                       int size,                    \
316                       int blink,                   \
317                       int justify,                 \
318                       char *pre_str,               \
319                       char *post_str,              \
320                       char *format,                \
321                       double (*load_value)( void ) );
322
323 Hptr fgHUDAddLadder ( Hptr hud,                    \
324                       int x_pos,                   \
325                       int y_pos,                   \
326                       int scr_width,               \
327                       int scr_height,              \
328                       int hole_len,                \
329                       int div_units,               \
330                       int label_pos,               \
331                       int max_value,               \
332                       double (*load_roll)( void ), \
333                       double (*load_pitch)( void ) );
334
335 Hptr fgHUDAddControlSurfaces( Hptr hud,                    \
336                               int x_pos,                   \
337                               int y_pos,                   \
338                               double (*load_value)( void) );
339
340 Hptr fgHUDAddControl( Hptr hud,                    \
341                       int ctrl_x,                  \
342                       int ctrl_y,                  \
343                       int ctrl_length,             \
344                       int orientation,             \
345                       int alignment,               \
346                       int min_value,               \
347                       int max_value,               \
348                       int width_units,             \
349                       double (*load_value)( void) );
350
351 /*
352 Hptr fgHUDAddLadder ( Hptr hud,
353                       int scr_min,
354                       int scr_max,
355                       int div_min,
356                       int div_max, \
357                                                     int orientation,
358                       int max_value,
359                       double *(load_value);
360
361 Hptr fgHUDAddCircularLadder( Hptr hud,
362                              int scr_min,
363                              int scr_max,
364                              int div_min,
365                              int div_max, \
366                                                            int max_value,
367                              double *(load_value) );
368
369 Hptr fgHUDAddNumDisp( Hptr hud,
370                       int x_pos,
371                       int y_pos,
372                       int size,
373                       int blink, \
374                                                     char *pre_str,
375                       char *post_str,
376                       double *(load_value) );
377 */
378
379 void fgUpdateHUD ( Hptr hud );
380 void fgUpdateHUD2( Hptr hud ); // Future use?
381
382
383 #endif // _HUD_HXX
384
385 /* $Log$
386 /* Revision 1.1  1998/04/24 00:45:58  curt
387 /* C++-ifing the code a bit.
388 /*
389  * Revision 1.15  1998/02/23 19:07:57  curt
390  * Incorporated Durk's Astro/ tweaks.  Includes unifying the sun position
391  * calculation code between sun display, and other FG sections that use this
392  * for things like lighting.
393  *
394  * Revision 1.14  1998/02/21 14:53:14  curt
395  * Added Charlie's HUD changes.
396  *
397  * Revision 1.13  1998/02/20 00:16:22  curt
398  * Thursday's tweaks.
399  *
400  * Revision 1.12  1998/02/19 13:05:52  curt
401  * Incorporated some HUD tweaks from Michelle America.
402  * Tweaked the sky's sunset/rise colors.
403  * Other misc. tweaks.
404  *
405  * Revision 1.11  1998/02/16 13:38:42  curt
406  * Integrated changes from Charlie Hotchkiss.
407  *
408  * Revision 1.10  1998/02/12 21:59:42  curt
409  * Incorporated code changes contributed by Charlie Hotchkiss
410  * <chotchkiss@namg.us.anritsu.com>
411  *
412  * Revision 1.8  1998/02/07 15:29:35  curt
413  * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
414  * <chotchkiss@namg.us.anritsu.com>
415  *
416  * Revision 1.7  1998/02/03 23:20:15  curt
417  * Lots of little tweaks to fix various consistency problems discovered by
418  * Solaris' CC.  Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
419  * passed arguments along to the real printf().  Also incorporated HUD changes
420  * by Michele America.
421  *
422  * Revision 1.6  1998/01/22 02:59:30  curt
423  * Changed #ifdef FILE_H to #ifdef _FILE_H
424  *
425  * Revision 1.5  1998/01/19 19:27:01  curt
426  * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
427  * This should simplify things tremendously.
428  *
429  * Revision 1.4  1998/01/19 18:40:21  curt
430  * Tons of little changes to clean up the code and to remove fatal errors
431  * when building with the c++ compiler.
432  *
433  * Revision 1.3  1997/12/30 16:36:41  curt
434  * Merged in Durk's changes ...
435  *
436  * Revision 1.2  1997/12/10 22:37:40  curt
437  * Prepended "fg" on the name of all global structures that didn't have it yet.
438  * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
439  *
440  * Revision 1.1  1997/08/29 18:03:22  curt
441  * Initial revision.
442  *
443  */