1
0
Fork 0
flightgear/src/Cockpit/hud_tbi.cxx

129 lines
3.4 KiB
C++
Raw Normal View History

#include "hud.hxx"
2000-02-15 03:30:01 +00:00
//============ Top of fgTBI_instr class member definitions ==============
fgTBI_instr ::
fgTBI_instr( int x,
int y,
UINT width,
UINT height,
FLTFNPTR chn1_source,
FLTFNPTR chn2_source,
float maxBankAngle,
float maxSlipAngle,
UINT gap_width,
bool working ) :
dual_instr_item( x, y, width, height,
chn1_source,
chn2_source,
working,
HUDS_TOP),
BankLimit ((int)(maxBankAngle)),
SlewLimit ((int)(maxSlipAngle)),
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;
}
//
// Draws a Turn Bank Indicator on the screen
//
void fgTBI_instr :: draw( void )
{
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;
}
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;
}
cen_x = centroid.x;
cen_y = centroid.y;
2001-03-24 04:48:44 +00:00
bank = bank_angle * SGD_RADIANS_TO_DEGREES;
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
// 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();
}