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