]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud.hxx
fe36c250fe1d41d218c2d12009e0a3b674a41ce0
[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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _OLDHUD_HXX
25 #define _OLDHUD_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 <stdlib.h>
42 #include <string.h>
43
44 //#ifdef HAVE_VALUES_H
45 //#  include <values.h>  // for MAXINT
46 //#endif
47
48 #include <algorithm>    // for_each()
49 #include <vector>       // STL vector
50 #include <deque>        // STL double ended queue
51 #include STL_FSTREAM
52
53 #include <simgear/math/SGMath.hxx>
54 #include <simgear/constants.h>
55
56 #include <Include/fg_typedefs.h>
57 #include <Aircraft/aircraft.hxx>
58 #include <Aircraft/controls.hxx>
59 #include <FDM/flight.hxx>
60 #include <GUI/gui.h>
61 #include <Main/fg_props.hxx>
62 #include <Main/globals.hxx>
63 #include <Main/viewmgr.hxx>
64 #include <Airports/runways.hxx>
65
66 #include <plib/sg.h>
67
68 SG_USING_STD(deque);
69 SG_USING_STD(vector);
70 SG_USING_NAMESPACE(std);
71
72 //#define float_to_int(v) SGMiscf::roundToInt(v)
73 #define float_to_int(v) int(floorf(v + 0.5f))
74
75 // some of Norman's crazy optimizations. :-)
76
77 #ifndef WIN32
78 typedef struct {
79     int x, y;
80 } POINT;
81
82 typedef struct {
83     int top, bottom, left, right;
84 } RECT;
85 #endif
86
87 // View mode definitions
88
89 enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
90
91 // Label constants
92 #define HUD_FONT_SMALL     1
93 #define HUD_FONT_LARGE     2
94
95 enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
96
97 #define HUDS_AUTOTICKS           0x0001
98 #define HUDS_VERT                0x0002
99 #define HUDS_HORZ                0x0000
100 #define HUDS_TOP                 0x0004
101 #define HUDS_BOTTOM              0x0008
102 #define HUDS_LEFT     HUDS_TOP
103 #define HUDS_RIGHT    HUDS_BOTTOM
104 #define HUDS_BOTH     (HUDS_LEFT | HUDS_RIGHT)
105 #define HUDS_NOTICKS             0x0010
106 #define HUDS_ARITHTIC            0x0020
107 #define HUDS_DECITICS            0x0040
108 #define HUDS_NOTEXT              0x0080
109
110 // Ladder orientaion
111 // #define HUD_VERTICAL        1
112 // #define HUD_HORIZONTAL       2
113 // #define HUD_FREEFLOAT        3
114
115 // Ladder orientation modes
116 // #define HUD_LEFT         1
117 // #define HUD_RIGHT            2
118 // #define HUD_TOP              1
119 // #define HUD_BOTTOM           2
120 // #define HUD_V_LEFT           1
121 // #define HUD_V_RIGHT          2
122 // #define HUD_H_TOP            1
123 // #define HUD_H_BOTTOM         2
124
125
126 // Ladder sub-types
127 // #define HUD_LIM              1
128 // #define HUD_NOLIM            2
129 // #define HUD_CIRC         3
130
131 // #define HUD_INSTR_LADDER 1
132 // #define HUD_INSTR_CLADDER    2
133 // #define HUD_INSTR_HORIZON    3
134 // #define HUD_INSTR_LABEL      4
135
136 // in cockpit.cxx
137 extern float get_throttleval ( void );
138 extern float get_aileronval  ( void );
139 extern float get_elevatorval ( void );
140 extern float get_elev_trimval( void );
141 extern float get_rudderval   ( void );
142 extern float get_speed       ( void );
143 extern float get_aoa         ( void );
144 extern float get_nlf         ( void );
145 extern float get_roll        ( void );
146 extern float get_pitch       ( void );
147 extern float get_heading     ( void );
148 extern float get_view_direction( void );
149 extern float get_altitude    ( void );
150 extern float get_agl         ( void );
151 extern float get_sideslip    ( void );
152 extern float get_frame_rate  ( void );
153 extern float get_latitude    ( void );
154 extern float get_lat_min     ( void );
155 extern float get_longitude   ( void );
156 extern float get_long_min    ( void );
157 extern float get_fov         ( void );
158 extern float get_vfc_ratio   ( void );
159 extern float get_vfc_tris_drawn   ( void );
160 extern float get_vfc_tris_culled   ( void );
161 extern float get_climb_rate  ( void );
162 extern float get_mach( void );
163 extern char *coord_format_lat(float);
164 extern char *coord_format_lon(float);
165 //extern char *coord_format_latlon(float latitude, float longitude);  // cockpit.cxx
166
167 // $$$ begin - added, VS Renganathan, 13 Oct 2K
168 // #define FIGHTER_HUD
169 extern float get_anzg (void);
170 extern float get_Vx (void);
171 extern float get_Vy (void);
172 extern float get_Vz (void);
173 extern float get_Ax (void);
174 extern float get_Ay (void);
175 extern float get_Az (void);
176 extern int get_iaux1 (void);
177 extern int get_iaux2 (void);
178 extern int get_iaux3 (void);
179 extern int get_iaux4 (void);
180 extern int get_iaux5 (void);
181 extern int get_iaux6 (void);
182 extern int get_iaux7 (void);
183 extern int get_iaux8 (void);
184 extern int get_iaux9 (void);
185 extern int get_iaux10 (void);
186 extern int get_iaux11 (void);
187 extern int get_iaux12 (void);
188 extern float get_aux1(void);
189 extern float get_aux2(void);
190 extern float get_aux3(void);
191 extern float get_aux4(void);
192 extern float get_aux5 (void);
193 extern float get_aux6 (void);
194 extern float get_aux7 (void);
195 extern float get_aux8(void);
196 extern float get_aux9(void);
197 extern float get_aux10(void);
198 extern float get_aux11(void);
199 extern float get_aux12(void);
200 extern float get_aux13(void);
201 extern float get_aux14(void);
202 extern float get_aux15(void);
203 extern float get_aux16(void);
204 extern float get_aux17(void);
205 extern float get_aux18(void);
206 // $$$ end - added, VS Renganathan, 13 Oct 2K
207
208 extern char *get_formated_gmt_time( void );
209 extern void fgHUDReshape(void);
210
211 enum  hudinstype{ HUDno_instr,
212                   HUDscale,
213                   HUDlabel,
214                   HUDladder,
215                   HUDcirc_ladder,
216                   HUDhorizon,
217                   HUDgauge,
218                   HUDdual_inst,
219                   HUDmoving_scale,
220                   HUDtbi
221 };
222
223 typedef struct gltagRGBTRIPLE { // rgbt
224     GLfloat Blue;
225     GLfloat Green;
226     GLfloat Red;
227 } glRGBTRIPLE;
228
229 class fgLineSeg2D {
230 private:
231     GLfloat x0, y0, x1, y1;
232
233 public:
234     fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
235         : x0(a), y0(b),  x1(c), y1(d) {}
236
237     fgLineSeg2D( const fgLineSeg2D & image )
238         : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
239
240     fgLineSeg2D& operator= ( const fgLineSeg2D & image ) { // seems unused
241         x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
242     }
243
244     void draw() const
245     {
246         glVertex2f(x0, y0);
247         glVertex2f(x1, y1);
248     }
249 };
250
251 class DrawLineSeg2D {
252     public:
253         void operator() (const fgLineSeg2D& elem) const {
254             elem.draw();
255         }
256 };
257
258
259 #define USE_HUD_TextList
260 extern fntTexFont        *HUD_Font;
261 extern float              HUD_TextSize;
262 extern fntRenderer       *HUDtext;
263 extern float HUD_matrix[16];
264
265 class fgText {
266 private:
267     float x, y;
268     char msg[64];
269 public:
270     int digit;
271     fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y)
272     {
273         strcpy(msg,c);
274         digit=digits;
275     }
276
277     fgText( const fgText & image )
278         : x(image.x), y(image.y),digit(image.digit) { strcpy(msg,image.msg); }
279
280     fgText& operator = ( const fgText & image ) {  // seems unused
281         strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit;
282         return *this;
283     }
284
285     ~fgText() { msg[0]='\0'; }  // used but useless
286
287     int getStringWidth ( char *str )
288     {
289         if ( HUDtext && str ) {
290             float r, l ;
291             HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
292             return float_to_int( r - l );
293         }
294         return 0 ;
295     }
296
297     int StringWidth (void )
298     {
299         if ( HUDtext && strlen( msg )) {
300             float r, l ;
301             HUD_Font->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
302             return float_to_int( r - l );
303         }
304         return 0 ;
305     }
306
307     // this code is changed to display Numbers with big/small digits
308     // according to MIL Standards for example Altitude above 10000 ft
309     // is shown as 10ooo.
310
311     void Draw(fntRenderer *fnt,int digits) {
312         if (digits==1) {
313             int c=0,i=0;
314             char *t=msg;
315             int p=4;
316
317             if (t[0]=='-') {
318                 //if negative value then increase the c and p values
319                 //for '-' sign.  c++;
320                 p++;
321             }
322             char *tmp=msg;
323             while (tmp[i]!='\0') {
324                 if ((tmp[i]>='0') && (tmp[i]<='9'))
325                     c++;
326                 i++;
327             }
328             float orig_size = fnt->getPointSize();
329             if (c>p) {
330                 fnt->setPointSize(HUD_TextSize * 0.8);
331                 int p1=c-3;
332                 char *tmp1=msg+p1;
333                 int p2=p1*8;
334
335                 fnt->start2f(x+p2,y);
336                 fnt->puts(tmp1);
337
338                 fnt->setPointSize(HUD_TextSize * 1.2);
339                 char tmp2[64];
340                 strncpy(tmp2,msg,p1);
341                 tmp2[p1]='\0';
342
343                 fnt->start2f(x,y);
344                 fnt->puts(tmp2);
345             } else {
346                 fnt->setPointSize(HUD_TextSize * 1.2);
347                 fnt->start2f( x, y );
348                 fnt->puts(tmp);
349             }
350             fnt->setPointSize(orig_size);
351         } else {
352             //if digits not equal to 1
353             fnt->start2f( x, y );
354             fnt->puts( msg ) ;
355         }
356     }
357
358     void Draw()
359     {
360         guiFnt.drawString( msg, float_to_int(x), float_to_int(y) );
361     }
362 };
363
364 class fgLineList {
365     vector < fgLineSeg2D > List;
366 public:
367     fgLineList( void ) {}
368     void add( const fgLineSeg2D& seg ) { List.push_back(seg); }
369     void erase( void ) { List.erase( List.begin(), List.end() ); }
370     void draw( void ) {
371         glBegin(GL_LINES);
372         for_each( List.begin(), List.end(), DrawLineSeg2D());
373         glEnd();
374     }
375 };
376
377 class fgTextList {
378     fntRenderer *Font;
379     vector< fgText > List;
380 public:
381     fgTextList ( void ) { Font = 0; }
382
383     void setFont( fntRenderer *Renderer ) { Font = Renderer; }
384     void add( const fgText& String ) { List.push_back(String); }
385     void erase( void ) { List.erase( List.begin(), List.end() ); }
386     void draw( void );
387 };
388
389
390 inline void Text( fgTextList &List, float x, float y, char *s)
391 {
392     List.add( fgText( x, y, s) );
393 }
394
395 inline void Text( fgTextList &List, const fgText &me)
396 {
397     List.add(me);
398 }
399
400 inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
401 {
402     List.add(fgLineSeg2D(x1,y1,x2,y2));
403 }
404
405
406 // Declare our externals
407 extern fgTextList         HUD_TextList;
408 extern fgLineList         HUD_LineList;
409 extern fgLineList         HUD_StippleLineList;
410
411
412 class instr_item {  // An Abstract Base Class (ABC)
413 private:
414     static UINT        instances;     // More than 64K instruments? Nah!
415     static int         brightness;
416     static glRGBTRIPLE color;
417
418     UINT               handle;
419     RECT               scrn_pos;      // Framing - affects scale dimensions
420                                       // and orientation. Vert vs Horz, etc.
421     FLTFNPTR           load_value_fn;
422     float              disp_factor;   // Multiply by to get numbers shown on scale.
423     UINT               opts;
424     bool               is_enabled;
425     bool               broken;
426     UINT               scr_span;      // Working values for draw;
427     POINT              mid_span;      //
428     int                digits;
429
430 public:
431     instr_item( int            x,
432                 int            y,
433                 UINT           height,
434                 UINT           width,
435                 FLTFNPTR       data_source,
436                 float          data_scaling,
437                 UINT           options,
438                 bool           working = true,
439                 int            digit = 0);
440
441     virtual ~instr_item ();
442
443     void    set_data_source ( FLTFNPTR fn ) { load_value_fn = fn; }
444     int     get_brightness  ( void ) { return brightness;}
445     RECT    get_location    ( void ) { return scrn_pos;  }
446     bool    is_broken       ( void ) { return broken;    }
447     bool    enabled         ( void ) { return is_enabled;}
448     bool    data_available  ( void ) { return !!load_value_fn; }
449     float   get_value       ( void ) { return load_value_fn(); }
450     float   data_scaling    ( void ) { return disp_factor; }
451     UINT    get_span        ( void ) { return scr_span;  }
452     POINT   get_centroid    ( void ) { return mid_span;  }
453     UINT    get_options     ( void ) { return opts;      }
454     int     get_digits      ( void ) { return digits;         }
455     inline int get_x() const { return scrn_pos.left; }
456     inline int get_y() const { return scrn_pos.top; }
457     inline int get_width() const { return scrn_pos.right; }
458     inline int get_height() const { return scrn_pos.bottom; }
459
460     UINT    huds_vert     (UINT options) { return (options & HUDS_VERT); }
461     UINT    huds_left     (UINT options) { return (options & HUDS_LEFT); }
462     UINT    huds_right    (UINT options) { return (options & HUDS_RIGHT); }
463     UINT    huds_both     (UINT options) {
464         return ((options & HUDS_BOTH) == HUDS_BOTH);
465     }
466     UINT    huds_noticks  (UINT options) { return (options & HUDS_NOTICKS); }
467     UINT    huds_notext   (UINT options) { return (options & HUDS_NOTEXT); }
468     UINT    huds_top      (UINT options) { return (options & HUDS_TOP); }
469     UINT    huds_bottom   (UINT options) { return (options & HUDS_BOTTOM); }
470
471     virtual void display_enable( bool working ) { is_enabled = working;}
472
473     virtual void break_display ( bool bad );
474     virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
475     void         SetPosition  ( int x, int y, UINT width, UINT height );
476     UINT         get_Handle( void );
477     virtual void draw( void ) = 0;   // Required method in derived classes
478
479     void drawOneLine( float x1, float y1, float x2, float y2)
480     {
481         HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
482     }
483     void drawOneStippleLine( float x1, float y1, float x2, float y2)
484     {
485         HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
486     }
487     void TextString( char *msg, float x, float y,int digit )
488     {
489         HUD_TextList.add(fgText(x, y, msg,digit));
490     }
491     int getStringWidth ( char *str )
492     {
493         if ( HUDtext && str ) {
494             float r, l ;
495             HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
496             return float_to_int( r - l );
497         }
498         return 0 ;
499     }
500
501     //code to draw ticks as small circles
502     void drawOneCircle(float x1, float y1, float r)
503     {
504         glBegin(GL_LINE_LOOP);  // Use polygon to approximate a circle
505         for (int count=0; count<25; count++) {
506             float cosine = r * cos(count * 2 * SG_PI/10.0);
507             float sine =   r * sin(count * 2 * SG_PI/10.0);
508             glVertex2f(cosine+x1, sine+y1);
509         }
510         glEnd();
511     }
512
513 };
514
515 typedef instr_item *HIptr;
516
517 class HUDdraw {
518     public:
519         void operator() (HIptr elem) const {
520             if ( elem->enabled())
521                 elem->draw();
522         }
523 };
524
525
526 extern deque< instr_item *> HUD_deque;
527 extern int HUD_style;
528 //extern hud_deque_type HUD_deque;
529
530 // instr_item           This class has no other purpose than to maintain
531 //                      a linked list of instrument and derived class
532 // object pointers.
533
534
535 class instr_label : public instr_item {
536 private:
537     const char  *pformat;
538     const char  *pre_str;
539     const char  *post_str;
540     fgLabelJust justify;
541     int         fontSize;
542     int         blink;
543     char        format_buffer[80];
544     bool        lat;
545     bool        lon;
546     bool        lbox;
547     SGPropertyNode_ptr lon_node;
548     SGPropertyNode_ptr lat_node;
549
550 public:
551     instr_label(const SGPropertyNode *);
552     virtual void draw(void);
553 };
554
555
556 //
557 // fgRunway_instr   This class is responsible for rendering the active runway
558 //                  in the hud (if visible).
559 class runway_instr : public instr_item {
560 private:
561         void boundPoint(const sgdVec3& v, sgdVec3& m);
562         bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
563         bool drawLine(const sgdVec3& a1, const sgdVec3& a2,
564                 const sgdVec3& p1, const sgdVec3& p2);
565         void drawArrow();
566         bool get_active_runway(FGRunway& rwy);
567         void get_rwy_points(sgdVec3 *points);
568         void setLineWidth(void);
569
570         sgdVec3 points3d[6], points2d[6];
571         double mm[16],pm[16], arrowScale, arrowRad, lnScale;
572         double scaleDist, default_pitch, default_heading;
573         GLint view[4];
574         FGRunway runway;
575         FGViewer* cockpit_view;
576         unsigned short stippleOut, stippleCen;
577         bool drawIA, drawIAAlways;
578         RECT location;
579         POINT center;
580
581 public:
582     runway_instr(const SGPropertyNode *);
583
584     virtual void draw( void );
585     void setArrowRotationRadius(double radius);
586     // Scales the runway indication arrow
587     void setArrowScale(double scale);
588     // Draws arrow when runway is not visible in HUD if draw=true
589     void setDrawArrow(bool draw);
590     // Always draws arrow if draw=true;
591     void setDrawArrowAlways(bool draw);
592     // Sets the maximum line scale
593     void setLineScale(double scale);
594     // Sets the distance where to start scaling the lines
595     void setScaleDist(double dist_nm);
596     // Sets the stipple pattern of the outline of the runway
597     void setStippleOutline(unsigned short stipple);
598     // Sets the stipple patter of the center line of the runway
599     void setStippleCenterline(unsigned short stipple);
600 };
601
602
603 //
604 // instr_scale           This class is an abstract base class for both moving
605 //                       scale and moving needle (fixed scale) indicators. It
606 // does not draw itself, but is not instanciable.
607 //
608
609 class instr_scale : public instr_item {
610 private:
611     float range_shown;   // Width Units.
612     float Maximum_value; //                ceiling.
613     float Minimum_value; // Representation floor.
614     float scale_factor;  // factor => screen units/range values.
615     UINT   Maj_div;       // major division marker units
616     UINT   Min_div;       // minor division marker units
617     UINT   Modulo;        // Roll over point
618     int    signif_digits; // digits to show to the right.
619
620 public:
621     instr_scale( int          x,
622                  int          y,
623                  UINT         width,
624                  UINT         height,
625                  FLTFNPTR     load_fn,
626                  UINT         options,
627                  float        show_range,
628                  float        max_value,
629                  float        min_value,
630                  float        disp_scaling,
631                  UINT         major_divs,
632                  UINT         minor_divs,
633                  UINT         rollover,
634                  int          dp_showing,
635                  bool         working = true);
636
637     virtual void draw    ( void ) {}; // No-op here. Defined in derived classes.
638     UINT   div_min       ( void ) { return Min_div;}
639     UINT   div_max       ( void ) { return Maj_div;}
640     float  min_val       ( void ) { return Minimum_value;}
641     float  max_val       ( void ) { return Maximum_value;}
642     UINT   modulo        ( void ) { return Modulo; }
643     float  factor        ( void ) { return scale_factor;}
644     float  range_to_show ( void ) { return range_shown;}
645 };
646
647 // hud_card                This class displays the indicated quantity on
648 //                         a scale that moves past the pointer. It may be
649 // horizontal or vertical, read above(left) or below(right) of the base
650 // line.
651
652 class hud_card : public instr_scale {
653 private:
654     float  val_span;
655     string type;
656     float  half_width_units;
657     bool   draw_tick_bottom;
658     bool   draw_tick_top;
659     bool   draw_tick_right;
660     bool   draw_tick_left;
661     bool   draw_cap_bottom;
662     bool   draw_cap_top;
663     bool   draw_cap_right;
664     bool   draw_cap_left;
665     float  marker_offset;
666     bool   pointer;
667     string pointer_type;
668     string tick_type;
669     string tick_length;
670     float  radius;
671     float  maxValue;
672     float  minValue;
673     int    divisions;
674     int    zoom;
675     UINT   Maj_div;
676     UINT   Min_div;
677
678 public:
679     hud_card(const SGPropertyNode *);
680     //    virtual void display_enable( bool setting );                  // FIXME
681     virtual void draw(void);
682     void circles(float, float, float);
683     void fixed(float, float, float, float, float, float);
684     void zoomed_scale(int, int);
685 };
686
687
688 class gauge_instr : public instr_scale {
689 public:
690     gauge_instr(const SGPropertyNode *);
691     virtual void draw( void );       // Required method in base class
692 };
693
694
695 //
696 // dual_instr_item         This class was created to form the base class
697 //                         for both panel and HUD Turn Bank Indicators.
698
699 class dual_instr_item : public instr_item {
700 private:
701     FLTFNPTR alt_data_source;
702
703 public:
704     dual_instr_item ( int       x,
705                       int       y,
706                       UINT      width,
707                       UINT      height,
708                       FLTFNPTR  chn1_source,
709                       FLTFNPTR  chn2_source,
710                       bool      working,
711                       UINT      options );
712
713     float current_ch1( void ) { return (float)alt_data_source(); }
714     float current_ch2( void ) { return (float)get_value(); }
715     virtual void draw( void ) {}
716 };
717
718
719 class fgTBI_instr : public dual_instr_item {
720 private:
721     UINT BankLimit;
722     UINT SlewLimit;
723     UINT scr_hole;
724     bool tsi;
725     float rad;
726
727 public:
728     fgTBI_instr(const SGPropertyNode *);
729
730     UINT bank_limit(void) { return BankLimit; }
731     UINT slew_limit(void) { return SlewLimit; }
732
733     virtual void draw(void);
734 };
735
736
737 class HudLadder : public dual_instr_item {
738 private:
739     UINT   width_units;
740     int    div_units;
741     UINT   minor_div;
742     UINT   label_pos;
743     UINT   scr_hole;
744     float  vmax;
745     float  vmin;
746     float  factor;
747     string hudladder_type;
748     bool   frl;
749     bool   target_spot;
750     bool   velocity_vector;
751     bool   drift_marker;
752     bool   alpha_bracket;
753     bool   energy_marker;
754     bool   climb_dive_marker;
755     bool   glide_slope_marker;
756     float  glide_slope;
757     bool   energy_worm;
758     bool   waypoint_marker;
759     int    zenith;
760     int    nadir;
761     int    hat;
762
763     // The Ladder has it's own temporary display lists
764     fgTextList         TextList;
765     fgLineList         LineList;
766     fgLineList         StippleLineList;
767
768 public:
769     HudLadder(const SGPropertyNode *);
770
771     virtual void draw(void);
772     void drawZenith(float, float, float);
773     void drawNadir(float, float, float);
774
775     void Text(float x, float y, char *s)
776     {
777         TextList.add(fgText(x, y, s));
778     }
779
780     void Line(float x1, float y1, float x2, float y2)
781     {
782         LineList.add(fgLineSeg2D(x1, y1, x2, y2));
783     }
784
785     void StippleLine(float x1, float y1, float x2, float y2)
786     {
787         StippleLineList.add(fgLineSeg2D(x1, y1, x2, y2));
788     }
789 };
790
791
792 //using namespace std;
793 //deque <instr_item>  * Hdeque_ptr;
794
795 extern int  fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
796 extern int  fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
797 extern void fgUpdateHUD( void );
798 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
799                          GLfloat x_end, GLfloat y_end );
800
801 /*
802 bool AddHUDInstrument( instr_item *pBlackBox );
803 void DrawHUD ( void );
804 bool DamageInstrument( INSTR_HANDLE unit );
805 bool RepairInstrument( INSTR_HANDLE unit );
806
807
808 void fgUpdateHUD ( Hptr hud );
809 void fgUpdateHUD2( Hptr hud ); // Future use?
810 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
811 */
812
813
814
815
816 class HUD_Properties : public SGPropertyChangeListener {
817 public:
818     HUD_Properties();
819     void valueChanged(SGPropertyNode *n);
820     void setColor() const;
821     bool isVisible() const { return _visible; }
822     bool isAntialiased() const { return _antialiased; }
823     bool isTransparent() const { return _transparent; }
824     float alphaClamp() const { return _cl; }
825
826 private:
827     float clamp(float f) { return f < 0.0f ? 0.0f : f > 1.0f ? 1.0f : f; }
828     SGPropertyNode_ptr _current;
829     SGPropertyNode_ptr _visibility;
830     SGPropertyNode_ptr _antialiasing;
831     SGPropertyNode_ptr _transparency;
832     SGPropertyNode_ptr _red, _green, _blue, _alpha;
833     SGPropertyNode_ptr _alpha_clamp;
834     SGPropertyNode_ptr _brightness;
835     bool _visible;
836     bool _antialiased;
837     bool _transparent;
838     float _r, _g, _b, _a, _cl;
839 };
840
841 #endif // _OLDHUD_H