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