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