~ubuntu-branches/ubuntu/precise/flightgear/precise

« back to all changes in this revision

Viewing changes to src/Cockpit/hud.hxx

  • Committer: Package Import Robot
  • Author(s): Ove Kaaven
  • Date: 2011-09-03 22:16:12 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20110903221612-2cjy0z7ztj5nkln5
Tags: 2.4.0-1
* New upstream release. Closes: #638588.
* Build-Depend on OpenSceneGraph 3.0, and the Subversion library.
* Recommend fgfs-scenery-base.
* Enable parallel builds (shorter compile times on multicore CPUs).
* Removed hack that tried to build without optimizations if
  building with optimizations fails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// hud.hxx -- hud defines and prototypes (initial draft)
2
 
//
3
 
// Written by Michele America, started September 1997.
4
 
//
5
 
// Copyright (C) 1997  Michele F. America  - nomimarketing@mail.telepac.pt
6
 
//
7
 
// This program is free software; you can redistribute it and/or
8
 
// modify it under the terms of the GNU General Public License as
9
 
// published by the Free Software Foundation; either version 2 of the
10
 
// License, or (at your option) any later version.
11
 
//
12
 
// This program is distributed in the hope that it will be useful, but
13
 
// WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
// General Public License for more details.
16
 
//
17
 
// You should have received a copy of the GNU General Public License
18
 
// along with this program; if not, write to the Free Software
19
 
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
 
//
21
 
// $Id$
22
 
 
23
 
 
24
 
#ifndef _OLDHUD_HXX
25
 
#define _OLDHUD_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 __CYGWIN__
38
 
#include <ieeefp.h>
39
 
#endif
40
 
 
41
 
#include <stdlib.h>
42
 
#include <string.h>
43
 
 
44
 
#include <algorithm>    // for_each()
45
 
#include <vector>       // STL vector
46
 
#include <deque>        // STL double ended queue
47
 
#include <fstream>
48
 
 
49
 
namespace osg {
50
 
    class State;
51
 
}
52
 
 
53
 
#include <simgear/math/SGMath.hxx>
54
 
#include <simgear/constants.h>
55
 
 
56
 
#include <Include/fg_typedefs.h>
57
 
#include <Aircraft/aircraft.hxx>
58
 
#include <Aircraft/controls.hxx>
59
 
#include <FDM/flight.hxx>
60
 
#include <GUI/gui.h>
61
 
#include <Main/fg_props.hxx>
62
 
#include <Main/globals.hxx>
63
 
#include <Main/viewmgr.hxx>
64
 
 
65
 
class FGRunway;
66
 
 
67
 
using std::deque;
68
 
using std::vector;
69
 
 
70
 
#define float_to_int(v) SGMiscf::roundToInt(v)
71
 
 
72
 
// some of Norman's crazy optimizations. :-)
73
 
 
74
 
#ifndef WIN32
75
 
typedef struct {
76
 
    int x, y;
77
 
} POINT;
78
 
 
79
 
typedef struct {
80
 
    int top, bottom, left, right;
81
 
} RECT;
82
 
#endif
83
 
 
84
 
// View mode definitions
85
 
 
86
 
enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
87
 
 
88
 
// Label constants
89
 
#define HUD_FONT_SMALL     1
90
 
#define HUD_FONT_LARGE     2
91
 
 
92
 
enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ;
93
 
 
94
 
#define HUDS_AUTOTICKS           0x0001
95
 
#define HUDS_VERT                0x0002
96
 
#define HUDS_HORZ                0x0000
97
 
#define HUDS_TOP                 0x0004
98
 
#define HUDS_BOTTOM              0x0008
99
 
#define HUDS_LEFT     HUDS_TOP
100
 
#define HUDS_RIGHT    HUDS_BOTTOM
101
 
#define HUDS_BOTH     (HUDS_LEFT | HUDS_RIGHT)
102
 
#define HUDS_NOTICKS             0x0010
103
 
#define HUDS_ARITHTIC            0x0020
104
 
#define HUDS_DECITICS            0x0040
105
 
#define HUDS_NOTEXT              0x0080
106
 
 
107
 
// in cockpit.cxx
108
 
extern float get_throttleval ( void );
109
 
extern float get_aileronval  ( void );
110
 
extern float get_elevatorval ( void );
111
 
extern float get_elev_trimval( void );
112
 
extern float get_rudderval   ( void );
113
 
extern float get_speed       ( void );
114
 
extern float get_aoa         ( void );
115
 
extern float get_nlf         ( void );
116
 
extern float get_roll        ( void );
117
 
extern float get_pitch       ( void );
118
 
extern float get_heading     ( void );
119
 
extern float get_view_direction( void );
120
 
extern float get_altitude    ( void );
121
 
extern float get_agl         ( void );
122
 
extern float get_sideslip    ( void );
123
 
extern float get_frame_rate  ( void );
124
 
extern float get_latitude    ( void );
125
 
extern float get_lat_min     ( void );
126
 
extern float get_longitude   ( void );
127
 
extern float get_long_min    ( void );
128
 
extern float get_fov         ( void );
129
 
extern float get_vfc_ratio   ( void );
130
 
extern float get_vfc_tris_drawn   ( void );
131
 
extern float get_vfc_tris_culled   ( void );
132
 
extern float get_climb_rate  ( void );
133
 
extern float get_mach( void );
134
 
extern char *coord_format_lat(float);
135
 
extern char *coord_format_lon(float);
136
 
 
137
 
// $$$ begin - added, VS Renganathan, 13 Oct 2K
138
 
extern float get_anzg (void);
139
 
extern float get_Vx (void);
140
 
extern float get_Vy (void);
141
 
extern float get_Vz (void);
142
 
extern float get_Ax (void);
143
 
extern float get_Ay (void);
144
 
extern float get_Az (void);
145
 
extern int get_iaux1 (void);
146
 
extern int get_iaux2 (void);
147
 
extern int get_iaux3 (void);
148
 
extern int get_iaux4 (void);
149
 
extern int get_iaux5 (void);
150
 
extern int get_iaux6 (void);
151
 
extern int get_iaux7 (void);
152
 
extern int get_iaux8 (void);
153
 
extern int get_iaux9 (void);
154
 
extern int get_iaux10 (void);
155
 
extern int get_iaux11 (void);
156
 
extern int get_iaux12 (void);
157
 
extern float get_aux1(void);
158
 
extern float get_aux2(void);
159
 
extern float get_aux3(void);
160
 
extern float get_aux4(void);
161
 
extern float get_aux5 (void);
162
 
extern float get_aux6 (void);
163
 
extern float get_aux7 (void);
164
 
extern float get_aux8(void);
165
 
extern float get_aux9(void);
166
 
extern float get_aux10(void);
167
 
extern float get_aux11(void);
168
 
extern float get_aux12(void);
169
 
extern float get_aux13(void);
170
 
extern float get_aux14(void);
171
 
extern float get_aux15(void);
172
 
extern float get_aux16(void);
173
 
extern float get_aux17(void);
174
 
extern float get_aux18(void);
175
 
// $$$ end - added, VS Renganathan, 13 Oct 2K
176
 
 
177
 
extern char *get_formated_gmt_time( void );
178
 
 
179
 
enum  hudinstype{ HUDno_instr,
180
 
                  HUDscale,
181
 
                  HUDlabel,
182
 
                  HUDladder,
183
 
                  HUDcirc_ladder,
184
 
                  HUDhorizon,
185
 
                  HUDgauge,
186
 
                  HUDdual_inst,
187
 
                  HUDmoving_scale,
188
 
                  HUDtbi
189
 
};
190
 
 
191
 
typedef struct gltagRGBTRIPLE { // rgbt
192
 
    GLfloat Blue;
193
 
    GLfloat Green;
194
 
    GLfloat Red;
195
 
} glRGBTRIPLE;
196
 
 
197
 
class fgLineSeg2D {
198
 
private:
199
 
    GLfloat x0, y0, x1, y1;
200
 
 
201
 
public:
202
 
    fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
203
 
        : x0(a), y0(b),  x1(c), y1(d) {}
204
 
 
205
 
    fgLineSeg2D( const fgLineSeg2D & image )
206
 
        : x0(image.x0), y0(image.y0), x1(image.x1), y1(image.y1) {}
207
 
 
208
 
    fgLineSeg2D& operator= ( const fgLineSeg2D & image ) { // seems unused
209
 
        x0 = image.x0; y0 = image.y0; x1 = image.x1; y1 = image.y1; return *this;
210
 
    }
211
 
 
212
 
    void draw() const
213
 
    {
214
 
        glVertex2f(x0, y0);
215
 
        glVertex2f(x1, y1);
216
 
    }
217
 
};
218
 
 
219
 
class DrawLineSeg2D {
220
 
    public:
221
 
        void operator() (const fgLineSeg2D& elem) const {
222
 
            elem.draw();
223
 
        }
224
 
};
225
 
 
226
 
 
227
 
#define USE_HUD_TextList
228
 
extern fntTexFont        *HUD_Font;
229
 
extern float              HUD_TextSize;
230
 
extern fntRenderer       *HUDtext;
231
 
extern float HUD_matrix[16];
232
 
 
233
 
class fgText {
234
 
private:
235
 
    float x, y;
236
 
    string msg;
237
 
        bool digit;
238
 
    // seems unused   
239
 
        
240
 
public:
241
 
        fgText(float x, float y, const string& c, bool digits=false): x(x), y(y), msg( c), digit( digits) {};   
242
 
 
243
 
    fgText( const fgText & image )
244
 
                : x(image.x), y(image.y), msg(image.msg), digit(image.digit) { }
245
 
 
246
 
        fgText& operator = ( const fgText & image ) {
247
 
                x = image.x; y = image.y; msg= image.msg; digit = image.digit;
248
 
                return *this;
249
 
        }
250
 
        
251
 
    static int getStringWidth ( const char *str )
252
 
    {
253
 
        if ( HUDtext && str ) {
254
 
            float r, l ;
255
 
            HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
256
 
            return float_to_int( r - l );
257
 
        }
258
 
        return 0 ;
259
 
    }
260
 
 
261
 
    int StringWidth ()
262
 
    {
263
 
        if ( HUDtext && msg != "") {
264
 
            float r, l ;
265
 
            HUD_Font->getBBox ( msg.c_str(), HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
266
 
            return float_to_int( r - l );
267
 
        }
268
 
        return 0 ;
269
 
    }
270
 
 
271
 
    // this code is changed to display Numbers with big/small digits
272
 
    // according to MIL Standards for example Altitude above 10000 ft
273
 
    // is shown as 10ooo.
274
 
 
275
 
    void Draw(fntRenderer *fnt) {
276
 
        if (digit) {
277
 
            int c=0;
278
 
            
279
 
            int p=4;
280
 
 
281
 
            if (msg[0]=='-') {
282
 
                //if negative value then increase the c and p values
283
 
                //for '-' sign.  c++;
284
 
                p++;
285
 
            }
286
 
                        
287
 
                        for (string::size_type i = 0; i < msg.size(); i++) {
288
 
                if ((msg[i]>='0') && (msg[i]<='9'))
289
 
                    c++;
290
 
            }
291
 
            float orig_size = fnt->getPointSize();
292
 
            if (c>p) {
293
 
                fnt->setPointSize(HUD_TextSize * 0.8);
294
 
                int p2=(c-3)*8;  //advance to the last 3 digits
295
 
 
296
 
                fnt->start2f(x+p2,y);
297
 
                fnt->puts(msg.c_str() + c - 3); // display last 3 digits
298
 
 
299
 
                fnt->setPointSize(HUD_TextSize * 1.2);
300
 
              
301
 
                fnt->start2f(x,y);
302
 
                                fnt->puts(msg.substr(0,c-3).c_str());
303
 
            } else {
304
 
                fnt->setPointSize(HUD_TextSize * 1.2);
305
 
                fnt->start2f( x, y );
306
 
                fnt->puts(msg.c_str());
307
 
            }
308
 
            fnt->setPointSize(orig_size);
309
 
        } else {
310
 
            //if digits not true
311
 
            fnt->start2f( x, y );
312
 
            fnt->puts( msg.c_str()) ;
313
 
        }
314
 
    }
315
 
 
316
 
    void Draw()
317
 
    {
318
 
                guiFnt.drawString( msg.c_str(), float_to_int(x), float_to_int(y) );
319
 
    }
320
 
};
321
 
 
322
 
class fgLineList {
323
 
    vector < fgLineSeg2D > List;
324
 
public:
325
 
    fgLineList( void ) {}
326
 
    void add( const fgLineSeg2D& seg ) { List.push_back(seg); }
327
 
        void erase( void ) { List.clear();}
328
 
    void draw( void ) {
329
 
        glBegin(GL_LINES);
330
 
        for_each( List.begin(), List.end(), DrawLineSeg2D());
331
 
        glEnd();
332
 
    }
333
 
};
334
 
 
335
 
class fgTextList {
336
 
    fntRenderer *Font;
337
 
    vector< fgText > List;
338
 
public:
339
 
    fgTextList ( void ) { Font = 0; }
340
 
 
341
 
    void setFont( fntRenderer *Renderer ) { Font = Renderer; }
342
 
    void add( const fgText& String ) { List.push_back(String); }
343
 
    void erase( void ) { List.clear(); }
344
 
    void draw( void );
345
 
};
346
 
 
347
 
 
348
 
inline void Text( fgTextList &List, float x, float y, char *s)
349
 
{
350
 
    List.add( fgText( x, y, s) );
351
 
}
352
 
 
353
 
inline void Text( fgTextList &List, const fgText &me)
354
 
{
355
 
    List.add(me);
356
 
}
357
 
 
358
 
inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
359
 
{
360
 
    List.add(fgLineSeg2D(x1,y1,x2,y2));
361
 
}
362
 
 
363
 
 
364
 
// Declare our externals
365
 
extern fgTextList         HUD_TextList;
366
 
extern fgLineList         HUD_LineList;
367
 
extern fgLineList         HUD_StippleLineList;
368
 
 
369
 
 
370
 
class instr_item : public SGReferenced {  // An Abstract Base Class (ABC)
371
 
private:
372
 
    static UINT        instances;     // More than 64K instruments? Nah!
373
 
    static int         brightness;
374
 
    static glRGBTRIPLE color;
375
 
 
376
 
    UINT               handle;
377
 
    RECT               scrn_pos;      // Framing - affects scale dimensions
378
 
                                      // and orientation. Vert vs Horz, etc.
379
 
    FLTFNPTR           load_value_fn;
380
 
    float              disp_factor;   // Multiply by to get numbers shown on scale.
381
 
    UINT               opts;
382
 
    bool               is_enabled;
383
 
    bool               broken;
384
 
    UINT               scr_span;      // Working values for draw;
385
 
    POINT              mid_span;      //
386
 
    int                digits;
387
 
 
388
 
public:
389
 
    instr_item( int            x,
390
 
                int            y,
391
 
                UINT           height,
392
 
                UINT           width,
393
 
                FLTFNPTR       data_source,
394
 
                float          data_scaling,
395
 
                UINT           options,
396
 
                bool           working = true,
397
 
                int            digit = 0);
398
 
 
399
 
    virtual ~instr_item ();
400
 
 
401
 
    void    set_data_source ( FLTFNPTR fn ) { load_value_fn = fn; }
402
 
    int     get_brightness  ( void ) { return brightness;}
403
 
    RECT    get_location    ( void ) { return scrn_pos;  }
404
 
    bool    is_broken       ( void ) { return broken;    }
405
 
    bool    enabled         ( void ) { return is_enabled;}
406
 
    bool    data_available  ( void ) { return !!load_value_fn; }
407
 
    float   get_value       ( void ) { return load_value_fn(); }
408
 
    float   data_scaling    ( void ) { return disp_factor; }
409
 
    UINT    get_span        ( void ) { return scr_span;  }
410
 
    POINT   get_centroid    ( void ) { return mid_span;  }
411
 
    UINT    get_options     ( void ) { return opts;      }
412
 
    int     get_digits      ( void ) { return digits;         }
413
 
    inline int get_x() const { return scrn_pos.left; }
414
 
    inline int get_y() const { return scrn_pos.top; }
415
 
    inline int get_width() const { return scrn_pos.right; }
416
 
    inline int get_height() const { return scrn_pos.bottom; }
417
 
 
418
 
    UINT    huds_vert     (UINT options) { return (options & HUDS_VERT); }
419
 
    UINT    huds_left     (UINT options) { return (options & HUDS_LEFT); }
420
 
    UINT    huds_right    (UINT options) { return (options & HUDS_RIGHT); }
421
 
    UINT    huds_both     (UINT options) {
422
 
        return ((options & HUDS_BOTH) == HUDS_BOTH);
423
 
    }
424
 
    UINT    huds_noticks  (UINT options) { return (options & HUDS_NOTICKS); }
425
 
    UINT    huds_notext   (UINT options) { return (options & HUDS_NOTEXT); }
426
 
    UINT    huds_top      (UINT options) { return (options & HUDS_TOP); }
427
 
    UINT    huds_bottom   (UINT options) { return (options & HUDS_BOTTOM); }
428
 
 
429
 
    virtual void display_enable( bool working ) { is_enabled = working;}
430
 
 
431
 
    virtual void break_display ( bool bad );
432
 
    virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
433
 
    void         SetPosition  ( int x, int y, UINT width, UINT height );
434
 
    UINT         get_Handle( void );
435
 
    virtual void draw( void ) = 0;   // Required method in derived classes
436
 
 
437
 
    void drawOneLine( float x1, float y1, float x2, float y2)
438
 
    {
439
 
        HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
440
 
    }
441
 
    void drawOneStippleLine( float x1, float y1, float x2, float y2)
442
 
    {
443
 
        HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
444
 
    }
445
 
    void TextString( char *msg, float x, float y, bool digit )
446
 
    {
447
 
        HUD_TextList.add(fgText(x, y, msg,digit));
448
 
    }
449
 
    int getStringWidth ( char *str )
450
 
    {
451
 
        if ( HUDtext && str ) {
452
 
            float r, l ;
453
 
            HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
454
 
            return float_to_int( r - l );
455
 
        }
456
 
        return 0 ;
457
 
    }
458
 
 
459
 
 
460
 
 
461
 
};
462
 
 
463
 
typedef instr_item *HIptr;
464
 
 
465
 
class HUDdraw {
466
 
    public:
467
 
        void operator() (HIptr elem) const {
468
 
            if ( elem->enabled())
469
 
                elem->draw();
470
 
        }
471
 
};
472
 
 
473
 
 
474
 
extern int HUD_style;
475
 
 
476
 
// instr_item           This class has no other purpose than to maintain
477
 
//                      a linked list of instrument and derived class
478
 
// object pointers.
479
 
 
480
 
 
481
 
class instr_label : public instr_item {
482
 
private:
483
 
    const char  *pformat;
484
 
    
485
 
    fgLabelJust justify;
486
 
    int         fontSize;
487
 
    int         blink;
488
 
    string      format_buffer;
489
 
    bool        lat;
490
 
    bool        lon;
491
 
    bool        lbox;
492
 
    SGPropertyNode_ptr lon_node;
493
 
    SGPropertyNode_ptr lat_node;
494
 
 
495
 
public:
496
 
    instr_label(const SGPropertyNode *);
497
 
    virtual void draw(void);
498
 
};
499
 
 
500
 
 
501
 
//
502
 
// fgRunway_instr   This class is responsible for rendering the active runway
503
 
//                  in the hud (if visible).
504
 
class runway_instr : public instr_item {
505
 
private:
506
 
        void boundPoint(const sgdVec3& v, sgdVec3& m);
507
 
        bool boundOutsidePoints(sgdVec3& v, sgdVec3& m);
508
 
        bool drawLine(const sgdVec3& a1, const sgdVec3& a2,
509
 
                const sgdVec3& p1, const sgdVec3& p2);
510
 
        void drawArrow();
511
 
        FGRunway* get_active_runway();
512
 
        void get_rwy_points(sgdVec3 *points);
513
 
        void setLineWidth(void);
514
 
 
515
 
        sgdVec3 points3d[6], points2d[6];
516
 
        double mm[16],pm[16], arrowScale, arrowRad, lnScale;
517
 
        double scaleDist, default_pitch, default_heading;
518
 
        GLint view[4];
519
 
        FGRunway* runway;
520
 
        FGViewer* cockpit_view;
521
 
        unsigned short stippleOut, stippleCen;
522
 
        bool drawIA, drawIAAlways;
523
 
        RECT location;
524
 
        POINT center;
525
 
 
526
 
public:
527
 
    runway_instr(const SGPropertyNode *);
528
 
 
529
 
    virtual void draw( void );
530
 
    void setArrowRotationRadius(double radius);
531
 
    // Scales the runway indication arrow
532
 
    void setArrowScale(double scale);
533
 
    // Draws arrow when runway is not visible in HUD if draw=true
534
 
    void setDrawArrow(bool draw);
535
 
    // Always draws arrow if draw=true;
536
 
    void setDrawArrowAlways(bool draw);
537
 
    // Sets the maximum line scale
538
 
    void setLineScale(double scale);
539
 
    // Sets the distance where to start scaling the lines
540
 
    void setScaleDist(double dist_nm);
541
 
    // Sets the stipple pattern of the outline of the runway
542
 
    void setStippleOutline(unsigned short stipple);
543
 
    // Sets the stipple patter of the center line of the runway
544
 
    void setStippleCenterline(unsigned short stipple);
545
 
};
546
 
 
547
 
 
548
 
//
549
 
// instr_scale           This class is an abstract base class for both moving
550
 
//                       scale and moving needle (fixed scale) indicators. It
551
 
// does not draw itself, but is not instanciable.
552
 
//
553
 
 
554
 
class instr_scale : public instr_item {
555
 
private:
556
 
    float range_shown;   // Width Units.
557
 
    float Maximum_value; //                ceiling.
558
 
    float Minimum_value; // Representation floor.
559
 
    float scale_factor;  // factor => screen units/range values.
560
 
    UINT   Maj_div;       // major division marker units
561
 
    UINT   Min_div;       // minor division marker units
562
 
    UINT   Modulo;        // Roll over point
563
 
    int    signif_digits; // digits to show to the right.
564
 
 
565
 
public:
566
 
    instr_scale( int          x,
567
 
                 int          y,
568
 
                 UINT         width,
569
 
                 UINT         height,
570
 
                 FLTFNPTR     load_fn,
571
 
                 UINT         options,
572
 
                 float        show_range,
573
 
                 float        max_value,
574
 
                 float        min_value,
575
 
                 float        disp_scaling,
576
 
                 UINT         major_divs,
577
 
                 UINT         minor_divs,
578
 
                 UINT         rollover,
579
 
                 int          dp_showing,
580
 
                 bool         working = true);
581
 
 
582
 
    virtual void draw    ( void ) {}; // No-op here. Defined in derived classes.
583
 
    UINT   div_min       ( void ) { return Min_div;}
584
 
    UINT   div_max       ( void ) { return Maj_div;}
585
 
    float  min_val       ( void ) { return Minimum_value;}
586
 
    float  max_val       ( void ) { return Maximum_value;}
587
 
    UINT   modulo        ( void ) { return Modulo; }
588
 
    float  factor        ( void ) { return scale_factor;}
589
 
    float  range_to_show ( void ) { return range_shown;}
590
 
};
591
 
 
592
 
// hud_card                This class displays the indicated quantity on
593
 
//                         a scale that moves past the pointer. It may be
594
 
// horizontal or vertical, read above(left) or below(right) of the base
595
 
// line.
596
 
 
597
 
class hud_card : public instr_scale {
598
 
private:
599
 
    float  val_span;
600
 
    string type;
601
 
    float  half_width_units;
602
 
    bool   draw_tick_bottom;
603
 
    bool   draw_tick_top;
604
 
    bool   draw_tick_right;
605
 
    bool   draw_tick_left;
606
 
    bool   draw_cap_bottom;
607
 
    bool   draw_cap_top;
608
 
    bool   draw_cap_right;
609
 
    bool   draw_cap_left;
610
 
    float  marker_offset;
611
 
    bool   pointer;
612
 
    string pointer_type;
613
 
    string tick_type;
614
 
    string tick_length;
615
 
    float  radius;
616
 
    float  maxValue;
617
 
    float  minValue;
618
 
    int    divisions;
619
 
    int    zoom;
620
 
    UINT   Maj_div;
621
 
    UINT   Min_div;
622
 
 
623
 
public:
624
 
    hud_card(const SGPropertyNode *);
625
 
    //    virtual void display_enable( bool setting );                  // FIXME
626
 
    virtual void draw(void);
627
 
    void circles(float, float, float);
628
 
    void fixed(float, float, float, float, float, float);
629
 
    void zoomed_scale(int, int);
630
 
};
631
 
 
632
 
 
633
 
class gauge_instr : public instr_scale {
634
 
public:
635
 
    gauge_instr(const SGPropertyNode *);
636
 
    virtual void draw( void );       // Required method in base class
637
 
};
638
 
 
639
 
 
640
 
//
641
 
// dual_instr_item         This class was created to form the base class
642
 
//                         for both panel and HUD Turn Bank Indicators.
643
 
 
644
 
class dual_instr_item : public instr_item {
645
 
private:
646
 
    FLTFNPTR alt_data_source;
647
 
 
648
 
public:
649
 
    dual_instr_item ( int       x,
650
 
                      int       y,
651
 
                      UINT      width,
652
 
                      UINT      height,
653
 
                      FLTFNPTR  chn1_source,
654
 
                      FLTFNPTR  chn2_source,
655
 
                      bool      working,
656
 
                      UINT      options );
657
 
 
658
 
    float current_ch1( void ) { return (float)alt_data_source(); }
659
 
    float current_ch2( void ) { return (float)get_value(); }
660
 
    virtual void draw( void ) {}
661
 
};
662
 
 
663
 
 
664
 
class fgTBI_instr : public dual_instr_item {
665
 
private:
666
 
    UINT BankLimit;
667
 
    UINT SlewLimit;
668
 
    UINT scr_hole;
669
 
    bool tsi;
670
 
    float rad;
671
 
 
672
 
public:
673
 
    fgTBI_instr(const SGPropertyNode *);
674
 
 
675
 
    UINT bank_limit(void) { return BankLimit; }
676
 
    UINT slew_limit(void) { return SlewLimit; }
677
 
 
678
 
    virtual void draw(void);
679
 
};
680
 
 
681
 
 
682
 
class HudLadder : public dual_instr_item {
683
 
private:
684
 
    UINT   width_units;
685
 
    int    div_units;
686
 
    UINT   minor_div;
687
 
    UINT   label_pos;
688
 
    UINT   scr_hole;
689
 
    float  vmax;
690
 
    float  vmin;
691
 
    float  factor;
692
 
    string hudladder_type;
693
 
    bool   frl;
694
 
    bool   target_spot;
695
 
    bool   velocity_vector;
696
 
    bool   drift_marker;
697
 
    bool   alpha_bracket;
698
 
    bool   energy_marker;
699
 
    bool   climb_dive_marker;
700
 
    bool   glide_slope_marker;
701
 
    float  glide_slope;
702
 
    bool   energy_worm;
703
 
    bool   waypoint_marker;
704
 
    int    zenith;
705
 
    int    nadir;
706
 
    int    hat;
707
 
 
708
 
    // The Ladder has it's own temporary display lists
709
 
    fgTextList         TextList;
710
 
    fgLineList         LineList;
711
 
    fgLineList         StippleLineList;
712
 
 
713
 
public:
714
 
    HudLadder(const SGPropertyNode *);
715
 
 
716
 
    virtual void draw(void);
717
 
    void drawZenith(float, float, float);
718
 
    void drawNadir(float, float, float);
719
 
 
720
 
    void Text(float x, float y, char *s)
721
 
    {
722
 
        TextList.add(fgText(x, y, s));
723
 
    }
724
 
 
725
 
    void Line(float x1, float y1, float x2, float y2)
726
 
    {
727
 
        LineList.add(fgLineSeg2D(x1, y1, x2, y2));
728
 
    }
729
 
 
730
 
    void StippleLine(float x1, float y1, float x2, float y2)
731
 
    {
732
 
        StippleLineList.add(fgLineSeg2D(x1, y1, x2, y2));
733
 
    }
734
 
};
735
 
 
736
 
 
737
 
extern int  fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
738
 
extern int  fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
739
 
extern void fgUpdateHUD( osg::State* );
740
 
extern void fgUpdateHUD( osg::State*, GLfloat x_start, GLfloat y_start,
741
 
                         GLfloat x_end, GLfloat y_end );
742
 
 
743
 
 
744
 
 
745
 
 
746
 
class HUD_Properties : public SGPropertyChangeListener {
747
 
public:
748
 
    HUD_Properties();
749
 
    void valueChanged(SGPropertyNode *n);
750
 
    void setColor() const;
751
 
    bool isVisible() const { return _visible; }
752
 
    bool isAntialiased() const { return _antialiased; }
753
 
    bool isTransparent() const { return _transparent; }
754
 
    float alphaClamp() const { return _cl; }
755
 
 
756
 
private:
757
 
    float clamp(float f) { return f < 0.0f ? 0.0f : f > 1.0f ? 1.0f : f; }
758
 
    SGPropertyNode_ptr _current;
759
 
    SGPropertyNode_ptr _visibility;
760
 
    SGPropertyNode_ptr _antialiasing;
761
 
    SGPropertyNode_ptr _transparency;
762
 
    SGPropertyNode_ptr _red, _green, _blue, _alpha;
763
 
    SGPropertyNode_ptr _alpha_clamp;
764
 
    SGPropertyNode_ptr _brightness;
765
 
    bool _visible;
766
 
    bool _antialiased;
767
 
    bool _transparent;
768
 
    float _r, _g, _b, _a, _cl;
769
 
};
770
 
 
771
 
#endif // _OLDHUD_H