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

@ -573,9 +573,9 @@ static char *toDM(float dd)
double sign = 1;
int deg;
if (dd < 0) {
if (dd < 0)
sign = -1;
}
/* round for minutes expressed to three decimal places */
tempdd = fabs(dd) + (5.0E-4 / 60.0);
deg = (int)tempdd;
@ -604,9 +604,9 @@ static char *toDMS(float dd)
double sec;
double sign = 1;
if(dd < 0) {
if (dd < 0)
sign = -1;
}
/* round up for seconds expressed to one decimal place */
tempdd = fabs(dd) + (0.05 / 3600.0);
deg = (int)tempdd;

View file

@ -140,18 +140,18 @@ static bool glide;
static float glide_slope_val;
static bool worm_energy;
static bool waypoint;
static string type_tick;//hud
static string length_tick;//hud
static bool label_box;//hud
static int digits; //suma
static float radius; //suma
static int divisions; //suma
static int zoom; //suma
static int zenith; //suma
static int nadir ; //suma
static int hat; //suma
static bool tsi; //suma
static float rad; //suma
static string type_tick;
static string length_tick;
static bool label_box;
static int digits;
static float radius;
static int divisions;
static int zoom;
static int zenith;
static int nadir ;
static int hat;
static bool tsi;
static float rad;
static FLTFNPTR load_fn;
@ -229,16 +229,14 @@ readLadder(const SGPropertyNode * node)
worm_energy = node->getBoolValue("enable_energy_marker",false);
waypoint = node->getBoolValue("enable_waypoint_marker",false);
working = node->getBoolValue("working");
zenith = node->getIntValue("zenith"); //suma
nadir = node->getIntValue("nadir"); //suma
zenith = node->getIntValue("zenith");
nadir = node->getIntValue("nadir");
hat = node->getIntValue("hat");
// The factor assumes a base of 55 degrees per 640 pixels.
// Invert to convert the "compression" factor to a
// pixels-per-degree number.
if(fgGetBool("/sim/hud/enable3d", true))
{
if (HUD_style == 1)
{
if (fgGetBool("/sim/hud/enable3d", true)) {
if (HUD_style == 1) {
factor = 1;
factor = (640./55.) / factor;
}
@ -291,12 +289,12 @@ readCard(const SGPropertyNode * node)
marker_off = node->getFloatValue("marker_offset",0.0);
enable_pointer = node->getBoolValue("enable_pointer",true);
type_pointer = node->getStringValue("pointer_type");
type_tick = node->getStringValue("tick_type");//hud Can be 'circle' or 'line'
length_tick = node->getStringValue("tick_length");//hud For variable length
type_tick = node->getStringValue("tick_type"); // 'circle' or 'line'
length_tick = node->getStringValue("tick_length"); // for variable length
working = node->getBoolValue("working");
radius = node->getFloatValue("radius"); //suma
divisions = node->getIntValue("divisions"); //suma
zoom = node->getIntValue("zoom"); //suma
radius = node->getFloatValue("radius");
divisions = node->getIntValue("divisions");
zoom = node->getIntValue("zoom");
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
@ -359,12 +357,12 @@ readCard(const SGPropertyNode * node)
marker_off,
enable_pointer,
type_pointer,
type_tick,//hud
length_tick,//hud
type_tick,
length_tick,
working,
radius, //suma
divisions, //suma
zoom //suma
radius,
divisions,
zoom
);
} else {
p = (instr_item *) new gauge_instr( x, // x
@ -406,9 +404,9 @@ readLabel(const SGPropertyNode * node)
blinking = node->getIntValue("blinking");
latitude = node->getBoolValue("latitude",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");
digits = node->getIntValue("digits"); //suma
digits = node->getIntValue("digits");
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
@ -536,9 +534,9 @@ readLabel(const SGPropertyNode * node)
blinking,
latitude,
longitude,
label_box, //hud
label_box,
working,
digits); //suma
digits);
return p;
} // end readLabel
@ -558,8 +556,8 @@ readTBI(const SGPropertyNode * node)
maxSlipAngle = node->getFloatValue("maxSlipAngle");
gap_width = node->getIntValue("gap_width");
working = node->getBoolValue("working");
tsi = node->getBoolValue("tsi"); //suma
rad = node->getFloatValue("rad"); //suma
tsi = node->getBoolValue("tsi");
rad = node->getFloatValue("rad");
SG_LOG(SG_INPUT, SG_INFO, "Done reading instrument " << name);
@ -574,8 +572,8 @@ readTBI(const SGPropertyNode * node)
maxSlipAngle,
gap_width,
working,
tsi, //suma
rad); //suma
tsi,
rad);
return p;
} //end readTBI
@ -877,7 +875,8 @@ void fgUpdateHUDVirtual()
lookat[0] = -sin(SG_DEGREES_TO_RADIANS * view->getHeadingOffset_deg());
lookat[1] = tan(SG_DEGREES_TO_RADIANS * view->getPitchOffset_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);
// Map the -1:1 square to a 55.0x41.25 degree wide patch at z=1.

View file

@ -266,18 +266,18 @@ private:
float x, y;
char msg[64];
public:
int digit; //suma
fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y) //suma
int digit;
fgText(float x = 0, float y = 0, char *c = NULL,int digits=0): x(x), y(y)
{
strcpy(msg,c);
digit=digits; //suma
digit=digits;
}
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 ) {
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;
}
@ -305,7 +305,7 @@ public:
// 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
// is shown as 10ooo.
void Draw(fntRenderer *fnt,int digits) {
if (digits==1) {
@ -352,7 +352,6 @@ public:
fnt->puts( msg ) ;
}
}
//end suma
void Draw()
{
@ -426,7 +425,7 @@ private:
bool broken;
UINT scr_span; // Working values for draw;
POINT mid_span; //
int digits; //suma
int digits;
public:
instr_item( int x,
@ -437,7 +436,7 @@ public:
float data_scaling,
UINT options,
bool working = true,
int digit = 0); //suma
int digit = 0);
instr_item( const instr_item & image );
@ -453,7 +452,7 @@ public:
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; }
UINT huds_vert (UINT options) { return( options & HUDS_VERT ); }
UINT huds_left (UINT options) { return( options & HUDS_LEFT ); }
@ -483,9 +482,9 @@ public:
{
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 )
{
@ -565,7 +564,7 @@ public:
bool longitude,
bool label_box,
bool working,
int digit ); //suma);
int digit );
~instr_label();
@ -601,7 +600,7 @@ public:
int font_size,
int blinking,
bool working,
int digits =0 );//suma
int digits =0 );
~lat_label();
@ -636,7 +635,7 @@ public:
int font_size,
int blinking,
bool working,
int digit=0); //suma
int digit=0);
~lon_label();
@ -761,13 +760,13 @@ private:
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 radius;
float maxValue;
float minValue;
int divisions;
int zoom;
UINT Maj_div;
UINT Min_div;
public:
@ -800,9 +799,9 @@ public:
string tick_type,
string tick_length,
bool working,
float radius, //suma
int divisions, //suma
int zoom //suma
float radius,
int divisions,
int zoom
);
@ -810,9 +809,9 @@ public:
hud_card( const hud_card & image);
// virtual void display_enable( bool setting );
virtual void draw( void ); // Required method in base class
void circles(float,float,float); // suma
void fixed(float,float,float,float,float,float); //suma
void zoomed_scale(int,int); //suma
void circles(float,float,float);
void fixed(float,float,float,float,float,float);
void zoomed_scale(int,int);
};
typedef hud_card * pCardScale;
@ -872,8 +871,8 @@ private:
UINT BankLimit;
UINT SlewLimit;
UINT scr_hole;
bool tsi; //suma
float rad; //suma
bool tsi;
float rad;
public:
fgTBI_instr( int x,
@ -886,8 +885,8 @@ public:
float maxSlipAngle,
UINT gap_width,
bool working,
bool tsi, //suma
float rad); //suma
bool tsi,
float rad);
fgTBI_instr( const fgTBI_instr & image);
@ -923,9 +922,9 @@ private:
float glide_slope;
bool energy_worm;
bool waypoint_marker;
int zenith; //suma
int nadir; //suma
int hat; //suma
int zenith;
int nadir;
int hat;
// The Ladder has it's own temporary display lists
@ -959,18 +958,18 @@ public:
bool energy_worm,
bool waypoint_marker,
bool working,
int zenith, //suma
int nadir, //suma
int zenith,
int nadir,
int hat
); //suma
);
~HudLadder();
HudLadder( const HudLadder & image );
virtual void draw( void );
void drawZenith(float,float,float); //suma
void drawNadir(float, float, float); //suma
void drawZenith(float,float,float);
void drawNadir(float, float, float);
void Text( float x, float y, char *s)
{

View file

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

View file

@ -4,8 +4,8 @@
//============ Top of dual_instr_item class member definitions ============
dual_instr_item ::
dual_instr_item ( int x,
dual_instr_item::dual_instr_item(
int x,
int y,
UINT width,
UINT height,
@ -19,8 +19,8 @@ dual_instr_item ::
{
}
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 ),
alt_data_source( image.alt_data_source)
{

View file

@ -8,8 +8,8 @@ int instr_item :: brightness = 5;/*HUD_BRT_MEDIUM*/
glRGBTRIPLE instr_item :: color = {0.0, 1.0, 0.0};
// constructor ( No default provided )
instr_item ::
instr_item( int x,
instr_item::instr_item(
int x,
int y,
UINT width,
UINT height,
@ -17,14 +17,14 @@ instr_item ::
float data_scaling,
UINT options,
bool working,
int digit) : //suma
int digit) :
handle ( ++instances ),
load_value_fn ( data_source ),
disp_factor ( data_scaling ),
opts ( options ),
is_enabled ( working ),
broken ( FALSE ),
digits ( digit ) //suma
digits ( digit )
{
scrn_pos.left = x;
scrn_pos.top = y;
@ -37,19 +37,20 @@ instr_item ::
if (opts & HUDS_VERT) { // Vertical style
// Insure that the midpoint marker will fall exactly at the
// middle of the bar.
if( !(scrn_pos.bottom % 2)) {
if (!(scrn_pos.bottom % 2))
scrn_pos.bottom++;
}
scr_span = scrn_pos.bottom;
}
else {
} else {
// Insure that the midpoint marker will fall exactly at the
// middle of the bar.
if( !(scrn_pos.right % 2)) {
if (!(scrn_pos.right % 2))
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);
@ -57,8 +58,7 @@ instr_item ::
// copy constructor
instr_item ::
instr_item ( const instr_item & image ):
instr_item::instr_item( const instr_item & image ) :
handle ( ++instances ),
scrn_pos ( image.scrn_pos ),
load_value_fn( image.load_value_fn),
@ -74,13 +74,12 @@ instr_item ::
instr_item::~instr_item ()
{
if( instances ) {
if (instances)
instances--;
}
}
void instr_item ::
update( void )
void instr_item::update( void )
{
}
@ -89,15 +88,14 @@ void instr_item ::
// to simply not display, but more sophisticated behavior is available
// by over riding the function which is virtual in this class.
void instr_item ::
break_display ( bool bad )
void instr_item::break_display ( bool bad )
{
broken = !!bad;
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 levels will be sensitive both to
@ -105,8 +103,10 @@ void instr_item ::
// to emulated night vision effects.
}
UINT instr_item::get_Handle( void )
{
return handle;
}

View file

@ -3,14 +3,14 @@
#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
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ); //suma
#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif
//======================= Top of instr_label class =========================
instr_label ::
instr_label( int x,
instr_label::instr_label(
int x,
int y,
UINT width,
UINT height,
@ -25,11 +25,11 @@ instr_label ::
int blinking,
bool latitude,
bool longitude,
bool label_box,//hud
bool label_box,
bool working,
int digit): //suma
int digit) :
instr_item( x, y, width, height,
data_source,scale_data,options, working, digit), //suma
data_source,scale_data,options, working, digit),
pformat ( label_format ),
pre_str ( pre_label_string ),
post_str ( post_label_string ),
@ -38,33 +38,26 @@ instr_label ::
blink ( blinking ),
lat ( latitude ),
lon ( longitude ),
lbox ( label_box ) //hud
lbox ( label_box )
{
if (pre_str != NULL) {
if( post_str != NULL ) {
if (post_str != NULL )
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
}
else {
else
sprintf( format_buffer, "%s%s", pre_str, pformat );
}
}
else {
if( post_str != NULL ) {
} 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.
}
// I put this in to make it easy to construct a class member using the current
// C code.
instr_label::~instr_label()
{
}
// Copy constructor
instr_label::instr_label(const instr_label & image) :
instr_item((const instr_item &)image),
@ -74,21 +67,17 @@ instr_label :: instr_label( const instr_label & image) :
blink ( image.blink ),
lat ( image.lat ),
lon ( image.lon ),
lbox (image.lbox ) //hud
lbox ( image.lbox )
{
if (pre_str != NULL) {
if( post_str != NULL ) {
if (post_str != NULL)
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
}
else {
else
sprintf( format_buffer, "%s%s", pre_str, pformat );
}
}
else {
if( post_str != NULL ) {
} 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.
}
@ -98,10 +87,8 @@ instr_label :: instr_label( const instr_label & image) :
// draw Draws a label anywhere in the HUD
//
//
void instr_label ::
draw( void ) // Required method in base class
void instr_label::draw( void )
{
// char format_buffer[80];
char label_buffer[80];
int posincr;
int lenstr;
@ -110,13 +97,10 @@ draw( void ) // Required method in base class
if (data_available()) {
if (lat)
sprintf( label_buffer, format_buffer, coord_format_lat(get_value()) );
else
if(lon)
else if (lon)
sprintf( label_buffer, format_buffer, coord_format_lon(get_value()) );
else
{
if(lbox)//hud
{// Box for label
else {
if (lbox) {// Box for label
float x = scrn_rect.left;
float y = scrn_rect.top;
float w = scrn_rect.right;
@ -124,27 +108,31 @@ draw( void ) // Required method in base class
glPushMatrix();
glLoadIdentity();
glBegin(GL_LINES);
glVertex2f( x - 2.0, y - 2.0);
glVertex2f( x + w + 2.0, y - 2.0);
glVertex2f( x + w + 2.0, y + h + 2.0);
glVertex2f( x - 2.0, y + h + 2.0);
glEnd();
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0xAAAA );
glBegin(GL_LINES);
glVertex2f( x + w + 2.0, y - 2.0);
glVertex2f( x + w + 2.0, y + h + 2.0);
glVertex2f( x - 2.0, y + h + 2.0);
glVertex2f( x - 2.0, y - 2.0);
glEnd();
glDisable(GL_LINE_STIPPLE);
glPopMatrix();
}//hud
}
sprintf( label_buffer, format_buffer, get_value()*data_scaling() );
}
}
else {
} else {
// sprintf( label_buffer, format_buffer );
}
@ -170,13 +158,11 @@ draw( void ) // Required method in base class
if (fontSize == HUD_FONT_SMALL) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, get_digits()); //suma
}
else {
if( fontSize == HUD_FONT_LARGE ) {
label_buffer, get_digits());
} else if (fontSize == HUD_FONT_LARGE) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, get_digits()); //suma
}
label_buffer, get_digits());
}
}

View file

@ -3,32 +3,30 @@
#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
#define textString( x , y, text, digit ) puDrawString ( guiFnt, text, x, y ); //suma
#define textString(x, y, text, digit) puDrawString(guiFnt, text, x, y)
#endif
//======================= Top of instr_label class =========================
lon_label ::
lon_label( int x,
lon_label::lon_label(
int x,
int y,
UINT width,
UINT height,
FLTFNPTR data_source,
// DBLFNPTR data_source,
const char *label_format,
const char *pre_label_string,
const char *post_label_string,
float scale_data,
// double scale_data,
UINT options,
fgLabelJust justification,
int font_size,
int blinking,
bool working,
int digit): //suma
int digit) :
instr_item( x, y, width, height,
data_source, scale_data,options, working,digit ), //suma
data_source, scale_data,options, working,digit ),
pformat ( label_format ),
pre_str ( pre_label_string ),
post_str ( post_label_string ),
@ -37,29 +35,23 @@ lon_label ::
blink ( blinking )
{
if (pre_str != NULL) {
if( post_str != NULL ) {
if (post_str != NULL)
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
}
else {
else
sprintf( format_buffer, "%s%s", pre_str, pformat );
}
}
else {
if( post_str != NULL ) {
} 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.
}
// I put this in to make it easy to construct a class member using the current
// C code.
lon_label::~lon_label()
{
}
// Copy constructor
lon_label::lon_label( const lon_label & image) :
instr_item((const instr_item &)image),
@ -69,19 +61,14 @@ lon_label :: lon_label( const lon_label & image) :
blink ( image.blink )
{
if (pre_str != NULL) {
if( post_str != NULL ) {
if (post_str != NULL)
sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
}
else {
else
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,21 +76,17 @@ lon_label :: lon_label( const lon_label & image) :
// draw Draws a label anywhere in the HUD
//
//
void lon_label ::
draw( void ) // Required method in base class
void lon_label::draw( void )
{
// char format_buffer[80];
char label_buffer[80];
int posincr;
int lenstr;
RECT scrn_rect = get_location();
float lon = get_value();
// double lon = get_value();
if ( data_available() ) {
// char *lonstring = coord_format_lon(lon);
lenstr = sprintf( label_buffer, format_buffer, coord_format_lon(lon) );
}
else {
} else {
lenstr = sprintf( label_buffer, format_buffer );
}
@ -116,24 +99,21 @@ draw( void ) // Required method in base class
lenstr = getStringWidth(label_buffer);
if( justify == RIGHT_JUST ) {
if (justify == RIGHT_JUST)
posincr = scrn_rect.right - lenstr;
}else if( justify == CENTER_JUST ) {
else if (justify == CENTER_JUST)
posincr = get_span() - (lenstr/2);
} else {
// justify == LEFT_JUST
else // justify == LEFT_JUST
posincr = 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 ) {
label_buffer, get_digits());
} else if (fontSize == HUD_FONT_LARGE) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, get_digits()); //suma
}
label_buffer, get_digits());
}
}

View file

@ -41,7 +41,8 @@ runway_instr::runway_instr(int x,
int width,
int height,
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;
stippleCen=0xFFFF;
@ -62,6 +63,7 @@ runway_instr::runway_instr(int x,
default_pitch = fgGetDouble("/sim/view[0]/config/pitch-pitch-deg",0.0);
}
void runway_instr::draw() {
if (!is_broken() && get_active_runway(runway)) {
glPushAttrib(GL_LINE_STIPPLE | GL_LINE_STIPPLE_PATTERN | GL_LINE_WIDTH);
@ -146,6 +148,7 @@ void runway_instr::draw() {
}//if not broken
}
bool runway_instr::get_active_runway(FGRunway& runway) {
FGEnvironment stationweather =
((FGEnvironmentMgr *)globals->get_subsystem("environment"))->getEnvironment();
@ -153,6 +156,7 @@ bool runway_instr::get_active_runway(FGRunway& 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();
@ -184,8 +188,7 @@ void runway_instr::get_rwy_points(sgdVec3 *points3d) {
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++)
{
for (int i = 0; i < 6; i++) {
points3d[i][0] -= tileCenter.x();
points3d[i][1] -= tileCenter.y();
points3d[i][2] -= tileCenter.z();
@ -193,6 +196,7 @@ void runway_instr::get_rwy_points(sgdVec3 *points3d) {
center = currentCenter;
}
bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3& point1, const sgdVec3& point2) {
sgdVec3 p1, p2;
sgdCopyVec3(p1, point1);
@ -209,8 +213,8 @@ bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3&
glVertex2d(p1[0],p1[1]);
glVertex2d(p2[0],p2[1]);
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]};
//create the unit vector
sgdScaleVec3(vec,1.0/sgdLengthVec3(vec));
@ -224,8 +228,8 @@ bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3&
glVertex2d(p2[0],p2[1]);
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]};
//create the unit vector
sgdScaleVec3(vec,1.0/sgdLengthVec3(vec));
@ -239,8 +243,8 @@ bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3&
glVertex2d(p1[0],p1[1]);
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);
if (v) {
glBegin(GL_LINES);
@ -254,31 +258,34 @@ bool runway_instr::drawLine(const sgdVec3& a1, const sgdVec3& a2, const sgdVec3&
return (p1Valid && p2Valid);
}
void runway_instr::boundPoint(const sgdVec3& v, sgdVec3& m) {
double y = v[1];
if(m[1] < v[1]) {
if (m[1] < v[1])
y = location.bottom;
}
else if(m[1] > v[1]) {
else if (m[1] > v[1])
y = location.top;
}
if (m[0] == v[0]) {
m[1]=y;
return; //prevent divide by zero
}
double slope = (m[1]-v[1])/(m[0]-v[0]);
m[0] = (y-v[1])/slope + v[0];
m[1] = y;
if (m[0] < location.left) {
m[0] = location.left;
m[1] = slope * (location.left-v[0])+v[1];
}
else if (m[0] > location.right) {
} else if (m[0] > location.right) {
m[0] = location.right;
m[1] = slope * (location.right-v[0])+v[1];
}
}
bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
bool pointsInvalid = (v[1]>location.top && m[1]>location.top) ||
(v[1]<location.bottom && m[1]<location.bottom) ||
@ -286,28 +293,29 @@ bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
(v[0]<location.left && m[0]<location.left);
if (pointsInvalid)
return false;
if (m[0] == v[0]) {//x's are equal, vertical line
if (m[1]>v[1]) {
m[1]=location.top;
v[1]=location.bottom;
}
else {
} else {
v[1]=location.top;
m[1]=location.bottom;
}
return true;
}
if (m[1] == v[1]) { //y's are equal, horizontal line
if (m[0] > v[0]) {
m[0] = location.right;
v[0] = location.left;
}
else {
} else {
v[0] = location.right;
m[0] = location.left;
}
return true;
}
double slope = (m[1]-v[1])/(m[0]-v[0]);
double b = v[1]-(slope*v[0]);
double y1 = slope * location.left + b;
@ -315,33 +323,35 @@ bool runway_instr::boundOutsidePoints(sgdVec3& v, sgdVec3& m) {
double x1 = (location.bottom - b) / slope;
double x2 = (location.top - b) / slope;
int counter = 0;
if (y1 >= location.bottom && y1 <= location.top) {
v[0] = location.left;
v[1] = y1;
counter++;
}
if (y2 >= location.bottom && y2 <= location.top) {
if (counter > 0) {
m[0] = location.right;
m[1] = y2;
}
else {
} else {
v[0] = location.right;
v[1] = y2;
}
counter++;
}
if (x1 >= location.left && x1 <= location.right) {
if (counter > 0) {
m[0] = x1;
m[1] = location.bottom;
}
else {
} else {
v[0] = x1;
v[1] = location.bottom;
}
counter++;
}
if (x2 >= location.left && x2 <= location.right) {
m[0] = x1;
m[1] = location.bottom;
@ -365,11 +375,13 @@ void runway_instr::drawArrow() {
glRotated(theta,0.0,0.0,1.0);
glTranslated(0.0,arrowRad,0.0);
glScaled(arrowScale,arrowScale,0.0);
glBegin(GL_TRIANGLES);
glVertex2d(-5.0,12.5);
glVertex2d(0.0,25.0);
glVertex2d(5.0,12.5);
glEnd();
glBegin(GL_QUADS);
glVertex2d(-2.5,0.0);
glVertex2d(-2.5,12.5);
@ -390,10 +402,12 @@ void runway_instr::setLineWidth() {
double alt_nm = get_agl();
static const SGPropertyNode *startup_units_node
= fgGetNode("/sim/startup/units");
if (!strcmp(startup_units_node->getStringValue(), "feet"))
alt_nm *= SG_FEET_TO_METER*SG_METER_TO_NM;
else
alt_nm *= SG_METER_TO_NM;
//Calculate distance away from runway, C = v(A²+B²)
distance = sqrt(alt_nm*alt_nm + distance*distance);
if (distance < scaleDist)

View file

@ -14,8 +14,8 @@
// 2. This class was not intended to be instanciated. See moving_scale
// and gauge_instr classes.
//============================================================================
instr_scale ::
instr_scale ( int x,
instr_scale::instr_scale(
int x,
int y,
UINT width,
UINT height,
@ -30,8 +30,7 @@ instr_scale ( int x,
UINT rollover,
int dp_showing,
bool working ) :
instr_item( x, y, width, height,
load_fn, disp_scale, options, working),
instr_item( x, y, width, height, load_fn, disp_scale, options, working),
range_shown ( show_range ),
Maximum_value( maxValue ),
Minimum_value( minValue ),
@ -43,17 +42,16 @@ instr_scale ( int x,
int temp;
scale_factor = (float)get_span() / range_shown;
if( show_range < 0 ) {
if (show_range < 0)
range_shown = -range_shown;
}
temp = FloatToInt(Maximum_value - Minimum_value) / 100;
if( range_shown < temp ) {
if (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),
range_shown ( image.range_shown ),
Maximum_value( image.Maximum_value ),
@ -67,5 +65,8 @@ instr_scale ::
}
instr_scale :: ~ instr_scale () {}
instr_scale::~instr_scale ()
{
}

View file

@ -5,8 +5,8 @@
//============ Top of fgTBI_instr class member definitions ==============
fgTBI_instr ::
fgTBI_instr( int x,
fgTBI_instr::fgTBI_instr(
int x,
int y,
UINT width,
UINT height,
@ -16,8 +16,8 @@ fgTBI_instr( int x,
float maxSlipAngle,
UINT gap_width,
bool working,
bool tsivalue, //suma
float radius) : //suma
bool tsivalue,
float radius) :
dual_instr_item( x, y, width, height,
chn1_source,
chn2_source,
@ -27,12 +27,14 @@ fgTBI_instr( int x,
SlewLimit ((int)(maxSlipAngle)),
scr_hole (gap_width)
{
tsi=tsivalue; //suma
rad=radius; //suma
tsi=tsivalue;
rad=radius;
}
fgTBI_instr::~fgTBI_instr() {}
fgTBI_instr::fgTBI_instr(const fgTBI_instr & image) :
dual_instr_item( (const dual_instr_item &) image),
BankLimit( image.BankLimit),
@ -53,7 +55,6 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
float cen_x, cen_y, bank, fspan, tee, hole;
int span = get_span();
float zero = 0.0;
RECT My_box = get_location();
@ -63,25 +64,17 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
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 )
{
sideslip_angle = -SGD_PI/9;
}
else if ( sideslip_angle > SGD_PI/9 )
{
sideslip_angle = SGD_PI/9;
}
cen_x = centroid.x;
cen_y = centroid.y;
@ -100,18 +93,15 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
glTranslatef(cen_x, cen_y, zero);
glRotatef(-bank, zero, zero, 1.0);
if(!tsi)
{
if (!tsi) {
glBegin(GL_LINES);
if( !scr_hole )
{
if ( !scr_hole ) {
glVertex2f( -fspan, zero );
glVertex2f( fspan, zero );
}
else
{
} else {
glVertex2f( -fspan, zero );
glVertex2f( -hole, zero );
glVertex2f( hole, zero );
@ -122,7 +112,6 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
glVertex2f( hole, tee );
glVertex2f( -hole, zero );
glVertex2f( -hole, tee );
glEnd();
glBegin(GL_LINE_LOOP);
@ -132,12 +121,7 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
glVertex2f( ss_const - hole, zero);
glEnd();
}
else //if tsi enabled
{
} 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);
@ -234,7 +218,6 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
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);
y1= yc + r * sin ((valbank+270.0) * SGD_DEGREES_TO_RADIANS);
@ -249,9 +232,6 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
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);
@ -280,9 +260,8 @@ fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
drawOneLine(x3, y3, x5, y5);
drawOneLine(x5, y5, x4, y4);
drawOneLine(x4, y4, x2, y2);
}
glPopMatrix();
}