]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud.hxx
A couple more straggling instrumentation clean ups.
[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., 675 Mass Ave, Cambridge, MA 02139, 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 <FDM/flight.hxx>
58 #include <Controls/controls.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 // DAY, NIGHT and brightness levels need to be visible where dialogs and
89 // controls can be used to set intensity and appropriate color. This will
90 // be moved.
91 // Hud general constants
92 #define HUD_DAY                1
93 #define HUD_NIGHT              2
94 #define HUD_BRT_BLACK          3
95 #define HUD_BRT_DARK           4
96 #define HUD_BRT_MEDIUM         5
97 #define HUD_BRT_LIGHT          6
98
99 // Label constants
100 #define HUD_FONT_SMALL     1
101 #define HUD_FONT_LARGE     2
102
103 enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
104
105 #define HUDS_AUTOTICKS           0x0001
106 #define HUDS_VERT                0x0002
107 #define HUDS_HORZ                0x0000
108 #define HUDS_TOP                 0x0004
109 #define HUDS_BOTTOM              0x0008
110 #define HUDS_LEFT     HUDS_TOP
111 #define HUDS_RIGHT    HUDS_BOTTOM
112 #define HUDS_BOTH     (HUDS_LEFT | HUDS_RIGHT)
113 #define HUDS_NOTICKS             0x0010
114 #define HUDS_ARITHTIC            0x0020
115 #define HUDS_DECITICS            0x0040
116 #define HUDS_NOTEXT              0x0080
117
118 // Ladder orientaion
119 // #define HUD_VERTICAL        1
120 // #define HUD_HORIZONTAL       2
121 // #define HUD_FREEFLOAT        3
122
123 // Ladder orientation modes
124 // #define HUD_LEFT         1
125 // #define HUD_RIGHT            2
126 // #define HUD_TOP              1
127 // #define HUD_BOTTOM           2
128 // #define HUD_V_LEFT           1
129 // #define HUD_V_RIGHT          2
130 // #define HUD_H_TOP            1
131 // #define HUD_H_BOTTOM         2
132
133
134 // Ladder sub-types
135 // #define HUD_LIM              1
136 // #define HUD_NOLIM            2
137 // #define HUD_CIRC         3
138
139 // #define HUD_INSTR_LADDER 1
140 // #define HUD_INSTR_CLADDER    2
141 // #define HUD_INSTR_HORIZON    3
142 // #define HUD_INSTR_LABEL      4
143
144 // in cockpit.cxx
145 extern float get_throttleval ( void );
146 extern float get_aileronval  ( void );
147 extern float get_elevatorval ( void );
148 extern float get_elev_trimval( void );
149 extern float get_rudderval   ( void );
150 extern float get_speed       ( void );
151 extern float get_aoa         ( void );
152 extern float get_nlf         ( void );
153 extern float get_roll        ( void );
154 extern float get_pitch       ( void );
155 extern float get_heading     ( void );
156 extern float get_view_direction( void );
157 extern float get_altitude    ( void );
158 extern float get_agl         ( void );
159 extern float get_sideslip    ( void );
160 extern float get_frame_rate  ( void );
161 extern float get_latitude    ( void );
162 extern float get_lat_min     ( void );
163 extern float get_longitude   ( void );
164 extern float get_long_min    ( void );
165 extern float get_fov         ( void );
166 extern float get_vfc_ratio   ( void );
167 extern float get_vfc_tris_drawn   ( void );
168 extern float get_vfc_tris_culled   ( void );
169 extern float get_climb_rate  ( void );
170 extern float get_mach( void );
171 extern char *coord_format_lat(float);
172 extern char *coord_format_lon(float);
173 //extern char *coord_format_latlon(float latitude, float longitude);  // cockpit.cxx
174
175 // $$$ begin - added, VS Renganathan, 13 Oct 2K
176 // #define FIGHTER_HUD
177 extern float get_anzg (void);
178 extern float get_Vx (void);
179 extern float get_Vy (void);
180 extern float get_Vz (void);
181 extern float get_Ax (void);
182 extern float get_Ay (void);
183 extern float get_Az (void);
184 extern int get_iaux1 (void);
185 extern int get_iaux2 (void);
186 extern int get_iaux3 (void);
187 extern int get_iaux4 (void);
188 extern int get_iaux5 (void);
189 extern int get_iaux6 (void);
190 extern int get_iaux7 (void);
191 extern int get_iaux8 (void);
192 extern int get_iaux9 (void);
193 extern int get_iaux10 (void);
194 extern int get_iaux11 (void);
195 extern int get_iaux12 (void);
196 extern float get_aux1(void);
197 extern float get_aux2(void);
198 extern float get_aux3(void);
199 extern float get_aux4(void);
200 extern float get_aux5 (void);
201 extern float get_aux6 (void);
202 extern float get_aux7 (void);
203 extern float get_aux8(void);
204 extern float get_aux9(void);
205 extern float get_aux10(void);
206 extern float get_aux11(void);
207 extern float get_aux12(void);
208 extern float get_aux13(void);
209 extern float get_aux14(void);
210 extern float get_aux15(void);
211 extern float get_aux16(void);
212 extern float get_aux17(void);
213 extern float get_aux18(void);
214 // $$$ end - added, VS Renganathan, 13 Oct 2K
215
216 extern char *get_formated_gmt_time( void );
217 extern void fgHUDReshape(void);
218
219 enum  hudinstype{ HUDno_instr,
220                   HUDscale,
221                   HUDlabel,
222                   HUDladder,
223                   HUDcirc_ladder,
224                   HUDhorizon,
225                   HUDgauge,
226                   HUDdual_inst,
227                   HUDmoving_scale,
228                   HUDtbi
229 };
230
231 typedef struct gltagRGBTRIPLE { // rgbt
232     GLfloat Blue;
233     GLfloat Green;
234     GLfloat Red;
235 } glRGBTRIPLE;
236
237 class fgLineSeg2D {
238 private:
239     GLfloat x0, y0, x1, y1;
240
241 public:
242     fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
243         : x0(a), y0(b),  x1(c), y1(d) {}
244
245     fgLineSeg2D( const fgLineSeg2D & image )
246         : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
247
248     fgLineSeg2D& operator= ( const fgLineSeg2D & image ) {
249         x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
250     }
251
252     ~fgLineSeg2D() {}
253     
254     void draw()
255     {
256         glVertex2f(x0, y0);
257         glVertex2f(x1, y1);
258     }
259 };
260
261 class DrawLineSeg2D {
262     public:
263         void operator() (fgLineSeg2D elem) const {
264             elem.draw();
265         }
266 };
267
268
269 #define USE_HUD_TextList
270 extern float              HUD_TextSize;
271 extern fntRenderer       *HUDtext;
272 extern float HUD_matrix[16];
273
274 class fgText {
275 private:
276     float x, y;
277     char msg[64];
278 public:
279     int digit; //suma
280     fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y) //suma
281     { 
282         strcpy(msg,c);
283         digit=digits; //suma
284     }
285                    
286     fgText( const fgText & image )
287         : x(image.x), y(image.y),digit(image.digit) {strcpy(msg,image.msg);} //suma
288
289     fgText& operator = ( const fgText & image ) {
290         strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit; //suma
291         return *this;   
292     }
293
294     ~fgText() {msg[0]='\0';}
295
296     int getStringWidth ( char *str )
297     {
298         if ( HUDtext && str ) {
299             float r, l ;
300             guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
301             return FloatToInt( r - l );
302         }
303         return 0 ;
304     }
305     
306     int StringWidth (void )
307     {
308         if ( HUDtext && strlen( msg )) {
309             float r, l ;
310             guiFntHandle->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
311             return FloatToInt( r - l );
312         }
313         return 0 ;
314     }
315    
316     // this code is changed to display Numbers with big/small digits
317     // according to MIL Standards for example Altitude above 10000 ft
318     // is shown as 10ooo.  begin suma
319
320     void Draw(fntRenderer *fnt,int digits) {
321         if(digits==1) {
322             int c=0,i=0;
323             char *t=msg;
324             int p=4;
325
326             if(t[0]=='-') {
327                 //if negative value then increase the c and p values
328                 //for '-' sign.  c++;
329                 p++;
330             }
331             char *tmp=msg;
332             while(tmp[i]!='\0') {
333                 if((tmp[i]>='0') && (tmp[i]<='9'))  
334                     c++;
335                 i++;
336             }
337             if(c>p) {
338                 fnt->setPointSize(8);
339                 int p1=c-3;
340                 char *tmp1=msg+p1;
341                 int p2=p1*8;
342                           
343                 fnt->start2f(x+p2,y);
344                 fnt->puts(tmp1);
345
346                 fnt->setPointSize(12);
347                 char tmp2[64];
348                 strncpy(tmp2,msg,p1);
349                 tmp2[p1]='\0';
350                          
351                 fnt->start2f(x,y);
352                 fnt->puts(tmp2);
353             } else {
354                 fnt->setPointSize(12);                                  
355                 fnt->start2f( x, y );
356                 fnt->puts(tmp);
357             }
358         } else {
359             //if digits not equal to 1
360             fnt->setPointSize(8);         
361             fnt->start2f( x, y );
362             fnt->puts( msg ) ;
363         }
364     }
365     //end suma
366
367     void Draw()
368     {
369         guiFnt.drawString( msg, FloatToInt(x), FloatToInt(y) );
370     }
371 };
372
373 class fgLineList {
374     vector < fgLineSeg2D > List;
375 public:
376     fgLineList( void ) {}
377     ~fgLineList( void ) {}
378     void add( fgLineSeg2D seg ) { List.push_back(seg); }
379     void erase( void ) { List.erase( List.begin(), List.end() ); }
380     void draw( void ) {
381         glBegin(GL_LINES);
382         for_each( List.begin(), List.end(), DrawLineSeg2D());
383         glEnd();
384     }
385 };
386
387 class fgTextList {
388     fntRenderer *Font;
389     vector< fgText > List;
390 public:
391     fgTextList ( void ) { Font = 0; }
392     ~fgTextList( void ) {}
393     
394     void setFont( fntRenderer *Renderer ) { Font = Renderer; }
395     void add( fgText String ) { List.push_back(String); }
396     void erase( void ) { List.erase( List.begin(), List.end() ); }
397     
398     void draw( void ) {
399         if( Font == 0 )
400             return;
401         vector < fgText > :: iterator curString = List.begin();
402         vector < fgText > :: iterator lastString = List.end();
403
404         glPushAttrib( GL_COLOR_BUFFER_BIT );
405         glEnable    ( GL_ALPHA_TEST   ) ;
406         glEnable    ( GL_BLEND        ) ;
407         glAlphaFunc ( GL_GREATER, 0.1 ) ;
408         glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
409
410         Font->begin();
411         for( ; curString != lastString; curString++ ) {
412             curString->Draw(Font,curString->digit); //suma
413         }
414         Font->end();
415
416         glDisable ( GL_TEXTURE_2D ) ;
417         glPopAttrib();
418     }
419 };
420
421
422 inline void Text( fgTextList &List, float x, float y, char *s)
423 {
424     List.add( fgText( x, y, s) );
425 }
426
427 inline void Text( fgTextList &List, fgText &me)
428 {
429     List.add(me);
430 }
431
432 inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
433 {
434     List.add(fgLineSeg2D(x1,y1,x2,y2));
435 }
436
437
438 // Declare our externals
439 extern fgTextList         HUD_TextList;
440 extern fgLineList         HUD_LineList;
441 extern fgLineList         HUD_StippleLineList;
442
443
444 class instr_item {  // An Abstract Base Class (ABC)
445 private:
446     static UINT        instances;     // More than 64K instruments? Nah!
447     static int         brightness;
448     static glRGBTRIPLE color;
449
450     UINT               handle;
451     RECT               scrn_pos;      // Framing - affects scale dimensions
452                                       // and orientation. Vert vs Horz, etc.
453     FLTFNPTR           load_value_fn;
454     float              disp_factor;   // Multiply by to get numbers shown on scale.
455     UINT               opts;
456     bool               is_enabled;
457     bool               broken;
458     UINT               scr_span;      // Working values for draw;
459     POINT              mid_span;      //
460     int                digits;        //suma
461   
462 public:
463     instr_item( int            x,
464                 int            y,
465                 UINT           height,
466                 UINT           width,
467                 FLTFNPTR       data_source,
468                 float          data_scaling,
469                 UINT           options,
470                 bool           working  = true,
471                 int            digit = 0); //suma
472
473     instr_item( const instr_item & image );
474
475     instr_item & operator = ( const instr_item & rhs );
476     virtual ~instr_item ();
477
478     int     get_brightness  ( void ) { return brightness;}
479     RECT    get_location    ( void ) { return scrn_pos;  }
480     bool    is_broken       ( void ) { return broken;    }
481     bool    enabled         ( void ) { return is_enabled;}
482     bool    data_available  ( void ) { return !!load_value_fn; }
483     float   get_value       ( void ) { return load_value_fn(); }
484     float   data_scaling    ( void ) { return disp_factor; }
485     UINT    get_span        ( void ) { return scr_span;  }
486     POINT   get_centroid    ( void ) { return mid_span;  }
487     UINT    get_options     ( void ) { return opts;      }
488     int     get_digits      ( void ) { return digits;    } //suma
489
490     UINT    huds_vert     (UINT options) { return( options  & HUDS_VERT ); }
491     UINT    huds_left     (UINT options) { return( options  & HUDS_LEFT ); }
492     UINT    huds_right    (UINT options) { return( options  & HUDS_RIGHT ); }
493     UINT    huds_both     (UINT options) {
494         return( (options & HUDS_BOTH) == HUDS_BOTH );
495     }
496     UINT    huds_noticks  (UINT options) { return( options  & HUDS_NOTICKS ); }
497     UINT    huds_notext   (UINT options) { return( options  & HUDS_NOTEXT ); }
498     UINT    huds_top      (UINT options) { return( options  & HUDS_TOP ); }
499     UINT    huds_bottom   (UINT options) { return( options  & HUDS_BOTTOM ); }
500   
501     virtual void display_enable( bool working ) { is_enabled = !! working;}
502
503     virtual void update( void );
504     virtual void break_display ( bool bad );
505     virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
506     void         SetPosition  ( int x, int y, UINT width, UINT height );
507     UINT         get_Handle( void );
508     virtual void draw( void ) = 0;   // Required method in derived classes
509     
510     void drawOneLine( float x1, float y1, float x2, float y2)
511     {
512         HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
513     }
514     void drawOneStippleLine( float x1, float y1, float x2, float y2)
515     {
516         HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
517     }
518     void TextString( char *msg, float x, float y,int digit ) //suma
519     {
520         HUD_TextList.add(fgText(x, y, msg,digit)); //suma  
521     }
522     int getStringWidth ( char *str )
523     {
524         if ( HUDtext && str ) {
525             float r, l ;
526             guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
527             return FloatToInt( r - l );
528         }
529         return 0 ;
530     }
531
532     //code to draw ticks as small circles
533     void drawOneCircle(float x1, float y1, float r)
534     {
535         glBegin(GL_LINE_LOOP);  // Use polygon to approximate a circle 
536         for(int count=0; count<25; count++) {             
537             float cosine = r * cos(count * 2 * SG_PI/10.0); 
538             float sine =   r * sin(count * 2 * SG_PI/10.0); 
539             glVertex2f(cosine+x1, sine+y1);
540         }     
541         glEnd(); 
542     }
543     
544 };
545
546 typedef instr_item *HIptr;
547
548 class HUDdraw {
549     public:
550         void operator() (HIptr elem) const {
551             if( elem->enabled())
552                 elem->draw();
553         }
554 };
555
556 //typedef deque <  instr_item * > hud_deque_type;
557 //typedef hud_deque_type::iterator hud_deque_iterator;
558 //typedef hud_deque_type::const_iterator hud_deque_const_iterator;
559
560 extern deque< instr_item *> HUD_deque;
561 extern int HUD_style;
562 //extern hud_deque_type HUD_deque;
563
564 // instr_item           This class has no other purpose than to maintain
565 //                      a linked list of instrument and derived class
566 // object pointers.
567
568
569 class instr_label : public instr_item {
570 private:
571     const char *pformat;
572     const char *pre_str;
573     const char *post_str;
574     fgLabelJust justify;
575     int         fontSize;
576     int         blink;
577     char format_buffer[80];
578     bool                lat;
579     bool                lon;
580     bool                lbox;
581
582 public:
583     instr_label( int          x,
584                  int          y,
585                  UINT         width,
586                  UINT         height,
587                  FLTFNPTR     data_source,
588                  const char  *label_format,
589                  const char  *pre_label_string,
590                  const char  *post_label_string,
591                  float        scale_data,
592                  UINT         options,
593                  fgLabelJust  justification,
594                  int          font_size,
595                  int          blinking,
596                  bool             latitude,
597                  bool             longitude,
598                  bool             label_box,
599                  bool         working,
600                  int          digit ); //suma);
601
602     ~instr_label();
603
604     instr_label( const instr_label & image);
605     instr_label & operator = (const instr_label & rhs );
606     virtual void draw( void );       // Required method in base class
607 };
608
609 typedef instr_label * pInstlabel;
610
611
612 class lat_label : public instr_item {
613 private:
614     const char *pformat;
615     const char *pre_str;
616     const char *post_str;
617     fgLabelJust justify;
618     int         fontSize;
619     int         blink;
620     char format_buffer[80];
621
622 public:
623     lat_label( int          x,
624                int          y,
625                UINT         width,
626                UINT         height,
627                FLTFNPTR     data_source,
628                const char  *label_format,
629                const char  *pre_label_string,
630                const char  *post_label_string,
631                float       scale_data,
632                UINT         options,
633                fgLabelJust  justification,
634                int          font_size,
635                int          blinking,
636                bool         working,
637                int          digits =0 );//suma
638
639     ~lat_label();
640
641     lat_label( const lat_label & image);
642     lat_label & operator = (const lat_label & rhs );
643     virtual void draw( void );       // Required method in base class
644 };
645
646 typedef lat_label * pLatlabel;
647
648 class lon_label : public instr_item {
649 private:
650     const char *pformat;
651     const char *pre_str;
652     const char *post_str;
653     fgLabelJust justify;
654     int         fontSize;
655     int         blink;
656     char format_buffer[80];
657
658 public:
659     lon_label( int          x,
660                int          y,
661                UINT         width,
662                UINT         height,
663                FLTFNPTR     data_source,
664                const char  *label_format,
665                const char  *pre_label_string,
666                const char  *post_label_string,
667                float       scale_data,
668                UINT         options,
669                fgLabelJust  justification,
670                int          font_size,
671                int          blinking,
672                bool         working,
673                int          digit=0); //suma
674
675
676     ~lon_label();
677
678     lon_label( const lon_label & image);
679     lon_label & operator = (const lon_label & rhs );
680     virtual void draw( void );       // Required method in base class
681 };
682
683 typedef lon_label * pLonlabel;
684
685 //
686 // fgRunway_instr       This class is responsible for rendering the active runway
687 //                      in the hud (if visible).
688 class runway_instr : public instr_item 
689 {
690 private:        
691         void boundPoint(sgdVec3 v, sgdVec3 m);
692         bool boundOutsidePoints(sgdVec3 v, sgdVec3 m);
693         bool drawLine(sgdVec3 a1, sgdVec3 a2, sgdVec3 p1, sgdVec3 p2);
694         void drawArrow();
695         bool get_active_runway(FGRunway& rwy);
696         void get_rwy_points(sgdVec3 *points);
697         void setLineWidth(void);
698
699         sgdVec3 points3d[6],points2d[6];
700         double mm[16],pm[16], arrowScale, arrowRad, lnScale, scaleDist, default_pitch, default_heading;
701         int view[4];
702         FGRunway runway;
703         FGViewer* cockpit_view; 
704         unsigned short stippleOut,stippleCen;
705         bool drawIA,drawIAAlways;
706         RECT location;
707         POINT center; 
708         
709 public:
710     runway_instr( int    x,
711                   int    y,                     
712                                   int    width,
713                                   int    height,
714                   float  scale_data,
715                   bool   working = true);
716
717     virtual void draw( void );       // Required method in base class
718         void setArrowRotationRadius(double radius);
719         void setArrowScale(double scale); // Scales the runway indication arrow
720         void setDrawArrow(bool draw);    // Draws arrow when runway is not visible in HUD if draw=true
721         void setDrawArrowAlways(bool draw); //Always draws arrow if draw=true;
722         void setLineScale(double scale); //Sets the maximum line scale
723         void setScaleDist(double dist_nm); //Sets the distance where to start scaling the lines
724         void setStippleOutline(unsigned short stipple); //Sets the stipple pattern of the outline of the runway
725         void setStippleCenterline(unsigned short stipple); //Sets the stipple patter of the center line of the runway
726 };
727
728
729 //
730 // instr_scale           This class is an abstract base class for both moving
731 //                       scale and moving needle (fixed scale) indicators. It
732 // does not draw itself, but is not instanciable.
733 //
734
735 class instr_scale : public instr_item {
736 private:
737     float range_shown;   // Width Units.
738     float Maximum_value; //                ceiling.
739     float Minimum_value; // Representation floor.
740     float scale_factor;  // factor => screen units/range values.
741     UINT   Maj_div;       // major division marker units
742     UINT   Min_div;       // minor division marker units
743     UINT   Modulo;        // Roll over point
744     int    signif_digits; // digits to show to the right.
745
746 public:
747     instr_scale( int          x,
748                  int          y,
749                  UINT         width,
750                  UINT         height,
751                  FLTFNPTR     load_fn,
752                  UINT         options,
753                  float       show_range,
754                  float       max_value,
755                  float       min_value,
756                  float       disp_scaling,
757                  UINT         major_divs,
758                  UINT         minor_divs,
759                  UINT         rollover,
760                  int          dp_showing,
761                  bool         working = true);
762
763     virtual ~instr_scale();
764     instr_scale( const instr_scale & image);
765     instr_scale & operator = (const instr_scale & rhs);
766
767     virtual void draw   ( void ) {}; // No-op here. Defined in derived classes.
768     UINT   div_min      ( void ) { return Min_div;}
769     UINT   div_max      ( void ) { return Maj_div;}
770     float min_val      ( void ) { return Minimum_value;}
771     float max_val      ( void ) { return Maximum_value;}
772     UINT   modulo       ( void ) { return Modulo; }
773     float factor       ( void ) { return scale_factor;}
774     float range_to_show( void ) { return range_shown;}
775 };
776
777 // hud_card_               This class displays the indicated quantity on
778 //                         a scale that moves past the pointer. It may be
779 // horizontal or vertical, read above(left) or below(right) of the base
780 // line.
781
782 class hud_card : public instr_scale {
783 private:
784     float val_span;
785     string type;
786     float half_width_units;
787     bool  draw_tick_bottom;
788     bool  draw_tick_top;
789     bool  draw_tick_right;
790     bool  draw_tick_left;
791     bool  draw_cap_bottom;
792     bool  draw_cap_top;
793     bool  draw_cap_right;
794     bool  draw_cap_left;
795     float marker_offset;
796     bool  pointer;
797     string  pointer_type;
798     string  tick_type;
799     string  tick_length;
800     float   radius; //suma
801     float   maxValue; //suma
802     float   minValue; //suma
803     int         divisions; //suma
804     int     zoom; //suma
805     UINT        Maj_div; //suma
806     UINT        Min_div; //suma
807         
808     
809 public:
810     hud_card( int      x,
811               int      y,
812               UINT     width,
813               UINT     height,
814               FLTFNPTR load_fn,
815               UINT     options,
816               float    maxValue,
817               float    minValue,
818               float    disp_scaling,
819               UINT     major_divs,
820               UINT     minor_divs,
821               UINT     modulator,
822               int      dp_showing,
823               float    value_span,
824               string   type,
825               bool     draw_tick_bottom,
826               bool     draw_tick_top,
827               bool     draw_tick_right,
828               bool     draw_tick_left,
829               bool     draw_cap_bottom,
830               bool     draw_cap_top,
831               bool     draw_cap_right,
832               bool     draw_cap_left,
833               float    marker_offset,
834               bool     pointer,
835               string   pointer_type,
836               string  tick_type,
837               string  tick_length,
838               bool     working,
839               float    radius, //suma
840               int      divisions, //suma
841               int       zoom //suma
842             );
843
844
845     ~hud_card();
846     hud_card( const hud_card & image);
847     hud_card & operator = (const hud_card & rhs );
848     //    virtual void display_enable( bool setting );
849     virtual void draw( void );       // Required method in base class
850     void circles(float,float,float); // suma
851     void fixed(float,float,float,float,float,float); //suma
852     void zoomed_scale(int,int); //suma
853 };
854
855 typedef hud_card * pCardScale;
856
857 class gauge_instr : public instr_scale {
858 public:
859     gauge_instr( int       x,
860                  int       y,
861                  UINT      width,
862                  UINT      height,
863                  FLTFNPTR  load_fn,
864                  UINT      options,
865                  float     disp_scaling,
866                  float     maxValue,
867                  float     minValue,
868                  UINT      major_divs,
869                  UINT      minor_divs,
870                  int       dp_showing,
871                  UINT      modulus,
872                  bool      working);
873
874     ~gauge_instr();
875     gauge_instr( const gauge_instr & image);
876     gauge_instr & operator = (const gauge_instr & rhs );
877     virtual void draw( void );       // Required method in base class
878 };
879
880 typedef gauge_instr * pGaugeInst;
881 //
882 // dual_instr_item         This class was created to form the base class
883 //                         for both panel and HUD Turn Bank Indicators.
884
885 class dual_instr_item : public instr_item {
886 private:
887     FLTFNPTR alt_data_source;
888
889 public:
890     dual_instr_item ( int       x,
891                       int       y,
892                       UINT      width,
893                       UINT      height,
894                       FLTFNPTR  chn1_source,
895                       FLTFNPTR  chn2_source,
896                       bool      working,
897                       UINT      options );
898
899     virtual ~dual_instr_item() {};
900     dual_instr_item( const dual_instr_item & image);
901     dual_instr_item & operator = (const dual_instr_item & rhs );
902
903     float current_ch1( void ) { return (float)alt_data_source();}
904     float current_ch2( void ) { return (float)get_value();}
905     virtual void draw ( void ) { }
906 };
907
908 class fgTBI_instr : public dual_instr_item 
909 {
910 private:
911     UINT BankLimit;
912     UINT SlewLimit;
913     UINT scr_hole;
914     bool tsi;  //suma
915     float rad; //suma
916
917 public:
918     fgTBI_instr( int       x,
919                  int       y,
920                  UINT      width,
921                  UINT      height,
922                  FLTFNPTR  chn1_source,
923                  FLTFNPTR  chn2_source,
924                  float    maxBankAngle,
925                  float    maxSlipAngle,
926                  UINT      gap_width,
927                  bool      working,
928                  bool      tsi, //suma
929                  float     rad); //suma
930
931     fgTBI_instr( const fgTBI_instr & image);
932     fgTBI_instr & operator = (const fgTBI_instr & rhs );
933
934     ~fgTBI_instr();
935
936     UINT bank_limit( void ) { return BankLimit;}
937     UINT slew_limit( void ) { return SlewLimit;}
938
939     virtual void draw( void );       // Required method in base class
940 };
941
942 typedef fgTBI_instr * pTBI;
943
944 class HudLadder : public dual_instr_item {
945 private:
946     UINT   width_units;
947     int    div_units;
948     UINT   minor_div;
949     UINT   label_pos;
950     UINT   scr_hole;
951     float  vmax;
952     float  vmin;
953     float  factor;
954     string hudladder_type;
955     bool   frl;
956     bool   target_spot;
957     bool   velocity_vector;
958     bool   drift_marker;
959     bool   alpha_bracket;
960     bool        energy_marker;
961     bool        climb_dive_marker;
962     bool        glide_slope_marker;
963     float       glide_slope;
964     bool        energy_worm;
965     bool        waypoint_marker;
966     int     zenith; //suma
967     int     nadir; //suma
968     int         hat; //suma
969     
970
971     // The Ladder has it's own temporary display lists
972     fgTextList         TextList;
973     fgLineList         LineList;
974     fgLineList         StippleLineList;
975
976 public:
977     HudLadder( string    name,
978                int       x,
979                int       y,
980                UINT      width,
981                UINT      height,
982                float     factor,
983                FLTFNPTR  ptch_source,
984                FLTFNPTR  roll_source,
985                float     span_units,
986                float     division_units,
987                float     minor_division,
988                UINT      screen_hole,
989                UINT      lbl_pos,
990                bool      frl,
991                bool      target_spot,
992                bool     velocity_vector,
993                bool     drift_marker,
994                bool     alpha_bracket,
995                bool      energy_marker,
996                bool      climb_dive_marker,
997                bool      glide_slope_marker,
998                float     glide_slope,
999                bool      energy_worm,
1000                bool      waypoint_marker,
1001                bool  working,
1002                int   zenith, //suma
1003                int   nadir, //suma
1004                int      hat
1005              ); //suma
1006
1007
1008     ~HudLadder();
1009
1010     HudLadder( const HudLadder & image );
1011     HudLadder & operator = ( const HudLadder & rhs );
1012     virtual void draw( void );
1013     void drawZenith(float,float,float); //suma
1014     void drawNadir(float, float, float); //suma
1015
1016     void Text( float x, float y, char *s)
1017     {
1018         TextList.add( fgText( x, y, s) );
1019     }
1020
1021     void Line( float x1, float y1, float x2, float y2)
1022     {
1023         LineList.add(fgLineSeg2D(x1,y1,x2,y2));
1024     }
1025
1026     void StippleLine( float x1, float y1, float x2, float y2)
1027     {
1028         StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
1029     }
1030 };
1031
1032
1033 //using namespace std;
1034 //deque <instr_item>  * Hdeque_ptr;
1035
1036 extern void HUD_masterswitch( bool incr );
1037 extern void HUD_brightkey( bool incr_bright );
1038 extern int  fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
1039 extern int  fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
1040 extern void fgUpdateHUD( void );
1041 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
1042                          GLfloat x_end, GLfloat y_end );
1043
1044 /*
1045 bool AddHUDInstrument( instr_item *pBlackBox );
1046 void DrawHUD ( void );
1047 bool DamageInstrument( INSTR_HANDLE unit );
1048 bool RepairInstrument( INSTR_HANDLE unit );
1049
1050
1051 void fgUpdateHUD ( Hptr hud );
1052 void fgUpdateHUD2( Hptr hud ); // Future use?
1053 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
1054 */
1055
1056 #endif // _HUD_H