]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/hud.hxx
Go back to the simpler arrangement syntax of a map of vectors.
[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 GLUT_H
42
43 #include <stdlib.h>
44 #include <string.h>
45
46 //#ifdef HAVE_VALUES_H
47 //#  include <values.h>  // for MAXINT
48 //#endif
49
50 #include <vector>       // STL vector
51 #include <deque>        // STL double ended queue
52 #include STL_FSTREAM
53
54 #include <simgear/constants.h>
55
56 #include <Include/fg_typedefs.h>
57 #include <Aircraft/aircraft.hxx>
58 #include <FDM/flight.hxx>
59 #include <Controls/controls.hxx>
60 #include <GUI/gui.h>
61 #include <Main/globals.hxx>
62 #include <Main/viewmgr.hxx>
63
64 #include "hud_opts.hxx"
65
66 SG_USING_STD(deque);
67 SG_USING_STD(vector);
68 SG_USING_NAMESPACE(std);
69
70
71 // some of Norman's crazy optimizations. :-)
72
73 #ifndef WIN32
74 typedef struct {
75     int x, y;
76 } POINT;
77  
78 typedef struct {
79     int top, bottom, left, right;
80 } RECT;
81 #endif
82
83 // View mode definitions
84
85 enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
86
87 // DAY, NIGHT and brightness levels need to be visible where dialogs and
88 // controls can be used to set intensity and appropriate color. This will
89 // be moved.
90 // Hud general constants
91 #define HUD_DAY                1
92 #define HUD_NIGHT              2
93 #define HUD_BRT_BLACK          3
94 #define HUD_BRT_DARK           4
95 #define HUD_BRT_MEDIUM         5
96 #define HUD_BRT_LIGHT          6
97
98 // Label constants
99 #define HUD_FONT_SMALL     1
100 #define HUD_FONT_LARGE     2
101
102 enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
103
104 #define HUDS_AUTOTICKS           0x0001
105 #define HUDS_VERT                0x0002
106 #define HUDS_HORZ                0x0000
107 #define HUDS_TOP                 0x0004
108 #define HUDS_BOTTOM              0x0008
109 #define HUDS_LEFT     HUDS_TOP
110 #define HUDS_RIGHT    HUDS_BOTTOM
111 #define HUDS_BOTH     (HUDS_LEFT | HUDS_RIGHT)
112 #define HUDS_NOTICKS             0x0010
113 #define HUDS_ARITHTIC            0x0020
114 #define HUDS_DECITICS            0x0040
115 #define HUDS_NOTEXT              0x0080
116
117 // Ladder orientaion
118 // #define HUD_VERTICAL        1
119 // #define HUD_HORIZONTAL       2
120 // #define HUD_FREEFLOAT        3
121
122 // Ladder orientation modes
123 // #define HUD_LEFT         1
124 // #define HUD_RIGHT            2
125 // #define HUD_TOP              1
126 // #define HUD_BOTTOM           2
127 // #define HUD_V_LEFT           1
128 // #define HUD_V_RIGHT          2
129 // #define HUD_H_TOP            1
130 // #define HUD_H_BOTTOM         2
131
132
133 // Ladder sub-types
134 // #define HUD_LIM              1
135 // #define HUD_NOLIM            2
136 // #define HUD_CIRC         3
137
138 // #define HUD_INSTR_LADDER 1
139 // #define HUD_INSTR_CLADDER    2
140 // #define HUD_INSTR_HORIZON    3
141 // #define HUD_INSTR_LABEL      4
142
143 // in cockpit.cxx
144 extern float get_throttleval ( void );
145 extern float get_aileronval  ( void );
146 extern float get_elevatorval ( void );
147 extern float get_elev_trimval( void );
148 extern float get_rudderval   ( void );
149 extern float get_speed       ( void );
150 extern float get_aoa         ( void );
151 extern float get_nlf         ( void );
152 extern float get_roll        ( void );
153 extern float get_pitch       ( void );
154 extern float get_heading     ( void );
155 extern float get_view_direction( void );
156 extern float get_altitude    ( void );
157 extern float get_agl         ( void );
158 extern float get_sideslip    ( void );
159 extern float get_frame_rate  ( void );
160 extern float get_latitude    ( void );
161 extern float get_lat_min     ( void );
162 extern float get_longitude   ( void );
163 extern float get_long_min    ( void );
164 extern float get_fov         ( void );
165 extern float get_vfc_ratio   ( void );
166 extern float get_vfc_tris_drawn   ( void );
167 extern float get_vfc_tris_culled   ( void );
168 extern float get_climb_rate  ( void );
169 extern float get_mach( void );
170 extern char *coord_format_lat(float);
171 extern char *coord_format_lon(float);
172 //extern char *coord_format_latlon(float latitude, float longitude);  // cockpit.cxx
173
174 // $$$ begin - added, VS Renganathan, 13 Oct 2K
175 // #define FIGHTER_HUD
176 extern float get_anzg (void);
177 extern float get_Vx (void);
178 extern float get_Vy (void);
179 extern float get_Vz (void);
180 extern float get_Ax (void);
181 extern float get_Ay (void);
182 extern float get_Az (void);
183 extern int get_iaux1 (void);
184 extern int get_iaux2 (void);
185 extern int get_iaux3 (void);
186 extern int get_iaux4 (void);
187 extern int get_iaux5 (void);
188 extern int get_iaux6 (void);
189 extern int get_iaux7 (void);
190 extern int get_iaux8 (void);
191 extern int get_iaux9 (void);
192 extern int get_iaux10 (void);
193 extern int get_iaux11 (void);
194 extern int get_iaux12 (void);
195 extern float get_aux1(void);
196 extern float get_aux2(void);
197 extern float get_aux3(void);
198 extern float get_aux4(void);
199 extern float get_aux5 (void);
200 extern float get_aux6 (void);
201 extern float get_aux7 (void);
202 extern float get_aux8(void);
203 extern float get_aux9(void);
204 extern float get_aux10(void);
205 extern float get_aux11(void);
206 extern float get_aux12(void);
207 extern float get_aux13(void);
208 extern float get_aux14(void);
209 extern float get_aux15(void);
210 extern float get_aux16(void);
211 extern float get_aux17(void);
212 extern float get_aux18(void);
213 // $$$ end - added, VS Renganathan, 13 Oct 2K
214
215 extern char *get_formated_gmt_time( void );
216 extern void fgHUDReshape(void);
217
218 enum  hudinstype{ HUDno_instr,
219                   HUDscale,
220                   HUDlabel,
221                   HUDladder,
222                   HUDcirc_ladder,
223                   HUDhorizon,
224                   HUDgauge,
225                   HUDdual_inst,
226                   HUDmoving_scale,
227                   HUDtbi
228 };
229
230 typedef struct gltagRGBTRIPLE { // rgbt
231     GLfloat Blue;
232     GLfloat Green;
233     GLfloat Red;
234 } glRGBTRIPLE;
235
236 class fgLineSeg2D {
237 private:
238     GLfloat x0, y0, x1, y1;
239
240 public:
241     fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
242         : x0(a), y0(b),  x1(c), y1(d) {}
243
244     fgLineSeg2D( const fgLineSeg2D & image )
245         : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
246
247     fgLineSeg2D& operator= ( const fgLineSeg2D & image ) {
248         x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
249     }
250
251     ~fgLineSeg2D() {}
252     
253     void draw()
254     {
255         glVertex2f(x0, y0);
256         glVertex2f(x1, y1);
257     }
258 };
259
260 #define USE_HUD_TextList
261 extern float              HUD_TextSize;
262 extern fntRenderer       *HUDtext;
263 extern float HUD_matrix[16];
264
265 class fgText {
266 private:
267     float x, y;
268     char msg[64];
269 public:
270     int digit; //suma
271     fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y) //suma
272     { 
273         strcpy(msg,c);
274         digit=digits; //suma
275     }
276                    
277     fgText( const fgText & image )
278         : x(image.x), y(image.y),digit(image.digit) {strcpy(msg,image.msg);} //suma
279
280     fgText& operator = ( const fgText & image ) {
281         strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit; //suma
282         return *this;   
283     }
284
285     ~fgText() {msg[0]='\0';}
286
287     int getStringWidth ( char *str )
288     {
289         if ( HUDtext && str ) {
290             float r, l ;
291             guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
292             return FloatToInt( r - l );
293         }
294         return 0 ;
295     }
296     
297     int StringWidth (void )
298     {
299         if ( HUDtext && strlen( msg )) {
300             float r, l ;
301             guiFntHandle->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
302             return FloatToInt( r - l );
303         }
304         return 0 ;
305     }
306    
307     // this code is changed to display Numbers with big/small digits
308     // according to MIL Standards for example Altitude above 10000 ft
309     // is shown as 10ooo.  begin suma
310
311     void Draw(fntRenderer *fnt,int digits) {
312         if(digits==1) {
313             int c=0,i=0;
314             char *t=msg;
315             int p=4;
316
317             if(t[0]=='-') {
318                 //if negative value then increase the c and p values
319                 //for '-' sign.  c++;
320                 p++;
321             }
322             char *tmp=msg;
323             while(tmp[i]!='\0') {
324                 if((tmp[i]>='0') && (tmp[i]<='9'))  
325                     c++;
326                 i++;
327             }
328             if(c>p) {
329                 fnt->setPointSize(8);
330                 int p1=c-3;
331                 char *tmp1=msg+p1;
332                 int p2=p1*8;
333                           
334                 fnt->start2f(x+p2,y);
335                 fnt->puts(tmp1);
336
337                 fnt->setPointSize(12);
338                 char tmp2[64];
339                 strncpy(tmp2,msg,p1);
340                 tmp2[p1]='\0';
341                          
342                 fnt->start2f(x,y);
343                 fnt->puts(tmp2);
344             } else {
345                 fnt->setPointSize(12);                                  
346                 fnt->start2f( x, y );
347                 fnt->puts(tmp);
348             }
349         } else {
350             //if digits not equal to 1
351             fnt->setPointSize(8);         
352             fnt->start2f( x, y );
353             fnt->puts( msg ) ;
354         }
355     }
356     //end suma
357
358     void Draw()
359     {
360         guiFnt.drawString( msg, FloatToInt(x), FloatToInt(y) );
361     }
362 };
363
364 class fgLineList {
365     vector < fgLineSeg2D > List;
366 public:
367     fgLineList( void ) {}
368     ~fgLineList( void ) {}
369     void add( fgLineSeg2D seg ) { List.push_back(seg); }
370     void erase( void ) { List.erase( List.begin(), List.end() ); }
371     void draw( void ) {
372         vector < fgLineSeg2D > :: iterator curSeg;
373         vector < fgLineSeg2D > :: iterator lastSeg;
374         curSeg  = List.begin();
375         lastSeg = List.end();
376         glBegin(GL_LINES);
377         for ( ; curSeg != lastSeg; curSeg++ ) {
378             curSeg->draw();
379         }
380         glEnd();
381     }
382     /*    void draw( void ) {
383           vector < fgLineSeg2D > :: iterator curSeg;
384           vector < fgLineSeg2D > :: iterator lastSeg;
385           curSeg  = List.begin();
386           lastSeg = List.end();
387           glBegin(GL_LINES);
388           for ( ; curSeg != lastSeg; curSeg++ ) {
389           curSeg->draw();
390           }
391           glEnd();
392           } */
393 };
394
395 class fgTextList {
396     fntRenderer *Font;
397     vector< fgText > List;
398 public:
399     fgTextList ( void ) { Font = 0; }
400     ~fgTextList( void ) {}
401     
402     void setFont( fntRenderer *Renderer ) { Font = Renderer; }
403     void add( fgText String ) { List.push_back(String); }
404     void erase( void ) { List.erase( List.begin(), List.end() ); }
405     
406     void draw( void ) {
407         vector < fgText > :: iterator curString;
408         vector < fgText > :: iterator lastString;
409         if( Font == 0 ) return;
410         curString  = List.begin();
411         lastString = List.end();
412         glPushAttrib( GL_COLOR_BUFFER_BIT );
413         glEnable    ( GL_ALPHA_TEST   ) ;
414         glEnable    ( GL_BLEND        ) ;
415         glAlphaFunc ( GL_GREATER, 0.1 ) ;
416         glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
417
418         Font->begin();
419         for( ; curString != lastString; curString++ ) {
420             curString->Draw(Font,curString->digit); //suma
421         }
422         Font->end();
423
424         glDisable ( GL_TEXTURE_2D ) ;
425         glPopAttrib();
426     }
427 };
428
429
430 inline void Text( fgTextList &List, float x, float y, char *s)
431 {
432     List.add( fgText( x, y, s) );
433 }
434
435 inline void Text( fgTextList &List, fgText &me)
436 {
437     List.add(me);
438 }
439
440 inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
441 {
442     List.add(fgLineSeg2D(x1,y1,x2,y2));
443 }
444
445
446 // Declare our externals
447 extern fgTextList         HUD_TextList;
448 extern fgLineList         HUD_LineList;
449 extern fgLineList         HUD_StippleLineList;
450
451
452 class instr_item {  // An Abstract Base Class (ABC)
453 private:
454     static UINT        instances;     // More than 64K instruments? Nah!
455     static int         brightness;
456     static glRGBTRIPLE color;
457
458     UINT               handle;
459     RECT               scrn_pos;      // Framing - affects scale dimensions
460                                       // and orientation. Vert vs Horz, etc.
461     FLTFNPTR           load_value_fn;
462     float              disp_factor;   // Multiply by to get numbers shown on scale.
463     UINT               opts;
464     bool               is_enabled;
465     bool               broken;
466     UINT               scr_span;      // Working values for draw;
467     POINT              mid_span;      //
468     int                digits;        //suma
469   
470 public:
471     instr_item( int            x,
472                 int            y,
473                 UINT           height,
474                 UINT           width,
475                 FLTFNPTR       data_source,
476                 float          data_scaling,
477                 UINT           options,
478                 bool           working  = true,
479                 int            digit = 0); //suma
480
481
482     instr_item( const instr_item & image );
483
484     instr_item & operator = ( const instr_item & rhs );
485     virtual ~instr_item ();
486
487     int     get_brightness  ( void ) { return brightness;}
488     RECT    get_location    ( void ) { return scrn_pos;  }
489     bool    is_broken       ( void ) { return broken;    }
490     bool    enabled         ( void ) { return is_enabled;}
491     bool    data_available  ( void ) { return !!load_value_fn; }
492     float   get_value       ( void ) { return load_value_fn(); }
493     float   data_scaling    ( void ) { return disp_factor; }
494     UINT    get_span        ( void ) { return scr_span;  }
495     POINT   get_centroid    ( void ) { return mid_span;  }
496     UINT    get_options     ( void ) { return opts;      }
497     int     get_digits      ( void ) { return digits;    } //suma
498
499     UINT    huds_vert     (UINT options) { return( options  & HUDS_VERT ); }
500     UINT    huds_left     (UINT options) { return( options  & HUDS_LEFT ); }
501     UINT    huds_right    (UINT options) { return( options  & HUDS_RIGHT ); }
502     UINT    huds_both     (UINT options) {
503         return( (options & HUDS_BOTH) == HUDS_BOTH );
504     }
505     UINT    huds_noticks  (UINT options) { return( options  & HUDS_NOTICKS ); }
506     UINT    huds_notext   (UINT options) { return( options  & HUDS_NOTEXT ); }
507     UINT    huds_top      (UINT options) { return( options  & HUDS_TOP ); }
508     UINT    huds_bottom   (UINT options) { return( options  & HUDS_BOTTOM ); }
509   
510     virtual void display_enable( bool working ) { is_enabled = !! working;}
511
512     virtual void update( void );
513     virtual void break_display ( bool bad );
514     virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
515     void         SetPosition  ( int x, int y, UINT width, UINT height );
516     UINT         get_Handle( void );
517     virtual void draw( void ) = 0;   // Required method in derived classes
518     
519     void drawOneLine( float x1, float y1, float x2, float y2)
520     {
521         HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
522     }
523     void drawOneStippleLine( float x1, float y1, float x2, float y2)
524     {
525         HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
526     }
527     void TextString( char *msg, float x, float y,int digit ) //suma
528     {
529         HUD_TextList.add(fgText(x, y, msg,digit)); //suma  
530     }
531     int getStringWidth ( char *str )
532     {
533         if ( HUDtext && str ) {
534             float r, l ;
535             guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
536             return FloatToInt( r - l );
537         }
538         return 0 ;
539     }
540
541     //code to draw ticks as small circles
542     void drawOneCircle(float x1, float y1, float r)
543     {
544         glBegin(GL_LINE_LOOP);  // Use polygon to approximate a circle 
545         for(int count=0; count<25; count++) {             
546             float cosine = r * cos(count * 2 * SG_PI/10.0); 
547             float sine =   r * sin(count * 2 * SG_PI/10.0); 
548             glVertex2f(cosine+x1, sine+y1);
549         }     
550         glEnd(); 
551     }
552     
553 };
554
555 typedef instr_item *HIptr;
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 // instr_scale           This class is an abstract base class for both moving
687 //                       scale and moving needle (fixed scale) indicators. It
688 // does not draw itself, but is not instanciable.
689 //
690
691 class instr_scale : public instr_item {
692 private:
693     float range_shown;   // Width Units.
694     float Maximum_value; //                ceiling.
695     float Minimum_value; // Representation floor.
696     float scale_factor;  // factor => screen units/range values.
697     UINT   Maj_div;       // major division marker units
698     UINT   Min_div;       // minor division marker units
699     UINT   Modulo;        // Roll over point
700     int    signif_digits; // digits to show to the right.
701
702 public:
703     instr_scale( int          x,
704                  int          y,
705                  UINT         width,
706                  UINT         height,
707                  FLTFNPTR     load_fn,
708                  UINT         options,
709                  float       show_range,
710                  float       max_value,
711                  float       min_value,
712                  float       disp_scaling,
713                  UINT         major_divs,
714                  UINT         minor_divs,
715                  UINT         rollover,
716                  int          dp_showing,
717                  bool         working = true);
718
719     virtual ~instr_scale();
720     instr_scale( const instr_scale & image);
721     instr_scale & operator = (const instr_scale & rhs);
722
723     virtual void draw   ( void ) {}; // No-op here. Defined in derived classes.
724     UINT   div_min      ( void ) { return Min_div;}
725     UINT   div_max      ( void ) { return Maj_div;}
726     float min_val      ( void ) { return Minimum_value;}
727     float max_val      ( void ) { return Maximum_value;}
728     UINT   modulo       ( void ) { return Modulo; }
729     float factor       ( void ) { return scale_factor;}
730     float range_to_show( void ) { return range_shown;}
731 };
732
733 // hud_card_               This class displays the indicated quantity on
734 //                         a scale that moves past the pointer. It may be
735 // horizontal or vertical, read above(left) or below(right) of the base
736 // line.
737
738 class hud_card : public instr_scale {
739 private:
740     float val_span;
741     string type;
742     float half_width_units;
743     bool  draw_tick_bottom;
744     bool  draw_tick_top;
745     bool  draw_tick_right;
746     bool  draw_tick_left;
747     bool  draw_cap_bottom;
748     bool  draw_cap_top;
749     bool  draw_cap_right;
750     bool  draw_cap_left;
751     float marker_offset;
752     bool  pointer;
753     string  pointer_type;
754     string  tick_type;
755     string  tick_length;
756     float   radius; //suma
757     float   maxValue; //suma
758     float   minValue; //suma
759     int         divisions; //suma
760     int     zoom; //suma
761     UINT        Maj_div; //suma
762     UINT        Min_div; //suma
763         
764     
765 public:
766     hud_card( int      x,
767               int      y,
768               UINT     width,
769               UINT     height,
770               FLTFNPTR load_fn,
771               UINT     options,
772               float    maxValue,
773               float    minValue,
774               float    disp_scaling,
775               UINT     major_divs,
776               UINT     minor_divs,
777               UINT     modulator,
778               int      dp_showing,
779               float    value_span,
780               string   type,
781               bool     draw_tick_bottom,
782               bool     draw_tick_top,
783               bool     draw_tick_right,
784               bool     draw_tick_left,
785               bool     draw_cap_bottom,
786               bool     draw_cap_top,
787               bool     draw_cap_right,
788               bool     draw_cap_left,
789               float    marker_offset,
790               bool     pointer,
791               string   pointer_type,
792               string  tick_type,
793               string  tick_length,
794               bool     working,
795               float    radius, //suma
796               int      divisions, //suma
797               int          zoom); //suma
798
799
800     ~hud_card();
801     hud_card( const hud_card & image);
802     hud_card & operator = (const hud_card & rhs );
803     //    virtual void display_enable( bool setting );
804     virtual void draw( void );       // Required method in base class
805     void circles(float,float,float); // suma
806     void fixed(float,float,float,float,float,float); //suma
807     void zoomed_scale(int,int); //suma
808 };
809
810 typedef hud_card * pCardScale;
811
812 class gauge_instr : public instr_scale {
813 public:
814     gauge_instr( int       x,
815                  int       y,
816                  UINT      width,
817                  UINT      height,
818                  FLTFNPTR  load_fn,
819                  UINT      options,
820                  float     disp_scaling,
821                  float     maxValue,
822                  float     minValue,
823                  UINT      major_divs,
824                  UINT      minor_divs,
825                  int       dp_showing,
826                  UINT      modulus,
827                  bool      working);
828
829     ~gauge_instr();
830     gauge_instr( const gauge_instr & image);
831     gauge_instr & operator = (const gauge_instr & rhs );
832     virtual void draw( void );       // Required method in base class
833 };
834
835 typedef gauge_instr * pGaugeInst;
836 //
837 // dual_instr_item         This class was created to form the base class
838 //                         for both panel and HUD Turn Bank Indicators.
839
840 class dual_instr_item : public instr_item {
841 private:
842     FLTFNPTR alt_data_source;
843
844 public:
845     dual_instr_item ( int       x,
846                       int       y,
847                       UINT      width,
848                       UINT      height,
849                       FLTFNPTR  chn1_source,
850                       FLTFNPTR  chn2_source,
851                       bool      working,
852                       UINT      options );
853
854     virtual ~dual_instr_item() {};
855     dual_instr_item( const dual_instr_item & image);
856     dual_instr_item & operator = (const dual_instr_item & rhs );
857
858     float current_ch1( void ) { return (float)alt_data_source();}
859     float current_ch2( void ) { return (float)get_value();}
860     virtual void draw ( void ) { }
861 };
862
863 class fgTBI_instr : public dual_instr_item 
864 {
865 private:
866     UINT BankLimit;
867     UINT SlewLimit;
868     UINT scr_hole;
869     bool tsi;  //suma
870     float rad; //suma
871
872 public:
873     fgTBI_instr( int       x,
874                  int       y,
875                  UINT      width,
876                  UINT      height,
877                  FLTFNPTR  chn1_source,
878                  FLTFNPTR  chn2_source,
879                  float    maxBankAngle,
880                  float    maxSlipAngle,
881                  UINT      gap_width,
882                  bool      working,
883                  bool      tsi, //suma
884                  float     rad); //suma
885
886     fgTBI_instr( const fgTBI_instr & image);
887     fgTBI_instr & operator = (const fgTBI_instr & rhs );
888
889     ~fgTBI_instr();
890
891     UINT bank_limit( void ) { return BankLimit;}
892     UINT slew_limit( void ) { return SlewLimit;}
893
894     virtual void draw( void );       // Required method in base class
895 };
896
897 typedef fgTBI_instr * pTBI;
898
899 class HudLadder : public dual_instr_item {
900 private:
901     UINT   width_units;
902     int    div_units;
903     UINT   minor_div;
904     UINT   label_pos;
905     UINT   scr_hole;
906     float  vmax;
907     float  vmin;
908     float  factor;
909     string hudladder_type;
910     bool   frl;
911     bool   target_spot;
912     bool   velocity_vector;
913     bool   drift_marker;
914     bool   alpha_bracket;
915     bool        energy_marker;
916     bool        climb_dive_marker;
917     bool        glide_slope_marker;
918     float       glide_slope;
919     bool        energy_worm;
920     bool        waypoint_marker;
921     int     zenith; //suma
922     int     nadir; //suma
923     int         hat; //suma
924     
925
926     fgTextList         TextList;
927     fgLineList         LineList;
928     fgLineList         StippleLineList;
929
930 public:
931     HudLadder( string    name,
932                int       x,
933                int       y,
934                UINT      width,
935                UINT      height,
936                float     factor,
937                FLTFNPTR  ptch_source,
938                FLTFNPTR  roll_source,
939                float     span_units,
940                float     division_units,
941                float     minor_division,
942                UINT      screen_hole,
943                UINT      lbl_pos,
944                bool      frl,
945                bool      target_spot,
946                bool     velocity_vector,
947                bool     drift_marker,
948                bool     alpha_bracket,
949                bool      energy_marker,
950                bool      climb_dive_marker,
951                bool      glide_slope_marker,
952                float     glide_slope,
953                bool      energy_worm,
954                bool      waypoint_marker,
955                bool  working,
956                int   zenith, //suma
957                int   nadir, //suma
958                int   hat); //suma
959
960
961     ~HudLadder();
962
963     HudLadder( const HudLadder & image );
964     HudLadder & operator = ( const HudLadder & rhs );
965     virtual void draw( void );
966     void drawZenith(float,float,float); //suma
967     void drawNadir(float, float, float); //suma
968
969     void Text( float x, float y, char *s)
970     {
971         TextList.add( fgText( x, y, s) );
972     }
973
974     void Line( float x1, float y1, float x2, float y2)
975     {
976         LineList.add(fgLineSeg2D(x1,y1,x2,y2));
977     }
978
979     void StippleLine( float x1, float y1, float x2, float y2)
980     {
981         StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
982     }
983 };
984
985
986 //using namespace std;
987 //deque <instr_item>  * Hdeque_ptr;
988
989 extern void HUD_masterswitch( bool incr );
990 extern void HUD_brightkey( bool incr_bright );
991 extern int  fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
992 extern int  fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
993 extern void fgUpdateHUD( void );
994 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
995                          GLfloat x_end, GLfloat y_end );
996
997 extern void drawOneLine ( UINT x1, UINT y1, UINT x2, UINT y2);
998 extern void drawOneLine ( RECT &rect);
999 extern void textString  ( int x,
1000                           int y,
1001                           char *msg,
1002                           void *font = GLUT_BITMAP_9_BY_15,int digit=0); //suma
1003 extern void strokeString( int x,
1004                           int y,
1005                           char *msg,
1006                           void *font = GLUT_STROKE_ROMAN,
1007                           float theta = 0);
1008
1009 //extern void strokeString(float xx,
1010 //                       float yy,
1011 //                       char *msg,
1012 //                       void *font = GLUT_STROKE_ROMAN)
1013
1014 /*
1015 bool AddHUDInstrument( instr_item *pBlackBox );
1016 void DrawHUD ( void );
1017 bool DamageInstrument( INSTR_HANDLE unit );
1018 bool RepairInstrument( INSTR_HANDLE unit );
1019
1020
1021 void fgUpdateHUD ( Hptr hud );
1022 void fgUpdateHUD2( Hptr hud ); // Future use?
1023 void fgHUDSetTimeMode( Hptr hud, int time_of_day );
1024 */
1025
1026 #endif // _HUD_H