X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCockpit%2Fhud.hxx;h=8591bb9b2927583921ebeb344f00319286bc666f;hb=ddda2c68d5000377c7f76193f27ef78645fe316e;hp=f060bd69b9719ef40a4074f8c14352bdbb03a42e;hpb=cc26bb7fe73be1fa23b5e1c3b88f71e0d361a4c2;p=flightgear.git diff --git a/src/Cockpit/hud.hxx b/src/Cockpit/hud.hxx index f060bd69b..8591bb9b2 100644 --- a/src/Cockpit/hud.hxx +++ b/src/Cockpit/hud.hxx @@ -16,7 +16,7 @@ // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ @@ -28,6 +28,8 @@ # error This library requires C++ #endif +#include + #ifdef HAVE_CONFIG_H # include #endif @@ -36,90 +38,60 @@ # include #endif -#include #include #include -#ifdef HAVE_VALUES_H -# include // for MAXINT -#endif +//#ifdef HAVE_VALUES_H +//# include // for MAXINT +//#endif +#include // for_each() #include // STL vector #include // STL double ended queue +#include STL_FSTREAM #include +//#include -#include +#include #include +#include #include -#include #include +#include
+#include
+#include #include "hud_opts.hxx" +#include -FG_USING_STD(deque); -FG_USING_STD(vector); -FG_USING_NAMESPACE(std); +SG_USING_STD(deque); +SG_USING_STD(vector); +SG_USING_NAMESPACE(std); // some of Norman's crazy optimizations. :-) #ifndef WIN32 - typedef struct { - int x, y; - } POINT; - - typedef struct { - int top, bottom, left, right; - } RECT; +typedef struct { + int x, y; +} POINT; + +typedef struct { + int top, bottom, left, right; +} RECT; #endif // View mode definitions enum VIEW_MODES{ HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW }; -// DAY, NIGHT and brightness levels need to be visible where dialogs and -// controls can be used to set intensity and appropriate color. This will -// be moved. -// Hud general constants -#define DAY 1 -#define NIGHT 2 -#define BRT_BLACK 3 -#define BRT_DARK 4 -#define BRT_MEDIUM 5 -#define BRT_LIGHT 6 -#define SIZE_SMALL 7 -#define SIZE_LARGE 8 - // Label constants -#define SMALL 1 -#define LARGE 2 - -#define BLINK 3 -#define NOBLINK 4 +#define HUD_FONT_SMALL 1 +#define HUD_FONT_LARGE 2 enum fgLabelJust{ LEFT_JUST, CENTER_JUST, RIGHT_JUST } ; -// Ladder constants -#define NONE 1 -#define UPPER_LEFT 2 -#define UPPER_CENTER 3 -#define UPPER_RIGHT 4 -#define CENTER_RIGHT 5 -#define LOWER_RIGHT 6 -#define LOWER_CENTER 7 -#define LOWER_LEFT 8 -#define CENTER_LEFT 9 -#define SOLID_LINES 10 -#define DASHED_LINES 11 -#define DASHED_NEG_LINES 12 - - -#define HORIZON_FIXED 1 -#define HORIZON_MOVING 2 -#define LABEL_COUNTER 1 -#define LABEL_WARNING 2 - #define HUDS_AUTOTICKS 0x0001 #define HUDS_VERT 0x0002 #define HUDS_HORZ 0x0000 @@ -167,6 +139,7 @@ extern float get_elev_trimval( void ); extern float get_rudderval ( void ); extern float get_speed ( void ); extern float get_aoa ( void ); +extern float get_nlf ( void ); extern float get_roll ( void ); extern float get_pitch ( void ); extern float get_heading ( void ); @@ -189,19 +162,61 @@ extern char *coord_format_lat(float); extern char *coord_format_lon(float); //extern char *coord_format_latlon(float latitude, float longitude); // cockpit.cxx +// $$$ begin - added, VS Renganathan, 13 Oct 2K +// #define FIGHTER_HUD +extern float get_anzg (void); +extern float get_Vx (void); +extern float get_Vy (void); +extern float get_Vz (void); +extern float get_Ax (void); +extern float get_Ay (void); +extern float get_Az (void); +extern int get_iaux1 (void); +extern int get_iaux2 (void); +extern int get_iaux3 (void); +extern int get_iaux4 (void); +extern int get_iaux5 (void); +extern int get_iaux6 (void); +extern int get_iaux7 (void); +extern int get_iaux8 (void); +extern int get_iaux9 (void); +extern int get_iaux10 (void); +extern int get_iaux11 (void); +extern int get_iaux12 (void); +extern float get_aux1(void); +extern float get_aux2(void); +extern float get_aux3(void); +extern float get_aux4(void); +extern float get_aux5 (void); +extern float get_aux6 (void); +extern float get_aux7 (void); +extern float get_aux8(void); +extern float get_aux9(void); +extern float get_aux10(void); +extern float get_aux11(void); +extern float get_aux12(void); +extern float get_aux13(void); +extern float get_aux14(void); +extern float get_aux15(void); +extern float get_aux16(void); +extern float get_aux17(void); +extern float get_aux18(void); +// $$$ end - added, VS Renganathan, 13 Oct 2K + extern char *get_formated_gmt_time( void ); +extern void fgHUDReshape(void); enum hudinstype{ HUDno_instr, - HUDscale, - HUDlabel, - HUDladder, - HUDcirc_ladder, - HUDhorizon, - HUDguage, - HUDdual_inst, - HUDmoving_scale, - HUDtbi - }; + HUDscale, + HUDlabel, + HUDladder, + HUDcirc_ladder, + HUDhorizon, + HUDgauge, + HUDdual_inst, + HUDmoving_scale, + HUDtbi +}; typedef struct gltagRGBTRIPLE { // rgbt GLfloat Blue; @@ -225,15 +240,24 @@ public: } ~fgLineSeg2D() {} - - void draw() + + void draw() const { glVertex2f(x0, y0); glVertex2f(x1, y1); } }; +class DrawLineSeg2D { + public: + void operator() (const fgLineSeg2D& elem) const { + elem.draw(); + } +}; + + #define USE_HUD_TextList +extern fntTexFont *HUD_Font; extern float HUD_TextSize; extern fntRenderer *HUDtext; extern float HUD_matrix[16]; @@ -243,50 +267,96 @@ private: float x, y; char msg[64]; public: - fgText( float x = 0, float y = 0, char *c = NULL ) - : x(x), y(y) {strncpy(msg,c,64-1);} + int digit; + fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y) + { + strcpy(msg,c); + digit=digits; + } fgText( const fgText & image ) - : x(image.x), y(image.y) {strcpy(msg,image.msg);} + : x(image.x), y(image.y),digit(image.digit) { strcpy(msg,image.msg); } fgText& operator = ( const fgText & image ) { - strcpy(msg,image.msg); x = image.x; y = image.y; + strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit; return *this; } - ~fgText() {msg[0]='\0';} + ~fgText() { msg[0]='\0'; } int getStringWidth ( char *str ) { - if ( HUDtext && str ) - { + if ( HUDtext && str ) { float r, l ; - guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; + HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; return FloatToInt( r - l ); } return 0 ; } - + int StringWidth (void ) { - if ( HUDtext && strlen( msg )) - { + if ( HUDtext && strlen( msg )) { float r, l ; - guiFntHandle->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; + HUD_Font->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; return FloatToInt( r - l ); } return 0 ; } - - void Draw(fntRenderer *fnt) - { - fnt->start2f( x, y ); - fnt->puts ( msg ) ; + + // this code is changed to display Numbers with big/small digits + // according to MIL Standards for example Altitude above 10000 ft + // is shown as 10ooo. + + void Draw(fntRenderer *fnt,int digits) { + if (digits==1) { + int c=0,i=0; + char *t=msg; + int p=4; + + if (t[0]=='-') { + //if negative value then increase the c and p values + //for '-' sign. c++; + p++; + } + char *tmp=msg; + while (tmp[i]!='\0') { + if ((tmp[i]>='0') && (tmp[i]<='9')) + c++; + i++; + } + if (c>p) { + fnt->setPointSize(HUD_TextSize * 0.8); + int p1=c-3; + char *tmp1=msg+p1; + int p2=p1*8; + + fnt->start2f(x+p2,y); + fnt->puts(tmp1); + + fnt->setPointSize(HUD_TextSize * 1.2); + char tmp2[64]; + strncpy(tmp2,msg,p1); + tmp2[p1]='\0'; + + fnt->start2f(x,y); + fnt->puts(tmp2); + } else { + fnt->setPointSize(HUD_TextSize * 1.2); + fnt->start2f( x, y ); + fnt->puts(tmp); + } + } else { + //if digits not equal to 1 + fnt->setPointSize(HUD_TextSize * 0.8); + fnt->start2f( x, y ); + fnt->puts( msg ) ; + } } void Draw() { - puDrawString ( guiFnt, msg, FloatToInt(x), FloatToInt(y) ); + guiFnt.drawString( msg, FloatToInt(x), FloatToInt(y) ); } }; @@ -295,17 +365,11 @@ class fgLineList { public: fgLineList( void ) {} ~fgLineList( void ) {} - void add( fgLineSeg2D seg ) { List.push_back(seg); } + void add( const fgLineSeg2D& seg ) { List.push_back(seg); } void erase( void ) { List.erase( List.begin(), List.end() ); } void draw( void ) { - vector < fgLineSeg2D > :: iterator curSeg; - vector < fgLineSeg2D > :: iterator lastSeg; - curSeg = List.begin(); - lastSeg = List.end(); glBegin(GL_LINES); - for ( ; curSeg != lastSeg; curSeg++ ) { - curSeg->draw(); - } + for_each( List.begin(), List.end(), DrawLineSeg2D()); glEnd(); } }; @@ -316,32 +380,11 @@ class fgTextList { public: fgTextList ( void ) { Font = 0; } ~fgTextList( void ) {} - + void setFont( fntRenderer *Renderer ) { Font = Renderer; } - void add( fgText String ) { List.push_back(String); } + void add( const fgText& String ) { List.push_back(String); } void erase( void ) { List.erase( List.begin(), List.end() ); } - - void draw( void ) { - vector < fgText > :: iterator curString; - vector < fgText > :: iterator lastString; - if( Font == 0 ) return; - curString = List.begin(); - lastString = List.end(); - glPushAttrib( GL_COLOR_BUFFER_BIT ); - glEnable ( GL_ALPHA_TEST ) ; - glEnable ( GL_BLEND ) ; - glAlphaFunc ( GL_GREATER, 0.1 ) ; - glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ; - - Font->begin(); - for( ; curString != lastString; curString++ ) { - curString->Draw(Font); - } - Font->end(); - - glDisable ( GL_TEXTURE_2D ) ; - glPopAttrib(); - } + void draw( void ); }; @@ -350,7 +393,7 @@ inline void Text( fgTextList &List, float x, float y, char *s) List.add( fgText( x, y, s) ); } -inline void Text( fgTextList &List, fgText &me) +inline void Text( fgTextList &List, const fgText &me) { List.add(me); } @@ -368,14 +411,14 @@ extern fgLineList HUD_StippleLineList; class instr_item { // An Abstract Base Class (ABC) - private: +private: static UINT instances; // More than 64K instruments? Nah! static int brightness; static glRGBTRIPLE color; UINT handle; RECT scrn_pos; // Framing - affects scale dimensions - // and orientation. Vert vs Horz, etc. + // and orientation. Vert vs Horz, etc. FLTFNPTR load_value_fn; float disp_factor; // Multiply by to get numbers shown on scale. UINT opts; @@ -383,22 +426,24 @@ class instr_item { // An Abstract Base Class (ABC) bool broken; UINT scr_span; // Working values for draw; POINT mid_span; // + int digits; - public: +public: instr_item( int x, int y, UINT height, UINT width, FLTFNPTR data_source, - float data_scaling, + float data_scaling, UINT options, - bool working = true); + bool working = true, + int digit = 0); instr_item( const instr_item & image ); - instr_item & operator = ( const instr_item & rhs ); virtual ~instr_item (); + void set_data_source ( FLTFNPTR fn ) { load_value_fn = fn; } int get_brightness ( void ) { return brightness;} RECT get_location ( void ) { return scrn_pos; } bool is_broken ( void ) { return broken; } @@ -409,16 +454,19 @@ class instr_item { // An Abstract Base Class (ABC) UINT get_span ( void ) { return scr_span; } POINT get_centroid ( void ) { return mid_span; } UINT get_options ( void ) { return opts; } + int get_digits ( void ) { return digits; } UINT huds_vert (UINT options) { return( options & HUDS_VERT ); } UINT huds_left (UINT options) { return( options & HUDS_LEFT ); } UINT huds_right (UINT options) { return( options & HUDS_RIGHT ); } - UINT huds_both (UINT options) { return( (options & HUDS_BOTH) == HUDS_BOTH ); } + UINT huds_both (UINT options) { + return( (options & HUDS_BOTH) == HUDS_BOTH ); + } UINT huds_noticks (UINT options) { return( options & HUDS_NOTICKS ); } UINT huds_notext (UINT options) { return( options & HUDS_NOTEXT ); } UINT huds_top (UINT options) { return( options & HUDS_TOP ); } UINT huds_bottom (UINT options) { return( options & HUDS_BOTTOM ); } - + virtual void display_enable( bool working ) { is_enabled = !! working;} virtual void update( void ); @@ -427,7 +475,7 @@ class instr_item { // An Abstract Base Class (ABC) void SetPosition ( int x, int y, UINT width, UINT height ); UINT get_Handle( void ); virtual void draw( void ) = 0; // Required method in derived classes - + void drawOneLine( float x1, float y1, float x2, float y2) { HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2)); @@ -436,27 +484,44 @@ class instr_item { // An Abstract Base Class (ABC) { HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2)); } - void TextString( char *msg, float x, float y ) + void TextString( char *msg, float x, float y,int digit ) { - HUD_TextList.add(fgText(x, y, msg)); + HUD_TextList.add(fgText(x, y, msg,digit)); } int getStringWidth ( char *str ) { - if ( HUDtext && str ) - { + if ( HUDtext && str ) { float r, l ; - guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; + HUD_Font->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ; return FloatToInt( r - l ); } return 0 ; } - + + //code to draw ticks as small circles + void drawOneCircle(float x1, float y1, float r) + { + glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle + for (int count=0; count<25; count++) { + float cosine = r * cos(count * 2 * SG_PI/10.0); + float sine = r * sin(count * 2 * SG_PI/10.0); + glVertex2f(cosine+x1, sine+y1); + } + glEnd(); + } + }; typedef instr_item *HIptr; -//typedef deque < instr_item * > hud_deque_type; -//typedef hud_deque_type::iterator hud_deque_iterator; -//typedef hud_deque_type::const_iterator hud_deque_const_iterator; + +class HUDdraw { + public: + void operator() (HIptr elem) const { + if ( elem->enabled()) + elem->draw(); + } +}; + extern deque< instr_item *> HUD_deque; extern int HUD_style; @@ -468,43 +533,29 @@ extern int HUD_style; class instr_label : public instr_item { - private: - const char *pformat; - const char *pre_str; - const char *post_str; +private: + const char *pformat; + const char *pre_str; + const char *post_str; fgLabelJust justify; int fontSize; int blink; - char format_buffer[80]; - - public: - instr_label( int x, - int y, - UINT width, - UINT height, - FLTFNPTR data_source, - const char *label_format, - const char *pre_label_string = 0, - const char *post_label_string = 0, - float scale_data = 1.0, - UINT options = HUDS_TOP, - fgLabelJust justification = CENTER_JUST, - int font_size = SMALL, - int blinking = NOBLINK, - bool working = true); + char format_buffer[80]; + bool lat; + bool lon; + bool lbox; +public: + instr_label(const SGPropertyNode *); ~instr_label(); - instr_label( const instr_label & image); - instr_label & operator = (const instr_label & rhs ); - virtual void draw( void ); // Required method in base class + instr_label(const instr_label& image); + virtual void draw(void); }; -typedef instr_label * pInstlabel; - class lat_label : public instr_item { - private: +private: const char *pformat; const char *pre_str; const char *post_str; @@ -513,33 +564,32 @@ class lat_label : public instr_item { int blink; char format_buffer[80]; - public: +public: lat_label( int x, - int y, - UINT width, - UINT height, - FLTFNPTR data_source, - const char *label_format, - const char *pre_label_string = 0, - const char *post_label_string = 0, - float scale_data = 1.0, - UINT options = HUDS_TOP, - fgLabelJust justification = CENTER_JUST, - int font_size = SMALL, - int blinking = NOBLINK, - bool working = true); + int y, + UINT width, + UINT height, + FLTFNPTR data_source, + const char *label_format, + const char *pre_label_string, + const char *post_label_string, + float scale_data, + UINT options, + fgLabelJust justification, + int font_size, + int blinking, + bool working, + int digits =0 ); ~lat_label(); lat_label( const lat_label & image); - lat_label & operator = (const lat_label & rhs ); virtual void draw( void ); // Required method in base class }; -typedef lat_label * pLatlabel; class lon_label : public instr_item { - private: +private: const char *pformat; const char *pre_str; const char *post_str; @@ -548,30 +598,74 @@ class lon_label : public instr_item { int blink; char format_buffer[80]; - public: +public: lon_label( int x, - int y, - UINT width, - UINT height, - FLTFNPTR data_source, - const char *label_format, - const char *pre_label_string = 0, - const char *post_label_string = 0, - float scale_data = 1.0, - UINT options = HUDS_TOP, - fgLabelJust justification = CENTER_JUST, - int font_size = SMALL, - int blinking = NOBLINK, - bool working = true); + int y, + UINT width, + UINT height, + FLTFNPTR data_source, + const char *label_format, + const char *pre_label_string, + const char *post_label_string, + float scale_data, + UINT options, + fgLabelJust justification, + int font_size, + int blinking, + bool working, + int digit=0); + ~lon_label(); lon_label( const lon_label & image); - lon_label & operator = (const lon_label & rhs ); virtual void draw( void ); // Required method in base class }; -typedef lon_label * pLonlabel; + +// +// fgRunway_instr This class is responsible for rendering the active runway +// in the hud (if visible). +class runway_instr : public instr_item +{ +private: + void boundPoint(const sgdVec3& v, sgdVec3& m); + bool boundOutsidePoints(sgdVec3& v, sgdVec3& m); + bool drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& p1, const sgdVec3& p2); + void drawArrow(); + bool get_active_runway(FGRunway& rwy); + void get_rwy_points(sgdVec3 *points); + void setLineWidth(void); + + sgdVec3 points3d[6],points2d[6]; + double mm[16],pm[16], arrowScale, arrowRad, lnScale, scaleDist, default_pitch, default_heading; + GLint view[4]; + FGRunway runway; + FGViewer* cockpit_view; + unsigned short stippleOut,stippleCen; + bool drawIA,drawIAAlways; + RECT location; + POINT center; + +public: + runway_instr( int x, + int y, + int width, + int height, + float scale_data, + bool working = true); + + virtual void draw( void ); // Required method in base class + void setArrowRotationRadius(double radius); + void setArrowScale(double scale); // Scales the runway indication arrow + void setDrawArrow(bool draw); // Draws arrow when runway is not visible in HUD if draw=true + void setDrawArrowAlways(bool draw); //Always draws arrow if draw=true; + void setLineScale(double scale); //Sets the maximum line scale + void setScaleDist(double dist_nm); //Sets the distance where to start scaling the lines + void setStippleOutline(unsigned short stipple); //Sets the stipple pattern of the outline of the runway + void setStippleCenterline(unsigned short stipple); //Sets the stipple patter of the center line of the runway +}; + // // instr_scale This class is an abstract base class for both moving @@ -580,7 +674,7 @@ typedef lon_label * pLonlabel; // class instr_scale : public instr_item { - private: +private: float range_shown; // Width Units. float Maximum_value; // ceiling. float Minimum_value; // Representation floor. @@ -590,35 +684,34 @@ class instr_scale : public instr_item { UINT Modulo; // Roll over point int signif_digits; // digits to show to the right. - public: +public: instr_scale( int x, int y, UINT width, UINT height, FLTFNPTR load_fn, UINT options, - float show_range, - float max_value = 100.0, - float min_value = 0.0, - float disp_scaling = 1.0, - UINT major_divs = 10, - UINT minor_divs = 5, - UINT rollover = 0, - int dp_showing = 2, - bool working = true); + float show_range, + float max_value, + float min_value, + float disp_scaling, + UINT major_divs, + UINT minor_divs, + UINT rollover, + int dp_showing, + bool working = true); virtual ~instr_scale(); instr_scale( const instr_scale & image); - instr_scale & operator = (const instr_scale & rhs); virtual void draw ( void ) {}; // No-op here. Defined in derived classes. UINT div_min ( void ) { return Min_div;} UINT div_max ( void ) { return Maj_div;} - float min_val ( void ) { return Minimum_value;} - float max_val ( void ) { return Maximum_value;} + float min_val ( void ) { return Minimum_value;} + float max_val ( void ) { return Maximum_value;} UINT modulo ( void ) { return Modulo; } - float factor ( void ) { return scale_factor;} - float range_to_show( void ) { return range_shown;} + float factor ( void ) { return scale_factor;} + float range_to_show ( void ) { return range_shown;} }; // hud_card_ This class displays the indicated quantity on @@ -627,107 +720,151 @@ class instr_scale : public instr_item { // line. class hud_card : public instr_scale { - private: - float val_span; - float half_width_units; - - public: +private: + float val_span; + string type; + float half_width_units; + bool draw_tick_bottom; + bool draw_tick_top; + bool draw_tick_right; + bool draw_tick_left; + bool draw_cap_bottom; + bool draw_cap_top; + bool draw_cap_right; + bool draw_cap_left; + float marker_offset; + bool pointer; + string pointer_type; + string tick_type; + string tick_length; + float radius; + float maxValue; + float minValue; + int divisions; + int zoom; + UINT Maj_div; + UINT Min_div; + + +public: hud_card( int x, int y, UINT width, UINT height, FLTFNPTR load_fn, UINT options, - float maxValue = 100.0, - float minValue = 0.0, - float disp_scaling = 1.0, - UINT major_divs = 10, - UINT minor_divs = 5, - UINT modulator = 100, - int dp_showing = 2, - float value_span = 100.0, - bool working = true); + float maxValue, + float minValue, + float disp_scaling, + UINT major_divs, + UINT minor_divs, + UINT modulator, + int dp_showing, + float value_span, + string type, + bool draw_tick_bottom, + bool draw_tick_top, + bool draw_tick_right, + bool draw_tick_left, + bool draw_cap_bottom, + bool draw_cap_top, + bool draw_cap_right, + bool draw_cap_left, + float marker_offset, + bool pointer, + string pointer_type, + string tick_type, + string tick_length, + bool working, + float radius, + int divisions, + int zoom + ); + ~hud_card(); hud_card( const hud_card & image); - hud_card & operator = (const hud_card & rhs ); -// virtual void display_enable( bool setting ); + // virtual void display_enable( bool setting ); virtual void draw( void ); // Required method in base class + void circles(float,float,float); + void fixed(float,float,float,float,float,float); + void zoomed_scale(int,int); }; -typedef hud_card * pCardScale; -class guage_instr : public instr_scale { - public: - guage_instr( int x, +class gauge_instr : public instr_scale { +public: + gauge_instr( int x, int y, UINT width, UINT height, FLTFNPTR load_fn, UINT options, - float disp_scaling = 1.0, - float maxValue = 100, - float minValue = 0, - UINT major_divs = 50, - UINT minor_divs = 0, - int dp_showing = 2, - UINT modulus = 0, - bool working = true); - - ~guage_instr(); - guage_instr( const guage_instr & image); - guage_instr & operator = (const guage_instr & rhs ); + float disp_scaling, + float maxValue, + float minValue, + UINT major_divs, + UINT minor_divs, + int dp_showing, + UINT modulus, + bool working); + + ~gauge_instr(); + gauge_instr( const gauge_instr & image); virtual void draw( void ); // Required method in base class }; -typedef guage_instr * pGuageInst; + // // dual_instr_item This class was created to form the base class // for both panel and HUD Turn Bank Indicators. class dual_instr_item : public instr_item { - private: +private: FLTFNPTR alt_data_source; - public: +public: dual_instr_item ( int x, int y, UINT width, UINT height, FLTFNPTR chn1_source, FLTFNPTR chn2_source, - bool working = true, - UINT options = HUDS_TOP); + bool working, + UINT options ); virtual ~dual_instr_item() {}; dual_instr_item( const dual_instr_item & image); - dual_instr_item & operator = (const dual_instr_item & rhs ); float current_ch1( void ) { return (float)alt_data_source();} float current_ch2( void ) { return (float)get_value();} - virtual void draw ( void ) { } + virtual void draw( void ) { } }; -class fgTBI_instr : public dual_instr_item { - private: +class fgTBI_instr : public dual_instr_item +{ +private: UINT BankLimit; UINT SlewLimit; UINT scr_hole; + bool tsi; + float rad; - public: +public: fgTBI_instr( int x, int y, UINT width, UINT height, - FLTFNPTR chn1_source = get_roll, - FLTFNPTR chn2_source = get_sideslip, - float maxBankAngle = 45.0, - float maxSlipAngle = 5.0, - UINT gap_width = 5, - bool working = true); + FLTFNPTR chn1_source, + FLTFNPTR chn2_source, + float maxBankAngle, + float maxSlipAngle, + UINT gap_width, + bool working, + bool tsi, + float rad); fgTBI_instr( const fgTBI_instr & image); - fgTBI_instr & operator = (const fgTBI_instr & rhs ); ~fgTBI_instr(); @@ -737,58 +874,59 @@ class fgTBI_instr : public dual_instr_item { virtual void draw( void ); // Required method in base class }; -typedef fgTBI_instr * pTBI; class HudLadder : public dual_instr_item { - private: +private: UINT width_units; int div_units; UINT minor_div; UINT label_pos; UINT scr_hole; - UINT minimal; - float vmax; - float vmin; - float factor; - + float vmax; + float vmin; + float factor; + string hudladder_type; + bool frl; + bool target_spot; + bool velocity_vector; + bool drift_marker; + bool alpha_bracket; + bool energy_marker; + bool climb_dive_marker; + bool glide_slope_marker; + float glide_slope; + bool energy_worm; + bool waypoint_marker; + int zenith; + int nadir; + int hat; + + // The Ladder has it's own temporary display lists fgTextList TextList; fgLineList LineList; fgLineList StippleLineList; - public: - HudLadder( int x, - int y, - UINT width, - UINT height, - UINT minimal = 0, - FLTFNPTR ptch_source = get_roll, - FLTFNPTR roll_source = get_pitch, - float span_units = 45.0, - float division_units = 10.0, - float minor_division = 0.0, - UINT screen_hole = 70, - UINT lbl_pos = 0, - bool working = true ); - +public: + HudLadder(const SGPropertyNode *); ~HudLadder(); - HudLadder( const HudLadder & image ); - HudLadder & operator = ( const HudLadder & rhs ); - virtual void draw( void ); - - void Text( float x, float y, char *s) + virtual void draw(void); + void drawZenith(float, float, float); + void drawNadir(float, float, float); + + void Text(float x, float y, char *s) { - TextList.add( fgText( x, y, s) ); + TextList.add(fgText(x, y, s)); } - void Line( float x1, float y1, float x2, float y2) + void Line(float x1, float y1, float x2, float y2) { - LineList.add(fgLineSeg2D(x1,y1,x2,y2)); + LineList.add(fgLineSeg2D(x1, y1, x2, y2)); } - void StippleLine( float x1, float y1, float x2, float y2) + void StippleLine(float x1, float y1, float x2, float y2) { - StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2)); + StippleLineList.add(fgLineSeg2D(x1, y1, x2, y2)); } }; @@ -796,26 +934,11 @@ class HudLadder : public dual_instr_item { //using namespace std; //deque * Hdeque_ptr; -extern void HUD_brightkey( bool incr_bright ); extern int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ ); extern int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ ); extern void fgUpdateHUD( void ); - -extern void drawOneLine ( UINT x1, UINT y1, UINT x2, UINT y2); -extern void drawOneLine ( RECT &rect); -extern void textString ( int x, - int y, - char *msg, - void *font = GLUT_BITMAP_8_BY_13); -extern void strokeString( int x, - int y, - char *msg, - void *font = GLUT_STROKE_ROMAN, - float theta = 0); -//extern void strokeString(float xx, -// float yy, -// char *msg, -// void *font = GLUT_STROKE_ROMAN) +extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start, + GLfloat x_end, GLfloat y_end ); /* bool AddHUDInstrument( instr_item *pBlackBox ); @@ -829,4 +952,32 @@ void fgUpdateHUD2( Hptr hud ); // Future use? void fgHUDSetTimeMode( Hptr hud, int time_of_day ); */ + + + +class HUD_Properties : public SGPropertyChangeListener { +public: + HUD_Properties(); + void valueChanged(SGPropertyNode *n); + void setColor() const; + bool isVisible() const { return _visible; } + bool isAntialiased() const { return _antialiased; } + bool isTransparent() const { return _transparent; } + float alphaClamp() const { return _cl; } + +private: + float clamp(float f) { return f < 0.0f ? 0.0f : f > 1.0f ? 1.0f : f; } + SGPropertyNode_ptr _current; + SGPropertyNode_ptr _visibility; + SGPropertyNode_ptr _antialiasing; + SGPropertyNode_ptr _transparency; + SGPropertyNode_ptr _red, _green, _blue, _alpha; + SGPropertyNode_ptr _alpha_clamp; + SGPropertyNode_ptr _brightness; + bool _visible; + bool _antialiased; + bool _transparent; + float _r, _g, _b, _a, _cl; +}; + #endif // _HUD_H