//
// 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$
#include <Include/fg_typedefs.h>
#include <Aircraft/aircraft.hxx>
+#include <Aircraft/controls.hxx>
#include <FDM/flight.hxx>
-#include <Controls/controls.hxx>
#include <GUI/gui.h>
#include <Main/globals.hxx>
#include <Main/viewmgr.hxx>
typedef struct {
int x, y;
} POINT;
-
+
typedef struct {
int top, bottom, left, right;
} RECT;
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 HUD_DAY 1
-#define HUD_NIGHT 2
-#define HUD_BRT_BLACK 3
-#define HUD_BRT_DARK 4
-#define HUD_BRT_MEDIUM 5
-#define HUD_BRT_LIGHT 6
-
// Label constants
#define HUD_FONT_SMALL 1
#define HUD_FONT_LARGE 2
}
~fgLineSeg2D() {}
-
+
void draw() const
{
glVertex2f(x0, y0);
#define USE_HUD_TextList
+extern fntTexFont *HUD_Font;
extern float HUD_TextSize;
extern fntRenderer *HUDtext;
extern float HUD_matrix[16];
public:
int digit; //suma
fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y) //suma
- {
+ {
strcpy(msg,c);
digit=digits; //suma
}
-
+
fgText( const fgText & image )
- : x(image.x), y(image.y),digit(image.digit) {strcpy(msg,image.msg);} //suma
+ : x(image.x), y(image.y),digit(image.digit) { strcpy(msg,image.msg); } //suma
fgText& operator = ( const fgText & image ) {
strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit; //suma
- return *this;
+ return *this;
}
- ~fgText() {msg[0]='\0';}
+ ~fgText() { msg[0]='\0'; }
int getStringWidth ( char *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 )) {
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 ;
}
-
+
// 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. begin suma
}
char *tmp=msg;
while(tmp[i]!='\0') {
- if((tmp[i]>='0') && (tmp[i]<='9'))
+ if((tmp[i]>='0') && (tmp[i]<='9'))
c++;
i++;
}
if(c>p) {
- fnt->setPointSize(8);
+ 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(12);
+ 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(12);
+ fnt->setPointSize(HUD_TextSize * 1.2);
fnt->start2f( x, y );
fnt->puts(tmp);
}
} else {
//if digits not equal to 1
- fnt->setPointSize(8);
+ fnt->setPointSize(HUD_TextSize * 0.8);
fnt->start2f( x, y );
fnt->puts( msg ) ;
}
public:
fgTextList ( void ) { Font = 0; }
~fgTextList( void ) {}
-
+
void setFont( fntRenderer *Renderer ) { Font = Renderer; }
void add( const fgText& String ) { List.push_back(String); }
void erase( void ) { List.erase( List.begin(), List.end() ); }
-
- void draw( void ) {
- 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 ) ;
- glAlphaFunc ( GL_GREATER, 0.1 ) ;
- glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
-
- Font->begin();
- for( ; curString != lastString; curString++ ) {
- curString->Draw(Font,curString->digit); //suma
- }
- Font->end();
-
- glDisable ( GL_TEXTURE_2D ) ;
- glPopAttrib();
- }
+ void draw( void );
};
bool broken;
UINT scr_span; // Working values for draw;
POINT mid_span; //
- int digits; //suma
-
+ int digits; //suma
+
public:
instr_item( int x,
int y,
float data_scaling,
UINT options,
bool working = true,
- int digit = 0); //suma
+ int digit = 0); //suma
instr_item( const instr_item & image );
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; } //suma
+ int get_digits ( void ) { return digits; } //suma
UINT huds_vert (UINT options) { return( options & HUDS_VERT ); }
UINT huds_left (UINT options) { return( options & HUDS_LEFT ); }
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 );
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));
}
void TextString( char *msg, float x, float y,int digit ) //suma
{
- HUD_TextList.add(fgText(x, y, msg,digit)); //suma
+ HUD_TextList.add(fgText(x, y, msg,digit)); //suma
}
int getStringWidth ( char *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);
+ 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();
+ }
+ glEnd();
}
-
+
};
typedef instr_item *HIptr;
int fontSize;
int blink;
char format_buffer[80];
- bool lat;
- bool lon;
- bool lbox;
+ bool lat;
+ bool lon;
+ bool lbox;
public:
instr_label( int x,
fgLabelJust justification,
int font_size,
int blinking,
- bool latitude,
- bool longitude,
- bool label_box,
+ bool latitude,
+ bool longitude,
+ bool label_box,
bool working,
int digit ); //suma);
const char *label_format,
const char *pre_label_string,
const char *post_label_string,
- float scale_data,
+ float scale_data,
UINT options,
fgLabelJust justification,
int font_size,
int blinking,
bool working,
- int digits =0 );//suma
+ int digits =0 );//suma
~lat_label();
const char *label_format,
const char *pre_label_string,
const char *post_label_string,
- float scale_data,
+ float scale_data,
UINT options,
fgLabelJust justification,
int font_size,
int blinking,
bool working,
- int digit=0); //suma
+ int digit=0); //suma
~lon_label();
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
+// 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;
-
+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);
+ 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
+ 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
};
UINT height,
FLTFNPTR load_fn,
UINT options,
- float show_range,
- float max_value,
- float min_value,
- float disp_scaling,
+ float show_range,
+ float max_value,
+ float min_value,
+ float disp_scaling,
UINT major_divs,
UINT minor_divs,
UINT rollover,
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
class hud_card : public instr_scale {
private:
- float val_span;
+ 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; //suma
- float maxValue; //suma
- float minValue; //suma
- int divisions; //suma
- int zoom; //suma
- UINT Maj_div; //suma
- UINT Min_div; //suma
-
-
+ 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; //suma
+ float maxValue; //suma
+ float minValue; //suma
+ int divisions; //suma
+ int zoom; //suma
+ UINT Maj_div; //suma
+ UINT Min_div; //suma
+
+
public:
hud_card( int x,
int y,
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 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, //suma
int divisions, //suma
- int zoom //suma
+ int zoom //suma
);
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
+class fgTBI_instr : public dual_instr_item
{
private:
UINT BankLimit;
UINT height,
FLTFNPTR chn1_source,
FLTFNPTR chn2_source,
- float maxBankAngle,
- float maxSlipAngle,
+ float maxBankAngle,
+ float maxSlipAngle,
UINT gap_width,
bool working,
- bool tsi, //suma
+ bool tsi, //suma
float rad); //suma
fgTBI_instr( const fgTBI_instr & image);
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; //suma
- int nadir; //suma
- int hat; //suma
-
+ bool energy_marker;
+ bool climb_dive_marker;
+ bool glide_slope_marker;
+ float glide_slope;
+ bool energy_worm;
+ bool waypoint_marker;
+ int zenith; //suma
+ int nadir; //suma
+ int hat; //suma
+
// The Ladder has it's own temporary display lists
fgTextList TextList;
public:
HudLadder( const string& name,
- int x,
+ int x,
int y,
UINT width,
UINT height,
- float factor,
+ float factor,
FLTFNPTR ptch_source,
FLTFNPTR roll_source,
float span_units,
float minor_division,
UINT screen_hole,
UINT lbl_pos,
- 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,
- bool working,
- int zenith, //suma
- int nadir, //suma
- int hat
+ 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,
+ bool working,
+ int zenith, //suma
+ int nadir, //suma
+ int hat
); //suma
//using namespace std;
//deque <instr_item> * Hdeque_ptr;
-extern void HUD_masterswitch( bool incr );
-extern void HUD_brightkey( bool incr_bright );
extern int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ );
extern int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ );
extern void fgUpdateHUD( void );
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