]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud.hxx
- adjusted for no-value constructor for FGPanel
[flightgear.git] / src / Cockpit / hud.hxx
1 // hud.hxx -- hud defines and prototypes (initial draft)
2 //
3 // Written by Michele America, started September 1997.
4 //
5 // Copyright (C) 1997  Michele F. America  - nomimarketing@mail.telepac.pt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _HUD_HXX
25 #define _HUD_HXX
26
27 #ifndef __cplusplus
28 # error This library requires C++
29 #endif
30
31 #include <simgear/compiler.h>
32
33 #ifdef HAVE_CONFIG_H
34 #  include <config.h>
35 #endif
36
37 #ifdef HAVE_WINDOWS_H
38 #  include <windows.h>
39 #endif
40
41 #include <GL/glut.h>
42 #include <stdlib.h>
43 #include <string.h>
44
45 //#ifdef HAVE_VALUES_H
46 //#  include <values.h>  // for MAXINT
47 //#endif
48
49 #include <vector>       // STL vector
50 #include <deque>        // STL double ended queue
51
52 #include <simgear/constants.h>
53
54 #include <Include/fg_typedefs.h>
55 #include <Aircraft/aircraft.hxx>
56 #include <FDM/flight.hxx>
57 #include <Controls/controls.hxx>
58 #include <GUI/gui.h>
59
60 #include "hud_opts.hxx"
61
62 SG_USING_STD(deque);
63 SG_USING_STD(vector);
64 SG_USING_NAMESPACE(std);
65
66
67 // some of Norman's crazy optimizations. :-)
68
69 #ifndef WIN32
70   typedef struct {
71       int x, y;
72   } POINT;
73  
74   typedef struct {
75       int top, bottom, left, right;
76   } RECT;
77 #endif
78
79 // View mode definitions
80
81 enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
82
83 // DAY, NIGHT and brightness levels need to be visible where dialogs and
84 // controls can be used to set intensity and appropriate color. This will
85 // be moved.
86 // Hud general constants
87 #define DAY                1
88 #define NIGHT              2
89 #define BRT_BLACK          3
90 #define BRT_DARK           4
91 #define BRT_MEDIUM         5
92 #define BRT_LIGHT          6
93 #define SIZE_SMALL         7
94 #define SIZE_LARGE         8
95
96 // Label constants
97 #define SMALL              1
98 #define LARGE              2
99
100 #define BLINK              3
101 #define NOBLINK            4
102
103 enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
104
105 // Ladder constants
106 #define NONE               1
107 #define UPPER_LEFT         2
108 #define UPPER_CENTER       3
109 #define UPPER_RIGHT        4
110 #define CENTER_RIGHT       5
111 #define LOWER_RIGHT        6
112 #define LOWER_CENTER       7
113 #define LOWER_LEFT         8
114 #define CENTER_LEFT        9
115 #define SOLID_LINES       10
116 #define DASHED_LINES      11
117 #define DASHED_NEG_LINES  12
118
119
120 #define HORIZON_FIXED   1
121 #define HORIZON_MOVING  2
122 #define LABEL_COUNTER   1
123 #define LABEL_WARNING   2
124
125 #define HUDS_AUTOTICKS           0x0001
126 #define HUDS_VERT                0x0002
127 #define HUDS_HORZ                0x0000
128 #define HUDS_TOP                 0x0004
129 #define HUDS_BOTTOM              0x0008
130 #define HUDS_LEFT     HUDS_TOP
131 #define HUDS_RIGHT    HUDS_BOTTOM
132 #define HUDS_BOTH     (HUDS_LEFT | HUDS_RIGHT)
133 #define HUDS_NOTICKS             0x0010
134 #define HUDS_ARITHTIC            0x0020
135 #define HUDS_DECITICS            0x0040
136 #define HUDS_NOTEXT              0x0080
137
138 // Ladder orientaion
139 // #define HUD_VERTICAL        1
140 // #define HUD_HORIZONTAL       2
141 // #define HUD_FREEFLOAT        3
142
143 // Ladder orientation modes
144 // #define HUD_LEFT         1
145 // #define HUD_RIGHT            2
146 // #define HUD_TOP              1
147 // #define HUD_BOTTOM           2
148 // #define HUD_V_LEFT           1
149 // #define HUD_V_RIGHT          2
150 // #define HUD_H_TOP            1
151 // #define HUD_H_BOTTOM         2
152
153
154 // Ladder sub-types
155 // #define HUD_LIM              1
156 // #define HUD_NOLIM            2
157 // #define HUD_CIRC         3
158
159 // #define HUD_INSTR_LADDER 1
160 // #define HUD_INSTR_CLADDER    2
161 // #define HUD_INSTR_HORIZON    3
162 // #define HUD_INSTR_LABEL      4
163
164 // in cockpit.cxx
165 extern float get_throttleval ( void );
166 extern float get_aileronval  ( void );
167 extern float get_elevatorval ( void );
168 extern float get_elev_trimval( void );
169 extern float get_rudderval   ( void );
170 extern float get_speed       ( void );
171 extern float get_aoa         ( void );
172 extern float get_roll        ( void );
173 extern float get_pitch       ( void );
174 extern float get_heading     ( void );
175 extern float get_view_direction( void );
176 extern float get_altitude    ( void );
177 extern float get_agl         ( void );
178 extern float get_sideslip    ( void );
179 extern float get_frame_rate  ( void );
180 extern float get_latitude    ( void );
181 extern float get_lat_min     ( void );
182 extern float get_longitude   ( void );
183 extern float get_long_min    ( void );
184 extern float get_fov         ( void );
185 extern float get_vfc_ratio   ( void );
186 extern float get_vfc_tris_drawn   ( void );
187 extern float get_vfc_tris_culled   ( void );
188 extern float get_climb_rate  ( void );
189 extern float get_mach( void );
190 extern char *coord_format_lat(float);
191 extern char *coord_format_lon(float);
192 //extern char *coord_format_latlon(float latitude, float longitude);  // cockpit.cxx
193
194 // $$$ begin - added, VS Renganathan, 13 Oct 2K
195 // #define FIGHTER_HUD
196 extern float get_anzg (void);
197 extern float get_Vx (void);
198 extern float get_Vy (void);
199 extern float get_Vz (void);
200 extern float get_Ax (void);
201 extern float get_Ay (void);
202 extern float get_Az (void);
203 extern int get_iaux1 (void);
204 extern int get_iaux2 (void);
205 extern int get_iaux3 (void);
206 extern int get_iaux4 (void);
207 extern int get_iaux5 (void);
208 extern int get_iaux6 (void);
209 extern int get_iaux7 (void);
210 extern int get_iaux8 (void);
211 extern int get_iaux9 (void);
212 extern int get_iaux10 (void);
213 extern int get_iaux11 (void);
214 extern int get_iaux12 (void);
215 extern float get_aux1(void);
216 extern float get_aux2(void);
217 extern float get_aux3(void);
218 extern float get_aux4(void);
219 extern float get_aux5 (void);
220 extern float get_aux6 (void);
221 extern float get_aux8(void);
222 extern float get_aux9(void);
223 extern float get_aux10(void);
224 extern float get_aux11(void);
225 extern float get_aux12(void);
226 extern float get_aux13(void);
227 extern float get_aux14(void);
228 extern float get_aux15(void);
229 extern float get_aux16(void);
230 extern float get_aux17(void);
231 extern float get_aux18(void);
232 // $$$ end - added, VS Renganathan, 13 Oct 2K
233
234 extern char *get_formated_gmt_time( void );
235 extern void fgHUDReshape(void);
236
237 enum  hudinstype{ HUDno_instr,
238               HUDscale,
239               HUDlabel,
240               HUDladder,
241               HUDcirc_ladder,
242               HUDhorizon,
243               HUDguage,
244               HUDdual_inst,
245               HUDmoving_scale,
246               HUDtbi
247               };
248
249 typedef struct gltagRGBTRIPLE { // rgbt
250     GLfloat Blue;
251     GLfloat Green;
252     GLfloat Red;
253 } glRGBTRIPLE;
254
255 class fgLineSeg2D {
256 private:
257     GLfloat x0, y0, x1, y1;
258
259 public:
260     fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
261         : x0(a), y0(b),  x1(c), y1(d) {}
262
263     fgLineSeg2D( const fgLineSeg2D & image )
264         : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
265
266     fgLineSeg2D& operator= ( const fgLineSeg2D & image ) {
267         x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
268     }
269
270     ~fgLineSeg2D() {}
271     
272     void draw()
273     {
274         glVertex2f(x0, y0);
275         glVertex2f(x1, y1);
276     }
277 };
278
279 #define USE_HUD_TextList
280 extern float              HUD_TextSize;
281 extern fntRenderer       *HUDtext;
282 extern float HUD_matrix[16];
283
284 class fgText {
285 private:
286     float x, y;
287     char msg[64];
288 public:
289     fgText( float x = 0, float y = 0, char *c = NULL )
290         : x(x), y(y) {strncpy(msg,c,64-1);}
291
292     fgText( const fgText & image )
293         : x(image.x), y(image.y) {strcpy(msg,image.msg);}
294
295     fgText& operator = ( const fgText & image ) {
296         strcpy(msg,image.msg); x = image.x; y = image.y;
297         return *this;
298     }
299
300     ~fgText() {msg[0]='\0';}
301
302     int getStringWidth ( char *str )
303     {
304         if ( HUDtext && str )
305         {
306             float r, l ;
307             guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
308             return FloatToInt( r - l );
309         }
310         return 0 ;
311     }
312     
313     int StringWidth (void )
314     {
315         if ( HUDtext && strlen( msg ))
316         {
317             float r, l ;
318             guiFntHandle->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
319             return FloatToInt( r - l );
320         }
321         return 0 ;
322     }
323     
324     void Draw(fntRenderer *fnt)
325     {
326         fnt->start2f( x, y );
327         fnt->puts   ( msg ) ;
328     }
329
330     void Draw()
331     {
332         puDrawString ( guiFnt, msg, FloatToInt(x), FloatToInt(y) );
333     }
334 };
335
336 class fgLineList {
337     vector < fgLineSeg2D > List;
338 public:
339     fgLineList( void ) {}
340     ~fgLineList( void ) {}
341     void add( fgLineSeg2D seg ) { List.push_back(seg); }
342     void erase( void ) { List.erase( List.begin(), List.end() ); }
343         void draw( void ) {
344                 vector < fgLineSeg2D > :: iterator curSeg;
345                 vector < fgLineSeg2D > :: iterator lastSeg;
346                 curSeg  = List.begin();
347                 lastSeg = List.end();
348                 glBegin(GL_LINES);
349                 for ( ; curSeg != lastSeg; curSeg++ ) {
350                         curSeg->draw();
351                 }
352                 glEnd();
353         }
354 /*    void draw( void ) {
355         vector < fgLineSeg2D > :: iterator curSeg;
356         vector < fgLineSeg2D > :: iterator lastSeg;
357        curSeg  = List.begin();
358         lastSeg = List.end();
359         glBegin(GL_LINES);
360         for ( ; curSeg != lastSeg; curSeg++ ) {
361             curSeg->draw();
362         }
363         glEnd();
364     } */
365 };
366
367 class fgTextList {
368     fntRenderer *Font;
369     vector< fgText > List;
370 public:
371     fgTextList ( void ) { Font = 0; }
372     ~fgTextList( void ) {}
373     
374     void setFont( fntRenderer *Renderer ) { Font = Renderer; }
375     void add( fgText String ) { List.push_back(String); }
376     void erase( void ) { List.erase( List.begin(), List.end() ); }
377     
378     void draw( void ) {
379         vector < fgText > :: iterator curString;
380         vector < fgText > :: iterator lastString;
381         if( Font == 0 ) return;
382         curString  = List.begin();
383         lastString = List.end();
384         glPushAttrib( GL_COLOR_BUFFER_BIT );
385         glEnable    ( GL_ALPHA_TEST   ) ;
386         glEnable    ( GL_BLEND        ) ;
387         glAlphaFunc ( GL_GREATER, 0.1 ) ;
388         glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
389
390         Font->begin();
391         for( ; curString != lastString; curString++ ) {
392             curString->Draw(Font);
393         }
394         Font->end();
395
396         glDisable ( GL_TEXTURE_2D ) ;
397         glPopAttrib();
398     }
399 };
400
401
402 inline void Text( fgTextList &List, float x, float y, char *s)
403 {
404     List.add( fgText( x, y, s) );
405 }
406
407 inline void Text( fgTextList &List, fgText &me)
408 {
409     List.add(me);
410 }
411
412 inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
413 {
414     List.add(fgLineSeg2D(x1,y1,x2,y2));
415 }
416
417
418 // Declare our externals
419 extern fgTextList         HUD_TextList;
420 extern fgLineList         HUD_LineList;
421 extern fgLineList         HUD_StippleLineList;
422
423
424 class instr_item {  // An Abstract Base Class (ABC)
425   private:
426     static UINT        instances;     // More than 64K instruments? Nah!
427     static int         brightness;
428     static glRGBTRIPLE color;
429
430     UINT               handle;
431     RECT               scrn_pos;      // Framing - affects scale dimensions
432                                     // and orientation. Vert vs Horz, etc.
433     FLTFNPTR           load_value_fn;
434     float              disp_factor;   // Multiply by to get numbers shown on scale.
435     UINT               opts;
436     bool               is_enabled;
437     bool               broken;
438     UINT               scr_span;      // Working values for draw;
439     POINT              mid_span;      //
440
441   public:
442     instr_item( int            x,
443                 int            y,
444                 UINT           height,
445                 UINT           width,
446                 FLTFNPTR       data_source,
447                 float          data_scaling,
448                 UINT           options,
449                 bool           working  = true);
450
451     instr_item( const instr_item & image );
452
453     instr_item & operator = ( const instr_item & rhs );
454     virtual ~instr_item ();
455
456     int     get_brightness  ( void ) { return brightness;}
457     RECT    get_location    ( void ) { return scrn_pos;  }
458     bool    is_broken       ( void ) { return broken;    }
459     bool    enabled         ( void ) { return is_enabled;}
460     bool    data_available  ( void ) { return !!load_value_fn; }
461     float   get_value       ( void ) { return load_value_fn(); }
462     float   data_scaling    ( void ) { return disp_factor; }
463     UINT    get_span        ( void ) { return scr_span;  }
464     POINT   get_centroid    ( void ) { return mid_span;  }
465     UINT    get_options     ( void ) { return opts;      }
466
467     UINT    huds_vert     (UINT options) { return( options  & HUDS_VERT ); }
468     UINT    huds_left     (UINT options) { return( options  & HUDS_LEFT ); }
469     UINT    huds_right    (UINT options) { return( options  & HUDS_RIGHT ); }
470     UINT    huds_both     (UINT options) { return( (options & HUDS_BOTH) == HUDS_BOTH ); }
471     UINT    huds_noticks  (UINT options) { return( options  & HUDS_NOTICKS ); }
472     UINT    huds_notext   (UINT options) { return( options  & HUDS_NOTEXT ); }
473     UINT    huds_top      (UINT options) { return( options  & HUDS_TOP ); }
474     UINT    huds_bottom   (UINT options) { return( options  & HUDS_BOTTOM ); }
475   
476     virtual void display_enable( bool working ) { is_enabled = !! working;}
477
478     virtual void update( void );
479     virtual void break_display ( bool bad );
480     virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
481     void         SetPosition  ( int x, int y, UINT width, UINT height );
482     UINT         get_Handle( void );
483     virtual void draw( void ) = 0;   // Required method in derived classes
484     
485     void drawOneLine( float x1, float y1, float x2, float y2)
486     {
487         HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
488     }
489     void drawOneStippleLine( float x1, float y1, float x2, float y2)
490     {
491         HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
492     }
493     void TextString( char *msg, float x, float y )
494     {
495         HUD_TextList.add(fgText(x, y, msg));        
496     }
497     int getStringWidth ( char *str )
498     {
499         if ( HUDtext && str )
500         {
501             float r, l ;
502             guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
503             return FloatToInt( r - l );
504         }
505         return 0 ;
506     }
507     
508 };
509
510 typedef instr_item *HIptr;
511 //typedef deque <  instr_item * > hud_deque_type;
512 //typedef hud_deque_type::iterator hud_deque_iterator;
513 //typedef hud_deque_type::const_iterator hud_deque_const_iterator;
514
515 extern deque< instr_item *> HUD_deque;
516 extern int HUD_style;
517 //extern hud_deque_type HUD_deque;
518
519 // instr_item           This class has no other purpose than to maintain
520 //                      a linked list of instrument and derived class
521 // object pointers.
522
523
524 class instr_label : public instr_item {
525   private:
526     const char *pformat;
527     const char *pre_str;
528     const char *post_str;
529     fgLabelJust justify;
530     int         fontSize;
531     int         blink;
532     char format_buffer[80];
533     bool                lat;
534     bool                lon;
535
536   public:
537     instr_label( int          x,
538                  int          y,
539                  UINT         width,
540                  UINT         height,
541                  FLTFNPTR     data_source,
542                  const char  *label_format,
543                  const char  *pre_label_string,
544                  const char  *post_label_string,
545                  float        scale_data,
546                  UINT         options,
547                  fgLabelJust  justification,
548                  int          font_size,
549                  int          blinking,
550                  bool             latitude,
551                  bool             longitude,
552                  bool         working);
553
554     ~instr_label();
555
556     instr_label( const instr_label & image);
557     instr_label & operator = (const instr_label & rhs );
558     virtual void draw( void );       // Required method in base class
559 };
560
561 typedef instr_label * pInstlabel;
562
563
564 class lat_label : public instr_item {
565   private:
566     const char *pformat;
567     const char *pre_str;
568     const char *post_str;
569     fgLabelJust justify;
570     int         fontSize;
571     int         blink;
572     char format_buffer[80];
573
574   public:
575     lat_label( int          x,
576                  int          y,
577                  UINT         width,
578                  UINT         height,
579                  FLTFNPTR     data_source,
580                  const char  *label_format,
581                  const char  *pre_label_string,
582                  const char  *post_label_string,
583                  float       scale_data,
584                  UINT         options,
585                  fgLabelJust  justification,
586                  int          font_size,
587                  int          blinking,
588                  bool         working);
589
590     ~lat_label();
591
592     lat_label( const lat_label & image);
593     lat_label & operator = (const lat_label & rhs );
594     virtual void draw( void );       // Required method in base class
595 };
596
597 typedef lat_label * pLatlabel;
598
599 class lon_label : public instr_item {
600   private:
601     const char *pformat;
602     const char *pre_str;
603     const char *post_str;
604     fgLabelJust justify;
605     int         fontSize;
606     int         blink;
607     char format_buffer[80];
608
609   public:
610     lon_label( int          x,
611                  int          y,
612                  UINT         width,
613                  UINT         height,
614                  FLTFNPTR     data_source,
615                  const char  *label_format,
616                  const char  *pre_label_string,
617                  const char  *post_label_string,
618                  float       scale_data,
619                  UINT         options,
620                  fgLabelJust  justification,
621                  int          font_size,
622                  int          blinking,
623                  bool         working);
624
625     ~lon_label();
626
627     lon_label( const lon_label & image);
628     lon_label & operator = (const lon_label & rhs );
629     virtual void draw( void );       // Required method in base class
630 };
631
632 typedef lon_label * pLonlabel;
633
634 //
635 // instr_scale           This class is an abstract base class for both moving
636 //                       scale and moving needle (fixed scale) indicators. It
637 // does not draw itself, but is not instanciable.
638 //
639
640 class instr_scale : public instr_item {
641   private:
642     float range_shown;   // Width Units.
643     float Maximum_value; //                ceiling.
644     float Minimum_value; // Representation floor.
645     float scale_factor;  // factor => screen units/range values.
646     UINT   Maj_div;       // major division marker units
647     UINT   Min_div;       // minor division marker units
648     UINT   Modulo;        // Roll over point
649     int    signif_digits; // digits to show to the right.
650
651   public:
652     instr_scale( int          x,
653                  int          y,
654                  UINT         width,
655                  UINT         height,
656                  FLTFNPTR     load_fn,
657                  UINT         options,
658                  float       show_range,
659                  float       max_value,
660                  float       min_value,
661                  float       disp_scaling,
662                  UINT         major_divs,
663                  UINT         minor_divs,
664                  UINT         rollover,
665                  int          dp_showing,
666                  bool         working = true);
667
668     virtual ~instr_scale();
669     instr_scale( const instr_scale & image);
670     instr_scale & operator = (const instr_scale & rhs);
671
672     virtual void draw   ( void ) {}; // No-op here. Defined in derived classes.
673     UINT   div_min      ( void ) { return Min_div;}
674     UINT   div_max      ( void ) { return Maj_div;}
675     float min_val      ( void ) { return Minimum_value;}
676     float max_val      ( void ) { return Maximum_value;}
677     UINT   modulo       ( void ) { return Modulo; }
678     float factor       ( void ) { return scale_factor;}
679     float range_to_show( void ) { return range_shown;}
680 };
681
682 // hud_card_               This class displays the indicated quantity on
683 //                         a scale that moves past the pointer. It may be
684 // horizontal or vertical, read above(left) or below(right) of the base
685 // line.
686
687 class hud_card : public instr_scale {
688   private:
689     float val_span;
690     string type;
691     float half_width_units;
692     bool  draw_tick_bottom;
693     bool  draw_tick_top;
694     bool  draw_tick_right;
695     bool  draw_tick_left;
696     bool  draw_cap_bottom;
697     bool  draw_cap_top;
698     bool  draw_cap_right;
699     bool  draw_cap_left;
700     float marker_offset;
701     bool  pointer;
702     string  pointer_type;
703
704     
705   public:
706     hud_card( int      x,
707               int      y,
708               UINT     width,
709               UINT     height,
710               FLTFNPTR load_fn,
711               UINT     options,
712               float    maxValue,
713               float    minValue,
714               float    disp_scaling,
715               UINT     major_divs,
716               UINT     minor_divs,
717               UINT     modulator,
718               int      dp_showing,
719               float    value_span,
720               string   type,
721               bool     draw_tick_bottom,
722               bool     draw_tick_top,
723               bool     draw_tick_right,
724               bool     draw_tick_left,
725               bool     draw_cap_bottom,
726               bool     draw_cap_top,
727               bool     draw_cap_right,
728               bool     draw_cap_left,
729               float    marker_offset,
730               bool     pointer,
731               string   pointer_type,
732               bool     working);
733
734     ~hud_card();
735     hud_card( const hud_card & image);
736     hud_card & operator = (const hud_card & rhs );
737 //    virtual void display_enable( bool setting );
738     virtual void draw( void );       // Required method in base class
739 };
740
741 typedef hud_card * pCardScale;
742
743 class guage_instr : public instr_scale {
744   public:
745     guage_instr( int       x,
746                  int       y,
747                  UINT      width,
748                  UINT      height,
749                  FLTFNPTR  load_fn,
750                  UINT      options,
751                  float     disp_scaling,
752                  float     maxValue,
753                  float     minValue,
754                  UINT      major_divs,
755                  UINT      minor_divs,
756                  int       dp_showing,
757                  UINT      modulus,
758                  bool      working);
759
760     ~guage_instr();
761     guage_instr( const guage_instr & image);
762     guage_instr & operator = (const guage_instr & rhs );
763     virtual void draw( void );       // Required method in base class
764 };
765
766 typedef guage_instr * pGuageInst;
767 //
768 // dual_instr_item         This class was created to form the base class
769 //                         for both panel and HUD Turn Bank Indicators.
770
771 class dual_instr_item : public instr_item {
772   private:
773     FLTFNPTR alt_data_source;
774
775   public:
776     dual_instr_item ( int       x,
777                       int       y,
778                       UINT      width,
779                       UINT      height,
780                       FLTFNPTR  chn1_source,
781                       FLTFNPTR  chn2_source,
782                       bool      working,
783                       UINT      options );
784
785     virtual ~dual_instr_item() {};
786     dual_instr_item( const dual_instr_item & image);
787     dual_instr_item & operator = (const dual_instr_item & rhs );
788
789     float current_ch1( void ) { return (float)alt_data_source();}
790     float current_ch2( void ) { return (float)get_value();}
791     virtual void draw ( void ) { }
792 };
793
794 class fgTBI_instr : public dual_instr_item {
795   private:
796     UINT BankLimit;
797     UINT SlewLimit;
798     UINT scr_hole;
799
800   public:
801     fgTBI_instr( int       x,
802                  int       y,
803                  UINT      width,
804                  UINT      height,
805                  FLTFNPTR  chn1_source,
806                  FLTFNPTR  chn2_source,
807                  float    maxBankAngle,
808                  float    maxSlipAngle,
809                  UINT      gap_width,
810                  bool      working);
811
812     fgTBI_instr( const fgTBI_instr & image);
813     fgTBI_instr & operator = (const fgTBI_instr & rhs );
814
815     ~fgTBI_instr();
816
817     UINT bank_limit( void ) { return BankLimit;}
818     UINT slew_limit( void ) { return SlewLimit;}
819
820     virtual void draw( void );       // Required method in base class
821 };
822
823 typedef fgTBI_instr * pTBI;
824
825 class HudLadder : public dual_instr_item {
826   private:
827     UINT   width_units;
828     int    div_units;
829     UINT   minor_div;
830     UINT   label_pos;
831     UINT   scr_hole;
832     float  vmax;
833     float  vmin;
834     float  factor;
835     string hudladder_type;
836     bool   frl;
837     bool   target_spot;
838     bool   velocity_vector;
839     bool   drift_marker;
840     bool   alpha_bracket;
841     bool        energy_marker;
842     bool        climb_dive_marker;
843     bool        glide_slope_marker;
844     float       glide_slope;
845     bool        energy_worm;
846     bool        waypoint_marker;
847
848     fgTextList         TextList;
849     fgLineList         LineList;
850     fgLineList         StippleLineList;
851
852   public:
853     HudLadder( string    name,
854                int       x,
855                int       y,
856                UINT      width,
857                UINT      height,
858                float     factor,
859                FLTFNPTR  ptch_source,
860                FLTFNPTR  roll_source,
861                float     span_units,
862                float     division_units,
863                float     minor_division,
864                UINT      screen_hole,
865                UINT      lbl_pos,
866                bool      frl,
867                bool      target_spot,
868                bool     velocity_vector,
869                bool     drift_marker,
870                bool     alpha_bracket,
871                bool      energy_marker,
872                bool      climb_dive_marker,
873                bool      glide_slope_marker,
874                float     glide_slope,
875                bool      energy_worm,
876                bool      waypoint_marker,
877                bool      working);
878
879     ~HudLadder();
880
881     HudLadder( const HudLadder & image );
882     HudLadder & operator = ( const HudLadder & rhs );
883     virtual void draw( void );
884     
885     void Text( float x, float y, char *s)
886     {
887         TextList.add( fgText( x, y, s) );
888     }
889
890     void Line( float x1, float y1, float x2, float y2)
891     {
892         LineList.add(fgLineSeg2D(x1,y1,x2,y2));
893     }
894
895     void StippleLine( float x1, float y1, float x2, float y2)
896     {
897         StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
898     }
899 };
900
901
902 //using namespace std;
903 //deque <instr_item>  * Hdeque_ptr;
904
905 extern void HUD_masterswitch( bool incr );
906 extern void HUD_brightkey( bool incr_bright );
907 extern int  fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
908 extern int  fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
909 extern void fgUpdateHUD( void );
910 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
911                          GLfloat x_end, GLfloat y_end );
912
913 extern void drawOneLine ( UINT x1, UINT y1, UINT x2, UINT y2);
914 extern void drawOneLine ( RECT &rect);
915 extern void textString  ( int x,
916                           int y,
917                           char *msg,
918                           void *font = GLUT_BITMAP_8_BY_13);
919 extern void strokeString( int x,
920                           int y,
921                           char *msg,
922                           void *font = GLUT_STROKE_ROMAN,
923                           float theta = 0);
924
925 //extern void strokeString(float xx,
926 //                       float yy,
927 //                       char *msg,
928 //                       void *font = GLUT_STROKE_ROMAN)
929
930 /*
931 bool AddHUDInstrument( instr_item *pBlackBox );
932 void DrawHUD ( void );
933 bool DamageInstrument( INSTR_HANDLE unit );
934 bool RepairInstrument( INSTR_HANDLE unit );
935
936
937 void fgUpdateHUD ( Hptr hud );
938 void fgUpdateHUD2( Hptr hud ); // Future use?
939 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
940 */
941
942 #endif // _HUD_H