1
0
Fork 0

indentation, trailing spaces, ... (cosmetics only); doesn't make

the coding style fully consistent yet, but it's good enough for code changes
(mixed tab/space indents, 4 space tabs etc. are a royal pain)
This commit is contained in:
mfranz 2006-06-14 10:30:10 +00:00
parent e545c563d5
commit 471fecd72c
16 changed files with 1054 additions and 1096 deletions

View file

@ -25,7 +25,7 @@
# include <config.h> # include <config.h>
#endif #endif
#ifdef HAVE_WINDOWS_H #ifdef HAVE_WINDOWS_H
# include <windows.h> # include <windows.h>
#endif #endif
@ -77,7 +77,7 @@ float get_lat_min( void )
{ {
double a, d; double a, d;
a = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES; a = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
if (a < 0.0) { if (a < 0.0) {
a = -a; a = -a;
} }
@ -99,7 +99,7 @@ get_formated_gmt_time( void )
{ {
static char buf[32]; static char buf[32];
const struct tm *p = globals->get_time_params()->getGmt(); const struct tm *p = globals->get_time_params()->getGmt();
sprintf( buf, "%d/%d/%4d %d:%02d:%02d", sprintf( buf, "%d/%d/%4d %d:%02d:%02d",
p->tm_mon+1, p->tm_mday, 1900 + p->tm_year, p->tm_mon+1, p->tm_mday, 1900 + p->tm_year,
p->tm_hour, p->tm_min, p->tm_sec); p->tm_hour, p->tm_min, p->tm_sec);
@ -110,12 +110,12 @@ get_formated_gmt_time( void )
float get_long_min( void ) float get_long_min( void )
{ {
double a, d; double a, d;
a = current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES; a = current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
if (a < 0.0) { if (a < 0.0) {
a = -a; a = -a;
} }
d = (double) ( (int) a); d = (double) ( (int) a);
float lon_min = (a - d) * 60.0; float lon_min = (a - d) * 60.0;
return lon_min; return lon_min;
} }
@ -151,7 +151,7 @@ float get_speed( void )
static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up"); static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up");
float speed = current_aircraft.fdm_state->get_V_calibrated_kts() float speed = current_aircraft.fdm_state->get_V_calibrated_kts()
* speedup_node->getIntValue(); * speedup_node->getIntValue();
return speed; return speed;
} }
@ -159,7 +159,7 @@ float get_speed( void )
float get_mach(void) float get_mach(void)
{ {
return current_aircraft.fdm_state->get_Mach_number(); return current_aircraft.fdm_state->get_Mach_number();
} }
float get_aoa( void ) float get_aoa( void )
{ {
@ -228,7 +228,7 @@ float get_frame_rate( void )
float get_fov( void ) float get_fov( void )
{ {
return globals->get_current_view()->get_fov(); return globals->get_current_view()->get_fov();
} }
float get_vfc_ratio( void ) float get_vfc_ratio( void )
@ -272,13 +272,13 @@ float get_view_direction( void )
{ {
double view_off = SGD_2PI - globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS; double view_off = SGD_2PI - globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS;
double view = ( current_aircraft.fdm_state->get_Psi() + view_off) double view = ( current_aircraft.fdm_state->get_Psi() + view_off)
* SGD_RADIANS_TO_DEGREES; * SGD_RADIANS_TO_DEGREES;
if(view > 360.) if (view > 360.)
view -= 360.; view -= 360.;
else if(view<0.) else if (view<0.)
view += 360.; view += 360.;
return view; return view;
} }
@ -531,11 +531,11 @@ float get_aux18 (void)
/****************************************************************************/ /****************************************************************************/
char *dmshh_format(double degrees) char *dmshh_format(double degrees)
{ {
static char buf[16]; static char buf[16];
int deg_part; int deg_part;
int min_part; int min_part;
double sec_part; double sec_part;
if (degrees < 0) if (degrees < 0)
degrees = -degrees; degrees = -degrees;
@ -573,9 +573,9 @@ static char *toDM(float dd)
double sign = 1; double sign = 1;
int deg; int deg;
if (dd < 0) { if (dd < 0)
sign = -1; sign = -1;
}
/* round for minutes expressed to three decimal places */ /* round for minutes expressed to three decimal places */
tempdd = fabs(dd) + (5.0E-4 / 60.0); tempdd = fabs(dd) + (5.0E-4 / 60.0);
deg = (int)tempdd; deg = (int)tempdd;
@ -604,9 +604,9 @@ static char *toDMS(float dd)
double sec; double sec;
double sign = 1; double sign = 1;
if(dd < 0) { if (dd < 0)
sign = -1; sign = -1;
}
/* round up for seconds expressed to one decimal place */ /* round up for seconds expressed to one decimal place */
tempdd = fabs(dd) + (0.05 / 3600.0); tempdd = fabs(dd) + (0.05 / 3600.0);
deg = (int)tempdd; deg = (int)tempdd;
@ -631,7 +631,7 @@ char *coord_format_lat(float latitude)
// dmshh_format(latitude), // dmshh_format(latitude),
// toDMS(latitude), // toDMS(latitude),
// toDM(latitude), // toDM(latitude),
fgLatLonFormat(latitude), fgLatLonFormat(latitude),
latitude > 0 ? 'N' : 'S'); latitude > 0 ? 'N' : 'S');
return buf; return buf;
} }
@ -653,11 +653,11 @@ void fgLatLonFormatToggle( puObject *)
{ {
static int toggle = 0; static int toggle = 0;
if ( toggle ) if ( toggle )
fgLatLonFormat = toDM; fgLatLonFormat = toDM;
else else
fgLatLonFormat = toDMS; fgLatLonFormat = toDMS;
toggle = ~toggle; toggle = ~toggle;
} }
@ -685,30 +685,30 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
// If aircraft has HUD specified we will get the specs from its def // If aircraft has HUD specified we will get the specs from its def
// file. For now we will depend upon hard coding in hud? // file. For now we will depend upon hard coding in hud?
// We must insure that the existing instrument link is purged. // We must insure that the existing instrument link is purged.
// This is done by deleting the links in the list. // This is done by deleting the links in the list.
// HI_Head is now a null pointer so we can generate a new list from the // HI_Head is now a null pointer so we can generate a new list from the
// current aircraft. // current aircraft.
fgHUDInit( cur_aircraft ); fgHUDInit( cur_aircraft );
ac_cockpit = new fg_Cockpit(); ac_cockpit = new fg_Cockpit();
// Have to set the LatLon display type // Have to set the LatLon display type
fgLatLonFormat = toDM; fgLatLonFormat = toDM;
SG_LOG( SG_COCKPIT, SG_INFO, SG_LOG( SG_COCKPIT, SG_INFO,
" Code " << ac_cockpit->code() << " Status " " Code " << ac_cockpit->code() << " Status "
<< ac_cockpit->status() ); << ac_cockpit->status() );
return true; return true;
} }
void fgCockpitUpdate( void ) { void fgCockpitUpdate( void ) {
SG_LOG( SG_COCKPIT, SG_DEBUG, SG_LOG( SG_COCKPIT, SG_DEBUG,
"Cockpit: code " << ac_cockpit->code() << " status " "Cockpit: code " << ac_cockpit->code() << " status "
<< ac_cockpit->status() ); << ac_cockpit->status() );
static const SGPropertyNode * xsize_node = fgGetNode("/sim/startup/xsize"); static const SGPropertyNode * xsize_node = fgGetNode("/sim/startup/xsize");
@ -719,7 +719,7 @@ void fgCockpitUpdate( void ) {
int iwidth = xsize_node->getIntValue(); int iwidth = xsize_node->getIntValue();
int iheight = ysize_node->getIntValue(); int iheight = ysize_node->getIntValue();
// FIXME: inefficient // FIXME: inefficient
if ( hud_visibility_node->getBoolValue() ) { if ( hud_visibility_node->getBoolValue() ) {
// This will check the global hud linked list pointer. // This will check the global hud linked list pointer.
// If there is anything to draw it will. // If there is anything to draw it will.

View file

@ -41,8 +41,8 @@
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> // char related functions #include <stdio.h> // char related functions
#include <string.h> // strcmp() #include <string.h> // strcmp()
#include SG_GLU_H #include SG_GLU_H
@ -140,18 +140,18 @@ static bool glide;
static float glide_slope_val; static float glide_slope_val;
static bool worm_energy; static bool worm_energy;
static bool waypoint; static bool waypoint;
static string type_tick;//hud static string type_tick;
static string length_tick;//hud static string length_tick;
static bool label_box;//hud static bool label_box;
static int digits; //suma static int digits;
static float radius; //suma static float radius;
static int divisions; //suma static int divisions;
static int zoom; //suma static int zoom;
static int zenith; //suma static int zenith;
static int nadir ; //suma static int nadir ;
static int hat; //suma static int hat;
static bool tsi; //suma static bool tsi;
static float rad; //suma static float rad;
static FLTFNPTR load_fn; static FLTFNPTR load_fn;
@ -229,16 +229,14 @@ readLadder(const SGPropertyNode * node)
worm_energy = node->getBoolValue("enable_energy_marker",false); worm_energy = node->getBoolValue("enable_energy_marker",false);
waypoint = node->getBoolValue("enable_waypoint_marker",false); waypoint = node->getBoolValue("enable_waypoint_marker",false);
working = node->getBoolValue("working"); working = node->getBoolValue("working");
zenith = node->getIntValue("zenith"); //suma zenith = node->getIntValue("zenith");
nadir = node->getIntValue("nadir"); //suma nadir = node->getIntValue("nadir");
hat = node->getIntValue("hat"); hat = node->getIntValue("hat");
// The factor assumes a base of 55 degrees per 640 pixels. // The factor assumes a base of 55 degrees per 640 pixels.
// Invert to convert the "compression" factor to a // Invert to convert the "compression" factor to a
// pixels-per-degree number. // pixels-per-degree number.
if(fgGetBool("/sim/hud/enable3d", true)) if (fgGetBool("/sim/hud/enable3d", true)) {
{ if (HUD_style == 1) {
if (HUD_style == 1)
{
factor = 1; factor = 1;
factor = (640./55.) / factor; factor = (640./55.) / factor;
} }
@ -291,17 +289,17 @@ readCard(const SGPropertyNode * node)
marker_off = node->getFloatValue("marker_offset",0.0); marker_off = node->getFloatValue("marker_offset",0.0);
enable_pointer = node->getBoolValue("enable_pointer",true); enable_pointer = node->getBoolValue("enable_pointer",true);
type_pointer = node->getStringValue("pointer_type"); type_pointer = node->getStringValue("pointer_type");
type_tick = node->getStringValue("tick_type");//hud Can be 'circle' or 'line' type_tick = node->getStringValue("tick_type"); // 'circle' or 'line'
length_tick = node->getStringValue("tick_length");//hud For variable length length_tick = node->getStringValue("tick_length"); // for variable length
working = node->getBoolValue("working"); working = node->getBoolValue("working");
radius = node->getFloatValue("radius"); //suma radius = node->getFloatValue("radius");
divisions = node->getIntValue("divisions"); //suma divisions = node->getIntValue("divisions");
zoom = node->getIntValue("zoom"); //suma zoom = node->getIntValue("zoom");
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
if(type=="gauge") { if (type=="gauge") {
span_units = maxValue - minValue; span_units = maxValue - minValue;
} }
@ -359,12 +357,12 @@ readCard(const SGPropertyNode * node)
marker_off, marker_off,
enable_pointer, enable_pointer,
type_pointer, type_pointer,
type_tick,//hud type_tick,
length_tick,//hud length_tick,
working, working,
radius, //suma radius,
divisions, //suma divisions,
zoom //suma zoom
); );
} else { } else {
p = (instr_item *) new gauge_instr( x, // x p = (instr_item *) new gauge_instr( x, // x
@ -406,9 +404,9 @@ readLabel(const SGPropertyNode * node)
blinking = node->getIntValue("blinking"); blinking = node->getIntValue("blinking");
latitude = node->getBoolValue("latitude",false); latitude = node->getBoolValue("latitude",false);
longitude = node->getBoolValue("longitude",false); longitude = node->getBoolValue("longitude",false);
label_box = node->getBoolValue("label_box",false);//hud label_box = node->getBoolValue("label_box",false);
working = node->getBoolValue("working"); working = node->getBoolValue("working");
digits = node->getIntValue("digits"); //suma digits = node->getIntValue("digits");
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
@ -536,9 +534,9 @@ readLabel(const SGPropertyNode * node)
blinking, blinking,
latitude, latitude,
longitude, longitude,
label_box, //hud label_box,
working, working,
digits); //suma digits);
return p; return p;
} // end readLabel } // end readLabel
@ -558,8 +556,8 @@ readTBI(const SGPropertyNode * node)
maxSlipAngle = node->getFloatValue("maxSlipAngle"); maxSlipAngle = node->getFloatValue("maxSlipAngle");
gap_width = node->getIntValue("gap_width"); gap_width = node->getIntValue("gap_width");
working = node->getBoolValue("working"); working = node->getBoolValue("working");
tsi = node->getBoolValue("tsi"); //suma tsi = node->getBoolValue("tsi");
rad = node->getFloatValue("rad"); //suma rad = node->getFloatValue("rad");
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name); SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
@ -574,8 +572,8 @@ readTBI(const SGPropertyNode * node)
maxSlipAngle, maxSlipAngle,
gap_width, gap_width,
working, working,
tsi, //suma tsi,
rad); //suma rad);
return p; return p;
} //end readTBI } //end readTBI
@ -838,7 +836,7 @@ void fgHUDReshape(void) {
void fgUpdateHUD( void ) { void fgUpdateHUD( void ) {
static const SGPropertyNode *enable3d_node = fgGetNode("/sim/hud/enable3d"); static const SGPropertyNode *enable3d_node = fgGetNode("/sim/hud/enable3d");
if( HUD_style == 1 && enable3d_node->getBoolValue() ) { if ( HUD_style == 1 && enable3d_node->getBoolValue() ) {
fgUpdateHUDVirtual(); fgUpdateHUDVirtual();
return; return;
} }
@ -846,7 +844,7 @@ void fgUpdateHUD( void ) {
static const float normal_aspect = float(640) / float(480); static const float normal_aspect = float(640) / float(480);
// note: aspect_ratio is Y/X // note: aspect_ratio is Y/X
float current_aspect = 1.0f/globals->get_current_view()->get_aspect_ratio(); float current_aspect = 1.0f/globals->get_current_view()->get_aspect_ratio();
if( current_aspect > normal_aspect ) { if ( current_aspect > normal_aspect ) {
float aspect_adjust = current_aspect / normal_aspect; float aspect_adjust = current_aspect / normal_aspect;
float adjust = 320.0f*aspect_adjust - 320.0f; float adjust = 320.0f*aspect_adjust - 320.0f;
fgUpdateHUD( -adjust, 0.0f, 640.0f+adjust, 480.0f ); fgUpdateHUD( -adjust, 0.0f, 640.0f+adjust, 480.0f );
@ -877,7 +875,8 @@ void fgUpdateHUDVirtual()
lookat[0] = -sin(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg()); lookat[0] = -sin(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
lookat[1] = tan(SG_DEGREES_TO_RADIANS * view->getPitchOffset_deg()); lookat[1] = tan(SG_DEGREES_TO_RADIANS * view->getPitchOffset_deg());
lookat[2] = -cos(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg()); lookat[2] = -cos(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
if(fabs(lookat[1]) > 9999) lookat[1] = 9999; // FPU sanity if (fabs(lookat[1]) > 9999)
lookat[1] = 9999; // FPU sanity
gluLookAt(0, 0, 0, lookat[0], lookat[1], lookat[2], 0, 1, 0); gluLookAt(0, 0, 0, lookat[0], lookat[1], lookat[2], 0, 1, 0);
// Map the -1:1 square to a 55.0x41.25 degree wide patch at z=1. // Map the -1:1 square to a 55.0x41.25 degree wide patch at z=1.
@ -929,7 +928,7 @@ void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
void drawHUD() void drawHUD()
{ {
if( !HUD_deque.size() ) // Trust everyone, but ALWAYS cut the cards! if ( !HUD_deque.size() ) // Trust everyone, but ALWAYS cut the cards!
return; return;
HUD_TextList.erase(); HUD_TextList.erase();

View file

@ -266,18 +266,18 @@ private:
float x, y; float x, y;
char msg[64]; char msg[64];
public: public:
int digit; //suma int digit;
fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y) //suma fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y)
{ {
strcpy(msg,c); strcpy(msg,c);
digit=digits; //suma digit=digits;
} }
fgText( const fgText & image ) 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); }
fgText& operator = ( const fgText & image ) { fgText& operator = ( const fgText & image ) {
strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit; //suma strcpy(msg,image.msg); x = image.x; y = image.y;digit=image.digit;
return *this; return *this;
} }
@ -305,26 +305,26 @@ public:
// this code is changed to display Numbers with big/small digits // this code is changed to display Numbers with big/small digits
// according to MIL Standards for example Altitude above 10000 ft // according to MIL Standards for example Altitude above 10000 ft
// is shown as 10ooo. begin suma // is shown as 10ooo.
void Draw(fntRenderer *fnt,int digits) { void Draw(fntRenderer *fnt,int digits) {
if(digits==1) { if (digits==1) {
int c=0,i=0; int c=0,i=0;
char *t=msg; char *t=msg;
int p=4; int p=4;
if(t[0]=='-') { if (t[0]=='-') {
//if negative value then increase the c and p values //if negative value then increase the c and p values
//for '-' sign. c++; //for '-' sign. c++;
p++; p++;
} }
char *tmp=msg; char *tmp=msg;
while(tmp[i]!='\0') { while (tmp[i]!='\0') {
if((tmp[i]>='0') && (tmp[i]<='9')) if ((tmp[i]>='0') && (tmp[i]<='9'))
c++; c++;
i++; i++;
} }
if(c>p) { if (c>p) {
fnt->setPointSize(HUD_TextSize * 0.8); fnt->setPointSize(HUD_TextSize * 0.8);
int p1=c-3; int p1=c-3;
char *tmp1=msg+p1; char *tmp1=msg+p1;
@ -352,7 +352,6 @@ public:
fnt->puts( msg ) ; fnt->puts( msg ) ;
} }
} }
//end suma
void Draw() void Draw()
{ {
@ -426,7 +425,7 @@ private:
bool broken; bool broken;
UINT scr_span; // Working values for draw; UINT scr_span; // Working values for draw;
POINT mid_span; // POINT mid_span; //
int digits; //suma int digits;
public: public:
instr_item( int x, instr_item( int x,
@ -437,7 +436,7 @@ public:
float data_scaling, float data_scaling,
UINT options, UINT options,
bool working = true, bool working = true,
int digit = 0); //suma int digit = 0);
instr_item( const instr_item & image ); instr_item( const instr_item & image );
@ -453,7 +452,7 @@ public:
UINT get_span ( void ) { return scr_span; } UINT get_span ( void ) { return scr_span; }
POINT get_centroid ( void ) { return mid_span; } POINT get_centroid ( void ) { return mid_span; }
UINT get_options ( void ) { return opts; } UINT get_options ( void ) { return opts; }
int get_digits ( void ) { return digits; } //suma int get_digits ( void ) { return digits; }
UINT huds_vert (UINT options) { return( options & HUDS_VERT ); } UINT huds_vert (UINT options) { return( options & HUDS_VERT ); }
UINT huds_left (UINT options) { return( options & HUDS_LEFT ); } UINT huds_left (UINT options) { return( options & HUDS_LEFT ); }
@ -483,9 +482,9 @@ public:
{ {
HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2)); HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
} }
void TextString( char *msg, float x, float y,int digit ) //suma void TextString( char *msg, float x, float y,int digit )
{ {
HUD_TextList.add(fgText(x, y, msg,digit)); //suma HUD_TextList.add(fgText(x, y, msg,digit));
} }
int getStringWidth ( char *str ) int getStringWidth ( char *str )
{ {
@ -501,7 +500,7 @@ public:
void drawOneCircle(float x1, float y1, float r) void drawOneCircle(float x1, float y1, float r)
{ {
glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
for(int count=0; count<25; count++) { for (int count=0; count<25; count++) {
float cosine = r * cos(count * 2 * SG_PI/10.0); float cosine = r * cos(count * 2 * SG_PI/10.0);
float sine = r * sin(count * 2 * SG_PI/10.0); float sine = r * sin(count * 2 * SG_PI/10.0);
glVertex2f(cosine+x1, sine+y1); glVertex2f(cosine+x1, sine+y1);
@ -516,7 +515,7 @@ typedef instr_item *HIptr;
class HUDdraw { class HUDdraw {
public: public:
void operator() (HIptr elem) const { void operator() (HIptr elem) const {
if( elem->enabled()) if ( elem->enabled())
elem->draw(); elem->draw();
} }
}; };
@ -565,7 +564,7 @@ public:
bool longitude, bool longitude,
bool label_box, bool label_box,
bool working, bool working,
int digit ); //suma); int digit );
~instr_label(); ~instr_label();
@ -601,7 +600,7 @@ public:
int font_size, int font_size,
int blinking, int blinking,
bool working, bool working,
int digits =0 );//suma int digits =0 );
~lat_label(); ~lat_label();
@ -636,7 +635,7 @@ public:
int font_size, int font_size,
int blinking, int blinking,
bool working, bool working,
int digit=0); //suma int digit=0);
~lon_label(); ~lon_label();
@ -761,13 +760,13 @@ private:
string pointer_type; string pointer_type;
string tick_type; string tick_type;
string tick_length; string tick_length;
float radius; //suma float radius;
float maxValue; //suma float maxValue;
float minValue; //suma float minValue;
int divisions; //suma int divisions;
int zoom; //suma int zoom;
UINT Maj_div; //suma UINT Maj_div;
UINT Min_div; //suma UINT Min_div;
public: public:
@ -800,9 +799,9 @@ public:
string tick_type, string tick_type,
string tick_length, string tick_length,
bool working, bool working,
float radius, //suma float radius,
int divisions, //suma int divisions,
int zoom //suma int zoom
); );
@ -810,9 +809,9 @@ public:
hud_card( const hud_card & image); hud_card( const hud_card & image);
// virtual void display_enable( bool setting ); // virtual void display_enable( bool setting );
virtual void draw( void ); // Required method in base class virtual void draw( void ); // Required method in base class
void circles(float,float,float); // suma void circles(float,float,float);
void fixed(float,float,float,float,float,float); //suma void fixed(float,float,float,float,float,float);
void zoomed_scale(int,int); //suma void zoomed_scale(int,int);
}; };
typedef hud_card * pCardScale; typedef hud_card * pCardScale;
@ -872,8 +871,8 @@ private:
UINT BankLimit; UINT BankLimit;
UINT SlewLimit; UINT SlewLimit;
UINT scr_hole; UINT scr_hole;
bool tsi; //suma bool tsi;
float rad; //suma float rad;
public: public:
fgTBI_instr( int x, fgTBI_instr( int x,
@ -886,8 +885,8 @@ public:
float maxSlipAngle, float maxSlipAngle,
UINT gap_width, UINT gap_width,
bool working, bool working,
bool tsi, //suma bool tsi,
float rad); //suma float rad);
fgTBI_instr( const fgTBI_instr & image); fgTBI_instr( const fgTBI_instr & image);
@ -923,9 +922,9 @@ private:
float glide_slope; float glide_slope;
bool energy_worm; bool energy_worm;
bool waypoint_marker; bool waypoint_marker;
int zenith; //suma int zenith;
int nadir; //suma int nadir;
int hat; //suma int hat;
// The Ladder has it's own temporary display lists // The Ladder has it's own temporary display lists
@ -959,18 +958,18 @@ public:
bool energy_worm, bool energy_worm,
bool waypoint_marker, bool waypoint_marker,
bool working, bool working,
int zenith, //suma int zenith,
int nadir, //suma int nadir,
int hat int hat
); //suma );
~HudLadder(); ~HudLadder();
HudLadder( const HudLadder & image ); HudLadder( const HudLadder & image );
virtual void draw( void ); virtual void draw( void );
void drawZenith(float,float,float); //suma void drawZenith(float,float,float);
void drawNadir(float, float, float); //suma void drawNadir(float, float, float);
void Text( float x, float y, char *s) void Text( float x, float y, char *s)
{ {

View file

@ -45,8 +45,8 @@ hud_card::hud_card(
float mark_offset, float mark_offset,
bool pointer_enable, bool pointer_enable,
string type_pointer, string type_pointer,
string type_tick,//hud string type_tick,
string length_tick,//hud string length_tick,
bool working, bool working,
float rad, float rad,
int divs, int divs,
@ -70,8 +70,8 @@ hud_card::hud_card(
marker_offset (mark_offset), marker_offset (mark_offset),
pointer (pointer_enable), pointer (pointer_enable),
pointer_type (type_pointer), pointer_type (type_pointer),
tick_type (type_tick), //hud tick_type (type_tick),
tick_length (length_tick), //hud tick_length (length_tick),
Maj_div (major_divs), Maj_div (major_divs),
Min_div (minor_divs) Min_div (minor_divs)
@ -113,8 +113,8 @@ hud_card::hud_card(const hud_card & image) :
marker_offset (image.marker_offset), marker_offset (image.marker_offset),
pointer (image.pointer), pointer (image.pointer),
pointer_type (image.pointer_type), pointer_type (image.pointer_type),
tick_type(image.tick_type), //hud tick_type(image.tick_type),
tick_length(image.tick_length), //hud tick_length(image.tick_length),
Maj_div(image.Maj_div), Maj_div(image.Maj_div),
Min_div(image.Min_div) Min_div(image.Min_div)

View file

@ -4,25 +4,25 @@
//============ Top of dual_instr_item class member definitions ============ //============ Top of dual_instr_item class member definitions ============
dual_instr_item :: dual_instr_item::dual_instr_item(
dual_instr_item ( int x, int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR chn1_source, FLTFNPTR chn1_source,
FLTFNPTR chn2_source, FLTFNPTR chn2_source,
bool working, bool working,
UINT options ): UINT options ) :
instr_item( x, y, width, height, instr_item( x, y, width, height,
chn1_source, options, working), chn1_source, options, working),
alt_data_source( chn2_source ) alt_data_source( chn2_source )
{ {
} }
dual_instr_item ::
dual_instr_item( const dual_instr_item & image) : dual_instr_item::dual_instr_item( const dual_instr_item & image) :
instr_item ((instr_item &) image ), instr_item ((instr_item &) image ),
alt_data_source( image.alt_data_source) alt_data_source( image.alt_data_source)
{ {
} }

View file

@ -3,28 +3,28 @@
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, digit ) TextString( text, x , y,digit ) #define textString(x, y, text, digit) TextString(text, x , y ,digit)
#else #else
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ) #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif #endif
//============== Top of gauge_instr class member definitions ============== //============== Top of gauge_instr class member definitions ==============
gauge_instr::gauge_instr( gauge_instr::gauge_instr(
int x, int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR load_fn, FLTFNPTR load_fn,
UINT options, UINT options,
float disp_scale, float disp_scale,
float maxValue, float maxValue,
float minValue, float minValue,
UINT major_divs, UINT major_divs,
UINT minor_divs, UINT minor_divs,
int dp_showing, int dp_showing,
UINT modulus, UINT modulus,
bool working) : bool working) :
instr_scale( x, y, width, height, instr_scale( x, y, width, height,
load_fn, options, load_fn, options,
(maxValue - minValue), // Always shows span? (maxValue - minValue), // Always shows span?
@ -320,7 +320,7 @@ void gauge_instr::draw (void)
if ( !(i%(int)div_max()) ) { if ( !(i%(int)div_max()) ) {
if (modulo()) { if (modulo()) {
if ( disp_val < 0) { if ( disp_val < 0) {
while( disp_val < 0 ) { while ( disp_val < 0 ) {
disp_val += modulo(); disp_val += modulo();
} }
} }

View file

@ -8,79 +8,78 @@ int instr_item :: brightness = 5;/*HUD_BRT_MEDIUM*/
glRGBTRIPLE instr_item :: color = {0.0, 1.0, 0.0}; glRGBTRIPLE instr_item :: color = {0.0, 1.0, 0.0};
// constructor ( No default provided ) // constructor ( No default provided )
instr_item :: instr_item::instr_item(
instr_item( int x, int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR data_source, FLTFNPTR data_source,
float data_scaling, float data_scaling,
UINT options, UINT options,
bool working, bool working,
int digit) : //suma int digit) :
handle ( ++instances ), handle ( ++instances ),
load_value_fn ( data_source ), load_value_fn ( data_source ),
disp_factor ( data_scaling ), disp_factor ( data_scaling ),
opts ( options ), opts ( options ),
is_enabled ( working ), is_enabled ( working ),
broken ( FALSE ), broken ( FALSE ),
digits ( digit ) //suma digits ( digit )
{ {
scrn_pos.left = x; scrn_pos.left = x;
scrn_pos.top = y; scrn_pos.top = y;
scrn_pos.right = width; scrn_pos.right = width;
scrn_pos.bottom = height; scrn_pos.bottom = height;
// Set up convenience values for centroid of the box and // Set up convenience values for centroid of the box and
// the span values according to orientation // the span values according to orientation
if( opts & HUDS_VERT) { // Vertical style if (opts & HUDS_VERT) { // Vertical style
// Insure that the midpoint marker will fall exactly at the // Insure that the midpoint marker will fall exactly at the
// middle of the bar. // middle of the bar.
if( !(scrn_pos.bottom % 2)) { if (!(scrn_pos.bottom % 2))
scrn_pos.bottom++; scrn_pos.bottom++;
}
scr_span = scrn_pos.bottom; scr_span = scrn_pos.bottom;
} else {
// Insure that the midpoint marker will fall exactly at the
// middle of the bar.
if (!(scrn_pos.right % 2))
scrn_pos.right++;
scr_span = scrn_pos.right;
} }
else {
// Insure that the midpoint marker will fall exactly at the // Here we work out the centroid for the corrected box.
// middle of the bar. mid_span.x = scrn_pos.left + (scrn_pos.right >> 1);
if( !(scrn_pos.right % 2)) { mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
scrn_pos.right++;
}
scr_span = scrn_pos.right;
}
// Here we work out the centroid for the corrected box.
mid_span.x = scrn_pos.left + (scrn_pos.right >> 1);
mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
} }
// copy constructor // copy constructor
instr_item :: instr_item::instr_item( const instr_item & image ) :
instr_item ( const instr_item & image ): handle ( ++instances ),
handle ( ++instances ), scrn_pos ( image.scrn_pos ),
scrn_pos ( image.scrn_pos ), load_value_fn( image.load_value_fn),
load_value_fn( image.load_value_fn), disp_factor ( image.disp_factor ),
disp_factor ( image.disp_factor ), opts ( image.opts ),
opts ( image.opts ), is_enabled ( image.is_enabled ),
is_enabled ( image.is_enabled ), broken ( image.broken ),
broken ( image.broken ), scr_span ( image.scr_span ),
scr_span ( image.scr_span ), mid_span ( image.mid_span )
mid_span ( image.mid_span )
{ {
} }
instr_item :: ~instr_item () instr_item::~instr_item ()
{ {
if( instances ) { if (instances)
instances--; instances--;
}
} }
void instr_item ::
update( void ) void instr_item::update( void )
{ {
} }
@ -89,24 +88,25 @@ void instr_item ::
// to simply not display, but more sophisticated behavior is available // to simply not display, but more sophisticated behavior is available
// by over riding the function which is virtual in this class. // by over riding the function which is virtual in this class.
void instr_item :: void instr_item::break_display ( bool bad )
break_display ( bool bad )
{ {
broken = !!bad; broken = !!bad;
is_enabled = FALSE; is_enabled = FALSE;
} }
void instr_item ::
SetBrightness ( int level ) void instr_item::SetBrightness ( int level )
{ {
brightness = level; // This is all we will do for now. Later the brightness = level; // This is all we will do for now. Later the
// brightness levels will be sensitive both to // brightness levels will be sensitive both to
// the control knob and the outside light levels // the control knob and the outside light levels
// to emulated night vision effects. // to emulated night vision effects.
} }
UINT instr_item :: get_Handle( void )
UINT instr_item::get_Handle( void )
{ {
return handle; return handle;
} }

View file

@ -3,92 +3,81 @@
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, digit ) TextString( text, x , y,digit ) //suma #define textString(x, y, text, digit) TextString(text, x , y ,digit)
#else #else
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ); //suma #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================
instr_label :: instr_label::instr_label(
instr_label( int x, int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR data_source, FLTFNPTR data_source,
const char *label_format, const char *label_format,
const char *pre_label_string, const char *pre_label_string,
const char *post_label_string, const char *post_label_string,
float scale_data, float scale_data,
UINT options, UINT options,
fgLabelJust justification, fgLabelJust justification,
int font_size, int font_size,
int blinking, int blinking,
bool latitude, bool latitude,
bool longitude, bool longitude,
bool label_box,//hud bool label_box,
bool working, bool working,
int digit): //suma int digit) :
instr_item( x, y, width, height, instr_item( x, y, width, height,
data_source,scale_data,options, working, digit), //suma data_source,scale_data,options, working, digit),
pformat ( label_format ), pformat ( label_format ),
pre_str ( pre_label_string ), pre_str ( pre_label_string ),
post_str ( post_label_string ), post_str ( post_label_string ),
justify ( justification ), justify ( justification ),
fontSize ( font_size ), fontSize ( font_size ),
blink ( blinking ), blink ( blinking ),
lat ( latitude ), lat ( latitude ),
lon ( longitude ), lon ( longitude ),
lbox ( label_box ) //hud lbox ( label_box )
{ {
if( pre_str != NULL) { if (pre_str != NULL) {
if( post_str != NULL ) { if (post_str != NULL )
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str ); sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
} else
else { sprintf( format_buffer, "%s%s", pre_str, pformat );
sprintf( format_buffer, "%s%s", pre_str, pformat );
} } else if (post_str != NULL) {
} sprintf( format_buffer, "%s%s", pformat, post_str );
else {
if( post_str != NULL ) {
sprintf( format_buffer, "%s%s", pformat, post_str );
}
} // else do nothing if both pre and post strings are nulls. Interesting. } // else do nothing if both pre and post strings are nulls. Interesting.
} }
// I put this in to make it easy to construct a class member using the current
// C code.
instr_label::~instr_label()
instr_label :: ~instr_label()
{ {
} }
// Copy constructor // Copy constructor
instr_label :: instr_label( const instr_label & image) : instr_label::instr_label(const instr_label & image) :
instr_item((const instr_item &)image), instr_item((const instr_item &)image),
pformat ( image.pformat ), pformat ( image.pformat ),
pre_str ( image.pre_str ), pre_str ( image.pre_str ),
post_str ( image.post_str ), post_str ( image.post_str ),
blink ( image.blink ), blink ( image.blink ),
lat ( image.lat ), lat ( image.lat ),
lon ( image.lon ), lon ( image.lon ),
lbox (image.lbox ) //hud lbox ( image.lbox )
{ {
if( pre_str != NULL) { if (pre_str != NULL) {
if( post_str != NULL ) { if (post_str != NULL)
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str ); sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
} else
else { sprintf( format_buffer, "%s%s", pre_str, pformat );
sprintf( format_buffer, "%s%s", pre_str, pformat );
} } else if (post_str != NULL) {
} sprintf( format_buffer, "%s%s", pformat, post_str );
else {
if( post_str != NULL ) {
sprintf( format_buffer, "%s%s", pformat, post_str );
}
} // else do nothing if both pre and post strings are nulls. Interesting. } // else do nothing if both pre and post strings are nulls. Interesting.
} }
@ -98,85 +87,82 @@ instr_label :: instr_label( const instr_label & image) :
// draw Draws a label anywhere in the HUD // draw Draws a label anywhere in the HUD
// //
// //
void instr_label :: void instr_label::draw( void )
draw( void ) // Required method in base class
{ {
// char format_buffer[80]; char label_buffer[80];
char label_buffer[80]; int posincr;
int posincr; int lenstr;
int lenstr; RECT scrn_rect = get_location();
RECT scrn_rect = get_location();
if( data_available() ) { if (data_available()) {
if(lat) if (lat)
sprintf( label_buffer, format_buffer, coord_format_lat(get_value()) ); sprintf( label_buffer, format_buffer, coord_format_lat(get_value()) );
else else if (lon)
if(lon) sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) );
sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) ); else {
else if (lbox) {// Box for label
{ float x = scrn_rect.left;
if(lbox)//hud float y = scrn_rect.top;
{// Box for label float w = scrn_rect.right;
float x = scrn_rect.left; float h = HUD_TextSize;
float y = scrn_rect.top;
float w = scrn_rect.right;
float h = HUD_TextSize;
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glBegin(GL_LINES);
glVertex2f( x - 2.0, y - 2.0); glBegin(GL_LINES);
glVertex2f( x + w + 2.0, y - 2.0); glVertex2f( x - 2.0, y - 2.0);
glVertex2f( x + w + 2.0, y + h + 2.0); glVertex2f( x + w + 2.0, y - 2.0);
glVertex2f( x - 2.0, y + h + 2.0); glVertex2f( x + w + 2.0, y + h + 2.0);
glEnd(); glVertex2f( x - 2.0, y + h + 2.0);
glEnable(GL_LINE_STIPPLE); glEnd();
glLineStipple( 1, 0xAAAA );
glBegin(GL_LINES); glEnable(GL_LINE_STIPPLE);
glVertex2f( x + w + 2.0, y - 2.0); glLineStipple( 1, 0xAAAA );
glVertex2f( x + w + 2.0, y + h + 2.0);
glVertex2f( x - 2.0, y + h + 2.0); glBegin(GL_LINES);
glVertex2f( x - 2.0, y - 2.0); glVertex2f( x + w + 2.0, y - 2.0);
glEnd(); glVertex2f( x + w + 2.0, y + h + 2.0);
glDisable(GL_LINE_STIPPLE); glVertex2f( x - 2.0, y + h + 2.0);
glPopMatrix(); glVertex2f( x - 2.0, y - 2.0);
}//hud glEnd();
sprintf( label_buffer, format_buffer, get_value()*data_scaling() );
} glDisable(GL_LINE_STIPPLE);
} glPopMatrix();
else { }
sprintf( label_buffer, format_buffer, get_value()*data_scaling() );
}
} else {
// sprintf( label_buffer, format_buffer ); // sprintf( label_buffer, format_buffer );
}
lenstr = getStringWidth( label_buffer );
#ifdef DEBUGHUD
fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
#endif
lenstr = strlen( label_buffer );
if( justify == RIGHT_JUST ) {
posincr = scrn_rect.right - lenstr;
}else if( justify == CENTER_JUST ) {
posincr = get_span() - (lenstr/2); // -lenstr*4;
} else {
// justify == LEFT_JUST
posincr = 0; // 0;
}
if( fontSize == HUD_FONT_SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, get_digits()); //suma
} }
else {
if( fontSize == HUD_FONT_LARGE ) { lenstr = getStringWidth( label_buffer );
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, get_digits()); //suma
} #ifdef DEBUGHUD
fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
#endif
lenstr = strlen( label_buffer );
if (justify == RIGHT_JUST) {
posincr = scrn_rect.right - lenstr;
} else if (justify == CENTER_JUST) {
posincr = get_span() - (lenstr/2); // -lenstr*4;
} else {
// justify == LEFT_JUST
posincr = 0; // 0;
}
if (fontSize == HUD_FONT_SMALL) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, get_digits());
} else if (fontSize == HUD_FONT_LARGE) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, get_digits());
} }
} }

View file

@ -3,9 +3,9 @@
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, digit ) TextString( text, x , y,digit ) #define textString(x, y, text, digit) TextString(text, x , y ,digit)
#else #else
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ) #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================

View file

@ -3,85 +3,72 @@
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, digit ) TextString( text, x , y,digit ) //suma #define textString(x, y, text, digit) TextString(text, x , y ,digit)
#else #else
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ); //suma #define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================
lon_label :: lon_label::lon_label(
lon_label( int x, int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR data_source, FLTFNPTR data_source,
// DBLFNPTR data_source, const char *label_format,
const char *label_format, const char *pre_label_string,
const char *pre_label_string, const char *post_label_string,
const char *post_label_string, float scale_data,
float scale_data, UINT options,
// double scale_data, fgLabelJust justification,
UINT options, int font_size,
fgLabelJust justification, int blinking,
int font_size, bool working,
int blinking, int digit) :
bool working, instr_item( x, y, width, height,
int digit): //suma data_source, scale_data,options, working,digit ),
instr_item( x, y, width, height, pformat ( label_format ),
data_source, scale_data,options, working,digit ), //suma pre_str ( pre_label_string ),
pformat ( label_format ), post_str ( post_label_string ),
pre_str ( pre_label_string ), justify ( justification ),
post_str ( post_label_string ), fontSize ( font_size ),
justify ( justification ), blink ( blinking )
fontSize ( font_size ),
blink ( blinking )
{ {
if( pre_str != NULL) { if (pre_str != NULL) {
if( post_str != NULL ) { if (post_str != NULL)
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str ); sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
} else
else { sprintf( format_buffer, "%s%s", pre_str, pformat );
sprintf( format_buffer, "%s%s", pre_str, pformat );
} } else if (post_str != NULL) {
} sprintf( format_buffer, "%s%s", pformat, post_str );
else {
if( post_str != NULL ) {
sprintf( format_buffer, "%s%s", pformat, post_str );
}
} // else do nothing if both pre and post strings are nulls. Interesting. } // else do nothing if both pre and post strings are nulls. Interesting.
} }
// I put this in to make it easy to construct a class member using the current
// C code.
lon_label::~lon_label()
lon_label :: ~lon_label()
{ {
} }
// Copy constructor // Copy constructor
lon_label :: lon_label( const lon_label & image) : lon_label::lon_label( const lon_label & image) :
instr_item((const instr_item &)image), instr_item((const instr_item &)image),
pformat ( image.pformat ), pformat ( image.pformat ),
pre_str ( image.pre_str ), pre_str ( image.pre_str ),
post_str ( image.post_str ), post_str ( image.post_str ),
blink ( image.blink ) blink ( image.blink )
{ {
if( pre_str != NULL) { if (pre_str != NULL) {
if( post_str != NULL ) { if (post_str != NULL)
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str ); sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
} else
else { sprintf( format_buffer, "%s%s", pre_str, pformat );
sprintf( format_buffer, "%s%s", pre_str, pformat );
}
}
else {
if( post_str != NULL ) {
sprintf( format_buffer, "%s%s", pformat, post_str );
}
} // else do nothing if both pre and post strings are nulls. Interesting.
} else if (post_str != NULL) {
sprintf( format_buffer, "%s%s", pformat, post_str );
} // else do nothing if both pre and post strings are nulls. Interesting.
} }
@ -89,51 +76,44 @@ lon_label :: lon_label( const lon_label & image) :
// draw Draws a label anywhere in the HUD // draw Draws a label anywhere in the HUD
// //
// //
void lon_label :: void lon_label::draw( void )
draw( void ) // Required method in base class
{ {
// char format_buffer[80]; char label_buffer[80];
char label_buffer[80]; int posincr;
int posincr; int lenstr;
int lenstr; RECT scrn_rect = get_location();
RECT scrn_rect = get_location(); float lon = get_value();
float lon = get_value();
// double lon = get_value(); if ( data_available() ) {
if( data_available() ) { lenstr = sprintf( label_buffer, format_buffer, coord_format_lon(lon) );
// char *lonstring = coord_format_lon(lon); } else {
lenstr = sprintf( label_buffer, format_buffer, coord_format_lon(lon) ); lenstr = sprintf( label_buffer, format_buffer );
} }
else {
lenstr = sprintf( label_buffer, format_buffer );
}
#ifdef DEBUGHUD #ifdef DEBUGHUD
fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer ); fgPrintf( SG_COCKPIT, SG_DEBUG, format_buffer );
fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" ); fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer ); fgPrintf( SG_COCKPIT, SG_DEBUG, label_buffer );
fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" ); fgPrintf( SG_COCKPIT, SG_DEBUG, "\n" );
#endif #endif
lenstr = getStringWidth(label_buffer); lenstr = getStringWidth(label_buffer);
if( justify == RIGHT_JUST ) { if (justify == RIGHT_JUST)
posincr = scrn_rect.right - lenstr; posincr = scrn_rect.right - lenstr;
}else if( justify == CENTER_JUST ) { else if (justify == CENTER_JUST)
posincr = get_span() - (lenstr/2); posincr = get_span() - (lenstr/2);
} else { else // justify == LEFT_JUST
// justify == LEFT_JUST
posincr = 0; posincr = 0;
}
if (fontSize == HUD_FONT_SMALL) {
if( fontSize == HUD_FONT_SMALL ) { textString( scrn_rect.left + posincr, scrn_rect.top,
textString( scrn_rect.left + posincr, scrn_rect.top, label_buffer, get_digits());
label_buffer, get_digits()); //suma
} } else if (fontSize == HUD_FONT_LARGE) {
else { textString( scrn_rect.left + posincr, scrn_rect.top,
if( fontSize == HUD_FONT_LARGE ) { label_buffer, get_digits());
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, get_digits()); //suma
}
} }
} }

View file

@ -37,370 +37,384 @@
#include <ATC/ATCutils.hxx> #include <ATC/ATCutils.hxx>
runway_instr::runway_instr(int x, runway_instr::runway_instr(int x,
int y, int y,
int width, int width,
int height, int height,
float scale_data, float scale_data,
bool working):instr_item(x,y,width,height,NULL,scale_data,0,working) bool working) :
instr_item(x, y, width, height, NULL, scale_data, 0, working)
{ {
stippleOut=0xFFFF; stippleOut=0xFFFF;
stippleCen=0xFFFF; stippleCen=0xFFFF;
arrowScale = 1.0; arrowScale = 1.0;
arrowRad = 0.0; arrowRad = 0.0;
view[0] = 0; view[0] = 0;
view[1] = 0; view[1] = 0;
view[2] = 640; view[2] = 640;
view[3] = 480; view[3] = 480;
center.x = view[2]>>1; center.x = view[2]>>1;
center.y = view[3]>>1; center.y = view[3]>>1;
location.left = center.x-(width>>1)+x; location.left = center.x-(width>>1)+x;
location.right = center.x+(width>>1)+x; location.right = center.x+(width>>1)+x;
location.bottom = center.y-(height>>1)+y; location.bottom = center.y-(height>>1)+y;
location.top = center.y+(height>>1)+y; location.top = center.y+(height>>1)+y;
cockpit_view = globals->get_viewmgr()->get_view(0); cockpit_view = globals->get_viewmgr()->get_view(0);
default_heading = fgGetDouble("/sim/view[0]/config/pitch-heading-deg",0.0); default_heading = fgGetDouble("/sim/view[0]/config/pitch-heading-deg",0.0);
default_pitch = fgGetDouble("/sim/view[0]/config/pitch-pitch-deg",0.0); default_pitch = fgGetDouble("/sim/view[0]/config/pitch-pitch-deg",0.0);
} }
void runway_instr::draw() { void runway_instr::draw() {
if (!is_broken() && get_active_runway(runway)) { if (!is_broken() && get_active_runway(runway)) {
glPushAttrib(GL_LINE_STIPPLE | GL_LINE_STIPPLE_PATTERN | GL_LINE_WIDTH); glPushAttrib(GL_LINE_STIPPLE | GL_LINE_STIPPLE_PATTERN | GL_LINE_WIDTH);
float modelView[4][4],projMat[4][4]; float modelView[4][4],projMat[4][4];
bool anyLines; bool anyLines;
//Get the current view //Get the current view
FGViewer* curr_view = globals->get_viewmgr()->get_current_view(); FGViewer* curr_view = globals->get_viewmgr()->get_current_view();
int curr_view_id = globals->get_viewmgr()->get_current(); int curr_view_id = globals->get_viewmgr()->get_current();
double gpo = curr_view->getGoalPitchOffset_deg(); double gpo = curr_view->getGoalPitchOffset_deg();
double gho = curr_view->getGoalHeadingOffset_deg(); double gho = curr_view->getGoalHeadingOffset_deg();
double po = curr_view->getPitchOffset_deg(); double po = curr_view->getPitchOffset_deg();
double ho = curr_view->getHeadingOffset_deg(); double ho = curr_view->getHeadingOffset_deg();
double yaw = -(cockpit_view->getHeadingOffset_deg()-default_heading)*SG_DEGREES_TO_RADIANS;
double pitch = (cockpit_view->getPitchOffset_deg()-default_pitch)*SG_DEGREES_TO_RADIANS;
//double roll = fgGetDouble("/sim/view[0]/config/roll-offset-deg",0.0) //TODO: adjust for default roll offset
double sPitch = sin(pitch), cPitch = cos(pitch),
sYaw = sin(yaw), cYaw = cos(yaw);
//Assuming that the "Cockpit View" is always at position zero!!! double yaw = -(cockpit_view->getHeadingOffset_deg()-default_heading)*SG_DEGREES_TO_RADIANS;
if (curr_view_id != 0) { double pitch = (cockpit_view->getPitchOffset_deg()-default_pitch)*SG_DEGREES_TO_RADIANS;
globals->get_viewmgr()->set_view(0); //double roll = fgGetDouble("/sim/view[0]/config/roll-offset-deg",0.0) //TODO: adjust for default roll offset
globals->get_viewmgr()->copyToCurrent(); double sPitch = sin(pitch), cPitch = cos(pitch),
} sYaw = sin(yaw), cYaw = cos(yaw);
//Set the camera to the cockpit view to get the view of the runway from the cockpit
ssgSetCamera((sgVec4 *)cockpit_view->get_VIEW()); //Assuming that the "Cockpit View" is always at position zero!!!
get_rwy_points(points3d); if (curr_view_id != 0) {
//Get the current project matrix globals->get_viewmgr()->set_view(0);
ssgGetProjectionMatrix(projMat); globals->get_viewmgr()->copyToCurrent();
// const sgVec4 *viewMat = globals->get_current_view()->get_VIEW(); }
//Get the current model view matrix (cockpit view) //Set the camera to the cockpit view to get the view of the runway from the cockpit
ssgGetModelviewMatrix(modelView); ssgSetCamera((sgVec4 *)cockpit_view->get_VIEW());
//Create a rotation matrix to correct for any offsets (other than default offsets) to the model view matrix get_rwy_points(points3d);
sgMat4 xy; //rotation about the Rxy, negate the sin's on Ry //Get the current project matrix
xy[0][0]=cYaw; xy[1][0]=0.0f; xy[2][0]=-sYaw; xy[3][0]=0.0f; ssgGetProjectionMatrix(projMat);
xy[0][1]=sPitch*-sYaw; xy[1][1]=cPitch; xy[2][1]=-sPitch*cYaw; xy[3][1]=0.0f; // const sgVec4 *viewMat = globals->get_current_view()->get_VIEW();
xy[0][2]=cPitch*sYaw; xy[1][2]=sPitch; xy[2][2]=cPitch*cYaw; xy[3][2]=0.0f; //Get the current model view matrix (cockpit view)
xy[0][3]=0.0f; xy[1][3]=0.0f; xy[2][3]=0.0f; xy[3][3]=1.0f; ssgGetModelviewMatrix(modelView);
//Re-center the model view //Create a rotation matrix to correct for any offsets (other than default offsets) to the model view matrix
sgPostMultMat4(modelView,xy); sgMat4 xy; //rotation about the Rxy, negate the sin's on Ry
//copy float matrices to double xy[0][0]=cYaw; xy[1][0]=0.0f; xy[2][0]=-sYaw; xy[3][0]=0.0f;
for (int i=0; i<4; i++) { xy[0][1]=sPitch*-sYaw; xy[1][1]=cPitch; xy[2][1]=-sPitch*cYaw; xy[3][1]=0.0f;
for (int j=0; j<4; j++) { xy[0][2]=cPitch*sYaw; xy[1][2]=sPitch; xy[2][2]=cPitch*cYaw; xy[3][2]=0.0f;
int idx = (i*4)+j; xy[0][3]=0.0f; xy[1][3]=0.0f; xy[2][3]=0.0f; xy[3][3]=1.0f;
mm[idx] = (double)modelView[i][j]; //Re-center the model view
pm[idx] = (double)projMat[i][j]; sgPostMultMat4(modelView,xy);
} //copy float matrices to double
} for (int i=0; i<4; i++) {
//Calculate the 2D points via gluProject for (int j=0; j<4; j++) {
int result = GL_TRUE; int idx = (i*4)+j;
for (int i=0; i<6; i++) { mm[idx] = (double)modelView[i][j];
result = gluProject(points3d[i][0],points3d[i][1],points3d[i][2],mm,pm,view,&points2d[i][0],&points2d[i][1],&points2d[i][2]); pm[idx] = (double)projMat[i][j];
} }
//set the line width based on our distance from the runway }
setLineWidth(); //Calculate the 2D points via gluProject
//Draw the runway lines on the HUD int result = GL_TRUE;
glEnable(GL_LINE_STIPPLE); for (int i=0; i<6; i++) {
glLineStipple(1,stippleOut); result = gluProject(points3d[i][0],points3d[i][1],points3d[i][2],mm,pm,view,&points2d[i][0],&points2d[i][1],&points2d[i][2]);
anyLines = }
drawLine(points3d[0],points3d[1],points2d[0],points2d[1]) | //draw top //set the line width based on our distance from the runway
drawLine(points3d[2],points3d[1],points2d[2],points2d[1]) | //draw right setLineWidth();
drawLine(points3d[2],points3d[3],points2d[2],points2d[3]) | //draw bottom //Draw the runway lines on the HUD
drawLine(points3d[3],points3d[0],points2d[3],points2d[0]); //draw left glEnable(GL_LINE_STIPPLE);
glLineStipple(1,stippleCen); glLineStipple(1,stippleOut);
anyLines |= drawLine(points3d[5],points3d[4],points2d[5],points2d[4]); //draw center anyLines =
//Check to see if arrow needs drawn drawLine(points3d[0],points3d[1],points2d[0],points2d[1]) | //draw top
if ((!anyLines && drawIA) || drawIAAlways) { drawLine(points3d[2],points3d[1],points2d[2],points2d[1]) | //draw right
drawArrow(); //draw indication arrow drawLine(points3d[2],points3d[3],points2d[2],points2d[3]) | //draw bottom
} drawLine(points3d[3],points3d[0],points2d[3],points2d[0]); //draw left
//Restore the current view and any offsets glLineStipple(1,stippleCen);
if (curr_view_id != 0) { anyLines |= drawLine(points3d[5],points3d[4],points2d[5],points2d[4]); //draw center
globals->get_viewmgr()->set_view(curr_view_id); //Check to see if arrow needs drawn
globals->get_viewmgr()->copyToCurrent(); if ((!anyLines && drawIA) || drawIAAlways) {
curr_view->setHeadingOffset_deg(ho); drawArrow(); //draw indication arrow
curr_view->setPitchOffset_deg(po); }
curr_view->setGoalHeadingOffset_deg(gho); //Restore the current view and any offsets
curr_view->setGoalPitchOffset_deg(gpo); if (curr_view_id != 0) {
} globals->get_viewmgr()->set_view(curr_view_id);
//Set the camera back to the current view globals->get_viewmgr()->copyToCurrent();
ssgSetCamera((sgVec4 *)curr_view); curr_view->setHeadingOffset_deg(ho);
glPopAttrib(); curr_view->setPitchOffset_deg(po);
}//if not broken curr_view->setGoalHeadingOffset_deg(gho);
curr_view->setGoalPitchOffset_deg(gpo);
}
//Set the camera back to the current view
ssgSetCamera((sgVec4 *)curr_view);
glPopAttrib();
}//if not broken
} }
bool runway_instr::get_active_runway(FGRunway& runway) { bool runway_instr::get_active_runway(FGRunway& runway) {
FGEnvironment stationweather = FGEnvironment stationweather =
((FGEnvironmentMgr *)globals->get_subsystem("environment"))->getEnvironment(); ((FGEnvironmentMgr *)globals->get_subsystem("environment"))->getEnvironment();
double hdg = stationweather.get_wind_from_heading_deg(); double hdg = stationweather.get_wind_from_heading_deg();
return globals->get_runways()->search( fgGetString("/sim/presets/airport-id"), int(hdg), &runway); return globals->get_runways()->search( fgGetString("/sim/presets/airport-id"), int(hdg), &runway);
} }
void runway_instr::get_rwy_points(sgdVec3 *points3d) {
static Point3D center = globals->get_scenery()->get_center();
//Get the current tile center
Point3D currentCenter = globals->get_scenery()->get_center();
Point3D tileCenter = currentCenter;
if (center != currentCenter) //if changing tiles
tileCenter = center; //use last center
double alt = current_aircraft.fdm_state->get_Runway_altitude()*SG_FEET_TO_METER;
double length = (runway._length/2.0)*SG_FEET_TO_METER;
double width = (runway._width/2.0)*SG_FEET_TO_METER;
double frontLat,frontLon,backLat,backLon,az,tempLat,tempLon;
geo_direct_wgs_84(alt,runway._lat,runway._lon,runway._heading,length,&backLat,&backLon,&az);
sgGeodToCart(backLat*SG_DEGREES_TO_RADIANS,backLon*SG_DEGREES_TO_RADIANS,alt,points3d[4]);
geo_direct_wgs_84(alt,runway._lat,runway._lon,runway._heading+180,length,&frontLat,&frontLon,&az); void runway_instr::get_rwy_points(sgdVec3 *points3d) {
sgGeodToCart(frontLat*SG_DEGREES_TO_RADIANS,frontLon*SG_DEGREES_TO_RADIANS,alt,points3d[5]); static Point3D center = globals->get_scenery()->get_center();
geo_direct_wgs_84(alt,backLat,backLon,runway._heading+90,width,&tempLat,&tempLon,&az); //Get the current tile center
sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[0]); Point3D currentCenter = globals->get_scenery()->get_center();
Point3D tileCenter = currentCenter;
if (center != currentCenter) //if changing tiles
tileCenter = center; //use last center
double alt = current_aircraft.fdm_state->get_Runway_altitude()*SG_FEET_TO_METER;
double length = (runway._length/2.0)*SG_FEET_TO_METER;
double width = (runway._width/2.0)*SG_FEET_TO_METER;
double frontLat,frontLon,backLat,backLon,az,tempLat,tempLon;
geo_direct_wgs_84(alt,backLat,backLon,runway._heading-90,width,&tempLat,&tempLon,&az); geo_direct_wgs_84(alt,runway._lat,runway._lon,runway._heading,length,&backLat,&backLon,&az);
sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[1]); sgGeodToCart(backLat*SG_DEGREES_TO_RADIANS,backLon*SG_DEGREES_TO_RADIANS,alt,points3d[4]);
geo_direct_wgs_84(alt,frontLat,frontLon,runway._heading-90,width,&tempLat,&tempLon,&az); geo_direct_wgs_84(alt,runway._lat,runway._lon,runway._heading+180,length,&frontLat,&frontLon,&az);
sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[2]); sgGeodToCart(frontLat*SG_DEGREES_TO_RADIANS,frontLon*SG_DEGREES_TO_RADIANS,alt,points3d[5]);
geo_direct_wgs_84(alt,frontLat,frontLon,runway._heading+90,width,&tempLat,&tempLon,&az); geo_direct_wgs_84(alt,backLat,backLon,runway._heading+90,width,&tempLat,&tempLon,&az);
sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[3]); sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[0]);
for(int i = 0; i < 6; i++) geo_direct_wgs_84(alt,backLat,backLon,runway._heading-90,width,&tempLat,&tempLon,&az);
{ sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[1]);
points3d[i][0] -= tileCenter.x();
points3d[i][1] -= tileCenter.y(); geo_direct_wgs_84(alt,frontLat,frontLon,runway._heading-90,width,&tempLat,&tempLon,&az);
points3d[i][2] -= tileCenter.z(); sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[2]);
}
center = currentCenter; geo_direct_wgs_84(alt,frontLat,frontLon,runway._heading+90,width,&tempLat,&tempLon,&az);
sgGeodToCart(tempLat*SG_DEGREES_TO_RADIANS,tempLon*SG_DEGREES_TO_RADIANS,alt,points3d[3]);
for (int i = 0; i < 6; i++) {
points3d[i][0] -= tileCenter.x();
points3d[i][1] -= tileCenter.y();
points3d[i][2] -= tileCenter.z();
}
center = currentCenter;
} }
bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& point1, const sgdVec3& point2) { bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& point1, const sgdVec3& point2) {
sgdVec3 p1, p2; sgdVec3 p1, p2;
sgdCopyVec3(p1, point1); sgdCopyVec3(p1, point1);
sgdCopyVec3(p2, point2); sgdCopyVec3(p2, point2);
bool p1Inside = (p1[0]>=location.left && p1[0]<=location.right && p1[1]>=location.bottom && p1[1]<=location.top); bool p1Inside = (p1[0]>=location.left && p1[0]<=location.right && p1[1]>=location.bottom && p1[1]<=location.top);
bool p1Insight = (p1[2] >= 0.0 && p1[2] < 1.0); bool p1Insight = (p1[2] >= 0.0 && p1[2] < 1.0);
bool p1Valid = p1Insight && p1Inside; bool p1Valid = p1Insight && p1Inside;
bool p2Inside = (p2[0]>=location.left && p2[0]<=location.right && p2[1]>=location.bottom && p2[1]<=location.top); bool p2Inside = (p2[0]>=location.left && p2[0]<=location.right && p2[1]>=location.bottom && p2[1]<=location.top);
bool p2Insight = (p2[2] >= 0.0 && p2[2] < 1.0); bool p2Insight = (p2[2] >= 0.0 && p2[2] < 1.0);
bool p2Valid = p2Insight && p2Inside; bool p2Valid = p2Insight && p2Inside;
if (p1Valid && p2Valid) { //Both project points are valid, draw the line if (p1Valid && p2Valid) { //Both project points are valid, draw the line
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2d(p1[0],p1[1]); glVertex2d(p1[0],p1[1]);
glVertex2d(p2[0],p2[1]); glVertex2d(p2[0],p2[1]);
glEnd(); glEnd();
}
else if (p1Valid) { //p1 is valid and p2 is not, calculate a new valid point } else if (p1Valid) { //p1 is valid and p2 is not, calculate a new valid point
sgdVec3 vec = {a2[0]-a1[0], a2[1]-a1[1], a2[2]-a1[2]}; sgdVec3 vec = {a2[0]-a1[0], a2[1]-a1[1], a2[2]-a1[2]};
//create the unit vector //create the unit vector
sgdScaleVec3(vec,1.0/sgdLengthVec3(vec)); sgdScaleVec3(vec,1.0/sgdLengthVec3(vec));
sgdVec3 newPt; sgdVec3 newPt;
sgdCopyVec3(newPt,a1); sgdCopyVec3(newPt,a1);
sgdAddVec3(newPt,vec); sgdAddVec3(newPt,vec);
if (gluProject(newPt[0],newPt[1],newPt[2],mm,pm,view,&p2[0],&p2[1],&p2[2]) && (p2[2]>0&&p2[2]<1.0) ) { if (gluProject(newPt[0],newPt[1],newPt[2],mm,pm,view,&p2[0],&p2[1],&p2[2]) && (p2[2]>0&&p2[2]<1.0) ) {
boundPoint(p1,p2); boundPoint(p1,p2);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2d(p1[0],p1[1]); glVertex2d(p1[0],p1[1]);
glVertex2d(p2[0],p2[1]); glVertex2d(p2[0],p2[1]);
glEnd(); glEnd();
} }
}
else if (p2Valid) { //p2 is valid and p1 is not, calculate a new valid point } else if (p2Valid) { //p2 is valid and p1 is not, calculate a new valid point
sgdVec3 vec = {a1[0]-a2[0], a1[1]-a2[1], a1[2]-a2[2]}; sgdVec3 vec = {a1[0]-a2[0], a1[1]-a2[1], a1[2]-a2[2]};
//create the unit vector //create the unit vector
sgdScaleVec3(vec,1.0/sgdLengthVec3(vec)); sgdScaleVec3(vec,1.0/sgdLengthVec3(vec));
sgdVec3 newPt; sgdVec3 newPt;
sgdCopyVec3(newPt,a2); sgdCopyVec3(newPt,a2);
sgdAddVec3(newPt,vec); sgdAddVec3(newPt,vec);
if (gluProject(newPt[0],newPt[1],newPt[2],mm,pm,view,&p1[0],&p1[1],&p1[2]) && (p1[2]>0&&p1[2]<1.0)) { if (gluProject(newPt[0],newPt[1],newPt[2],mm,pm,view,&p1[0],&p1[1],&p1[2]) && (p1[2]>0&&p1[2]<1.0)) {
boundPoint(p2,p1); boundPoint(p2,p1);
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2d(p2[0],p2[1]); glVertex2d(p2[0],p2[1]);
glVertex2d(p1[0],p1[1]); glVertex2d(p1[0],p1[1]);
glEnd(); glEnd();
} }
}
else if (p1Insight && p2Insight) { //both points are insight, but not inside } else if (p1Insight && p2Insight) { //both points are insight, but not inside
bool v = boundOutsidePoints(p1,p2); bool v = boundOutsidePoints(p1,p2);
if (v) { if (v) {
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex2d(p1[0],p1[1]); glVertex2d(p1[0],p1[1]);
glVertex2d(p2[0],p2[1]); glVertex2d(p2[0],p2[1]);
glEnd(); glEnd();
} }
return v; return v;
} }
//else both points are not insight, don't draw anything //else both points are not insight, don't draw anything
return (p1Valid && p2Valid); return (p1Valid && p2Valid);
} }
void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m) { void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m) {
double y = v[1]; double y = v[1];
if(m[1] < v[1]) { if (m[1] < v[1])
y = location.bottom; y = location.bottom;
} else if (m[1] > v[1])
else if(m[1] > v[1]) { y = location.top;
y = location.top;
} if (m[0] == v[0]) {
if (m[0] == v[0]) { m[1]=y;
m[1]=y; return; //prevent divide by zero
return; //prevent divide by zero }
}
double slope = (m[1]-v[1])/(m[0]-v[0]); double slope = (m[1]-v[1])/(m[0]-v[0]);
m[0] = (y-v[1])/slope + v[0]; m[0] = (y-v[1])/slope + v[0];
m[1] = y; m[1] = y;
if (m[0] < location.left) {
m[0] = location.left; if (m[0] < location.left) {
m[1] = slope * (location.left-v[0])+v[1]; m[0] = location.left;
} m[1] = slope * (location.left-v[0])+v[1];
else if (m[0] > location.right) {
m[0] = location.right; } else if (m[0] > location.right) {
m[1] = slope * (location.right-v[0])+v[1]; m[0] = location.right;
} m[1] = slope * (location.right-v[0])+v[1];
}
} }
bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) { bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
bool pointsInvalid = (v[1]>location.top && m[1]>location.top) || bool pointsInvalid = (v[1]>location.top && m[1]>location.top) ||
(v[1]<location.bottom && m[1]<location.bottom) || (v[1]<location.bottom && m[1]<location.bottom) ||
(v[0]>location.right && m[0]>location.right) || (v[0]>location.right && m[0]>location.right) ||
(v[0]<location.left && m[0]<location.left); (v[0]<location.left && m[0]<location.left);
if (pointsInvalid) if (pointsInvalid)
return false; return false;
if (m[0] == v[0]) {//x's are equal, vertical line
if (m[1]>v[1]) { if (m[0] == v[0]) {//x's are equal, vertical line
m[1]=location.top; if (m[1]>v[1]) {
v[1]=location.bottom; m[1]=location.top;
} v[1]=location.bottom;
else { } else {
v[1]=location.top; v[1]=location.top;
m[1]=location.bottom; m[1]=location.bottom;
} }
return true; return true;
} }
if (m[1] == v[1]) { //y's are equal, horizontal line
if (m[0] > v[0]) { if (m[1] == v[1]) { //y's are equal, horizontal line
m[0] = location.right; if (m[0] > v[0]) {
v[0] = location.left; m[0] = location.right;
} v[0] = location.left;
else { } else {
v[0] = location.right; v[0] = location.right;
m[0] = location.left; m[0] = location.left;
} }
return true; return true;
} }
double slope = (m[1]-v[1])/(m[0]-v[0]);
double b = v[1]-(slope*v[0]); double slope = (m[1]-v[1])/(m[0]-v[0]);
double y1 = slope * location.left + b; double b = v[1]-(slope*v[0]);
double y2 = slope * location.right + b; double y1 = slope * location.left + b;
double x1 = (location.bottom - b) / slope; double y2 = slope * location.right + b;
double x2 = (location.top - b) / slope; double x1 = (location.bottom - b) / slope;
int counter = 0; double x2 = (location.top - b) / slope;
if (y1 >= location.bottom && y1 <= location.top) { int counter = 0;
v[0] = location.left;
v[1] = y1; if (y1 >= location.bottom && y1 <= location.top) {
counter++; v[0] = location.left;
} v[1] = y1;
if (y2 >= location.bottom && y2 <= location.top) { counter++;
if (counter > 0) { }
m[0] = location.right;
m[1] = y2; if (y2 >= location.bottom && y2 <= location.top) {
} if (counter > 0) {
else { m[0] = location.right;
v[0] = location.right; m[1] = y2;
v[1] = y2; } else {
} v[0] = location.right;
counter++; v[1] = y2;
} }
if (x1 >= location.left && x1 <= location.right) { counter++;
if (counter > 0) { }
m[0] = x1;
m[1] = location.bottom; if (x1 >= location.left && x1 <= location.right) {
} if (counter > 0) {
else { m[0] = x1;
v[0] = x1; m[1] = location.bottom;
v[1] = location.bottom; } else {
} v[0] = x1;
counter++; v[1] = location.bottom;
} }
if (x2 >= location.left && x2 <= location.right) { counter++;
m[0] = x1; }
m[1] = location.bottom;
counter++; if (x2 >= location.left && x2 <= location.right) {
} m[0] = x1;
return (counter == 2); m[1] = location.bottom;
counter++;
}
return (counter == 2);
} }
void runway_instr::drawArrow() { void runway_instr::drawArrow() {
Point3D ac(0.0), rwy(0.0); Point3D ac(0.0), rwy(0.0);
ac.setlat(current_aircraft.fdm_state->get_Latitude_deg()); ac.setlat(current_aircraft.fdm_state->get_Latitude_deg());
ac.setlon(current_aircraft.fdm_state->get_Longitude_deg()); ac.setlon(current_aircraft.fdm_state->get_Longitude_deg());
rwy.setlat(runway._lat); rwy.setlat(runway._lat);
rwy.setlon(runway._lon); rwy.setlon(runway._lon);
float theta = GetHeadingFromTo(ac,rwy); float theta = GetHeadingFromTo(ac,rwy);
theta -= fgGetDouble("/orientation/heading-deg"); theta -= fgGetDouble("/orientation/heading-deg");
theta = -theta; theta = -theta;
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
glTranslated((location.right+location.left)/2.0,(location.top+location.bottom)/2.0,0.0); glTranslated((location.right+location.left)/2.0,(location.top+location.bottom)/2.0,0.0);
glRotated(theta,0.0,0.0,1.0); glRotated(theta,0.0,0.0,1.0);
glTranslated(0.0,arrowRad,0.0); glTranslated(0.0,arrowRad,0.0);
glScaled(arrowScale,arrowScale,0.0); glScaled(arrowScale,arrowScale,0.0);
glBegin(GL_TRIANGLES);
glVertex2d(-5.0,12.5); glBegin(GL_TRIANGLES);
glVertex2d(0.0,25.0); glVertex2d(-5.0,12.5);
glVertex2d(5.0,12.5); glVertex2d(0.0,25.0);
glEnd(); glVertex2d(5.0,12.5);
glBegin(GL_QUADS); glEnd();
glVertex2d(-2.5,0.0);
glVertex2d(-2.5,12.5); glBegin(GL_QUADS);
glVertex2d(2.5,12.5); glVertex2d(-2.5,0.0);
glVertex2d(2.5,0.0); glVertex2d(-2.5,12.5);
glEnd(); glVertex2d(2.5,12.5);
glPopMatrix(); glVertex2d(2.5,0.0);
glEnd();
glPopMatrix();
} }
void runway_instr::setLineWidth() { void runway_instr::setLineWidth() {
//Calculate the distance from the runway, A //Calculate the distance from the runway, A
double course, distance; double course, distance;
calc_gc_course_dist(Point3D(runway._lon*SGD_DEGREES_TO_RADIANS, runway._lat*SGD_DEGREES_TO_RADIANS, 0.0), calc_gc_course_dist(Point3D(runway._lon*SGD_DEGREES_TO_RADIANS, runway._lat*SGD_DEGREES_TO_RADIANS, 0.0),
Point3D(current_aircraft.fdm_state->get_Longitude(),current_aircraft.fdm_state->get_Latitude(), 0.0 ), Point3D(current_aircraft.fdm_state->get_Longitude(),current_aircraft.fdm_state->get_Latitude(), 0.0 ),
&course, &distance); &course, &distance);
distance *= SG_METER_TO_NM; distance *= SG_METER_TO_NM;
//Get altitude above runway, B //Get altitude above runway, B
double alt_nm = get_agl(); double alt_nm = get_agl();
static const SGPropertyNode *startup_units_node static const SGPropertyNode *startup_units_node
= fgGetNode("/sim/startup/units"); = fgGetNode("/sim/startup/units");
if (!strcmp(startup_units_node->getStringValue(), "feet"))
alt_nm *= SG_FEET_TO_METER*SG_METER_TO_NM; if (!strcmp(startup_units_node->getStringValue(), "feet"))
else alt_nm *= SG_FEET_TO_METER*SG_METER_TO_NM;
alt_nm *= SG_METER_TO_NM; else
//Calculate distance away from runway, C = v(A²+B²) alt_nm *= SG_METER_TO_NM;
distance = sqrt(alt_nm*alt_nm + distance*distance);
if (distance < scaleDist) //Calculate distance away from runway, C = v(A²+B²)
glLineWidth( 1.0+( (lnScale-1)*( (scaleDist-distance)/scaleDist))); distance = sqrt(alt_nm*alt_nm + distance*distance);
else if (distance < scaleDist)
glLineWidth( 1.0 ); glLineWidth( 1.0+( (lnScale-1)*( (scaleDist-distance)/scaleDist)));
else
glLineWidth( 1.0 );
} }
void runway_instr::setArrowRotationRadius(double radius) { arrowRad = radius; } void runway_instr::setArrowRotationRadius(double radius) { arrowRad = radius; }

View file

@ -14,58 +14,59 @@
// 2. This class was not intended to be instanciated. See moving_scale // 2. This class was not intended to be instanciated. See moving_scale
// and gauge_instr classes. // and gauge_instr classes.
//============================================================================ //============================================================================
instr_scale :: instr_scale::instr_scale(
instr_scale ( int x, int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR load_fn, FLTFNPTR load_fn,
UINT options, UINT options,
float show_range, float show_range,
float maxValue, float maxValue,
float minValue, float minValue,
float disp_scale, float disp_scale,
UINT major_divs, UINT major_divs,
UINT minor_divs, UINT minor_divs,
UINT rollover, UINT rollover,
int dp_showing, int dp_showing,
bool working ) : bool working ) :
instr_item( x, y, width, height, instr_item( x, y, width, height, load_fn, disp_scale, options, working),
load_fn, disp_scale, options, working), range_shown ( show_range ),
range_shown ( show_range ), Maximum_value( maxValue ),
Maximum_value( maxValue ), Minimum_value( minValue ),
Minimum_value( minValue ), Maj_div ( major_divs ),
Maj_div ( major_divs ), Min_div ( minor_divs ),
Min_div ( minor_divs ), Modulo ( rollover ),
Modulo ( rollover ), signif_digits( dp_showing )
signif_digits( dp_showing )
{ {
int temp; int temp;
scale_factor = (float)get_span() / range_shown; scale_factor = (float)get_span() / range_shown;
if( show_range < 0 ) { if (show_range < 0)
range_shown = -range_shown; range_shown = -range_shown;
}
temp = FloatToInt(Maximum_value - Minimum_value) / 100; temp = FloatToInt(Maximum_value - Minimum_value) / 100;
if( range_shown < temp ) { if (range_shown < temp)
range_shown = temp; range_shown = temp;
}
} }
instr_scale ::
instr_scale( const instr_scale & image ) : instr_scale::instr_scale( const instr_scale & image ) :
instr_item( (const instr_item &) image), instr_item( (const instr_item &) image),
range_shown ( image.range_shown ), range_shown ( image.range_shown ),
Maximum_value( image.Maximum_value ), Maximum_value( image.Maximum_value ),
Minimum_value( image.Minimum_value ), Minimum_value( image.Minimum_value ),
scale_factor ( image.scale_factor ), scale_factor ( image.scale_factor ),
Maj_div ( image.Maj_div ), Maj_div ( image.Maj_div ),
Min_div ( image.Min_div ), Min_div ( image.Min_div ),
Modulo ( image.Modulo ), Modulo ( image.Modulo ),
signif_digits( image.signif_digits ) signif_digits( image.signif_digits )
{ {
} }
instr_scale :: ~ instr_scale () {} instr_scale::~instr_scale ()
{
}

View file

@ -5,39 +5,41 @@
//============ Top of fgTBI_instr class member definitions ============== //============ Top of fgTBI_instr class member definitions ==============
fgTBI_instr :: fgTBI_instr::fgTBI_instr(
fgTBI_instr( int x, int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR chn1_source, FLTFNPTR chn1_source,
FLTFNPTR chn2_source, FLTFNPTR chn2_source,
float maxBankAngle, float maxBankAngle,
float maxSlipAngle, float maxSlipAngle,
UINT gap_width, UINT gap_width,
bool working, bool working,
bool tsivalue, //suma bool tsivalue,
float radius) : //suma float radius) :
dual_instr_item( x, y, width, height, dual_instr_item( x, y, width, height,
chn1_source, chn1_source,
chn2_source, chn2_source,
working, working,
HUDS_TOP), HUDS_TOP),
BankLimit ((int)(maxBankAngle)), BankLimit ((int)(maxBankAngle)),
SlewLimit ((int)(maxSlipAngle)), SlewLimit ((int)(maxSlipAngle)),
scr_hole (gap_width ) scr_hole (gap_width)
{ {
tsi=tsivalue; //suma tsi=tsivalue;
rad=radius; //suma rad=radius;
} }
fgTBI_instr :: ~fgTBI_instr() {}
fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image): fgTBI_instr::~fgTBI_instr() {}
dual_instr_item( (const dual_instr_item &) image),
BankLimit( image.BankLimit),
SlewLimit( image.SlewLimit), fgTBI_instr::fgTBI_instr(const fgTBI_instr & image) :
scr_hole ( image.scr_hole ) dual_instr_item( (const dual_instr_item &) image),
BankLimit( image.BankLimit),
SlewLimit( image.SlewLimit),
scr_hole ( image.scr_hole )
{ {
} }
@ -46,243 +48,220 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
// Draws a Turn Bank Indicator on the screen // Draws a Turn Bank Indicator on the screen
// //
void fgTBI_instr :: draw( void ) void fgTBI_instr :: draw( void )
{ {
float bank_angle, sideslip_angle; float bank_angle, sideslip_angle;
float ss_const; // sideslip angle pixels per rad float ss_const; // sideslip angle pixels per rad
float cen_x, cen_y, bank, fspan, tee, hole; float cen_x, cen_y, bank, fspan, tee, hole;
int span = get_span(); int span = get_span();
float zero = 0.0;
float zero = 0.0;
RECT My_box = get_location();
POINT centroid = get_centroid();
int tee_height = My_box.bottom;
bank_angle = current_ch2(); // Roll limit +/- 30 degrees
if( bank_angle < -SGD_PI_2/3 )
{
bank_angle = -SGD_PI_2/3;
}
else if( bank_angle > SGD_PI_2/3 )
{
bank_angle = SGD_PI_2/3;
}
sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
if( sideslip_angle < -SGD_PI/9 ) RECT My_box = get_location();
{ POINT centroid = get_centroid();
sideslip_angle = -SGD_PI/9; int tee_height = My_box.bottom;
}
else if( sideslip_angle > SGD_PI/9 )
{
sideslip_angle = SGD_PI/9;
}
cen_x = centroid.x; bank_angle = current_ch2(); // Roll limit +/- 30 degrees
cen_y = centroid.y;
if ( bank_angle < -SGD_PI_2/3 )
bank = bank_angle * SGD_RADIANS_TO_DEGREES; bank_angle = -SGD_PI_2/3;
tee = -tee_height; else if ( bank_angle > SGD_PI_2/3 )
fspan = span; bank_angle = SGD_PI_2/3;
hole = scr_hole;
ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9); // width represents 40 degrees
// printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
// printf("ss_const: %f hole: %f\n", ss_const, hole);
glPushMatrix();
glTranslatef(cen_x, cen_y, zero);
glRotatef(-bank, zero, zero, 1.0);
if(!tsi)
{
glBegin(GL_LINES);
if( !scr_hole )
{
glVertex2f( -fspan, zero );
glVertex2f( fspan, zero );
}
else
{
glVertex2f( -fspan, zero );
glVertex2f( -hole, zero );
glVertex2f( hole, zero );
glVertex2f( fspan, zero );
}
// draw teemarks
glVertex2f( hole, zero );
glVertex2f( hole, tee );
glVertex2f( -hole, zero );
glVertex2f( -hole, tee );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f( ss_const, -hole);
glVertex2f( ss_const + hole, zero);
glVertex2f( ss_const, hole);
glVertex2f( ss_const - hole, zero);
glEnd();
} sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
else //if tsi enabled if ( sideslip_angle < -SGD_PI/9 )
{ sideslip_angle = -SGD_PI/9;
// float factor = My_box.right / 6.0; else if ( sideslip_angle > SGD_PI/9 )
sideslip_angle = SGD_PI/9;
drawOneLine(cen_x-1.0, My_box.top, cen_x+1.0, My_box.top); cen_x = centroid.x;
drawOneLine(cen_x-1.0, My_box.top, cen_x-1.0, My_box.top+10.0); cen_y = centroid.y;
drawOneLine(cen_x+1.0, My_box.top, cen_x+1.0, My_box.top+10.0);
drawOneLine(cen_x-1.0, My_box.top+10.0, cen_x+1.0, My_box.top+10.0);
float x1, y1, x2, y2, x3, y3, x4,y4, x5, y5; bank = bank_angle * SGD_RADIANS_TO_DEGREES;
float xc, yc, r=rad, r1= rad-10.0, r2=rad-5.0; tee = -tee_height;
fspan = span;
xc = My_box.left + My_box.right/ 2.0 ; hole = scr_hole;
yc = My_box.top + r; ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9); // width represents 40 degrees
// printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
// printf("ss_const: %f hole: %f\n", ss_const, hole);
glPushMatrix();
glTranslatef(cen_x, cen_y, zero);
glRotatef(-bank, zero, zero, 1.0);
if (!tsi) {
glBegin(GL_LINES);
if ( !scr_hole ) {
glVertex2f( -fspan, zero );
glVertex2f( fspan, zero );
} else {
glVertex2f( -fspan, zero );
glVertex2f( -hole, zero );
glVertex2f( hole, zero );
glVertex2f( fspan, zero );
}
// draw teemarks
glVertex2f( hole, zero );
glVertex2f( hole, tee );
glVertex2f( -hole, zero );
glVertex2f( -hole, tee );
glEnd();
glBegin(GL_LINE_LOOP);
glVertex2f( ss_const, -hole);
glVertex2f( ss_const + hole, zero);
glVertex2f( ss_const, hole);
glVertex2f( ss_const - hole, zero);
glEnd();
} else { //if tsi enabled
// float factor = My_box.right / 6.0;
drawOneLine(cen_x-1.0, My_box.top, cen_x+1.0, My_box.top);
drawOneLine(cen_x-1.0, My_box.top, cen_x-1.0, My_box.top+10.0);
drawOneLine(cen_x+1.0, My_box.top, cen_x+1.0, My_box.top+10.0);
drawOneLine(cen_x-1.0, My_box.top+10.0, cen_x+1.0, My_box.top+10.0);
float x1, y1, x2, y2, x3, y3, x4,y4, x5, y5;
float xc, yc, r=rad, r1= rad-10.0, r2=rad-5.0;
xc = My_box.left + My_box.right/ 2.0 ;
yc = My_box.top + r;
//first n last lines //first n last lines
x1= xc + r * cos (255.0 * SGD_DEGREES_TO_RADIANS); x1= xc + r * cos (255.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (255.0 * SGD_DEGREES_TO_RADIANS); y1= yc + r * sin (255.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r1 * cos (255.0 * SGD_DEGREES_TO_RADIANS); x2= xc + r1 * cos (255.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r1 * sin (255.0 * SGD_DEGREES_TO_RADIANS); y2= yc + r1 * sin (255.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
x1= xc + r * cos (285.0 * SGD_DEGREES_TO_RADIANS); drawOneLine(x1,y1,x2,y2);
y1= yc + r * sin (285.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r1 * cos (285.0 * SGD_DEGREES_TO_RADIANS); x1= xc + r * cos (285.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r1 * sin (285.0 * SGD_DEGREES_TO_RADIANS); y1= yc + r * sin (285.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2); x2= xc + r1 * cos (285.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r1 * sin (285.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
//second n fifth lines //second n fifth lines
x1= xc + r * cos (260.0 * SGD_DEGREES_TO_RADIANS); x1= xc + r * cos (260.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (260.0 * SGD_DEGREES_TO_RADIANS); y1= yc + r * sin (260.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r2 * cos (260.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (260.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
x1= xc + r * cos (280.0 * SGD_DEGREES_TO_RADIANS); x2= xc + r2 * cos (260.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (280.0 * SGD_DEGREES_TO_RADIANS); y2= yc + r2 * sin (260.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
x2= xc + r2 * cos (280.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (280.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2); x1= xc + r * cos (280.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (280.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r2 * cos (280.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (280.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
//third n fourth lines //third n fourth lines
x1= xc + r * cos (265.0 * SGD_DEGREES_TO_RADIANS); x1= xc + r * cos (265.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (265.0 * SGD_DEGREES_TO_RADIANS); y1= yc + r * sin (265.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r2 * cos (265.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (265.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2);
x1= xc + r * cos (275.0 * SGD_DEGREES_TO_RADIANS); x2= xc + r2 * cos (265.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (275.0 * SGD_DEGREES_TO_RADIANS); y2= yc + r2 * sin (265.0 * SGD_DEGREES_TO_RADIANS);
x2= xc + r2 * cos (275.0 * SGD_DEGREES_TO_RADIANS);
y2= yc + r2 * sin (275.0 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1,y1,x2,y2); drawOneLine(x1,y1,x2,y2);
//to draw marker x1= xc + r * cos (275.0 * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin (275.0 * SGD_DEGREES_TO_RADIANS);
float valbank, valsideslip, sideslip;
r = rad + 5.0; //5 is added to get a gap
// upper polygon
bank_angle = current_ch2();
bank= bank_angle * SGD_RADIANS_TO_DEGREES; // Roll limit +/- 30 degrees x2= xc + r2 * cos (275.0 * SGD_DEGREES_TO_RADIANS);
if(bank > BankLimit) y2= yc + r2 * sin (275.0 * SGD_DEGREES_TO_RADIANS);
bank = BankLimit;
if(bank < -1.0*BankLimit)
bank = -1.0*BankLimit;
valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees drawOneLine(x1,y1,x2,y2);
sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
sideslip= sideslip_angle * SGD_RADIANS_TO_DEGREES;
if(sideslip > SlewLimit)
sideslip = SlewLimit;
if(sideslip < -1.0*SlewLimit)
sideslip = -1.0*SlewLimit;
valsideslip = sideslip * 15.0 / SlewLimit;
//values 270, 225 and 315 are angles in degrees...
x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS); //to draw marker
y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1, y1, x2, y2);
drawOneLine(x2, y2, x3, y3);
drawOneLine(x3, y3, x1, y1);
//lower polygon... float valbank, valsideslip, sideslip;
x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS); r = rad + 5.0; //5 is added to get a gap
y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS); // upper polygon
bank_angle = current_ch2();
x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
x4= x1 + 10.0 * cos (225 * SGD_DEGREES_TO_RADIANS); bank= bank_angle * SGD_RADIANS_TO_DEGREES; // Roll limit +/- 30 degrees
y4= y1 + 10.0 * sin (225 * SGD_DEGREES_TO_RADIANS); if (bank > BankLimit)
bank = BankLimit;
x5= x1 + 10.0 * cos (315 * SGD_DEGREES_TO_RADIANS); if (bank < -1.0*BankLimit)
y5= y1 + 10.0 * sin (315 * SGD_DEGREES_TO_RADIANS); bank = -1.0*BankLimit;
x2 = x2 + cos (valsideslip * SGD_DEGREES_TO_RADIANS); valbank = bank * 15.0 / BankLimit; // total span of TSI is 30 degrees
y2 = y2 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x3 = x3 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y3 = y3 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x4 = x4 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y4 = y4 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x5 = x5 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y5 = y5 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
drawOneLine(x2, y2, x3, y3); sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
drawOneLine(x3, y3, x5, y5); sideslip= sideslip_angle * SGD_RADIANS_TO_DEGREES;
drawOneLine(x5, y5, x4, y4); if (sideslip > SlewLimit)
drawOneLine(x4, y4, x2, y2); sideslip = SlewLimit;
if (sideslip < -1.0*SlewLimit)
sideslip = -1.0*SlewLimit;
} valsideslip = sideslip * 15.0 / SlewLimit;
glPopMatrix(); //values 270, 225 and 315 are angles in degrees...
x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
drawOneLine(x1, y1, x2, y2);
drawOneLine(x2, y2, x3, y3);
drawOneLine(x3, y3, x1, y1);
//lower polygon...
x1= xc + r * cos ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
x2= x1 + 6.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
y2= y1 + 6.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
x3= x1 + 6.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
y3= y1 + 6.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
x4= x1 + 10.0 * cos (225 * SGD_DEGREES_TO_RADIANS);
y4= y1 + 10.0 * sin (225 * SGD_DEGREES_TO_RADIANS);
x5= x1 + 10.0 * cos (315 * SGD_DEGREES_TO_RADIANS);
y5= y1 + 10.0 * sin (315 * SGD_DEGREES_TO_RADIANS);
x2 = x2 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y2 = y2 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x3 = x3 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y3 = y3 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x4 = x4 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y4 = y4 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
x5 = x5 + cos (valsideslip * SGD_DEGREES_TO_RADIANS);
y5 = y5 + sin (valsideslip * SGD_DEGREES_TO_RADIANS);
drawOneLine(x2, y2, x3, y3);
drawOneLine(x3, y3, x5, y5);
drawOneLine(x5, y5, x4, y4);
drawOneLine(x4, y4, x2, y2);
}
glPopMatrix();
} }

View file

@ -92,13 +92,13 @@ get_aspect_adjust (int xsize, int ysize)
bool bool
fgPanelVisible () fgPanelVisible ()
{ {
if(globals->get_current_panel() == 0) if (globals->get_current_panel() == 0)
return false; return false;
if(globals->get_current_panel()->getVisibility() == 0) if (globals->get_current_panel()->getVisibility() == 0)
return false; return false;
if(globals->get_viewmgr()->get_current() != 0) if (globals->get_viewmgr()->get_current() != 0)
return false; return false;
if(globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS != 0) if (globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS != 0)
return false; return false;
return true; return true;
} }
@ -371,7 +371,7 @@ FGPanel::draw()
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
if( _enable_depth_test ) if ( _enable_depth_test )
glDepthFunc(GL_ALWAYS); glDepthFunc(GL_ALWAYS);
else else
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
@ -442,7 +442,7 @@ FGPanel::draw()
// restore some original state // restore some original state
if( _enable_depth_test ) if ( _enable_depth_test )
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);
glPopAttrib(); glPopAttrib();
glPolygonOffset(0, 0); glPolygonOffset(0, 0);
@ -873,7 +873,7 @@ FGInstrumentLayer::transform () const
val = t->max; val = t->max;
} }
if(t->table==0) { if (t->table==0) {
val = val * t->factor + t->offset; val = val * t->factor + t->offset;
} else { } else {
val = t->table->interpolate(val) * t->factor + t->offset; val = t->table->interpolate(val) * t->factor + t->offset;

View file

@ -21,9 +21,9 @@
#ifndef __PANEL_HXX #ifndef __PANEL_HXX
#define __PANEL_HXX #define __PANEL_HXX
#ifndef __cplusplus #ifndef __cplusplus
# error This library requires C++ # error This library requires C++
#endif #endif
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H

View file

@ -289,7 +289,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
SG_LOG( SG_COCKPIT, SG_INFO, "Found interpolation table with " SG_LOG( SG_COCKPIT, SG_INFO, "Found interpolation table with "
<< trans_table->nChildren() << "children" ); << trans_table->nChildren() << "children" );
t->table = new SGInterpTable(); t->table = new SGInterpTable();
for(int i = 0; i < trans_table->nChildren(); i++) { for (int i = 0; i < trans_table->nChildren(); i++) {
const SGPropertyNode * node = trans_table->getChild(i); const SGPropertyNode * node = trans_table->getChild(i);
if (!strcmp(node->getName(), "entry")) { if (!strcmp(node->getName(), "entry")) {
double ind = node->getDoubleValue("ind", 0.0); double ind = node->getDoubleValue("ind", 0.0);
@ -769,10 +769,10 @@ readPanel (const SGPropertyNode * root)
FGPanelInstrument * instrument = readInstrument(node); FGPanelInstrument * instrument = readInstrument(node);
if (instrument != 0) if (instrument != 0)
panel->addInstrument(instrument); panel->addInstrument(instrument);
} else if(!strcmp(node->getName(), "special-instrument")) { } else if (!strcmp(node->getName(), "special-instrument")) {
//cout << "Special instrument found in instruments section!\n"; //cout << "Special instrument found in instruments section!\n";
const string name = node->getStringValue("name"); const string name = node->getStringValue("name");
if(name == "KLN89 GPS") { if (name == "KLN89 GPS") {
//cout << "Special instrument is KLN89\n"; //cout << "Special instrument is KLN89\n";
int x = node->getIntValue("x", -1); int x = node->getIntValue("x", -1);
@ -804,7 +804,7 @@ readPanel (const SGPropertyNode * root)
// Warning - hardwired size!!! // Warning - hardwired size!!!
RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y); RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y);
KLN89* gps = (KLN89*)globals->get_subsystem("kln89"); KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
if(gps == NULL) { if (gps == NULL) {
gps = new KLN89(instrument); gps = new KLN89(instrument);
globals->add_subsystem("kln89", gps); globals->add_subsystem("kln89", gps);
} }