1998-07-03 13:16:27 +00:00
|
|
|
|
|
|
|
#include "hud.hxx"
|
2000-02-15 03:30:01 +00:00
|
|
|
|
|
|
|
|
1998-07-24 21:36:55 +00:00
|
|
|
//============ Top of fgTBI_instr class member definitions ==============
|
1998-07-03 13:16:27 +00:00
|
|
|
|
|
|
|
fgTBI_instr ::
|
|
|
|
fgTBI_instr( int x,
|
|
|
|
int y,
|
|
|
|
UINT width,
|
|
|
|
UINT height,
|
1999-05-12 02:04:38 +00:00
|
|
|
FLTFNPTR chn1_source,
|
|
|
|
FLTFNPTR chn2_source,
|
|
|
|
float maxBankAngle,
|
|
|
|
float maxSlipAngle,
|
1998-07-03 13:16:27 +00:00
|
|
|
UINT gap_width,
|
|
|
|
bool working ) :
|
|
|
|
dual_instr_item( x, y, width, height,
|
|
|
|
chn1_source,
|
|
|
|
chn2_source,
|
|
|
|
working,
|
|
|
|
HUDS_TOP),
|
1999-05-12 02:04:38 +00:00
|
|
|
BankLimit ((int)(maxBankAngle)),
|
|
|
|
SlewLimit ((int)(maxSlipAngle)),
|
1998-07-03 13:16:27 +00:00
|
|
|
scr_hole (gap_width )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
fgTBI_instr :: ~fgTBI_instr() {}
|
|
|
|
|
|
|
|
fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
|
|
|
|
dual_instr_item( (const dual_instr_item &) image),
|
|
|
|
BankLimit( image.BankLimit),
|
|
|
|
SlewLimit( image.SlewLimit),
|
|
|
|
scr_hole ( image.scr_hole )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
fgTBI_instr & fgTBI_instr ::
|
|
|
|
operator = (const fgTBI_instr & rhs )
|
|
|
|
{
|
|
|
|
if( !(this == &rhs)) {
|
|
|
|
dual_instr_item::operator = (rhs);
|
|
|
|
BankLimit = rhs.BankLimit;
|
|
|
|
SlewLimit = rhs.SlewLimit;
|
|
|
|
scr_hole = rhs.scr_hole;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-05-12 02:04:38 +00:00
|
|
|
// Draws a Turn Bank Indicator on the screen
|
1998-07-03 13:16:27 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
void fgTBI_instr :: draw( void )
|
|
|
|
{
|
1999-05-12 02:04:38 +00:00
|
|
|
float bank_angle, sideslip_angle;
|
|
|
|
float ss_const; // sideslip angle pixels per rad
|
|
|
|
float cen_x, cen_y, bank, fspan, tee, hole;
|
|
|
|
|
|
|
|
int span = get_span();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2001-03-24 02:36:45 +00:00
|
|
|
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;
|
1999-05-12 02:04:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
|
|
|
|
|
2001-03-24 02:36:45 +00:00
|
|
|
if( sideslip_angle < -SGD_PI/9 ) {
|
|
|
|
sideslip_angle = -SGD_PI/9;
|
|
|
|
} else if( sideslip_angle > SGD_PI/9 ) {
|
|
|
|
sideslip_angle = SGD_PI/9;
|
1999-05-12 02:04:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cen_x = centroid.x;
|
|
|
|
cen_y = centroid.y;
|
2001-03-24 04:48:44 +00:00
|
|
|
bank = bank_angle * SGD_RADIANS_TO_DEGREES;
|
1999-05-12 02:04:38 +00:00
|
|
|
tee = -tee_height;
|
|
|
|
fspan = span;
|
|
|
|
hole = scr_hole;
|
2001-03-24 02:36:45 +00:00
|
|
|
ss_const = 2 * sideslip_angle * fspan/(SGD_2PI/9); // width represents 40 degrees
|
1999-05-12 02:04:38 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
glPopMatrix();
|
1998-07-03 13:16:27 +00:00
|
|
|
}
|