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