]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud.hxx
remove obsolete constants
[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; //suma
270     fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y) //suma
271     { 
272         strcpy(msg,c);
273         digit=digits; //suma
274     }
275                    
276     fgText( const fgText & image )
277         : x(image.x), y(image.y),digit(image.digit) {strcpy(msg,image.msg);} //suma
278
279     fgText& operator = ( const fgText & image ) {
280         strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit; //suma
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.  begin suma
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     //end suma
356
357     void Draw()
358     {
359         guiFnt.drawString( msg, FloatToInt(x), FloatToInt(y) );
360     }
361 };
362
363 class fgLineList {
364     vector < fgLineSeg2D > List;
365 public:
366     fgLineList( void ) {}
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     ~fgTextList( void ) {}
383     
384     void setFont( fntRenderer *Renderer ) { Font = Renderer; }
385     void add( const fgText& String ) { List.push_back(String); }
386     void erase( void ) { List.erase( List.begin(), List.end() ); }
387     
388     void draw( void ) {
389         if( Font == 0 )
390             return;
391         vector < fgText > :: iterator curString = List.begin();
392         vector < fgText > :: iterator lastString = List.end();
393
394         glPushAttrib( GL_COLOR_BUFFER_BIT );
395         glEnable    ( GL_ALPHA_TEST   ) ;
396         glEnable    ( GL_BLEND        ) ;
397         glAlphaFunc ( GL_GREATER, 0.1 ) ;
398         glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
399
400         Font->begin();
401         for( ; curString != lastString; curString++ ) {
402             curString->Draw(Font,curString->digit); //suma
403         }
404         Font->end();
405
406         glDisable ( GL_TEXTURE_2D ) ;
407         glPopAttrib();
408     }
409 };
410
411
412 inline void Text( fgTextList &List, float x, float y, char *s)
413 {
414     List.add( fgText( x, y, s) );
415 }
416
417 inline void Text( fgTextList &List, const fgText &me)
418 {
419     List.add(me);
420 }
421
422 inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
423 {
424     List.add(fgLineSeg2D(x1,y1,x2,y2));
425 }
426
427
428 // Declare our externals
429 extern fgTextList         HUD_TextList;
430 extern fgLineList         HUD_LineList;
431 extern fgLineList         HUD_StippleLineList;
432
433
434 class instr_item {  // An Abstract Base Class (ABC)
435 private:
436     static UINT        instances;     // More than 64K instruments? Nah!
437     static int         brightness;
438     static glRGBTRIPLE color;
439
440     UINT               handle;
441     RECT               scrn_pos;      // Framing - affects scale dimensions
442                                       // and orientation. Vert vs Horz, etc.
443     FLTFNPTR           load_value_fn;
444     float              disp_factor;   // Multiply by to get numbers shown on scale.
445     UINT               opts;
446     bool               is_enabled;
447     bool               broken;
448     UINT               scr_span;      // Working values for draw;
449     POINT              mid_span;      //
450     int                digits;        //suma
451   
452 public:
453     instr_item( int            x,
454                 int            y,
455                 UINT           height,
456                 UINT           width,
457                 FLTFNPTR       data_source,
458                 float          data_scaling,
459                 UINT           options,
460                 bool           working  = true,
461                 int            digit = 0); //suma
462
463     instr_item( const instr_item & image );
464
465     instr_item & operator = ( const instr_item & rhs );
466     virtual ~instr_item ();
467
468     int     get_brightness  ( void ) { return brightness;}
469     RECT    get_location    ( void ) { return scrn_pos;  }
470     bool    is_broken       ( void ) { return broken;    }
471     bool    enabled         ( void ) { return is_enabled;}
472     bool    data_available  ( void ) { return !!load_value_fn; }
473     float   get_value       ( void ) { return load_value_fn(); }
474     float   data_scaling    ( void ) { return disp_factor; }
475     UINT    get_span        ( void ) { return scr_span;  }
476     POINT   get_centroid    ( void ) { return mid_span;  }
477     UINT    get_options     ( void ) { return opts;      }
478     int     get_digits      ( void ) { return digits;    } //suma
479
480     UINT    huds_vert     (UINT options) { return( options  & HUDS_VERT ); }
481     UINT    huds_left     (UINT options) { return( options  & HUDS_LEFT ); }
482     UINT    huds_right    (UINT options) { return( options  & HUDS_RIGHT ); }
483     UINT    huds_both     (UINT options) {
484         return( (options & HUDS_BOTH) == HUDS_BOTH );
485     }
486     UINT    huds_noticks  (UINT options) { return( options  & HUDS_NOTICKS ); }
487     UINT    huds_notext   (UINT options) { return( options  & HUDS_NOTEXT ); }
488     UINT    huds_top      (UINT options) { return( options  & HUDS_TOP ); }
489     UINT    huds_bottom   (UINT options) { return( options  & HUDS_BOTTOM ); }
490   
491     virtual void display_enable( bool working ) { is_enabled = !! working;}
492
493     virtual void update( void );
494     virtual void break_display ( bool bad );
495     virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
496     void         SetPosition  ( int x, int y, UINT width, UINT height );
497     UINT         get_Handle( void );
498     virtual void draw( void ) = 0;   // Required method in derived classes
499     
500     void drawOneLine( float x1, float y1, float x2, float y2)
501     {
502         HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
503     }
504     void drawOneStippleLine( float x1, float y1, float x2, float y2)
505     {
506         HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
507     }
508     void TextString( char *msg, float x, float y,int digit ) //suma
509     {
510         HUD_TextList.add(fgText(x, y, msg,digit)); //suma  
511     }
512     int getStringWidth ( char *str )
513     {
514         if ( HUDtext && str ) {
515             float r, l ;
516             HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
517             return FloatToInt( r - l );
518         }
519         return 0 ;
520     }
521
522     //code to draw ticks as small circles
523     void drawOneCircle(float x1, float y1, float r)
524     {
525         glBegin(GL_LINE_LOOP);  // Use polygon to approximate a circle 
526         for(int count=0; count<25; count++) {             
527             float cosine = r * cos(count * 2 * SG_PI/10.0); 
528             float sine =   r * sin(count * 2 * SG_PI/10.0); 
529             glVertex2f(cosine+x1, sine+y1);
530         }     
531         glEnd(); 
532     }
533     
534 };
535
536 typedef instr_item *HIptr;
537
538 class HUDdraw {
539     public:
540         void operator() (HIptr elem) const {
541             if( elem->enabled())
542                 elem->draw();
543         }
544 };
545
546 //typedef deque <  instr_item * > hud_deque_type;
547 //typedef hud_deque_type::iterator hud_deque_iterator;
548 //typedef hud_deque_type::const_iterator hud_deque_const_iterator;
549
550 extern deque< instr_item *> HUD_deque;
551 extern int HUD_style;
552 //extern hud_deque_type HUD_deque;
553
554 // instr_item           This class has no other purpose than to maintain
555 //                      a linked list of instrument and derived class
556 // object pointers.
557
558
559 class instr_label : public instr_item {
560 private:
561     const char *pformat;
562     const char *pre_str;
563     const char *post_str;
564     fgLabelJust justify;
565     int         fontSize;
566     int         blink;
567     char format_buffer[80];
568     bool                lat;
569     bool                lon;
570     bool                lbox;
571
572 public:
573     instr_label( int          x,
574                  int          y,
575                  UINT         width,
576                  UINT         height,
577                  FLTFNPTR     data_source,
578                  const char  *label_format,
579                  const char  *pre_label_string,
580                  const char  *post_label_string,
581                  float        scale_data,
582                  UINT         options,
583                  fgLabelJust  justification,
584                  int          font_size,
585                  int          blinking,
586                  bool             latitude,
587                  bool             longitude,
588                  bool             label_box,
589                  bool         working,
590                  int          digit ); //suma);
591
592     ~instr_label();
593
594     instr_label( const instr_label & image);
595     instr_label & operator = (const instr_label & rhs );
596     virtual void draw( void );       // Required method in base class
597 };
598
599 typedef instr_label * pInstlabel;
600
601
602 class lat_label : public instr_item {
603 private:
604     const char *pformat;
605     const char *pre_str;
606     const char *post_str;
607     fgLabelJust justify;
608     int         fontSize;
609     int         blink;
610     char format_buffer[80];
611
612 public:
613     lat_label( int          x,
614                int          y,
615                UINT         width,
616                UINT         height,
617                FLTFNPTR     data_source,
618                const char  *label_format,
619                const char  *pre_label_string,
620                const char  *post_label_string,
621                float       scale_data,
622                UINT         options,
623                fgLabelJust  justification,
624                int          font_size,
625                int          blinking,
626                bool         working,
627                int          digits =0 );//suma
628
629     ~lat_label();
630
631     lat_label( const lat_label & image);
632     lat_label & operator = (const lat_label & rhs );
633     virtual void draw( void );       // Required method in base class
634 };
635
636 typedef lat_label * pLatlabel;
637
638 class lon_label : public instr_item {
639 private:
640     const char *pformat;
641     const char *pre_str;
642     const char *post_str;
643     fgLabelJust justify;
644     int         fontSize;
645     int         blink;
646     char format_buffer[80];
647
648 public:
649     lon_label( int          x,
650                int          y,
651                UINT         width,
652                UINT         height,
653                FLTFNPTR     data_source,
654                const char  *label_format,
655                const char  *pre_label_string,
656                const char  *post_label_string,
657                float       scale_data,
658                UINT         options,
659                fgLabelJust  justification,
660                int          font_size,
661                int          blinking,
662                bool         working,
663                int          digit=0); //suma
664
665
666     ~lon_label();
667
668     lon_label( const lon_label & image);
669     lon_label & operator = (const lon_label & rhs );
670     virtual void draw( void );       // Required method in base class
671 };
672
673 typedef lon_label * pLonlabel;
674
675 //
676 // fgRunway_instr       This class is responsible for rendering the active runway
677 //                      in the hud (if visible).
678 class runway_instr : public instr_item 
679 {
680 private:        
681         void boundPoint(const sgdVec3& v, sgdVec3& m);
682         bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
683         bool drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& p1, const sgdVec3& p2);
684         void drawArrow();
685         bool get_active_runway(FGRunway& rwy);
686         void get_rwy_points(sgdVec3 *points);
687         void setLineWidth(void);
688
689         sgdVec3 points3d[6],points2d[6];
690         double mm[16],pm[16], arrowScale, arrowRad, lnScale, scaleDist, default_pitch, default_heading;
691         GLint view[4];
692         FGRunway runway;
693         FGViewer* cockpit_view; 
694         unsigned short stippleOut,stippleCen;
695         bool drawIA,drawIAAlways;
696         RECT location;
697         POINT center; 
698         
699 public:
700     runway_instr( int    x,
701                   int    y,                     
702                                   int    width,
703                                   int    height,
704                   float  scale_data,
705                   bool   working = true);
706
707     virtual void draw( void );       // Required method in base class
708         void setArrowRotationRadius(double radius);
709         void setArrowScale(double scale); // Scales the runway indication arrow
710         void setDrawArrow(bool draw);    // Draws arrow when runway is not visible in HUD if draw=true
711         void setDrawArrowAlways(bool draw); //Always draws arrow if draw=true;
712         void setLineScale(double scale); //Sets the maximum line scale
713         void setScaleDist(double dist_nm); //Sets the distance where to start scaling the lines
714         void setStippleOutline(unsigned short stipple); //Sets the stipple pattern of the outline of the runway
715         void setStippleCenterline(unsigned short stipple); //Sets the stipple patter of the center line of the runway
716 };
717
718
719 //
720 // instr_scale           This class is an abstract base class for both moving
721 //                       scale and moving needle (fixed scale) indicators. It
722 // does not draw itself, but is not instanciable.
723 //
724
725 class instr_scale : public instr_item {
726 private:
727     float range_shown;   // Width Units.
728     float Maximum_value; //                ceiling.
729     float Minimum_value; // Representation floor.
730     float scale_factor;  // factor => screen units/range values.
731     UINT   Maj_div;       // major division marker units
732     UINT   Min_div;       // minor division marker units
733     UINT   Modulo;        // Roll over point
734     int    signif_digits; // digits to show to the right.
735
736 public:
737     instr_scale( int          x,
738                  int          y,
739                  UINT         width,
740                  UINT         height,
741                  FLTFNPTR     load_fn,
742                  UINT         options,
743                  float       show_range,
744                  float       max_value,
745                  float       min_value,
746                  float       disp_scaling,
747                  UINT         major_divs,
748                  UINT         minor_divs,
749                  UINT         rollover,
750                  int          dp_showing,
751                  bool         working = true);
752
753     virtual ~instr_scale();
754     instr_scale( const instr_scale & image);
755     instr_scale & operator = (const instr_scale & rhs);
756
757     virtual void draw   ( void ) {}; // No-op here. Defined in derived classes.
758     UINT   div_min      ( void ) { return Min_div;}
759     UINT   div_max      ( void ) { return Maj_div;}
760     float min_val      ( void ) { return Minimum_value;}
761     float max_val      ( void ) { return Maximum_value;}
762     UINT   modulo       ( void ) { return Modulo; }
763     float factor       ( void ) { return scale_factor;}
764     float range_to_show( void ) { return range_shown;}
765 };
766
767 // hud_card_               This class displays the indicated quantity on
768 //                         a scale that moves past the pointer. It may be
769 // horizontal or vertical, read above(left) or below(right) of the base
770 // line.
771
772 class hud_card : public instr_scale {
773 private:
774     float val_span;
775     string type;
776     float half_width_units;
777     bool  draw_tick_bottom;
778     bool  draw_tick_top;
779     bool  draw_tick_right;
780     bool  draw_tick_left;
781     bool  draw_cap_bottom;
782     bool  draw_cap_top;
783     bool  draw_cap_right;
784     bool  draw_cap_left;
785     float marker_offset;
786     bool  pointer;
787     string  pointer_type;
788     string  tick_type;
789     string  tick_length;
790     float   radius; //suma
791     float   maxValue; //suma
792     float   minValue; //suma
793     int         divisions; //suma
794     int     zoom; //suma
795     UINT        Maj_div; //suma
796     UINT        Min_div; //suma
797         
798     
799 public:
800     hud_card( int      x,
801               int      y,
802               UINT     width,
803               UINT     height,
804               FLTFNPTR load_fn,
805               UINT     options,
806               float    maxValue,
807               float    minValue,
808               float    disp_scaling,
809               UINT     major_divs,
810               UINT     minor_divs,
811               UINT     modulator,
812               int      dp_showing,
813               float    value_span,
814               string   type,
815               bool     draw_tick_bottom,
816               bool     draw_tick_top,
817               bool     draw_tick_right,
818               bool     draw_tick_left,
819               bool     draw_cap_bottom,
820               bool     draw_cap_top,
821               bool     draw_cap_right,
822               bool     draw_cap_left,
823               float    marker_offset,
824               bool     pointer,
825               string   pointer_type,
826               string  tick_type,
827               string  tick_length,
828               bool     working,
829               float    radius, //suma
830               int      divisions, //suma
831               int       zoom //suma
832             );
833
834
835     ~hud_card();
836     hud_card( const hud_card & image);
837     hud_card & operator = (const hud_card & rhs );
838     //    virtual void display_enable( bool setting );
839     virtual void draw( void );       // Required method in base class
840     void circles(float,float,float); // suma
841     void fixed(float,float,float,float,float,float); //suma
842     void zoomed_scale(int,int); //suma
843 };
844
845 typedef hud_card * pCardScale;
846
847 class gauge_instr : public instr_scale {
848 public:
849     gauge_instr( int       x,
850                  int       y,
851                  UINT      width,
852                  UINT      height,
853                  FLTFNPTR  load_fn,
854                  UINT      options,
855                  float     disp_scaling,
856                  float     maxValue,
857                  float     minValue,
858                  UINT      major_divs,
859                  UINT      minor_divs,
860                  int       dp_showing,
861                  UINT      modulus,
862                  bool      working);
863
864     ~gauge_instr();
865     gauge_instr( const gauge_instr & image);
866     gauge_instr & operator = (const gauge_instr & rhs );
867     virtual void draw( void );       // Required method in base class
868 };
869
870 typedef gauge_instr * pGaugeInst;
871 //
872 // dual_instr_item         This class was created to form the base class
873 //                         for both panel and HUD Turn Bank Indicators.
874
875 class dual_instr_item : public instr_item {
876 private:
877     FLTFNPTR alt_data_source;
878
879 public:
880     dual_instr_item ( int       x,
881                       int       y,
882                       UINT      width,
883                       UINT      height,
884                       FLTFNPTR  chn1_source,
885                       FLTFNPTR  chn2_source,
886                       bool      working,
887                       UINT      options );
888
889     virtual ~dual_instr_item() {};
890     dual_instr_item( const dual_instr_item & image);
891     dual_instr_item & operator = (const dual_instr_item & rhs );
892
893     float current_ch1( void ) { return (float)alt_data_source();}
894     float current_ch2( void ) { return (float)get_value();}
895     virtual void draw ( void ) { }
896 };
897
898 class fgTBI_instr : public dual_instr_item 
899 {
900 private:
901     UINT BankLimit;
902     UINT SlewLimit;
903     UINT scr_hole;
904     bool tsi;  //suma
905     float rad; //suma
906
907 public:
908     fgTBI_instr( int       x,
909                  int       y,
910                  UINT      width,
911                  UINT      height,
912                  FLTFNPTR  chn1_source,
913                  FLTFNPTR  chn2_source,
914                  float    maxBankAngle,
915                  float    maxSlipAngle,
916                  UINT      gap_width,
917                  bool      working,
918                  bool      tsi, //suma
919                  float     rad); //suma
920
921     fgTBI_instr( const fgTBI_instr & image);
922     fgTBI_instr & operator = (const fgTBI_instr & rhs );
923
924     ~fgTBI_instr();
925
926     UINT bank_limit( void ) { return BankLimit;}
927     UINT slew_limit( void ) { return SlewLimit;}
928
929     virtual void draw( void );       // Required method in base class
930 };
931
932 typedef fgTBI_instr * pTBI;
933
934 class HudLadder : public dual_instr_item {
935 private:
936     UINT   width_units;
937     int    div_units;
938     UINT   minor_div;
939     UINT   label_pos;
940     UINT   scr_hole;
941     float  vmax;
942     float  vmin;
943     float  factor;
944     string hudladder_type;
945     bool   frl;
946     bool   target_spot;
947     bool   velocity_vector;
948     bool   drift_marker;
949     bool   alpha_bracket;
950     bool        energy_marker;
951     bool        climb_dive_marker;
952     bool        glide_slope_marker;
953     float       glide_slope;
954     bool        energy_worm;
955     bool        waypoint_marker;
956     int     zenith; //suma
957     int     nadir; //suma
958     int         hat; //suma
959     
960
961     // The Ladder has it's own temporary display lists
962     fgTextList         TextList;
963     fgLineList         LineList;
964     fgLineList         StippleLineList;
965
966 public:
967     HudLadder( const string&    name,
968                int       x,
969                int       y,
970                UINT      width,
971                UINT      height,
972                float     factor,
973                FLTFNPTR  ptch_source,
974                FLTFNPTR  roll_source,
975                float     span_units,
976                float     division_units,
977                float     minor_division,
978                UINT      screen_hole,
979                UINT      lbl_pos,
980                bool      frl,
981                bool      target_spot,
982                bool     velocity_vector,
983                bool     drift_marker,
984                bool     alpha_bracket,
985                bool      energy_marker,
986                bool      climb_dive_marker,
987                bool      glide_slope_marker,
988                float     glide_slope,
989                bool      energy_worm,
990                bool      waypoint_marker,
991                bool  working,
992                int   zenith, //suma
993                int   nadir, //suma
994                int      hat
995              ); //suma
996
997
998     ~HudLadder();
999
1000     HudLadder( const HudLadder & image );
1001     HudLadder & operator = ( const HudLadder & rhs );
1002     virtual void draw( void );
1003     void drawZenith(float,float,float); //suma
1004     void drawNadir(float, float, float); //suma
1005
1006     void Text( float x, float y, char *s)
1007     {
1008         TextList.add( fgText( x, y, s) );
1009     }
1010
1011     void Line( float x1, float y1, float x2, float y2)
1012     {
1013         LineList.add(fgLineSeg2D(x1,y1,x2,y2));
1014     }
1015
1016     void StippleLine( float x1, float y1, float x2, float y2)
1017     {
1018         StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
1019     }
1020 };
1021
1022
1023 //using namespace std;
1024 //deque <instr_item>  * Hdeque_ptr;
1025
1026 extern int  fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
1027 extern int  fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
1028 extern void fgUpdateHUD( void );
1029 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
1030                          GLfloat x_end, GLfloat y_end );
1031
1032 /*
1033 bool AddHUDInstrument( instr_item *pBlackBox );
1034 void DrawHUD ( void );
1035 bool DamageInstrument( INSTR_HANDLE unit );
1036 bool RepairInstrument( INSTR_HANDLE unit );
1037
1038
1039 void fgUpdateHUD ( Hptr hud );
1040 void fgUpdateHUD2( Hptr hud ); // Future use?
1041 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
1042 */
1043
1044
1045
1046
1047 class HUD_Properties : public SGPropertyChangeListener {
1048 public:
1049     HUD_Properties();
1050     void valueChanged(SGPropertyNode *n);
1051     void setColor() const;
1052     bool isVisible() const { return _visible; }
1053     bool isAntialiased() const { return _antialiased; }
1054
1055 private:
1056     float clamp(float f) { return f < 0.0f ? 0.0f : f > 1.0f ? 1.0f : f; }
1057     vector<SGPropertyNode_ptr> _colors;
1058     SGPropertyNode_ptr _which;
1059     SGPropertyNode_ptr _brightness;
1060     SGPropertyNode_ptr _alpha;
1061     SGPropertyNode_ptr _visibility;
1062     SGPropertyNode_ptr _antialiasing;
1063     bool _visible, _antialiased;
1064     float _r, _g, _b, _a;
1065 };
1066
1067 #endif // _HUD_H