X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCockpit%2Fhud.hxx;h=50365f35aaff4f5c54ca1e10d05f7865f060c08f;hb=029dda3297e3697438e1a58188527cbae90beebe;hp=2ddfb3a55c21f74b7111598f7d86bd28a570faec;hpb=fb40950e787e87da0ec9b8addeae5d44b53d6b7e;p=flightgear.git diff --git a/src/Cockpit/hud.hxx b/src/Cockpit/hud.hxx index 2ddfb3a55..50365f35a 100644 --- a/src/Cockpit/hud.hxx +++ b/src/Cockpit/hud.hxx @@ -38,7 +38,6 @@ # include #endif -#include #include #include @@ -46,6 +45,7 @@ //# include // for MAXINT //#endif +#include // for_each() #include // STL vector #include // STL double ended queue #include STL_FSTREAM @@ -54,13 +54,15 @@ #include #include +#include #include -#include #include #include
#include
+#include #include "hud_opts.hxx" +#include SG_USING_STD(deque); SG_USING_STD(vector); @@ -249,13 +251,21 @@ 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 float HUD_TextSize; extern fntRenderer *HUDtext; @@ -365,30 +375,13 @@ 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(); } - /* 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(); - } - glEnd(); - } */ }; class fgTextList { @@ -399,15 +392,15 @@ public: ~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(); + if( Font == 0 ) + return; + vector < fgText > :: iterator curString = List.begin(); + vector < fgText > :: iterator lastString = List.end(); + glPushAttrib( GL_COLOR_BUFFER_BIT ); glEnable ( GL_ALPHA_TEST ) ; glEnable ( GL_BLEND ) ; @@ -431,7 +424,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); } @@ -477,7 +470,6 @@ public: bool working = true, int digit = 0); //suma - instr_item( const instr_item & image ); instr_item & operator = ( const instr_item & rhs ); @@ -552,6 +544,15 @@ public: }; typedef instr_item *HIptr; + +class HUDdraw { + public: + void operator() (HIptr elem) const { + if( elem->enabled()) + elem->draw(); + } +}; + //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; @@ -681,6 +682,50 @@ public: 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 // scale and moving needle (fixed scale) indicators. It @@ -793,7 +838,8 @@ public: bool working, float radius, //suma int divisions, //suma - int zoom); //suma + int zoom //suma + ); ~hud_card(); @@ -922,12 +968,13 @@ private: int hat; //suma + // The Ladder has it's own temporary display lists fgTextList TextList; fgLineList LineList; fgLineList StippleLineList; public: - HudLadder( string name, + HudLadder( const string& name, int x, int y, UINT width, @@ -954,7 +1001,8 @@ public: bool working, int zenith, //suma int nadir, //suma - int hat); //suma + int hat + ); //suma ~HudLadder(); @@ -993,23 +1041,6 @@ extern void fgUpdateHUD( void ); extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start, GLfloat x_end, GLfloat y_end ); -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_9_BY_15,int digit=0); //suma -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) - /* bool AddHUDInstrument( instr_item *pBlackBox ); void DrawHUD ( void );