]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud.hxx
7765c4648734d2ec04ee530524f413555dfa8a33
[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 _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 <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/constants.h>
54
55 #include <Include/fg_typedefs.h>
56 #include <Aircraft/aircraft.hxx>
57 #include <Aircraft/controls.hxx>
58 #include <FDM/flight.hxx>
59 #include <GUI/gui.h>
60 #include <Main/globals.hxx>
61 #include <Main/viewmgr.hxx>
62 #include <Airports/runways.hxx>
63
64 #include "hud_opts.hxx"
65 #include <plib/sg.h>
66
67 SG_USING_STD(deque);
68 SG_USING_STD(vector);
69 SG_USING_NAMESPACE(std);
70
71
72 // some of Norman's crazy optimizations. :-)
73
74 #ifndef WIN32
75 typedef struct {
76     int x, y;
77 } POINT;
78
79 typedef struct {
80     int top, bottom, left, right;
81 } RECT;
82 #endif
83
84 // View mode definitions
85
86 enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
87
88 // Label constants
89 #define HUD_FONT_SMALL     1
90 #define HUD_FONT_LARGE     2
91
92 enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
93
94 #define HUDS_AUTOTICKS           0x0001
95 #define HUDS_VERT                0x0002
96 #define HUDS_HORZ                0x0000
97 #define HUDS_TOP                 0x0004
98 #define HUDS_BOTTOM              0x0008
99 #define HUDS_LEFT     HUDS_TOP
100 #define HUDS_RIGHT    HUDS_BOTTOM
101 #define HUDS_BOTH     (HUDS_LEFT | HUDS_RIGHT)
102 #define HUDS_NOTICKS             0x0010
103 #define HUDS_ARITHTIC            0x0020
104 #define HUDS_DECITICS            0x0040
105 #define HUDS_NOTEXT              0x0080
106
107 // Ladder orientaion
108 // #define HUD_VERTICAL        1
109 // #define HUD_HORIZONTAL       2
110 // #define HUD_FREEFLOAT        3
111
112 // Ladder orientation modes
113 // #define HUD_LEFT         1
114 // #define HUD_RIGHT            2
115 // #define HUD_TOP              1
116 // #define HUD_BOTTOM           2
117 // #define HUD_V_LEFT           1
118 // #define HUD_V_RIGHT          2
119 // #define HUD_H_TOP            1
120 // #define HUD_H_BOTTOM         2
121
122
123 // Ladder sub-types
124 // #define HUD_LIM              1
125 // #define HUD_NOLIM            2
126 // #define HUD_CIRC         3
127
128 // #define HUD_INSTR_LADDER 1
129 // #define HUD_INSTR_CLADDER    2
130 // #define HUD_INSTR_HORIZON    3
131 // #define HUD_INSTR_LABEL      4
132
133 // in cockpit.cxx
134 extern float get_throttleval ( void );
135 extern float get_aileronval  ( void );
136 extern float get_elevatorval ( void );
137 extern float get_elev_trimval( void );
138 extern float get_rudderval   ( void );
139 extern float get_speed       ( void );
140 extern float get_aoa         ( void );
141 extern float get_nlf         ( void );
142 extern float get_roll        ( void );
143 extern float get_pitch       ( void );
144 extern float get_heading     ( void );
145 extern float get_view_direction( void );
146 extern float get_altitude    ( void );
147 extern float get_agl         ( void );
148 extern float get_sideslip    ( void );
149 extern float get_frame_rate  ( void );
150 extern float get_latitude    ( void );
151 extern float get_lat_min     ( void );
152 extern float get_longitude   ( void );
153 extern float get_long_min    ( void );
154 extern float get_fov         ( void );
155 extern float get_vfc_ratio   ( void );
156 extern float get_vfc_tris_drawn   ( void );
157 extern float get_vfc_tris_culled   ( void );
158 extern float get_climb_rate  ( void );
159 extern float get_mach( void );
160 extern char *coord_format_lat(float);
161 extern char *coord_format_lon(float);
162 //extern char *coord_format_latlon(float latitude, float longitude);  // cockpit.cxx
163
164 // $$$ begin - added, VS Renganathan, 13 Oct 2K
165 // #define FIGHTER_HUD
166 extern float get_anzg (void);
167 extern float get_Vx (void);
168 extern float get_Vy (void);
169 extern float get_Vz (void);
170 extern float get_Ax (void);
171 extern float get_Ay (void);
172 extern float get_Az (void);
173 extern int get_iaux1 (void);
174 extern int get_iaux2 (void);
175 extern int get_iaux3 (void);
176 extern int get_iaux4 (void);
177 extern int get_iaux5 (void);
178 extern int get_iaux6 (void);
179 extern int get_iaux7 (void);
180 extern int get_iaux8 (void);
181 extern int get_iaux9 (void);
182 extern int get_iaux10 (void);
183 extern int get_iaux11 (void);
184 extern int get_iaux12 (void);
185 extern float get_aux1(void);
186 extern float get_aux2(void);
187 extern float get_aux3(void);
188 extern float get_aux4(void);
189 extern float get_aux5 (void);
190 extern float get_aux6 (void);
191 extern float get_aux7 (void);
192 extern float get_aux8(void);
193 extern float get_aux9(void);
194 extern float get_aux10(void);
195 extern float get_aux11(void);
196 extern float get_aux12(void);
197 extern float get_aux13(void);
198 extern float get_aux14(void);
199 extern float get_aux15(void);
200 extern float get_aux16(void);
201 extern float get_aux17(void);
202 extern float get_aux18(void);
203 // $$$ end - added, VS Renganathan, 13 Oct 2K
204
205 extern char *get_formated_gmt_time( void );
206 extern void fgHUDReshape(void);
207
208 enum  hudinstype{ HUDno_instr,
209                   HUDscale,
210                   HUDlabel,
211                   HUDladder,
212                   HUDcirc_ladder,
213                   HUDhorizon,
214                   HUDgauge,
215                   HUDdual_inst,
216                   HUDmoving_scale,
217                   HUDtbi
218 };
219
220 typedef struct gltagRGBTRIPLE { // rgbt
221     GLfloat Blue;
222     GLfloat Green;
223     GLfloat Red;
224 } glRGBTRIPLE;
225
226 class fgLineSeg2D {
227 private:
228     GLfloat x0, y0, x1, y1;
229
230 public:
231     fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
232         : x0(a), y0(b),  x1(c), y1(d) {}
233
234     fgLineSeg2D( const fgLineSeg2D & image )
235         : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
236
237     fgLineSeg2D& operator= ( const fgLineSeg2D & image ) {
238         x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
239     }
240
241     ~fgLineSeg2D() {}
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 ) {
280         strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit;
281         return *this;
282     }
283
284     ~fgText() { msg[0]='\0'; }
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 FloatToInt( 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 FloatToInt( 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             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         } else {
349             //if digits not equal to 1
350             fnt->setPointSize(HUD_TextSize * 0.8);
351             fnt->start2f( x, y );
352             fnt->puts( msg ) ;
353         }
354     }
355
356     void Draw()
357     {
358         guiFnt.drawString( msg, FloatToInt(x), FloatToInt(y) );
359     }
360 };
361
362 class fgLineList {
363     vector < fgLineSeg2D > List;
364 public:
365     fgLineList( void ) {}
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     ~fgTextList( void ) {}
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     instr_item( const instr_item & image );
442
443     virtual ~instr_item ();
444
445     int     get_brightness  ( void ) { return brightness;}
446     RECT    get_location    ( void ) { return scrn_pos;  }
447     bool    is_broken       ( void ) { return broken;    }
448     bool    enabled         ( void ) { return is_enabled;}
449     bool    data_available  ( void ) { return !!load_value_fn; }
450     float   get_value       ( void ) { return load_value_fn(); }
451     float   data_scaling    ( void ) { return disp_factor; }
452     UINT    get_span        ( void ) { return scr_span;  }
453     POINT   get_centroid    ( void ) { return mid_span;  }
454     UINT    get_options     ( void ) { return opts;      }
455     int     get_digits      ( void ) { return digits;         }
456
457     UINT    huds_vert     (UINT options) { return( options  & HUDS_VERT ); }
458     UINT    huds_left     (UINT options) { return( options  & HUDS_LEFT ); }
459     UINT    huds_right    (UINT options) { return( options  & HUDS_RIGHT ); }
460     UINT    huds_both     (UINT options) {
461         return( (options & HUDS_BOTH) == HUDS_BOTH );
462     }
463     UINT    huds_noticks  (UINT options) { return( options  & HUDS_NOTICKS ); }
464     UINT    huds_notext   (UINT options) { return( options  & HUDS_NOTEXT ); }
465     UINT    huds_top      (UINT options) { return( options  & HUDS_TOP ); }
466     UINT    huds_bottom   (UINT options) { return( options  & HUDS_BOTTOM ); }
467
468     virtual void display_enable( bool working ) { is_enabled = !! working;}
469
470     virtual void update( void );
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 FloatToInt( 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 //typedef deque <  instr_item * > hud_deque_type;
524 //typedef hud_deque_type::iterator hud_deque_iterator;
525 //typedef hud_deque_type::const_iterator hud_deque_const_iterator;
526
527 extern deque< instr_item *> HUD_deque;
528 extern int HUD_style;
529 //extern hud_deque_type HUD_deque;
530
531 // instr_item           This class has no other purpose than to maintain
532 //                      a linked list of instrument and derived class
533 // object pointers.
534
535
536 class instr_label : public instr_item {
537 private:
538     const char *pformat;
539     const char *pre_str;
540     const char *post_str;
541     fgLabelJust justify;
542     int         fontSize;
543     int         blink;
544     char format_buffer[80];
545     bool        lat;
546     bool        lon;
547     bool        lbox;
548
549 public:
550     instr_label( int          x,
551                  int          y,
552                  UINT         width,
553                  UINT         height,
554                  FLTFNPTR     data_source,
555                  const char  *label_format,
556                  const char  *pre_label_string,
557                  const char  *post_label_string,
558                  float        scale_data,
559                  UINT         options,
560                  fgLabelJust  justification,
561                  int          font_size,
562                  int          blinking,
563                  bool         latitude,
564                  bool         longitude,
565                  bool         label_box,
566                  bool         working,
567                  int          digit );
568
569     ~instr_label();
570
571     instr_label( const instr_label & image);
572     virtual void draw( void );       // Required method in base class
573 };
574
575 typedef instr_label * pInstlabel;
576
577
578 class lat_label : public instr_item {
579 private:
580     const char *pformat;
581     const char *pre_str;
582     const char *post_str;
583     fgLabelJust justify;
584     int         fontSize;
585     int         blink;
586     char format_buffer[80];
587
588 public:
589     lat_label( int          x,
590                int          y,
591                UINT         width,
592                UINT         height,
593                FLTFNPTR     data_source,
594                const char  *label_format,
595                const char  *pre_label_string,
596                const char  *post_label_string,
597                float        scale_data,
598                UINT         options,
599                fgLabelJust  justification,
600                int          font_size,
601                int          blinking,
602                bool         working,
603                int          digits =0 );
604
605     ~lat_label();
606
607     lat_label( const lat_label & image);
608     virtual void draw( void );       // Required method in base class
609 };
610
611 typedef lat_label * pLatlabel;
612
613 class lon_label : public instr_item {
614 private:
615     const char *pformat;
616     const char *pre_str;
617     const char *post_str;
618     fgLabelJust justify;
619     int         fontSize;
620     int         blink;
621     char format_buffer[80];
622
623 public:
624     lon_label( int          x,
625                int          y,
626                UINT         width,
627                UINT         height,
628                FLTFNPTR     data_source,
629                const char  *label_format,
630                const char  *pre_label_string,
631                const char  *post_label_string,
632                float        scale_data,
633                UINT         options,
634                fgLabelJust  justification,
635                int          font_size,
636                int          blinking,
637                bool         working,
638                int          digit=0);
639
640
641     ~lon_label();
642
643     lon_label( const lon_label & image);
644     virtual void draw( void );       // Required method in base class
645 };
646
647 typedef lon_label * pLonlabel;
648
649 //
650 // fgRunway_instr        This class is responsible for rendering the active runway
651 //                        in the hud (if visible).
652 class runway_instr : public instr_item
653 {
654 private:
655         void boundPoint(const sgdVec3& v, sgdVec3& m);
656         bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
657         bool drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& p1, const sgdVec3& p2);
658         void drawArrow();
659         bool get_active_runway(FGRunway& rwy);
660         void get_rwy_points(sgdVec3 *points);
661         void setLineWidth(void);
662
663         sgdVec3 points3d[6],points2d[6];
664         double mm[16],pm[16], arrowScale, arrowRad, lnScale, scaleDist, default_pitch, default_heading;
665         GLint view[4];
666         FGRunway runway;
667         FGViewer* cockpit_view;
668         unsigned short stippleOut,stippleCen;
669         bool drawIA,drawIAAlways;
670         RECT location;
671         POINT center;
672
673 public:
674     runway_instr( int    x,
675                   int    y,
676                   int    width,
677                   int    height,
678                   float  scale_data,
679                   bool   working = true);
680
681     virtual void draw( void );       // Required method in base class
682         void setArrowRotationRadius(double radius);
683         void setArrowScale(double scale); // Scales the runway indication arrow
684         void setDrawArrow(bool draw);         // Draws arrow when runway is not visible in HUD if draw=true
685         void setDrawArrowAlways(bool draw); //Always draws arrow if draw=true;
686         void setLineScale(double scale); //Sets the maximum line scale
687         void setScaleDist(double dist_nm); //Sets the distance where to start scaling the lines
688         void setStippleOutline(unsigned short stipple); //Sets the stipple pattern of the outline of the runway
689         void setStippleCenterline(unsigned short stipple); //Sets the stipple patter of the center line of the runway
690 };
691
692
693 //
694 // instr_scale           This class is an abstract base class for both moving
695 //                       scale and moving needle (fixed scale) indicators. It
696 // does not draw itself, but is not instanciable.
697 //
698
699 class instr_scale : public instr_item {
700 private:
701     float range_shown;   // Width Units.
702     float Maximum_value; //                ceiling.
703     float Minimum_value; // Representation floor.
704     float scale_factor;  // factor => screen units/range values.
705     UINT   Maj_div;       // major division marker units
706     UINT   Min_div;       // minor division marker units
707     UINT   Modulo;        // Roll over point
708     int    signif_digits; // digits to show to the right.
709
710 public:
711     instr_scale( int          x,
712                  int          y,
713                  UINT         width,
714                  UINT         height,
715                  FLTFNPTR     load_fn,
716                  UINT         options,
717                  float        show_range,
718                  float        max_value,
719                  float        min_value,
720                  float        disp_scaling,
721                  UINT         major_divs,
722                  UINT         minor_divs,
723                  UINT         rollover,
724                  int          dp_showing,
725                  bool         working = true);
726
727     virtual ~instr_scale();
728     instr_scale( const instr_scale & image);
729
730     virtual void draw   ( void ) {}; // No-op here. Defined in derived classes.
731     UINT   div_min      ( void ) { return Min_div;}
732     UINT   div_max      ( void ) { return Maj_div;}
733     float min_val       ( void ) { return Minimum_value;}
734     float max_val       ( void ) { return Maximum_value;}
735     UINT   modulo       ( void ) { return Modulo; }
736     float factor        ( void ) { return scale_factor;}
737     float range_to_show ( void ) { return range_shown;}
738 };
739
740 // hud_card_               This class displays the indicated quantity on
741 //                         a scale that moves past the pointer. It may be
742 // horizontal or vertical, read above(left) or below(right) of the base
743 // line.
744
745 class hud_card : public instr_scale {
746 private:
747     float  val_span;
748     string type;
749     float  half_width_units;
750     bool   draw_tick_bottom;
751     bool   draw_tick_top;
752     bool   draw_tick_right;
753     bool   draw_tick_left;
754     bool   draw_cap_bottom;
755     bool   draw_cap_top;
756     bool   draw_cap_right;
757     bool   draw_cap_left;
758     float  marker_offset;
759     bool   pointer;
760     string pointer_type;
761     string tick_type;
762     string tick_length;
763     float  radius;
764     float  maxValue;
765     float  minValue;
766     int    divisions;
767     int    zoom;
768     UINT   Maj_div;
769     UINT   Min_div;
770
771
772 public:
773     hud_card( int      x,
774               int      y,
775               UINT     width,
776               UINT     height,
777               FLTFNPTR load_fn,
778               UINT     options,
779               float    maxValue,
780               float    minValue,
781               float    disp_scaling,
782               UINT     major_divs,
783               UINT     minor_divs,
784               UINT     modulator,
785               int      dp_showing,
786               float    value_span,
787               string   type,
788               bool     draw_tick_bottom,
789               bool     draw_tick_top,
790               bool     draw_tick_right,
791               bool     draw_tick_left,
792               bool     draw_cap_bottom,
793               bool     draw_cap_top,
794               bool     draw_cap_right,
795               bool     draw_cap_left,
796               float    marker_offset,
797               bool     pointer,
798               string   pointer_type,
799               string  tick_type,
800               string  tick_length,
801               bool     working,
802               float    radius,
803               int      divisions,
804               int      zoom
805             );
806
807
808     ~hud_card();
809     hud_card( const hud_card & image);
810     //    virtual void display_enable( bool setting );
811     virtual void draw( void );       // Required method in base class
812     void circles(float,float,float);
813     void fixed(float,float,float,float,float,float);
814     void zoomed_scale(int,int);
815 };
816
817 typedef hud_card * pCardScale;
818
819 class gauge_instr : public instr_scale {
820 public:
821     gauge_instr( int       x,
822                  int       y,
823                  UINT      width,
824                  UINT      height,
825                  FLTFNPTR  load_fn,
826                  UINT      options,
827                  float     disp_scaling,
828                  float     maxValue,
829                  float     minValue,
830                  UINT      major_divs,
831                  UINT      minor_divs,
832                  int       dp_showing,
833                  UINT      modulus,
834                  bool      working);
835
836     ~gauge_instr();
837     gauge_instr( const gauge_instr & image);
838     virtual void draw( void );       // Required method in base class
839 };
840
841 typedef gauge_instr * pGaugeInst;
842 //
843 // dual_instr_item         This class was created to form the base class
844 //                         for both panel and HUD Turn Bank Indicators.
845
846 class dual_instr_item : public instr_item {
847 private:
848     FLTFNPTR alt_data_source;
849
850 public:
851     dual_instr_item ( int       x,
852                       int       y,
853                       UINT      width,
854                       UINT      height,
855                       FLTFNPTR  chn1_source,
856                       FLTFNPTR  chn2_source,
857                       bool      working,
858                       UINT      options );
859
860     virtual ~dual_instr_item() {};
861     dual_instr_item( const dual_instr_item & image);
862
863     float current_ch1( void ) { return (float)alt_data_source();}
864     float current_ch2( void ) { return (float)get_value();}
865     virtual void draw( void ) { }
866 };
867
868 class fgTBI_instr : public dual_instr_item
869 {
870 private:
871     UINT BankLimit;
872     UINT SlewLimit;
873     UINT scr_hole;
874     bool tsi;
875     float rad;
876
877 public:
878     fgTBI_instr( int       x,
879                  int       y,
880                  UINT      width,
881                  UINT      height,
882                  FLTFNPTR  chn1_source,
883                  FLTFNPTR  chn2_source,
884                  float     maxBankAngle,
885                  float     maxSlipAngle,
886                  UINT      gap_width,
887                  bool      working,
888                  bool      tsi,
889                  float     rad);
890
891     fgTBI_instr( const fgTBI_instr & image);
892
893     ~fgTBI_instr();
894
895     UINT bank_limit( void ) { return BankLimit;}
896     UINT slew_limit( void ) { return SlewLimit;}
897
898     virtual void draw( void );       // Required method in base class
899 };
900
901 typedef fgTBI_instr * pTBI;
902
903 class HudLadder : public dual_instr_item {
904 private:
905     UINT   width_units;
906     int    div_units;
907     UINT   minor_div;
908     UINT   label_pos;
909     UINT   scr_hole;
910     float  vmax;
911     float  vmin;
912     float  factor;
913     string hudladder_type;
914     bool   frl;
915     bool   target_spot;
916     bool   velocity_vector;
917     bool   drift_marker;
918     bool   alpha_bracket;
919     bool   energy_marker;
920     bool   climb_dive_marker;
921     bool   glide_slope_marker;
922     float  glide_slope;
923     bool   energy_worm;
924     bool   waypoint_marker;
925     int    zenith;
926     int    nadir;
927     int    hat;
928
929
930     // The Ladder has it's own temporary display lists
931     fgTextList         TextList;
932     fgLineList         LineList;
933     fgLineList         StippleLineList;
934
935 public:
936     HudLadder( const string&    name,
937                int       x,
938                int       y,
939                UINT      width,
940                UINT      height,
941                float     factor,
942                FLTFNPTR  ptch_source,
943                FLTFNPTR  roll_source,
944                float     span_units,
945                float     division_units,
946                float     minor_division,
947                UINT      screen_hole,
948                UINT      lbl_pos,
949                bool      frl,
950                bool      target_spot,
951                bool      velocity_vector,
952                bool      drift_marker,
953                bool      alpha_bracket,
954                bool      energy_marker,
955                bool      climb_dive_marker,
956                bool      glide_slope_marker,
957                float     glide_slope,
958                bool      energy_worm,
959                bool      waypoint_marker,
960                bool      working,
961                int       zenith,
962                int       nadir,
963                int       hat
964              );
965
966
967     ~HudLadder();
968
969     HudLadder( const HudLadder & image );
970     virtual void draw( void );
971     void drawZenith(float,float,float);
972     void drawNadir(float, float, float);
973
974     void Text( float x, float y, char *s)
975     {
976         TextList.add( fgText( x, y, s) );
977     }
978
979     void Line( float x1, float y1, float x2, float y2)
980     {
981         LineList.add(fgLineSeg2D(x1,y1,x2,y2));
982     }
983
984     void StippleLine( float x1, float y1, float x2, float y2)
985     {
986         StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
987     }
988 };
989
990
991 //using namespace std;
992 //deque <instr_item>  * Hdeque_ptr;
993
994 extern int  fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
995 extern int  fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
996 extern void fgUpdateHUD( void );
997 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
998                          GLfloat x_end, GLfloat y_end );
999
1000 /*
1001 bool AddHUDInstrument( instr_item *pBlackBox );
1002 void DrawHUD ( void );
1003 bool DamageInstrument( INSTR_HANDLE unit );
1004 bool RepairInstrument( INSTR_HANDLE unit );
1005
1006
1007 void fgUpdateHUD ( Hptr hud );
1008 void fgUpdateHUD2( Hptr hud ); // Future use?
1009 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
1010 */
1011
1012
1013
1014
1015 class HUD_Properties : public SGPropertyChangeListener {
1016 public:
1017     HUD_Properties();
1018     void valueChanged(SGPropertyNode *n);
1019     void setColor() const;
1020     bool isVisible() const { return _visible; }
1021     bool isAntialiased() const { return _antialiased; }
1022     bool isTransparent() const { return _transparent; }
1023     float alphaClamp() const { return _cl; }
1024
1025 private:
1026     float clamp(float f) { return f < 0.0f ? 0.0f : f > 1.0f ? 1.0f : f; }
1027     SGPropertyNode_ptr _current;
1028     SGPropertyNode_ptr _visibility;
1029     SGPropertyNode_ptr _antialiasing;
1030     SGPropertyNode_ptr _transparency;
1031     SGPropertyNode_ptr _red, _green, _blue, _alpha;
1032     SGPropertyNode_ptr _alpha_clamp;
1033     SGPropertyNode_ptr _brightness;
1034     bool _visible;
1035     bool _antialiased;
1036     bool _transparent;
1037     float _r, _g, _b, _a, _cl;
1038 };
1039
1040 #endif // _HUD_H