]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud.hxx
MSVC compatibility changes and code tweaks for minor nits caught by the
[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 FG_USING_STD(deque);
63 FG_USING_STD(vector);
64 FG_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 extern char *get_formated_gmt_time( void );
195 extern void fgHUDReshape(void);
196
197 enum  hudinstype{ HUDno_instr,
198               HUDscale,
199               HUDlabel,
200               HUDladder,
201               HUDcirc_ladder,
202               HUDhorizon,
203               HUDguage,
204               HUDdual_inst,
205               HUDmoving_scale,
206               HUDtbi
207               };
208
209 typedef struct gltagRGBTRIPLE { // rgbt
210     GLfloat Blue;
211     GLfloat Green;
212     GLfloat Red;
213 } glRGBTRIPLE;
214
215 class fgLineSeg2D {
216 private:
217     GLfloat x0, y0, x1, y1;
218
219 public:
220     fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
221         : x0(a), y0(b),  x1(c), y1(d) {}
222
223     fgLineSeg2D( const fgLineSeg2D & image )
224         : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
225
226     fgLineSeg2D& operator= ( const fgLineSeg2D & image ) {
227         x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
228     }
229
230     ~fgLineSeg2D() {}
231     
232     void draw()
233     {
234         glVertex2f(x0, y0);
235         glVertex2f(x1, y1);
236     }
237 };
238
239 #define USE_HUD_TextList
240 extern float              HUD_TextSize;
241 extern fntRenderer       *HUDtext;
242 extern float HUD_matrix[16];
243
244 class fgText {
245 private:
246     float x, y;
247     char msg[64];
248 public:
249     fgText( float x = 0, float y = 0, char *c = NULL )
250         : x(x), y(y) {strncpy(msg,c,64-1);}
251
252     fgText( const fgText & image )
253         : x(image.x), y(image.y) {strcpy(msg,image.msg);}
254
255     fgText& operator = ( const fgText & image ) {
256         strcpy(msg,image.msg); x = image.x; y = image.y;
257         return *this;
258     }
259
260     ~fgText() {msg[0]='\0';}
261
262     int getStringWidth ( char *str )
263     {
264         if ( HUDtext && str )
265         {
266             float r, l ;
267             guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
268             return FloatToInt( r - l );
269         }
270         return 0 ;
271     }
272     
273     int StringWidth (void )
274     {
275         if ( HUDtext && strlen( msg ))
276         {
277             float r, l ;
278             guiFntHandle->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
279             return FloatToInt( r - l );
280         }
281         return 0 ;
282     }
283     
284     void Draw(fntRenderer *fnt)
285     {
286         fnt->start2f( x, y );
287         fnt->puts   ( msg ) ;
288     }
289
290     void Draw()
291     {
292         puDrawString ( guiFnt, msg, FloatToInt(x), FloatToInt(y) );
293     }
294 };
295
296 class fgLineList {
297     vector < fgLineSeg2D > List;
298 public:
299     fgLineList( void ) {}
300     ~fgLineList( void ) {}
301     void add( fgLineSeg2D seg ) { List.push_back(seg); }
302     void erase( void ) { List.erase( List.begin(), List.end() ); }
303         void draw( void ) {
304                 vector < fgLineSeg2D > :: iterator curSeg;
305                 vector < fgLineSeg2D > :: iterator lastSeg;
306                 curSeg  = List.begin();
307                 lastSeg = List.end();
308                 glBegin(GL_LINES);
309                 for ( ; curSeg != lastSeg; curSeg++ ) {
310                         curSeg->draw();
311                 }
312                 glEnd();
313         }
314 /*    void draw( void ) {
315         vector < fgLineSeg2D > :: iterator curSeg;
316         vector < fgLineSeg2D > :: iterator lastSeg;
317        curSeg  = List.begin();
318         lastSeg = List.end();
319         glBegin(GL_LINES);
320         for ( ; curSeg != lastSeg; curSeg++ ) {
321             curSeg->draw();
322         }
323         glEnd();
324     } */
325 };
326
327 class fgTextList {
328     fntRenderer *Font;
329     vector< fgText > List;
330 public:
331     fgTextList ( void ) { Font = 0; }
332     ~fgTextList( void ) {}
333     
334     void setFont( fntRenderer *Renderer ) { Font = Renderer; }
335     void add( fgText String ) { List.push_back(String); }
336     void erase( void ) { List.erase( List.begin(), List.end() ); }
337     
338     void draw( void ) {
339         vector < fgText > :: iterator curString;
340         vector < fgText > :: iterator lastString;
341         if( Font == 0 ) return;
342         curString  = List.begin();
343         lastString = List.end();
344         glPushAttrib( GL_COLOR_BUFFER_BIT );
345         glEnable    ( GL_ALPHA_TEST   ) ;
346         glEnable    ( GL_BLEND        ) ;
347         glAlphaFunc ( GL_GREATER, 0.1 ) ;
348         glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
349
350         Font->begin();
351         for( ; curString != lastString; curString++ ) {
352             curString->Draw(Font);
353         }
354         Font->end();
355
356         glDisable ( GL_TEXTURE_2D ) ;
357         glPopAttrib();
358     }
359 };
360
361
362 inline void Text( fgTextList &List, float x, float y, char *s)
363 {
364     List.add( fgText( x, y, s) );
365 }
366
367 inline void Text( fgTextList &List, fgText &me)
368 {
369     List.add(me);
370 }
371
372 inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
373 {
374     List.add(fgLineSeg2D(x1,y1,x2,y2));
375 }
376
377
378 // Declare our externals
379 extern fgTextList         HUD_TextList;
380 extern fgLineList         HUD_LineList;
381 extern fgLineList         HUD_StippleLineList;
382
383
384 class instr_item {  // An Abstract Base Class (ABC)
385   private:
386     static UINT        instances;     // More than 64K instruments? Nah!
387     static int         brightness;
388     static glRGBTRIPLE color;
389
390     UINT               handle;
391     RECT               scrn_pos;      // Framing - affects scale dimensions
392                                     // and orientation. Vert vs Horz, etc.
393     FLTFNPTR           load_value_fn;
394     float              disp_factor;   // Multiply by to get numbers shown on scale.
395     UINT               opts;
396     bool               is_enabled;
397     bool               broken;
398     UINT               scr_span;      // Working values for draw;
399     POINT              mid_span;      //
400
401   public:
402     instr_item( int            x,
403                 int            y,
404                 UINT           height,
405                 UINT           width,
406                 FLTFNPTR       data_source,
407                 float         data_scaling,
408                 UINT           options,
409                 bool           working      = true);
410
411     instr_item( const instr_item & image );
412
413     instr_item & operator = ( const instr_item & rhs );
414     virtual ~instr_item ();
415
416     int     get_brightness  ( void ) { return brightness;}
417     RECT    get_location    ( void ) { return scrn_pos;  }
418     bool    is_broken       ( void ) { return broken;    }
419     bool    enabled         ( void ) { return is_enabled;}
420     bool    data_available  ( void ) { return !!load_value_fn; }
421     float   get_value       ( void ) { return load_value_fn(); }
422     float   data_scaling    ( void ) { return disp_factor; }
423     UINT    get_span        ( void ) { return scr_span;  }
424     POINT   get_centroid    ( void ) { return mid_span;  }
425     UINT    get_options     ( void ) { return opts;      }
426
427     UINT    huds_vert     (UINT options) { return( options  & HUDS_VERT ); }
428     UINT    huds_left     (UINT options) { return( options  & HUDS_LEFT ); }
429     UINT    huds_right    (UINT options) { return( options  & HUDS_RIGHT ); }
430     UINT    huds_both     (UINT options) { return( (options & HUDS_BOTH) == HUDS_BOTH ); }
431     UINT    huds_noticks  (UINT options) { return( options  & HUDS_NOTICKS ); }
432     UINT    huds_notext   (UINT options) { return( options  & HUDS_NOTEXT ); }
433     UINT    huds_top      (UINT options) { return( options  & HUDS_TOP ); }
434     UINT    huds_bottom   (UINT options) { return( options  & HUDS_BOTTOM ); }
435   
436     virtual void display_enable( bool working ) { is_enabled = !! working;}
437
438     virtual void update( void );
439     virtual void break_display ( bool bad );
440     virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
441     void         SetPosition  ( int x, int y, UINT width, UINT height );
442     UINT         get_Handle( void );
443     virtual void draw( void ) = 0;   // Required method in derived classes
444     
445     void drawOneLine( float x1, float y1, float x2, float y2)
446     {
447         HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
448     }
449     void drawOneStippleLine( float x1, float y1, float x2, float y2)
450     {
451         HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
452     }
453     void TextString( char *msg, float x, float y )
454     {
455         HUD_TextList.add(fgText(x, y, msg));        
456     }
457     int getStringWidth ( char *str )
458     {
459         if ( HUDtext && str )
460         {
461             float r, l ;
462             guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
463             return FloatToInt( r - l );
464         }
465         return 0 ;
466     }
467     
468 };
469
470 typedef instr_item *HIptr;
471 //typedef deque <  instr_item * > hud_deque_type;
472 //typedef hud_deque_type::iterator hud_deque_iterator;
473 //typedef hud_deque_type::const_iterator hud_deque_const_iterator;
474
475 extern deque< instr_item *> HUD_deque;
476 extern int HUD_style;
477 //extern hud_deque_type HUD_deque;
478
479 // instr_item           This class has no other purpose than to maintain
480 //                      a linked list of instrument and derived class
481 // object pointers.
482
483
484 class instr_label : public instr_item {
485   private:
486     const char *pformat;
487     const char *pre_str;
488     const char *post_str;
489     fgLabelJust justify;
490     int         fontSize;
491     int         blink;
492     char format_buffer[80];
493
494   public:
495     instr_label( int          x,
496                  int          y,
497                  UINT         width,
498                  UINT         height,
499                  FLTFNPTR     data_source,
500                  const char  *label_format,
501                  const char  *pre_label_string  = 0,
502                  const char  *post_label_string = 0,
503                  float       scale_data        = 1.0,
504                  UINT         options           = HUDS_TOP,
505                  fgLabelJust  justification     = CENTER_JUST,
506                  int          font_size         = SMALL,
507                  int          blinking          = NOBLINK,
508                  bool         working           = true);
509
510     ~instr_label();
511
512     instr_label( const instr_label & image);
513     instr_label & operator = (const instr_label & rhs );
514     virtual void draw( void );       // Required method in base class
515 };
516
517 typedef instr_label * pInstlabel;
518
519
520 class lat_label : public instr_item {
521   private:
522     const char *pformat;
523     const char *pre_str;
524     const char *post_str;
525     fgLabelJust justify;
526     int         fontSize;
527     int         blink;
528     char format_buffer[80];
529
530   public:
531     lat_label( int          x,
532                  int          y,
533                  UINT         width,
534                  UINT         height,
535                  FLTFNPTR     data_source,
536                  const char  *label_format,
537                  const char  *pre_label_string  = 0,
538                  const char  *post_label_string = 0,
539                  float       scale_data        = 1.0,
540                  UINT         options           = HUDS_TOP,
541                  fgLabelJust  justification     = CENTER_JUST,
542                  int          font_size         = SMALL,
543                  int          blinking          = NOBLINK,
544                  bool         working           = true);
545
546     ~lat_label();
547
548     lat_label( const lat_label & image);
549     lat_label & operator = (const lat_label & rhs );
550     virtual void draw( void );       // Required method in base class
551 };
552
553 typedef lat_label * pLatlabel;
554
555 class lon_label : public instr_item {
556   private:
557     const char *pformat;
558     const char *pre_str;
559     const char *post_str;
560     fgLabelJust justify;
561     int         fontSize;
562     int         blink;
563     char format_buffer[80];
564
565   public:
566     lon_label( int          x,
567                  int          y,
568                  UINT         width,
569                  UINT         height,
570                  FLTFNPTR     data_source,
571                  const char  *label_format,
572                  const char  *pre_label_string  = 0,
573                  const char  *post_label_string = 0,
574                  float       scale_data        = 1.0,
575                  UINT         options           = HUDS_TOP,
576                  fgLabelJust  justification     = CENTER_JUST,
577                  int          font_size         = SMALL,
578                  int          blinking          = NOBLINK,
579                  bool         working           = true);
580
581     ~lon_label();
582
583     lon_label( const lon_label & image);
584     lon_label & operator = (const lon_label & rhs );
585     virtual void draw( void );       // Required method in base class
586 };
587
588 typedef lon_label * pLonlabel;
589
590 //
591 // instr_scale           This class is an abstract base class for both moving
592 //                       scale and moving needle (fixed scale) indicators. It
593 // does not draw itself, but is not instanciable.
594 //
595
596 class instr_scale : public instr_item {
597   private:
598     float range_shown;   // Width Units.
599     float Maximum_value; //                ceiling.
600     float Minimum_value; // Representation floor.
601     float scale_factor;  // factor => screen units/range values.
602     UINT   Maj_div;       // major division marker units
603     UINT   Min_div;       // minor division marker units
604     UINT   Modulo;        // Roll over point
605     int    signif_digits; // digits to show to the right.
606
607   public:
608     instr_scale( int          x,
609                  int          y,
610                  UINT         width,
611                  UINT         height,
612                  FLTFNPTR     load_fn,
613                  UINT         options,
614                  float       show_range,
615                  float       max_value    = 100.0,
616                  float       min_value    =   0.0,
617                  float       disp_scaling =   1.0,
618                  UINT         major_divs   =    10,
619                  UINT         minor_divs   =     5,
620                  UINT         rollover     =     0,
621                  int          dp_showing   =     2,
622                  bool         working      =  true);
623
624     virtual ~instr_scale();
625     instr_scale( const instr_scale & image);
626     instr_scale & operator = (const instr_scale & rhs);
627
628     virtual void draw   ( void ) {}; // No-op here. Defined in derived classes.
629     UINT   div_min      ( void ) { return Min_div;}
630     UINT   div_max      ( void ) { return Maj_div;}
631     float min_val      ( void ) { return Minimum_value;}
632     float max_val      ( void ) { return Maximum_value;}
633     UINT   modulo       ( void ) { return Modulo; }
634     float factor       ( void ) { return scale_factor;}
635     float range_to_show( void ) { return range_shown;}
636 };
637
638 // hud_card_               This class displays the indicated quantity on
639 //                         a scale that moves past the pointer. It may be
640 // horizontal or vertical, read above(left) or below(right) of the base
641 // line.
642
643 class hud_card : public instr_scale {
644   private:
645     float val_span;
646     float half_width_units;
647     
648   public:
649     hud_card( int      x,
650               int      y,
651               UINT     width,
652               UINT     height,
653               FLTFNPTR load_fn,
654               UINT     options,
655               float   maxValue      = 100.0,
656               float   minValue      =   0.0,
657               float   disp_scaling  =   1.0,
658               UINT     major_divs    =  10,
659               UINT     minor_divs    =   5,
660               UINT     modulator     = 100,
661               int      dp_showing    =   2,
662               float   value_span    = 100.0,
663               bool     working       = true);
664
665     ~hud_card();
666     hud_card( const hud_card & image);
667     hud_card & operator = (const hud_card & rhs );
668 //    virtual void display_enable( bool setting );
669     virtual void draw( void );       // Required method in base class
670 };
671
672 typedef hud_card * pCardScale;
673
674 class guage_instr : public instr_scale {
675   public:
676     guage_instr( int       x,
677                  int       y,
678                  UINT      width,
679                  UINT      height,
680                  FLTFNPTR  load_fn,
681                  UINT      options,
682                  float    disp_scaling = 1.0,
683                  float    maxValue     = 100,
684                  float    minValue     =   0,
685                  UINT      major_divs   =  50,
686                  UINT      minor_divs   =   0,
687                  int       dp_showing   =   2,
688                  UINT      modulus      =   0,
689                  bool      working      = true);
690
691     ~guage_instr();
692     guage_instr( const guage_instr & image);
693     guage_instr & operator = (const guage_instr & rhs );
694     virtual void draw( void );       // Required method in base class
695 };
696
697 typedef guage_instr * pGuageInst;
698 //
699 // dual_instr_item         This class was created to form the base class
700 //                         for both panel and HUD Turn Bank Indicators.
701
702 class dual_instr_item : public instr_item {
703   private:
704     FLTFNPTR alt_data_source;
705
706   public:
707     dual_instr_item ( int       x,
708                       int       y,
709                       UINT      width,
710                       UINT      height,
711                       FLTFNPTR  chn1_source,
712                       FLTFNPTR  chn2_source,
713                       bool      working     = true,
714                       UINT      options  = HUDS_TOP);
715
716     virtual ~dual_instr_item() {};
717     dual_instr_item( const dual_instr_item & image);
718     dual_instr_item & operator = (const dual_instr_item & rhs );
719
720     float current_ch1( void ) { return (float)alt_data_source();}
721     float current_ch2( void ) { return (float)get_value();}
722     virtual void draw ( void ) { }
723 };
724
725 class fgTBI_instr : public dual_instr_item {
726   private:
727     UINT BankLimit;
728     UINT SlewLimit;
729     UINT scr_hole;
730
731   public:
732     fgTBI_instr( int       x,
733                  int       y,
734                  UINT      width,
735                  UINT      height,
736                  FLTFNPTR  chn1_source  = get_roll,
737                  FLTFNPTR  chn2_source  = get_sideslip,
738                  float    maxBankAngle = 45.0,
739                  float    maxSlipAngle =  5.0,
740                  UINT      gap_width    =  5,
741                  bool      working      =  true);
742
743     fgTBI_instr( const fgTBI_instr & image);
744     fgTBI_instr & operator = (const fgTBI_instr & rhs );
745
746     ~fgTBI_instr();
747
748     UINT bank_limit( void ) { return BankLimit;}
749     UINT slew_limit( void ) { return SlewLimit;}
750
751     virtual void draw( void );       // Required method in base class
752 };
753
754 typedef fgTBI_instr * pTBI;
755
756 class HudLadder : public dual_instr_item {
757   private:
758     UINT   width_units;
759     int    div_units;
760     UINT   minor_div;
761     UINT   label_pos;
762     UINT   scr_hole;
763     UINT   minimal;
764     float vmax;
765     float vmin;
766     float factor;
767
768     fgTextList         TextList;
769     fgLineList         LineList;
770     fgLineList         StippleLineList;
771
772   public:
773     HudLadder( int       x,
774                int       y,
775                UINT      width,
776                UINT      height,
777                UINT      minimal        =    0,
778                FLTFNPTR  ptch_source    = get_roll,
779                FLTFNPTR  roll_source    = get_pitch,
780                float     span_units     = 45.0,
781                float     division_units = 10.0,
782                float     minor_division =  0.0,
783                UINT      screen_hole    =   70,
784                UINT      lbl_pos        =    0,
785                bool      working        = true );
786
787     ~HudLadder();
788
789     HudLadder( const HudLadder & image );
790     HudLadder & operator = ( const HudLadder & rhs );
791     virtual void draw( void );
792     
793     void Text( float x, float y, char *s)
794     {
795         TextList.add( fgText( x, y, s) );
796     }
797
798     void Line( float x1, float y1, float x2, float y2)
799     {
800         LineList.add(fgLineSeg2D(x1,y1,x2,y2));
801     }
802
803     void StippleLine( float x1, float y1, float x2, float y2)
804     {
805         StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
806     }
807 };
808
809
810 //using namespace std;
811 //deque <instr_item>  * Hdeque_ptr;
812
813 extern void HUD_masterswitch( bool incr );
814 extern void HUD_brightkey( bool incr_bright );
815 extern int  fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
816 extern int  fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
817 extern void fgUpdateHUD( void );
818
819 extern void drawOneLine ( UINT x1, UINT y1, UINT x2, UINT y2);
820 extern void drawOneLine ( RECT &rect);
821 extern void textString  ( int x,
822                           int y,
823                           char *msg,
824                           void *font = GLUT_BITMAP_8_BY_13);
825 extern void strokeString( int x,
826                           int y,
827                           char *msg,
828                           void *font = GLUT_STROKE_ROMAN,
829                           float theta = 0);
830 //extern void strokeString(float xx,
831 //                       float yy,
832 //                       char *msg,
833 //                       void *font = GLUT_STROKE_ROMAN)
834
835 /*
836 bool AddHUDInstrument( instr_item *pBlackBox );
837 void DrawHUD ( void );
838 bool DamageInstrument( INSTR_HANDLE unit );
839 bool RepairInstrument( INSTR_HANDLE unit );
840
841
842 void fgUpdateHUD ( Hptr hud );
843 void fgUpdateHUD2( Hptr hud ); // Future use?
844 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
845 */
846
847 #endif // _HUD_H