1
0
Fork 0

GUI updates contributed by Norman Vine.

This commit is contained in:
curt 1999-06-01 21:17:10 +00:00
parent 84468dddea
commit 70505137eb
13 changed files with 1425 additions and 1440 deletions

View file

@ -32,12 +32,10 @@
#include "autopilot.hxx"
#include <GUI/gui.h>
#include <Include/fg_constants.h>
#include <Cockpit/panel.hxx>
#include <Debug/logstream.hxx>
#include <Main/options.hxx>
#include <Main/views.hxx>
#include <GUI/gui.h>
// The below routines were copied right from hud.c ( I hate reinventing
@ -103,7 +101,7 @@ static double fgAPget_agl( void )
// Local Prototype section
double LinearExtrapolate( double x,double x1, double y1, double x2, double y2);
double LinearExtrapolate( double x, double x1, double y1, double x2, double y2);
double NormalizeDegrees( double Input);
// End Local ProtoTypes
@ -155,8 +153,7 @@ bool fgAPAutoThrottleEnabled( void )
void fgAPAltitudeAdjust( double inc )
{
// Remove at a later date
fgAPDataPtr APData;
APData = APDataGlobal;
fgAPDataPtr APData = APDataGlobal;
// end section
double target_alt, target_agl;
@ -181,6 +178,21 @@ void fgAPAltitudeAdjust( double inc )
APData->TargetAGL = target_agl;
}
void fgAPAltitudeSet( double new_altitude ) {
// Remove at a later date
fgAPDataPtr APData = APDataGlobal;
// end section
double target_alt = new_altitude;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET )
target_alt = new_altitude * FEET_TO_METER;
if( target_alt < scenery.cur_elev )
target_alt = scenery.cur_elev;
APData->TargetAltitude = target_alt;
}
void fgAPHeadingAdjust( double inc )
{
fgAPDataPtr APData;
@ -191,6 +203,13 @@ void fgAPHeadingAdjust( double inc )
APData->TargetHeading = NormalizeDegrees(target);
}
void fgAPHeadingSet( double new_heading ) {
fgAPDataPtr APData = APDataGlobal;
new_heading = NormalizeDegrees( new_heading );
APData->TargetHeading = new_heading;
}
void fgAPAutoThrottleAdjust( double inc )
{
fgAPDataPtr APData;
@ -203,6 +222,8 @@ void fgAPAutoThrottleAdjust( double inc )
void fgAPReset(void)
{
fgAPDataPtr APData = APDataGlobal;
if( fgAPTerrainFollowEnabled() )
fgAPToggleTerrainFollow( );
@ -214,6 +235,10 @@ void fgAPReset(void)
if( fgAPAutoThrottleEnabled() )
fgAPToggleAutoThrottle();
APData->TargetHeading = 0.0; // default direction, due north
APData->TargetAltitude = 3000; // default altitude in meters
APData->alt_error_accum = 0.0;
}
#define mySlider puSlider
@ -242,9 +267,6 @@ static puText *APAdjustDialogMessage;
static puFont APAdjustLegendFont;
static puFont APAdjustLabelFont;
static int DialogX = 40;
static int DialogY = 100;
static puOneShot *APAdjustOkButton;
static puOneShot *APAdjustResetButton;
static puOneShot *APAdjustCancelButton;
@ -268,7 +290,210 @@ static mySlider *APAdjustHS3;
static char SliderText[4][8];
// THIS NEEDS IMPROVEMENT !!!!!!!!!!!!!
static int scan_number(char *s, double *new_value)
{
int ret = 0;
char WordBuf[64];
char *cptr = s;
char *WordBufPtr = WordBuf;
if (*cptr == '+')
cptr++;
if (*cptr == '-') {
*WordBufPtr++ = *cptr++;
}
while (isdigit(*cptr) ) {
*WordBufPtr++ = *cptr++;
ret = 1;
}
if (*cptr == '.')
*WordBufPtr++ = *cptr++; // put the '.' into the string
while (isdigit(*cptr)) {
*WordBufPtr++ = *cptr++;
ret = 1;
}
if( ret == 1 ) {
*WordBufPtr = '\0';
sscanf(WordBuf, "%lf", new_value);
}
return(ret);
} // scan_number
///////// AutoPilot New Heading Dialog
static puDialogBox *ApHeadingDialog;
static puFrame *ApHeadingDialogFrame;
static puText *ApHeadingDialogMessage;
static puInput *ApHeadingDialogInput;
static puOneShot *ApHeadingDialogOkButton;
static puOneShot *ApHeadingDialogCancelButton;
void ApHeadingDialog_Cancel(puObject *)
{
ApHeadingDialogInput->rejectInput();
FG_POP_PUI_DIALOG( ApHeadingDialog );
}
void ApHeadingDialog_OK (puObject *me)
{
int error = 0;
char *c;
string s;
ApHeadingDialogInput -> getValue( &c );
if( strlen(c) ) {
double NewHeading;
if( scan_number( c, &NewHeading ) )
{
if(!fgAPHeadingEnabled())
fgAPToggleHeading();
fgAPHeadingSet( NewHeading );
} else {
error = 1;
s = c;
s += " is not a valid number.";
}
}
ApHeadingDialog_Cancel(me);
if( error ) mkDialog(s.c_str());
}
void NewHeading(puObject *cb)
{
// string ApHeadingLabel( "Enter New Heading" );
// ApHeadingDialogMessage -> setLabel(ApHeadingLabel.c_str());
ApHeadingDialogInput -> acceptInput();
FG_PUSH_PUI_DIALOG( ApHeadingDialog );
}
void NewHeadingInit(void)
{
// printf("NewHeadingInit\n");
char NewHeadingLabel[] = "Enter New Heading";
char *s;
float heading = fgAPget_heading();
int len = 260/2 -
(puGetStringWidth( puGetDefaultLabelFont(), NewHeadingLabel ) /2 );
ApHeadingDialog = new puDialogBox (150, 50);
{
ApHeadingDialogFrame = new puFrame (0, 0, 260, 150);
ApHeadingDialogMessage = new puText (len, 110);
ApHeadingDialogMessage -> setDefaultValue (NewHeadingLabel);
ApHeadingDialogMessage -> getDefaultValue (&s);
ApHeadingDialogMessage -> setLabel (s);
ApHeadingDialogInput = new puInput ( 50, 70, 210, 100 );
ApHeadingDialogInput -> setValue ( heading );
ApHeadingDialogOkButton = new puOneShot (50, 10, 110, 50);
ApHeadingDialogOkButton -> setLegend (gui_msg_OK);
ApHeadingDialogOkButton -> makeReturnDefault (TRUE);
ApHeadingDialogOkButton -> setCallback (ApHeadingDialog_OK);
ApHeadingDialogCancelButton = new puOneShot (140, 10, 210, 50);
ApHeadingDialogCancelButton -> setLegend (gui_msg_CANCEL);
ApHeadingDialogCancelButton -> setCallback (ApHeadingDialog_Cancel);
}
FG_FINALIZE_PUI_DIALOG( ApHeadingDialog );
}
///////// AutoPilot New Altitude Dialog
static puDialogBox *ApAltitudeDialog = 0;
static puFrame *ApAltitudeDialogFrame = 0;
static puText *ApAltitudeDialogMessage = 0;
static puInput *ApAltitudeDialogInput = 0;
static puOneShot *ApAltitudeDialogOkButton = 0;
static puOneShot *ApAltitudeDialogCancelButton = 0;
void ApAltitudeDialog_Cancel(puObject *)
{
ApAltitudeDialogInput -> rejectInput();
FG_POP_PUI_DIALOG( ApAltitudeDialog );
}
void ApAltitudeDialog_OK (puObject *me)
{
int error = 0;
string s;
char *c;
ApAltitudeDialogInput->getValue( &c );
if( strlen( c ) ) {
double NewAltitude;
if( scan_number( c, &NewAltitude) )
{
if(!(fgAPAltitudeEnabled()))
fgAPToggleAltitude();
fgAPAltitudeSet( NewAltitude );
} else {
error = 1;
s = c;
s += " is not a valid number.";
}
}
ApAltitudeDialog_Cancel(me);
if( error ) mkDialog(s.c_str());
}
void NewAltitude(puObject *cb)
{
ApAltitudeDialogInput -> acceptInput();
FG_PUSH_PUI_DIALOG( ApAltitudeDialog );
}
void NewAltitudeInit(void)
{
// printf("NewAltitudeInit\n");
char NewAltitudeLabel[] = "Enter New Altitude";
char *s;
float alt = current_aircraft.fdm_state->get_Altitude();
int len = 260/2 -
(puGetStringWidth( puGetDefaultLabelFont(), NewAltitudeLabel )/2);
ApAltitudeDialog = new puDialogBox (150, 50);
{
ApAltitudeDialogFrame = new puFrame (0, 0, 260, 150);
ApAltitudeDialogMessage = new puText (len, 110);
ApAltitudeDialogMessage -> setDefaultValue (NewAltitudeLabel);
ApAltitudeDialogMessage -> getDefaultValue (&s);
ApAltitudeDialogMessage -> setLabel (s);
ApAltitudeDialogInput = new puInput ( 50, 70, 210, 100 );
ApAltitudeDialogInput -> setValue ( alt );
// Uncomment the next line to have input active on startup
// ApAltitudeDialogInput -> acceptInput ( );
// cursor at begining or end of line ?
//len = strlen(s);
// len = 0;
// ApAltitudeDialogInput -> setCursor ( len );
// ApAltitudeDialogInput -> setSelectRegion ( 5, 9 );
ApAltitudeDialogOkButton = new puOneShot (50, 10, 110, 50);
ApAltitudeDialogOkButton -> setLegend (gui_msg_OK);
ApAltitudeDialogOkButton -> makeReturnDefault (TRUE);
ApAltitudeDialogOkButton -> setCallback (ApAltitudeDialog_OK);
ApAltitudeDialogCancelButton = new puOneShot (140, 10, 210, 50);
ApAltitudeDialogCancelButton -> setLegend (gui_msg_CANCEL);
ApAltitudeDialogCancelButton -> setCallback (ApAltitudeDialog_Cancel);
}
FG_FINALIZE_PUI_DIALOG( ApAltitudeDialog );
}
/////// simple AutoPilot GAIN / LIMITS ADJUSTER
#define fgAP_CLAMP(val,min,max) \
( (val) = (val) > (max) ? (max) : (val) < (min) ? (min) : (val) )
@ -331,21 +556,10 @@ static void rolloutsmooth_adj( puObject *hs )
static void goAwayAPAdjust (puObject *)
{
FGView *v = &current_view;
puPopLiveInterface ( ) ;
puPopGroup ( ) ;
APAdjustDialog -> hide();
if ( current_options.get_panel_status() ) {
// this seems to be the only way to do this :-(
// problem is the viewport has been mucked with
// current_options.toggle_panel();
// current_options.toggle_panel();
xglViewport(0, 0, (GLint)(v->winWidth), (GLint)(v->winHeight) );
FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
}
FG_POP_PUI_DIALOG( APAdjustDialog );
}
void cancelAPAdjust(puObject *)
void cancelAPAdjust(puObject *self)
{
fgAPDataPtr APData = APDataGlobal;
@ -353,13 +567,8 @@ void cancelAPAdjust(puObject *)
APData->RollOut = TmpRollOutValue;
APData->MaxAileron = TmpMaxAileronValue;
APData->RollOutSmooth = TmpRollOutSmoothValue;
puPopLiveInterface ( ) ;
// puPopInterface ( ) ;
puPopGroup ( ) ;
APAdjustDialog -> hide();
goAwayAPAdjust(self);
}
void resetAPAdjust(puObject *self)
@ -370,13 +579,10 @@ void resetAPAdjust(puObject *self)
APData->RollOut = RollOutAdjust / 2;
APData->MaxAileron = MaxAileronAdjust / 2;
APData->RollOutSmooth = RollOutSmoothAdjust / 2;
puPopLiveInterface ( ) ;
// puPopInterface ( ) ;
puPopGroup ( ) ;
APAdjustDialog -> hide();
fgAPAdjust(self);
FG_POP_PUI_DIALOG( APAdjustDialog );
fgAPAdjust( self );
}
void fgAPAdjust( puObject * )
@ -397,180 +603,140 @@ void fgAPAdjust( puObject * )
APAdjustHS1 -> setValue ( RollOutValue ) ;
APAdjustHS2 -> setValue ( RollOutSmoothValue ) ;
APAdjustHS3 -> setValue ( MaxAileronValue ) ;
// puPushInterface ( APAdjustDialog ) ;
puPushGroup ( APAdjustDialog ) ;
puPushLiveInterface ( APAdjustDialog ) ;
APAdjustDialog -> reveal();
FG_PUSH_PUI_DIALOG( APAdjustDialog );
}
#ifdef NOT_USED
void dragAPAdjust(puObject *self)
{
return;
int LastX, LastY;
int DeltaX, DeltaY, X, Y;
int button, count;
// button = guiGetMouseButton();
guiGetMouse(&LastX, &LastY);
button = 0;
printf("button %d LastX %d LastY %d\n", button, LastX, LastY);
// count = 0;
// while( guiGetMouseButton() == button )
for(count=0;count<1000;count++)
{
guiGetMouse(&X, &Y);
printf(" X %d Y %d\n", X, Y);
}
DeltaX = X - LastX;
DeltaY = Y - LastY;
// LiveInterface is Dialog Box
puInterface *Interface = puGetBaseLiveInterface();
puObject *dlist = Interface->getFirstChild() ;
// printf("%s %p %s %p\n",
// Interface->getTypeString(), Interface, dlist->getTypeString(), dlist);
Interface -> getPosition ( &X, &Y ) ;
Interface -> setPosition ( X + DeltaX, Y + DeltaY ) ;
// Interface -> recalc_bbox();
for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
{
bo -> getPosition ( &X, &Y ) ;
bo -> setPosition ( X + DeltaX, Y + DeltaY ) ;
bo -> recalc_bbox();
// printf("%s %p X %d Y %d\n", bo->getTypeString(), bo, X, Y);
}
Interface->recalc_bbox();
puPopLiveInterface ( ) ;
// puPopInterface ( ) ;
puPopGroup ( ) ;
APAdjustDialog -> hide();
fgAPAdjust(dlist);
}
#endif // NOT_USED
// Done once at system initialization
void fgAPAdjustInit( void )
{
// Done once at system initialization
void fgAPAdjustInit( void ) {
// printf("fgAPAdjustInit\n");
#define HORIZONTAL FALSE
fgAPDataPtr APData = APDataGlobal;
TmpMaxRollValue = APData->MaxRoll;
TmpRollOutValue = APData->RollOut;
TmpMaxAileronValue = APData->MaxAileron;
TmpRollOutSmoothValue = APData->RollOutSmooth;
int DialogX = 40;
int DialogY = 100;
int DialogWidth = 230;
MaxRollValue = APData->MaxRoll / MaxRollAdjust;
RollOutValue = APData->RollOut / RollOutAdjust;
MaxAileronValue = APData->MaxAileron / MaxAileronAdjust;
RollOutSmoothValue = APData->RollOutSmooth / RollOutSmoothAdjust;
char Label[] = "AutoPilot Adjust";
char *s;
fgAPDataPtr APData = APDataGlobal;
int labelX = (DialogWidth / 2) -
(puGetStringWidth( puGetDefaultLabelFont(), Label ) / 2);
labelX -= 30; // KLUDGEY
int nSliders = 4;
int slider_x = 10;
int slider_y = 55;
int slider_width = 210;
int slider_title_x = 15;
int slider_value_x = 160;
float slider_delta = 0.1f;
TmpMaxRollValue = APData-> MaxRoll;
TmpRollOutValue = APData-> RollOut;
TmpMaxAileronValue = APData-> MaxAileron;
TmpRollOutSmoothValue = APData-> RollOutSmooth;
MaxRollValue = APData-> MaxRoll / MaxRollAdjust;
RollOutValue = APData-> RollOut / RollOutAdjust;
MaxAileronValue = APData-> MaxAileron / MaxAileronAdjust;
RollOutSmoothValue = APData-> RollOutSmooth / RollOutSmoothAdjust;
puGetDefaultFonts ( &APAdjustLegendFont, &APAdjustLabelFont );
APAdjustDialog = new puDialogBox (DialogX, DialogY);
{
int horiz_slider_height = puGetStringHeight (APAdjustLabelFont) +
APAdjustDialog = new puDialogBox ( DialogX, DialogY ); {
int horiz_slider_height = puGetStringHeight (APAdjustLabelFont) +
puGetStringDescender (APAdjustLabelFont) +
PUSTR_TGAP + PUSTR_BGAP+5;
PUSTR_TGAP + PUSTR_BGAP + 5;
APAdjustFrame = new puFrame (0,0,230, 85+4*horiz_slider_height);
APAdjustDialogMessage = new puText (40, 52 + 4*horiz_slider_height);
APAdjustDialogMessage -> setLabel ("AutoPilot Adjust");
// APAdjustDragButton = new puButton (0, 75+4*horiz_slider_height,
// 230, 85+4*horiz_slider_height);
// APAdjustDragButton -> setLegend ("*");
// APAdjustDragButton -> setCallback (dragAPAdjust);
int slider_y = 55;
APAdjustHS0 = new mySlider ( 10, slider_y, 210, HORIZONTAL ) ;
APAdjustHS0 -> setDelta ( 0.1 ) ;
APAdjustHS0 -> setValue ( MaxRollValue ) ;
APAdjustHS0 -> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS0 -> setCallback ( maxroll_adj ) ;
sprintf(SliderText[0],"%05.2f", APData->MaxRoll );
APAdjustMaxRollTitle = new puText ( 15, slider_y ) ;
APAdjustMaxRollTitle -> setLabel ( "MaxRoll" ) ;
APAdjustMaxRollText = new puText ( 160, slider_y ) ;
APAdjustMaxRollText -> setLabel ( SliderText[0] ) ;
APAdjustFrame = new puFrame ( 0, 0,
DialogWidth, 85 + nSliders * horiz_slider_height );
APAdjustDialogMessage = new puText ( labelX, 52 + nSliders * horiz_slider_height );
APAdjustDialogMessage -> setDefaultValue ( Label );
APAdjustDialogMessage -> getDefaultValue ( &s );
APAdjustDialogMessage -> setLabel ( s );
APAdjustHS0 = new mySlider ( slider_x, slider_y, slider_width, HORIZONTAL ) ;
APAdjustHS0-> setDelta ( slider_delta ) ;
APAdjustHS0-> setValue ( MaxRollValue ) ;
APAdjustHS0-> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS0-> setCallback ( maxroll_adj ) ;
sprintf( SliderText[ 0 ], "%05.2f", APData->MaxRoll );
APAdjustMaxRollTitle = new puText ( slider_title_x, slider_y ) ;
APAdjustMaxRollTitle-> setDefaultValue ( "MaxRoll" ) ;
APAdjustMaxRollTitle-> getDefaultValue ( &s ) ;
APAdjustMaxRollTitle-> setLabel ( s ) ;
APAdjustMaxRollText = new puText ( slider_value_x, slider_y ) ;
APAdjustMaxRollText-> setLabel ( SliderText[ 0 ] ) ;
slider_y += horiz_slider_height;
APAdjustHS1 = new mySlider ( 10, slider_y, 210, HORIZONTAL ) ;
APAdjustHS1 -> setDelta ( 0.1 ) ;
APAdjustHS1 -> setValue ( RollOutValue ) ;
APAdjustHS1 -> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS1 -> setCallback ( rollout_adj ) ;
sprintf(SliderText[1],"%05.2f", APData->RollOut );
APAdjustRollOutTitle = new puText ( 15, slider_y ) ;
APAdjustRollOutTitle -> setLabel ( "AdjustRollOut" ) ;
APAdjustRollOutText = new puText ( 160, slider_y ) ;
APAdjustRollOutText -> setLabel ( SliderText[1] );
slider_y += horiz_slider_height;
APAdjustHS2 = new mySlider ( 10, slider_y, 210, HORIZONTAL ) ;
APAdjustHS2 -> setDelta ( 0.1 ) ;
APAdjustHS2 -> setValue ( RollOutSmoothValue ) ;
APAdjustHS2 -> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS2 -> setCallback ( rolloutsmooth_adj ) ;
sprintf(SliderText[2],"%5.2f", APData->RollOutSmooth );
APAdjustRollOutSmoothTitle = new puText ( 15, slider_y ) ;
APAdjustRollOutSmoothTitle -> setLabel ( "RollOutSmooth" ) ;
APAdjustRollOutSmoothText = new puText ( 160, slider_y ) ;
APAdjustRollOutSmoothText -> setLabel ( SliderText[2] );
APAdjustHS1 = new mySlider ( slider_x, slider_y, slider_width, HORIZONTAL ) ;
APAdjustHS1-> setDelta ( slider_delta ) ;
APAdjustHS1-> setValue ( RollOutValue ) ;
APAdjustHS1-> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS1-> setCallback ( rollout_adj ) ;
sprintf( SliderText[ 1 ], "%05.2f", APData->RollOut );
APAdjustRollOutTitle = new puText ( slider_title_x, slider_y ) ;
APAdjustRollOutTitle-> setDefaultValue ( "AdjustRollOut" ) ;
APAdjustRollOutTitle-> getDefaultValue ( &s ) ;
APAdjustRollOutTitle-> setLabel ( s ) ;
APAdjustRollOutText = new puText ( slider_value_x, slider_y ) ;
APAdjustRollOutText-> setLabel ( SliderText[ 1 ] );
slider_y += horiz_slider_height;
APAdjustHS3 = new mySlider ( 10, slider_y, 210, HORIZONTAL ) ;
APAdjustHS3 -> setDelta ( 0.1 ) ;
APAdjustHS3 -> setValue ( MaxAileronValue ) ;
APAdjustHS3 -> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS3 -> setCallback ( maxaileron_adj ) ;
sprintf(SliderText[3],"%05.2f", APData->MaxAileron );
APAdjustMaxAileronTitle = new puText ( 15, slider_y ) ;
APAdjustMaxAileronTitle -> setLabel ( "MaxAileron" ) ;
APAdjustMaxAileronText = new puText ( 160, slider_y ) ;
APAdjustMaxAileronText -> setLabel ( SliderText[3] );
APAdjustOkButton = new puOneShot (10, 10, 60, 50);
APAdjustOkButton -> setLegend ("OK");
APAdjustOkButton -> makeReturnDefault (TRUE );
APAdjustOkButton -> setCallback (goAwayAPAdjust);
APAdjustCancelButton = new puOneShot (70, 10, 150, 50);
APAdjustCancelButton -> setLegend ("Cancel");
APAdjustCancelButton -> makeReturnDefault (TRUE );
APAdjustCancelButton -> setCallback (cancelAPAdjust);
APAdjustResetButton = new puOneShot (160, 10, 220, 50);
APAdjustResetButton -> setLegend ("Reset");
APAdjustResetButton -> makeReturnDefault (TRUE );
APAdjustResetButton -> setCallback (resetAPAdjust);
APAdjustHS2 = new mySlider ( slider_x, slider_y, slider_width, HORIZONTAL ) ;
APAdjustHS2-> setDelta ( slider_delta ) ;
APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
APAdjustHS2-> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS2-> setCallback ( rolloutsmooth_adj ) ;
sprintf( SliderText[ 2 ], "%5.2f", APData->RollOutSmooth );
APAdjustRollOutSmoothTitle = new puText ( slider_title_x, slider_y ) ;
APAdjustRollOutSmoothTitle-> setDefaultValue ( "RollOutSmooth" ) ;
APAdjustRollOutSmoothTitle-> getDefaultValue ( &s ) ;
APAdjustRollOutSmoothTitle-> setLabel ( s ) ;
APAdjustRollOutSmoothText = new puText ( slider_value_x, slider_y ) ;
APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
slider_y += horiz_slider_height;
APAdjustHS3 = new mySlider ( slider_x, slider_y, slider_width, HORIZONTAL ) ;
APAdjustHS3-> setDelta ( slider_delta ) ;
APAdjustHS3-> setValue ( MaxAileronValue ) ;
APAdjustHS3-> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS3-> setCallback ( maxaileron_adj ) ;
sprintf( SliderText[ 3 ], "%05.2f", APData->MaxAileron );
APAdjustMaxAileronTitle = new puText ( slider_title_x, slider_y ) ;
APAdjustMaxAileronTitle-> setDefaultValue ( "MaxAileron" ) ;
APAdjustMaxAileronTitle-> getDefaultValue ( &s ) ;
APAdjustMaxAileronTitle-> setLabel ( s ) ;
APAdjustMaxAileronText = new puText ( slider_value_x, slider_y ) ;
APAdjustMaxAileronText-> setLabel ( SliderText[ 3 ] );
APAdjustOkButton = new puOneShot ( 10, 10, 60, 50 );
APAdjustOkButton-> setLegend ( gui_msg_OK );
APAdjustOkButton-> makeReturnDefault ( TRUE );
APAdjustOkButton-> setCallback ( goAwayAPAdjust );
APAdjustCancelButton = new puOneShot ( 70, 10, 150, 50 );
APAdjustCancelButton-> setLegend ( gui_msg_CANCEL );
APAdjustCancelButton-> setCallback ( cancelAPAdjust );
APAdjustResetButton = new puOneShot ( 160, 10, 220, 50 );
APAdjustResetButton-> setLegend ( gui_msg_RESET );
APAdjustResetButton-> setCallback ( resetAPAdjust );
}
APAdjustDialog -> close();
// APAdjustDialog -> reveal();
// Take it off the Stack
puPopLiveInterface ( ) ;
// puPopInterface ( ) ;
puPopGroup ( ) ;
FG_FINALIZE_PUI_DIALOG( APAdjustDialog );
#undef HORIZONTAL
}
@ -632,6 +798,8 @@ void fgAPInit( fgAIRCRAFT *current_aircraft )
#endif // !defined( USING_SLIDER_CLASS )
fgAPAdjustInit( ) ;
NewHeadingInit();
NewAltitudeInit();
};
int fgAPRun( void )
@ -805,27 +973,27 @@ int fgAPRun( void )
/*
if (APData->Mode == 2) // Glide slope hold
{
double RelSlope;
double RelElevator;
// First, calculate Relative slope and normalize it
RelSlope = NormalizeDegrees( APData->TargetSlope - get_pitch());
// Now calculate the elevator offset from current angle
if ( abs(RelSlope) > APData->SlopeSmooth )
{
if ( RelSlope < 0 ) // set RelElevator to max in the correct direction
RelElevator = -APData->MaxElevator;
else
RelElevator = APData->MaxElevator;
}
else
RelElevator = LinearExtrapolate(RelSlope,-APData->SlopeSmooth,-APData->MaxElevator,APData->SlopeSmooth,APData->MaxElevator);
// set the elevator
fgElevMove(RelElevator);
double RelSlope;
double RelElevator;
// First, calculate Relative slope and normalize it
RelSlope = NormalizeDegrees( APData->TargetSlope - get_pitch());
// Now calculate the elevator offset from current angle
if ( abs(RelSlope) > APData->SlopeSmooth )
{
if ( RelSlope < 0 ) // set RelElevator to max in the correct direction
RelElevator = -APData->MaxElevator;
else
RelElevator = APData->MaxElevator;
}
else
RelElevator = LinearExtrapolate(RelSlope,-APData->SlopeSmooth,-APData->MaxElevator,APData->SlopeSmooth,APData->MaxElevator);
// set the elevator
fgElevMove(RelElevator);
}
*/
@ -947,11 +1115,11 @@ double LinearExtrapolate( double x,double x1,double y1,double x2,double y2)
// This procedure extrapolates the y value for the x posistion on a line defined by x1,y1; x2,y2
//assert(x1 != x2); // Divide by zero error. Cold abort for now
double m, b, y; // the constants to find in y=mx+b
m=(y2-y1)/(x2-x1); // calculate the m
b= y1- m * x1; // calculate the b
y = m * x + b; // the final calculation
double m, b, y; // the constants to find in y=mx+b
m=(y2-y1)/(x2-x1); // calculate the m
b= y1- m * x1; // calculate the b
y = m * x + b; // the final calculation
return y;
};

View file

@ -38,7 +38,6 @@
#include <Aircraft/aircraft.hxx>
#include <Debug/logstream.hxx>
#include <GUI/gui.h>
#include <Include/fg_constants.h>
#include <Include/general.hxx>
#include <Main/options.hxx>
@ -49,6 +48,7 @@
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
#include <Time/fg_time.hxx>
#include <GUI/gui.h>
#include "cockpit.hxx"
@ -57,7 +57,11 @@
// cockpit/panel/hud system
static pCockpit ac_cockpit;
fntRenderer *HUDtext = 0;
float HUD_TextSize = 0;
int HUD_style = 0;
float HUD_matrix[16];
// The following routines obtain information concerntin the aircraft's
// current state and return it to calling instrument display routines.
// They should eventually be member functions of the aircraft.
@ -65,32 +69,19 @@ static pCockpit ac_cockpit;
float get_latitude( void )
{
// FGState *f;
double lat;
// current_aircraft.fdm_state
lat = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
float flat = lat;
return(flat);
// if(fabs(lat)<1.0)
// {
// if(lat<0)
// return( -(double)((int)lat) );
// else
// return( (double)((int)lat) );
// }
// return( (double)((int)lat) );
}
float get_lat_min( void )
{
// FGState *f;
double a, d;
// current_aircraft.fdm_state
a = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
if (a < 0.0) {
a = -a;
@ -104,23 +95,11 @@ float get_lat_min( void )
float get_longitude( void )
{
double lon;
// FGState *f;
// current_aircraft.fdm_state
lon = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
float flon = lon;
return(flon);
// if(fabs(lon)<1.0)
// {
// if(lon<0)
// return( -(double)((int)lon) );
// else
// return( (double)((int)lon) );
// }
// return( (double)((int)lon) );
}
@ -139,11 +118,7 @@ get_formated_gmt_time( void )
float get_long_min( void )
{
// FGState *f;
double a, d;
// current_aircraft.fdm_state
a = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
if (a < 0.0) {
a = -a;
@ -234,10 +209,6 @@ float get_altitude( void )
float get_agl( void )
{
// FGState *f;
// f = current_aircraft.fdm_state;
float agl;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
@ -252,11 +223,7 @@ float get_agl( void )
float get_sideslip( void )
{
// FGState *f;
// f = current_aircraft.fdm_state;
float sideslip = current_aircraft.fdm_state->get_Beta();
return( sideslip );
}
@ -292,10 +259,6 @@ float get_vfc_tris_culled ( void )
float get_climb_rate( void )
{
// FGState *f;
// current_aircraft.fdm_state
float climb_rate;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
@ -308,22 +271,16 @@ float get_climb_rate( void )
float get_view_direction( void )
{
// FGState *f;
// FGView *pview;
double view;
// pview = &current_view;
// current_aircraft.fdm_state
view = FG_2PI - current_view.get_view_offset();
view = ( current_aircraft.fdm_state->get_Psi() + view) * RAD_TO_DEG;
if(view > 360.)
view -= 360.;
else if(view<0.)
view += 360.;
float fview = view;
return( fview );
}
@ -352,7 +309,7 @@ char *dmshh_format(double degrees)
if (min_part >= 60)
min_part -= 60, deg_part += 1;
sprintf(buf,"%02d*%02d\'%05.2f\"",deg_part,min_part,sec_part);
sprintf(buf,"%02d*%02d %05.2f",deg_part,min_part,sec_part);
return buf;
}
@ -387,7 +344,7 @@ static char *toDMS(float a)
if (neg)
d = -d;
sprintf(dms, "%.0f*%02.0f'%04.1f\"", d, m, s);
sprintf(dms, "%.0f*%02.0f %04.1f", d, m, s);
return dms;
}
@ -415,10 +372,12 @@ static char *toDM(float a)
}
if (neg) d = -d;
sprintf(dm, "%.0f*%06.3f'", d, m);
sprintf(dm, "%.0f*%06.3f", d, m);
return dm;
}
// Have to set the LatLon display type
//static char *(*fgLatLonFormat)(float) = toDM;
static char *(*fgLatLonFormat)(float);
char *coord_format_lat(float latitude)
@ -473,105 +432,6 @@ char *coord_format_latlon(double latitude, double longitude)
}
#endif
#ifdef FAST_TEXT_TEST
#undef FAST_TEXT_TEST
#endif
#ifdef FAST_TEXT_TEST
static unsigned int first=0, last=128;
unsigned int font_base;
#define FONT "-adobe-courier-medium-r-normal--24-240-75-75-m-150-iso8859-1"
HFONT hFont;
void Font_Setup(void)
{
#ifdef _WIN32
int count;
HDC hdc;
HGLRC hglrc;
hdc = wglGetCurrentDC();
hglrc = wglGetCurrentContext();
if (hdc == 0 || hglrc == 0) {
printf("Could not get context or DC\n");
exit(1);
}
if (!wglMakeCurrent(hdc, hglrc)) {
printf("Could not make context current\n");
exit(1);
}
#define FONTBASE 0x1000
/*
hFont = GetStockObject(SYSTEM_FONT);
hFont = CreateFont(h, w, esc, orient, weight,
ital, under, strike, set, out, clip, qual, pitch/fam, face);
*/
hFont = CreateFont(30, 0, 0, 0, FW_NORMAL,
FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY,
FIXED_PITCH | FF_MODERN, "Arial");
if (!hFont) {
MessageBox(WindowFromDC(hdc),
"Failed to find acceptable bitmap font.",
"OpenGL Application Error",
MB_ICONERROR | MB_OK);
exit(1);
}
(void) SelectObject(hdc, hFont);
wglUseFontBitmaps(hdc, 0, 255, FONTBASE);
glListBase(FONTBASE);
#if 0
SelectObject (hdc, GetStockObject (SYSTEM_FONT));
count=last-first+1;
font_base = glGenLists(count);
wglUseFontBitmaps (hdc, first, last, font_base);
if (font_base == 0) {
printf("Could not generate Text_Setup list\n");
exit(1);
}
#endif // 0
#else
Display *Dpy;
XFontStruct *fontInfo;
Font id;
Dpy = XOpenDisplay(NULL);
fontInfo = XLoadQueryFont(Dpy, FONT);
if (fontInfo == NULL)
{
printf("Failed to load font %s\n", FONT);
exit(1);
}
id = fontInfo->fid;
first = fontInfo->min_char_or_byte2;
last = fontInfo->max_char_or_byte2;
base = glGenLists((GLuint) last+1);
if (base == 0) {
printf ("out of display lists\n");
exit (1);
}
glXUseXFont(id, first, last-first+1, base+first);
#endif
}
static void
drawString(char *string, GLfloat x, GLfloat y, GLfloat color[4])
{
glColor4fv(color);
glRasterPos2f(x, y);
glCallLists(strlen(string), GL_BYTE, (GLbyte *) string);
}
#endif // #ifdef FAST_TEXT_TEST
bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
{
@ -589,10 +449,6 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
// HI_Head is now a null pointer so we can generate a new list from the
// current aircraft.
#ifdef FAST_TEXT_TEST
Font_Setup();
#endif // #ifdef FAST_TEXT_TEST
fgHUDInit( cur_aircraft );
ac_cockpit = new fg_Cockpit();
@ -606,80 +462,61 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
FG_LOG( FG_COCKPIT, FG_INFO,
" Code " << ac_cockpit->code() << " Status "
<< ac_cockpit->status() );
// HUD_TextSize = (current_options.get_xsize() > 1000) ? 10 : 8;
HUD_TextSize = 10;
HUDtext = new fntRenderer();
HUDtext -> setFont ( guiFntHandle ) ;
HUDtext -> setPointSize ( HUD_TextSize ) ;
HUD_TextList.setFont( HUDtext );
return true;
}
void fgCockpitUpdate( void ) {
#define DISPLAY_COUNTER
#ifdef DISPLAY_COUNTER
static float lightCheck[4] = { 0.7F, 0.7F, 0.7F, 1.0F };
char buf[64],*ptr;
// int fontSize;
int c;
#endif
int iwidth = current_view.get_winWidth();
int iheight = current_view.get_winHeight();
float width = iwidth;
float height = iheight;
FG_LOG( FG_COCKPIT, FG_DEBUG,
"Cockpit: code " << ac_cockpit->code() << " status "
<< ac_cockpit->status() );
if ( current_options.get_hud_status() ) {
// This will check the global hud linked list pointer.
// If these is anything to draw it will.
fgUpdateHUD();
// This will check the global hud linked list pointer.
// If these is anything to draw it will.
fgUpdateHUD();
}
#define DISPLAY_COUNTER
#ifdef DISPLAY_COUNTER
else
{
char buf[64];
float fps = get_frame_rate();
float tris = fps * get_vfc_tris_drawn();
float culled = fps * get_vfc_tris_culled();
int len = sprintf(buf," %4.1f %7.0f %7.0f",
fps, tris, culled);
// sprintf(buf,"Tris Per Sec: %7.0f", t);
// fontSize = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
// float tris = fps * get_vfc_tris_drawn();
// float culled = fps * get_vfc_tris_culled();
// sprintf(buf,"%-4.1f %7.0f %7.0f", fps, tris, culled);
sprintf(buf,"%-5.1f", fps);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, 1024, 0, 768);
gluOrtho2D(0, width, 0, height);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
// glColor3f (.90, 0.27, 0.67);
glColor3f (0.9, 0.4, 0.2);
#ifdef FAST_TEXT_TEST
drawString(buf, 250.0F, 10.0F, lightCheck);
// glRasterPos2f( 220, 10);
// for (int i=0; i < len; i++) {
// glCallList(font_base+buf[i]);
// }
#else
glColor3f (.8, 0.8, 0.8);
glTranslatef( 400, 10, 0);
glScalef(.1, .1, 0.0);
ptr = buf;
while ( ( c = *ptr++) ){
glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
}
#endif // #ifdef FAST_TEXT_TEST
// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, ' ');
// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, ' ');
// ptr = get_formated_gmt_time();
// while ( ( c = *ptr++) ){
// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
// }
guiFnt.drawString( buf,
width/2 - guiFnt.getStringWidth(buf)/2,
10 );
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
@ -687,14 +524,13 @@ void fgCockpitUpdate( void ) {
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
#endif // DISPLAY_COUNTER
if ( current_options.get_panel_status() &&
(fabs( current_view.get_view_offset() ) < 0.2) )
#endif // #ifdef DISPLAY_COUNTER
if( current_options.get_panel_status() &&
(fabs( current_view.get_view_offset() ) < 0.2) )
{
xglViewport( 0, 0,
current_view.get_winWidth(),
current_view.get_winHeight() );
FGPanel::OurPanel->Update();
xglViewport( 0, 0, iwidth, iheight );
FGPanel::OurPanel->Update();
}
}

View file

@ -69,14 +69,10 @@ static char units[5];
//
deque< instr_item * > HUD_deque;
vector< fgLineSeg2D > HUD_LineList;
vector< fgLineSeg2D > HUD_StippleLineList;
#ifdef USE_HUD_TextList
vector< fgTextString > HUD_TextList;
#endif
//GLFONT *myFont;
fgTextList HUD_TextList;
fgLineList HUD_LineList;
fgLineList HUD_StippleLineList;
class locRECT {
public:
@ -158,6 +154,17 @@ void strokeString(int x, int y, char *msg, void *font, float theta)
}
}
int getStringWidth ( char *str )
{
if ( HUDtext && str )
{
float r, l ;
guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l );
}
return 0 ;
}
//========================= End of Class Implementations===================
// fgHUDInit
//
@ -187,10 +194,12 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
unsigned int ladr_w2 = 60;
int ladr_h2 = 90;
int ladr_t = 35;
// int compass_w2 = 100;
int compass_w = 200;
int gap = 10;
font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
HUD_style = 1;
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
@ -223,9 +232,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
HUD_deque.insert( HUD_deque.begin(), HIptr);
// case 4: // GYRO COMPASS
HIptr = (instr_item *) new hud_card( cen_x-100,
HIptr = (instr_item *) new hud_card( cen_x-(compass_w/2),
max_y,
200,
compass_w,
28,
get_heading,
HUDS_TOP,
@ -240,9 +249,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
// case 5: // AMSL
HIptr = (instr_item *) new hud_card( max_x - 35 -15, // 15 to balance speed card
cen_y-100,
cen_y-(compass_w/2),
35,
200,
compass_w,
get_altitude,
// HUDS_RIGHT | HUDS_VERT,
HUDS_LEFT | HUDS_VERT,
@ -276,7 +285,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
HUDS_LEFT | HUDS_VERT,
1000, 0,
1.0,
25, 5,
25, 5,
0,
0,
200.0,
@ -309,9 +318,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
// case 2: // KIAS
HIptr = (instr_item *) new hud_card( min_x +10 +5, //min_x +18,
cen_y-100,
cen_y-(compass_w/2),
28,
200,
compass_w,
get_speed,
// HUDS_LEFT | HUDS_VERT,
HUDS_RIGHT | HUDS_VERT,
@ -340,7 +349,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
// Remove this when below uncommented
// case 10:
HIptr = (instr_item *) new instr_label( 10,
10,
25,
60,
10,
get_frame_rate,
@ -355,9 +364,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
TRUE );
HUD_deque.insert( HUD_deque.begin(), HIptr);
HIptr = (instr_item *) new lat_label( (cen_x -ladr_w2)/2,
HIptr = (instr_item *) new lat_label( (cen_x - (compass_w/2))/2,
max_y,
60,
1,
text_h,
get_latitude,
"%s%", //"%.0f",
@ -371,21 +380,19 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
TRUE );
HUD_deque.insert( HUD_deque.begin(), HIptr);
HIptr = (instr_item *) new lon_label(
//(cen_x+ladr_x2) +((max_x-(cen_x+ladr_x2))/2),
(2*cen_x) - ((cen_x -ladr_w2)/2),
max_y,
60, text_h,
get_longitude,
"%s%",//"%.0f",
"", //"Lon ",
"",
1.0,
HUDS_TOP,
CENTER_JUST,
font_size,
0,
TRUE );
HIptr = (instr_item *) new lon_label(((cen_x+compass_w/2)+(2*cen_x))/2,
max_y,
1, text_h,
get_longitude,
"%s%",//"%.0f",
"", //"Lon ",
"",
1.0,
HUDS_TOP,
CENTER_JUST,
font_size,
0,
TRUE );
HUD_deque.insert( HUD_deque.begin(), HIptr);
/*
@ -644,11 +651,13 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
int ladr_w2 = 60;
// int ladr_h2 = 90;
// int ladr_t = 35;
// int compass_w2 = 100;
int compass_w = 200;
// int gap = 10;
font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
HUD_style = 2;
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
// deque < instr_item * > :: iterator first = HUD_deque.begin();
@ -672,9 +681,9 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
instr_item* p;
// case 4: // GYRO COMPASS
p =new hud_card( cen_x-100,
p =new hud_card( cen_x-(compass_w/2),
max_y,
200,
compass_w,
28,
get_view_direction,
HUDS_TOP,
@ -687,9 +696,9 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
true);
HUD_deque.push_front( p );
p = new lat_label( (cen_x -ladr_w2)/2,
p = new lat_label( (cen_x - compass_w/2)/2,
max_y,
60, text_h,
0, text_h,
get_latitude,
"%s%", //"%.0f",
"", //"Lat ",
@ -715,9 +724,9 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
// TRUE );
// HUD_deque.push_front( p );
p = new lon_label( (2*cen_x) - ((cen_x -ladr_w2)/2),
p = new lon_label(((cen_x+compass_w/2)+(2*cen_x))/2,
max_y,
60, text_h,
1, text_h,
get_longitude,
"%s%",//"%.0f",
"", //"Lon ",
@ -730,72 +739,61 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
TRUE );
HUD_deque.push_front( p );
// p = new instr_label( 480, 450, 60, 10,
// get_long_min,
// "%05.2f",
// "",
// NULL,
// 1.0,
// HUDS_TOP,
// CENTER_JUST,
// font_size,
// 0,
// TRUE );
// HUD_deque.push_front( p );
int x_pos = 40;
p = new instr_label( 10, 10, 60, 10,
p = new instr_label( x_pos, 25, 60, 10,
get_frame_rate,
"%7.1f",
"Frame rate =",
NULL,
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
HUD_deque.push_front( p );
p = new instr_label( 10, 25, 120, 10,
p = new instr_label( x_pos, 40, 120, 10,
get_vfc_tris_culled,
"%7.0f",
"Culled =",
"Culled =",
NULL,
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
HUD_deque.push_front( p );
p = new instr_label( 10, 40, 120, 10,
p = new instr_label( x_pos, 55, 120, 10,
get_vfc_tris_drawn,
"%7.0f",
"Rendered =",
NULL,
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
HUD_deque.push_front( p );
p = new instr_label( 10, 55, 90, 10,
p = new instr_label( x_pos, 70, 90, 10,
get_fov,
"%7.1f",
"FOV ",
"FOV = ",
NULL,
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
HUD_deque.push_front( p );
const int x_pos = 480;
x_pos = 480;
p = new instr_label ( x_pos,
70,
@ -803,11 +801,11 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
10,
get_aoa,
"%7.2f",
"AOA ",
"AOA ",
" Deg",
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
@ -820,7 +818,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
" Kts",
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
@ -838,7 +836,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
units,
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
@ -851,7 +849,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
units,
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
@ -864,7 +862,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
" Deg",
1.0,
HUDS_TOP,
RIGHT_JUST,
LEFT_JUST,
font_size,
0,
TRUE );
@ -1001,35 +999,20 @@ int brightness = pHUDInstr->get_brightness();
// all C++.
//
void fgUpdateHUD( void ) {
// int i;
int brightness;
// int day_night_sw = current_aircraft.controls->day_night_switch;
int day_night_sw = global_day_night_switch;
int hud_displays = HUD_deque.size();
instr_item *pHUDInstr;
int line_width;
float line_width;
if( !hud_displays ) { // Trust everyone, but ALWAYS cut the cards!
return;
}
// vector < fgLineSeg2D > :: iterator first_lineSeg = HUD_LineList.begin();
// vector < fgLineSeg2D > :: iterator last_lineSeg = HUD_LineList.end();
// HUD_LineList.erase( first_lineSeg, last_lineSeg);
HUD_LineList.erase( HUD_LineList.begin(), HUD_LineList.end() );
// first = HUD_StippleLineList.begin();
// last = HUD_StippleLineList.end();
// HUD_StippleLineList.erase( first, last);
// HUD_StippleLineList.erase( HUD_StippleLineList.begin(),
// HUD_StippleLineList.end() );
#ifdef USE_HUD_TextList
// vector < fgTextString > :: iterator first_string = HUD_TextList.begin();
// vector < fgTextString > :: iterator last_string = HUD_TextList.end();
// HUD_TextList.erase( first_string, last_string);
HUD_TextList.erase( HUD_TextList.begin(), HUD_TextList.end() );
#endif
line_width = (current_options.get_xsize() > 1000) ? 2 : 1;
HUD_TextList.erase();
HUD_LineList.erase();
// HUD_StippleLineList.erase();
pHUDInstr = HUD_deque[0];
brightness = pHUDInstr->get_brightness();
@ -1040,7 +1023,6 @@ void fgUpdateHUD( void ) {
glLoadIdentity();
gluOrtho2D(0, 640, 0, 480);
// gluOrtho2D(0, 1024, 0, 768);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
@ -1051,8 +1033,6 @@ void fgUpdateHUD( void ) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glLineWidth(line_width);
// We can do translucency, so why not. :-)
// glEnable ( GL_BLEND ) ;
// glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
@ -1060,18 +1040,22 @@ void fgUpdateHUD( void ) {
if( day_night_sw == DAY) {
switch (brightness) {
case BRT_LIGHT:
// glColor4f (0.1, 0.9, 0.1, 0.75);
glColor3f (0.1, 0.9, 0.1);
break;
case BRT_MEDIUM:
// glColor4f (0.1, 0.7, 0.0, 0.75);
glColor3f (0.1, 0.7, 0.0);
break;
case BRT_DARK:
glColor3f (0.0, 0.5, 0.0);
// glColor4f (0.0, 0.6, 0.0, 0.75);
glColor3f(0.0, 0.6, 0.0);
break;
case BRT_BLACK:
// glColor4f( 0.0, 0.0, 0.0, 0.75);
glColor3f( 0.0, 0.0, 0.0);
break;
@ -1082,31 +1066,33 @@ void fgUpdateHUD( void ) {
if( day_night_sw == NIGHT) {
switch (brightness) {
case BRT_LIGHT:
// glColor4f (0.9, 0.1, 0.1, 0.75);
glColor3f (0.9, 0.1, 0.1);
break;
case BRT_MEDIUM:
// glColor4f (0.7, 0.0, 0.1, 0.75);
glColor3f (0.7, 0.0, 0.1);
break;
case BRT_DARK:
default:
glColor3f (0.5, 0.0, 0.0);
// glColor4f (0.6, 0.0, 0.0, 0.75);
glColor3f (0.6, 0.0, 0.0);
}
}
else { // Just in case default
// glColor4f (0.1, 0.9, 0.1, 0.75);
glColor3f (0.1, 0.9, 0.1);
}
}
deque < instr_item * > :: iterator current = HUD_deque.begin();
deque < instr_item * > :: iterator last = HUD_deque.end();
for ( ; current != last; ++current ) {
pHUDInstr = *current;
// for( i = hud_displays; i; --i) { // Draw everything
// if( HUD_deque.at(i)->enabled()) {
// pHUDInstr = HUD_deque[i - 1];
if( pHUDInstr->enabled()) {
// fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
// hud->code, hud->status );
@ -1116,52 +1102,22 @@ void fgUpdateHUD( void ) {
}
}
vector < fgLineSeg2D > :: iterator curSeg = HUD_LineList.begin();
vector < fgLineSeg2D > :: iterator lastSeg = HUD_LineList.end();
char *gmt_str = get_formated_gmt_time();
HUD_TextList.add( fgText( gmt_str, 40, 10) );
HUD_TextList.draw();
line_width = (current_options.get_xsize() > 1000) ? 1.0 : 0.5;
glLineWidth(line_width);
HUD_LineList.draw();
glBegin(GL_LINES);
for ( ; curSeg != lastSeg; curSeg++ ) {
curSeg->draw();
}
glEnd();
// curSeg = HUD_StippleLineList.begin();
// lastSeg = HUD_StippleLineList.end();
// glEnable(GL_LINE_STIPPLE);
// glLineStipple( 1, 0x00FF );
// glBegin(GL_LINES);
// for ( ; curSeg != lastSeg; curSeg++ ) {
// curSeg->draw();
// }
// glEnd();
// HUD_StippleLineList.draw();
// glDisable(GL_LINE_STIPPLE);
#ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y )
#endif
#ifdef USE_HUD_TextList
GLfloat mat[16];
glPushMatrix();
glGetFloatv(GL_MODELVIEW_MATRIX, mat);
HUD_TextList.push_back( fgTextString( GLUT_BITMAP_8_BY_13,
get_formated_gmt_time(),
450, 445)
);
// glFontBegin ( myFont );
vector < fgTextString > :: iterator curString = HUD_TextList.begin();
vector < fgTextString > :: iterator lastString = HUD_TextList.end();
for ( ; curString != lastString; curString++ ) {
glLoadMatrixf( mat );
curString->draw();
}
// glFontEnd ();
glPopMatrix();
#endif
// glDisable ( GL_BLEND ) ;
// glDisable( GL_BLEND );
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);

View file

@ -52,10 +52,8 @@
#include <Aircraft/aircraft.hxx>
#include <FDM/flight.hxx>
#include <Controls/controls.hxx>
//#include "glfont.h"
//extern GLFONT *myFont;
#include <GUI/gui.h>
#include <Math/mat3.h>
FG_USING_STD(deque);
FG_USING_STD(vector);
@ -203,26 +201,10 @@ typedef struct gltagRGBTRIPLE { // rgbt
GLfloat Green;
GLfloat Red;
} glRGBTRIPLE;
/*
struct fgVertex2D {
UINT x, y;
fgVertex2D( UINT a = 0, UINT b =0 )
: x(a), y(b) {}
fgVertex2D( const fgVertex2D & image )
: x(image.x), y(image.y) {}
fgVertex2D& operator= ( const fgVertex2D & image ) {
x = image.x; y = image.y; return *this;
}
~fgVertex2D() {}
};
*/
class fgLineSeg2D {
private:
GLfloat x0, y0, x1, y1; //UINT
GLfloat x0, y0, x1, y1;
public:
fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
@ -245,89 +227,141 @@ public:
};
#define USE_HUD_TextList
#ifdef USE_HUD_TextList
extern float HUD_TextSize;
extern fntRenderer *HUDtext;
extern float HUD_matrix[16];
//#define FAST_TEXT_TEST
#ifdef FAST_TEXT_TEST
extern void Font_Setup(void);
extern unsigned int font_base;
#endif
class fgTextString {
class fgText {
private:
void *font;
char msg[80];
char msg[32];
float x, y;
// static GLfloat mat[16];
public:
fgTextString( void *d = NULL, char *c = NULL, UINT x = 0, UINT y =0 )
: font(d), x(x), y(y) {strcpy(msg,c);}
fgText( char *c = NULL, float x = 0, float y =0 )
: x(x), y(y) {strncpy(msg,c,32-1);}
fgTextString( const fgTextString & image )
: font(image.font), x(image.x), y(image.y) {strcpy(msg,image.msg);}
fgText( float x = 0, float y = 0, char *c = NULL )
: x(x), y(y) {strncpy(msg,c,32-1);}
fgTextString& operator = ( const fgTextString & image ) {
font = image.font; strcpy(msg,image.msg); x = image.x; y = image.y;
fgText( const fgText & image )
: x(image.x), y(image.y) {strcpy(msg,image.msg);}
fgText& operator = ( const fgText & image ) {
strcpy(msg,image.msg); x = image.x; y = image.y;
return *this;
}
~fgTextString() {msg[0]='\0';}
~fgText() {msg[0]='\0';}
// void set_mat(void) {
// glScalef(.075, .075, 0.0);
// glGetFloatv(GL_MODELVIEW_MATRIX, mat);
// }
void draw()
int getStringWidth ( char *str )
{
#ifdef FAST_TEXT_TEST
glRasterPos2f( x, y);
int len = (int) strlen(msg);
for (int i=0; i < len; i++) {
glCallList(font_base+msg[i]);
}
// glFontTextOut ( msg, x, y, 0.0f);
#else
#define USE_STROKED_CHAR
#ifdef USE_STROKED_CHAR
int c;
char *buf;
buf = msg;
if(*buf)
if ( HUDtext && str )
{
// glRasterPos2f( x, y);
glTranslatef( x, y, 0);
glScalef(.075, .075, 0.0);
while ((c=*buf++)) {
glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
}
float r, l ;
guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l );
}
#else
char *c = msg;
if(*c)
return 0 ;
}
int StringWidth (void )
{
if ( HUDtext && strlen( msg ))
{
glRasterPos2f(x, y);
while (*c) {
glutBitmapCharacter(font, *c);
c++;
}
float r, l ;
guiFntHandle->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l );
}
#endif // #ifdef USE_STROKED_CHAR
#endif // FAST_TEXT_TEST
return 0 ;
}
void Draw(fntRenderer *fnt)
{
fnt->start2f( x, y );
fnt->puts ( msg ) ;
}
void Draw()
{
puDrawString ( guiFnt, msg, FloatToInt(x), FloatToInt(y) );
}
};
typedef vector< fgTextString > TYPE_HUD_TextList;
extern TYPE_HUD_TextList HUD_TextList;
#endif //#ifdef USE_HUD_TextList
class fgLineList {
vector < fgLineSeg2D > List;
public:
fgLineList( void ) {}
~fgLineList( void ) {}
void add( fgLineSeg2D seg ) { List.push_back(seg); }
void erase( void ) { List.erase( List.begin(), List.end() ); }
void draw( void ) {
vector < fgLineSeg2D > :: iterator curSeg;
vector < fgLineSeg2D > :: iterator lastSeg;
curSeg = List.begin();
lastSeg = List.end();
glBegin(GL_LINES);
for ( ; curSeg != lastSeg; curSeg++ ) {
curSeg->draw();
}
glEnd();
}
};
class fgTextList {
fntRenderer *Font;
vector< fgText > List;
public:
fgTextList ( void ) { Font = 0; }
~fgTextList( void ) {}
void setFont( fntRenderer *Renderer ) { Font = Renderer; }
void add( fgText String ) { List.push_back(String); }
void erase( void ) { List.erase( List.begin(), List.end() ); }
void draw( void ) {
vector < fgText > :: iterator curString;
vector < fgText > :: iterator lastString;
if( Font == 0 ) return;
curString = List.begin();
lastString = List.end();
glPushAttrib( GL_COLOR_BUFFER_BIT );
glEnable ( GL_ALPHA_TEST ) ;
glEnable ( GL_BLEND ) ;
glAlphaFunc ( GL_GREATER, 0.1 ) ;
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
Font->begin();
for( ; curString != lastString; curString++ ) {
curString->Draw(Font);
}
Font->end();
glDisable ( GL_TEXTURE_2D ) ;
glPopAttrib();
}
};
typedef vector< fgLineSeg2D > TYPE_HUD_LineList;
extern TYPE_HUD_LineList HUD_LineList;
extern TYPE_HUD_LineList HUD_StippleLineList;
inline void Text( fgTextList &List, float x, float y, char *s)
{
List.add( fgText( x, y, s) );
}
inline void Text( fgTextList &List, fgText &me)
{
List.add(me);
}
inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
{
List.add(fgLineSeg2D(x1,y1,x2,y2));
}
// Declare our externals
extern fgTextList HUD_TextList;
extern fgLineList HUD_LineList;
extern fgLineList HUD_StippleLineList;
class instr_item { // An Abstract Base Class (ABC)
private:
@ -361,16 +395,16 @@ class instr_item { // An Abstract Base Class (ABC)
instr_item & operator = ( const instr_item & rhs );
virtual ~instr_item ();
int get_brightness ( void ) { return brightness;}
RECT get_location ( void ) { return scrn_pos; }
bool is_broken ( void ) { return broken; }
bool enabled ( void ) { return is_enabled;}
bool data_available ( void ) { return !!load_value_fn; }
float get_value ( void ) { return load_value_fn(); }
float data_scaling ( void ) { return disp_factor; }
UINT get_span ( void ) { return scr_span; }
POINT get_centroid ( void ) { return mid_span; }
UINT get_options ( void ) { return opts; }
int get_brightness ( void ) { return brightness;}
RECT get_location ( void ) { return scrn_pos; }
bool is_broken ( void ) { return broken; }
bool enabled ( void ) { return is_enabled;}
bool data_available ( void ) { return !!load_value_fn; }
float get_value ( void ) { return load_value_fn(); }
float data_scaling ( void ) { return disp_factor; }
UINT get_span ( void ) { return scr_span; }
POINT get_centroid ( void ) { return mid_span; }
UINT get_options ( void ) { return opts; }
UINT huds_vert (UINT options) { return( options & HUDS_VERT ); }
UINT huds_left (UINT options) { return( options & HUDS_LEFT ); }
@ -387,34 +421,32 @@ class instr_item { // An Abstract Base Class (ABC)
virtual void break_display ( bool bad );
virtual void SetBrightness( int illumination_level ); // fgHUDSetBright...
void SetPosition ( int x, int y, UINT width, UINT height );
UINT get_Handle( void );
UINT get_Handle( void );
virtual void draw( void ) = 0; // Required method in derived classes
void drawOneLine( UINT x1, UINT y1, UINT x2, UINT y2)
void drawOneLine( float x1, float y1, float x2, float y2)
{
HUD_LineList.push_back(fgLineSeg2D(x1,y1,x2,y2));
// glBegin(GL_LINES);
// glVertex2i(x1, y1);
// glVertex2i(x2, y2);
// glEnd();
HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
}
void drawOneStippleLine( UINT x1, UINT y1, UINT x2, UINT y2)
void drawOneStippleLine( float x1, float y1, float x2, float y2)
{
HUD_StippleLineList.push_back(fgLineSeg2D(x1,y1,x2,y2));
// glEnable(GL_LINE_STIPPLE);
// glLineStipple( 1, 0x00FF );
// glBegin(GL_LINES);
// glVertex2i(x1, y1);
// glVertex2i(x2, y2);
// glEnd();
// glDisable(GL_LINE_STIPPLE);
HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
}
#ifdef USE_HUD_TextList
void TextString( void *font, char *msg, UINT x, UINT y )
void TextString( char *msg, float x, float y )
{
HUD_TextList.push_back(fgTextString(font, msg, x, y));
HUD_TextList.add(fgText(msg, x, y));
}
#endif
int getStringWidth ( char *str )
{
if ( HUDtext && str )
{
float r, l ;
guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l );
}
return 0 ;
}
};
typedef instr_item *HIptr;
@ -423,6 +455,7 @@ typedef instr_item *HIptr;
//typedef hud_deque_type::const_iterator hud_deque_const_iterator;
extern deque< instr_item *> HUD_deque;
extern int HUD_style;
//extern hud_deque_type HUD_deque;
// instr_item This class has no other purpose than to maintain
@ -713,6 +746,10 @@ class HudLadder : public dual_instr_item {
float vmin;
float factor;
fgTextList TextList;
fgLineList LineList;
fgLineList StippleLineList;
public:
HudLadder( int x,
int y,
@ -720,9 +757,9 @@ class HudLadder : public dual_instr_item {
UINT height,
FLTFNPTR ptch_source = get_roll,
FLTFNPTR roll_source = get_pitch,
float span_units = 45.0,
float division_units = 10.0,
float minor_division = 0.0,
float span_units = 45.0,
float division_units = 10.0,
float minor_division = 0.0,
UINT screen_hole = 70,
UINT lbl_pos = 0,
bool working = true );
@ -732,6 +769,21 @@ class HudLadder : public dual_instr_item {
HudLadder( const HudLadder & image );
HudLadder & operator = ( const HudLadder & rhs );
virtual void draw( void );
void Text( float x, float y, char *s)
{
TextList.add( fgText( x, y, s) );
}
void Line( float x1, float y1, float x2, float y2)
{
LineList.add(fgLineSeg2D(x1,y1,x2,y2));
}
void StippleLine( float x1, float y1, float x2, float y2)
{
StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
}
};

View file

@ -19,7 +19,9 @@
#include "hud.hxx"
#ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y )
#define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif
//========== Top of hud_card class member definitions =============

View file

@ -19,73 +19,75 @@
#include "hud.hxx"
#ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y )
#define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif
//============== Top of guage_instr class member definitions ==============
guage_instr ::
guage_instr( int x,
int y,
UINT width,
UINT height,
FLTFNPTR load_fn,
UINT options,
float disp_scale,
float maxValue,
float minValue,
UINT major_divs,
UINT minor_divs,
int dp_showing,
UINT modulus,
bool working) :
instr_scale( x, y, width, height,
load_fn, options,
(maxValue - minValue), // Always shows span?
maxValue, minValue,
disp_scale,
major_divs, minor_divs,
modulus, dp_showing,
working)
guage_instr( int x,
int y,
UINT width,
UINT height,
FLTFNPTR load_fn,
UINT options,
float disp_scale,
float maxValue,
float minValue,
UINT major_divs,
UINT minor_divs,
int dp_showing,
UINT modulus,
bool working) :
instr_scale( x, y, width, height,
load_fn, options,
(maxValue - minValue), // Always shows span?
maxValue, minValue,
disp_scale,
major_divs, minor_divs,
modulus, dp_showing,
working)
{
// UINT options = get_options();
// huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM;
// UINT options = get_options();
// huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM;
}
guage_instr ::
~guage_instr()
~guage_instr()
{
}
guage_instr ::
guage_instr( const guage_instr & image):
instr_scale( (instr_scale &) image)
guage_instr( const guage_instr & image):
instr_scale( (instr_scale &) image)
{
// UINT options = get_options();
// huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM;
// UINT options = get_options();
// huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM;
}
guage_instr & guage_instr ::
operator = (const guage_instr & rhs )
operator = (const guage_instr & rhs )
{
if( !(this == &rhs)) {
instr_scale::operator = (rhs);
if( !(this == &rhs)) {
instr_scale::operator = (rhs);
}
return *this;
return *this;
}
// As implemented, draw only correctly draws a horizontal or vertical
@ -96,295 +98,298 @@ guage_instr & guage_instr ::
void guage_instr :: draw (void)
{
int marker_xs, marker_xe;
int marker_ys, marker_ye;
int text_x, text_y;
int width, height, bottom_4;
int lenstr;
int i;
char TextScale[80];
bool condition;
int disp_val = 0;
float vmin = min_val();
float vmax = max_val();
POINT mid_scr = get_centroid();
float cur_value = get_value();
RECT scrn_rect = get_location();
UINT options = get_options();
width = scrn_rect.left + scrn_rect.right;
height = scrn_rect.top + scrn_rect.bottom;
bottom_4 = scrn_rect.bottom / 4;
int marker_xs, marker_xe;
int marker_ys, marker_ye;
int text_x, text_y;
int width, height, bottom_4;
int lenstr;
int i;
char TextScale[80];
bool condition;
int disp_val = 0;
float vmin = min_val();
float vmax = max_val();
POINT mid_scr = get_centroid();
float cur_value = get_value();
RECT scrn_rect = get_location();
UINT options = get_options();
width = scrn_rect.left + scrn_rect.right;
height = scrn_rect.top + scrn_rect.bottom,
bottom_4 = scrn_rect.bottom / 4;
// Draw the basic markings for the scale...
if( huds_vert(options) ) { // Vertical scale
drawOneLine( scrn_rect.left, // Bottom tick bar
scrn_rect.top,
width,
scrn_rect.top);
if( huds_vert(options) ) { // Vertical scale
drawOneLine( scrn_rect.left, // Bottom tick bar
scrn_rect.top,
width,
scrn_rect.top);
drawOneLine( scrn_rect.left, // Top tick bar
height,
width,
height );
drawOneLine( scrn_rect.left, // Top tick bar
height,
width,
height );
marker_xs = scrn_rect.left;
marker_xe = width;
marker_xs = scrn_rect.left;
marker_xe = width;
if( huds_left(options) ) { // Read left, so line down right side
drawOneLine( width,
scrn_rect.top,
width,
height);
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
}
if( huds_right(options) ) { // Read right, so down left sides
drawOneLine( scrn_rect.left,
scrn_rect.top,
scrn_rect.left,
height);
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
}
if( huds_left(options) ) { // Read left, so line down right side
drawOneLine( width,
scrn_rect.top,
width,
height);
marker_xs = marker_xe - scrn_rect.right / 3; // Adjust tick xs
}
if( huds_right(options) ) { // Read right, so down left sides
drawOneLine( scrn_rect.left,
scrn_rect.top,
scrn_rect.left,
height);
marker_xe = scrn_rect.left + scrn_rect.right / 3; // Adjust tick xe
}
// At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged.
if( huds_both(options) ) {
marker_ye = marker_xs;
marker_xs = marker_xe;
marker_xe = marker_ye;
}
// At this point marker x_start and x_end values are transposed.
// To keep this from confusing things they are now interchanged.
if( huds_both(options) ) {
marker_ye = marker_xs;
marker_xs = marker_xe;
marker_xe = marker_ye;
}
// Work through from bottom to top of scale. Calculating where to put
// minor and major ticks.
// Work through from bottom to top of scale. Calculating where to put
// minor and major ticks.
if( !huds_noticks(options)) { // If not no ticks...:)
// Calculate x marker offsets
int last = (int)vmax + 1; //FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin);
for(; i <last ; i++ ) {
// for( i = (int)vmin; i <= (int)vmax; i++ ) {
if( !huds_noticks(options)) { // If not no ticks...:)
// Calculate x marker offsets
int last = (int)vmax + 1; //FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin);
for(; i <last ; i++ ) {
// for( i = (int)vmin; i <= (int)vmax; i++ ) {
// Calculate the location of this tick
marker_ys = scrn_rect.top + FloatToInt((i - vmin) * factor()/* +.5f*/);
// Calculate the location of this tick
marker_ys = scrn_rect.top + FloatToInt((i - vmin) * factor()/* +.5f*/);
// We compute marker_ys even though we don't know if we will use
// either major or minor divisions. Simpler.
// We compute marker_ys even though we don't know if we will use
// either major or minor divisions. Simpler.
if( div_min()) { // Minor tick marks
if( !(i%(int)div_min()) ) {
if( huds_left(options) && huds_right(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs - 3, marker_ys );
drawOneLine( marker_xe + 3, marker_ys,
width, marker_ys );
}
else {
if( huds_left(options) ) {
drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe - 3, marker_ys );
}
}
}
}
if( div_min()) { // Minor tick marks
if( !(i%(int)div_min()) ) {
if( huds_left(options) && huds_right(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs - 3, marker_ys );
drawOneLine( marker_xe + 3, marker_ys,
width, marker_ys );
}
else {
if( huds_left(options) ) {
drawOneLine( marker_xs + 3, marker_ys, marker_xe, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe - 3, marker_ys );
}
}
}
}
// Now we work on the major divisions. Since these are also labeled
// and no labels are drawn otherwise, we label inside this if
// statement.
// Now we work on the major divisions. Since these are also labeled
// and no labels are drawn otherwise, we label inside this if
// statement.
if( div_max()) { // Major tick mark
if( !(i%(int)div_max()) ) {
if( huds_left(options) && huds_right(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs, marker_ys );
drawOneLine( marker_xe, marker_ys,
width, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
}
if( div_max()) { // Major tick mark
if( !(i%(int)div_max()) ) {
if( huds_left(options) && huds_right(options) ) {
drawOneLine( scrn_rect.left, marker_ys,
marker_xs, marker_ys );
drawOneLine( marker_xe, marker_ys,
width, marker_ys );
}
else {
drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
}
if( !huds_notext(options) ) {
disp_val = i;
lenstr = sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/*+.5*/ ));
if( !huds_notext(options) ) {
disp_val = i;
sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/*+.5*/ ));
if( huds_left(options) && huds_right(options) ) {
text_x = mid_scr.x - 2 - ((3 * lenstr) >> 1);
}
else {
if( huds_left(options) ) {
text_x = marker_xs - 2 - 3 * lenstr;
}
else {
text_x = marker_xe + 10 - lenstr;
}
}
// Now we know where to put the text.
text_y = marker_ys;
textString( text_x, text_y, TextScale, GLUT_BITMAP_8_BY_13 );
}
}
} //
} //
} //
// Now that the scale is drawn, we draw in the pointer(s). Since labels
// have been drawn, text_x and text_y may be recycled. This is used
// with the marker start stops to produce a pointer for each side reading
lenstr = getStringWidth( TextScale );
if( huds_left(options) && huds_right(options) ) {
text_x = mid_scr.x - lenstr/2 ;
}
else {
if( huds_left(options) ) {
text_x = marker_xs - lenstr;
}
else {
text_x = marker_xe - lenstr;
}
}
// Now we know where to put the text.
text_y = marker_ys;
textString( text_x, text_y, TextScale, GLUT_BITMAP_8_BY_13 );
}
}
} //
} //
} //
// Now that the scale is drawn, we draw in the pointer(s). Since labels
// have been drawn, text_x and text_y may be recycled. This is used
// with the marker start stops to produce a pointer for each side reading
text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
// text_x = marker_xs - scrn_rect.left;
text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
// text_x = marker_xs - scrn_rect.left;
if( huds_right(options) ) {
glBegin(GL_LINE_STRIP);
glVertex2f( scrn_rect.left, text_y + 5);
glVertex2f( marker_xe, text_y);
glVertex2f( scrn_rect.left, text_y - 5);
glEnd();
}
if( huds_left(options) ) {
glBegin(GL_LINE_STRIP);
glVertex2f( width, text_y + 5);
glVertex2f( marker_xs, text_y);
glVertex2f( width, text_y - 5);
glEnd();
}
if( huds_right(options) ) {
glBegin(GL_LINE_STRIP);
glVertex2f( scrn_rect.left, text_y + 5);
glVertex2f( marker_xe, text_y);
glVertex2f( scrn_rect.left, text_y - 5);
glEnd();
}
if( huds_left(options) ) {
glBegin(GL_LINE_STRIP);
glVertex2f( width, text_y + 5);
glVertex2f( marker_xs, text_y);
glVertex2f( width, text_y - 5);
glEnd();
}
} // End if VERTICAL SCALE TYPE
else { // Horizontal scale by default
drawOneLine( scrn_rect.left, // left tick bar
scrn_rect.top,
scrn_rect.left,
height);
else { // Horizontal scale by default
drawOneLine( scrn_rect.left, // left tick bar
scrn_rect.top,
scrn_rect.left,
height);
drawOneLine( width, // right tick bar
scrn_rect.top,
width,
height );
drawOneLine( width, // right tick bar
scrn_rect.top,
width,
height );
marker_ys = scrn_rect.top; // Starting point for
marker_ye = height; // tick y location calcs
marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
marker_ys = scrn_rect.top; // Starting point for
marker_ye = height; // tick y location calcs
marker_xs = scrn_rect.left + FloatToInt((cur_value - vmin) * factor() /*+ .5f*/);
if( huds_top(options) ) {
drawOneLine( scrn_rect.left,
scrn_rect.top,
width,
scrn_rect.top); // Bottom box line
marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
// Bottom arrow
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs - bottom_4, scrn_rect.top);
glVertex2f( marker_xs, marker_ye);
glVertex2f( marker_xs + bottom_4, scrn_rect.top);
glEnd();
}
if( huds_bottom(options) ) {
// Top box line
drawOneLine( scrn_rect.left, height, width, height);
// Tick point adjust
marker_ys = height - scrn_rect.bottom / 2;
if( huds_top(options) ) {
drawOneLine( scrn_rect.left,
scrn_rect.top,
width,
scrn_rect.top); // Bottom box line
marker_ye = scrn_rect.top + scrn_rect.bottom / 2; // Tick point adjust
// Bottom arrow
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs - bottom_4, scrn_rect.top);
glVertex2f( marker_xs, marker_ye);
glVertex2f( marker_xs + bottom_4, scrn_rect.top);
glEnd();
}
if( huds_bottom(options) ) {
// Top box line
drawOneLine( scrn_rect.left, height, width, height);
// Tick point adjust
marker_ys = height - scrn_rect.bottom / 2;
// Top arrow
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs + bottom_4, height);
glVertex2f( marker_xs, marker_ys );
glVertex2f( marker_xs - bottom_4, height);
glEnd();
}
// Top arrow
glBegin(GL_LINE_STRIP);
glVertex2f( marker_xs + bottom_4, height);
glVertex2f( marker_xs, marker_ys );
glVertex2f( marker_xs - bottom_4, height);
glEnd();
}
int last = (int)vmax + 1; //FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin);
for( ; i <last ; i++ ) {
condition = true;
if( !modulo()) {
if( i < min_val()) {
condition = false;
}
}
if( condition ) {
marker_xs = scrn_rect.left + FloatToInt((i - vmin) * factor()/* +.5f*/);
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
if( div_min()){
if( !(i%(int)div_min()) ) {
// draw in ticks only if they aren't too close to the edge.
if((( marker_xs + 5) > scrn_rect.left ) ||
(( marker_xs - 5 )< (width))){
int last = (int)vmax + 1; //FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin);
for( ; i <last ; i++ ) {
condition = true;
if( !modulo()) {
if( i < min_val()) {
condition = false;
}
}
if( condition ) {
marker_xs = scrn_rect.left + FloatToInt((i - vmin) * factor()/* +.5f*/);
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
if( div_min()){
if( !(i%(int)div_min()) ) {
// draw in ticks only if they aren't too close to the edge.
if((( marker_xs + 5) > scrn_rect.left ) ||
(( marker_xs - 5 )< (width))){
if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys - 4);
drawOneLine( marker_xs, marker_ye + 4,
marker_xs, height);
}
else {
if( huds_top(options) ) {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye - 4);
}
else {
drawOneLine( marker_xs, marker_ys + 4,
marker_xs, marker_ye);
}
}
}
}
}
if( div_max()) {
if( !(i%(int)div_max()) ) {
if(modulo()) {
if( disp_val < 0) {
while( disp_val < 0 ) {
disp_val += modulo();
}
}
disp_val = i % (int)modulo();
} else {
disp_val = i;
}
lenstr = 4 * sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/* +.5*/ ));
// Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) &&
( (marker_xs + 10) < width )){
if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys);
drawOneLine( marker_xs, marker_ye,
marker_xs, height);
if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys - 4);
drawOneLine( marker_xs, marker_ye + 4,
marker_xs, height);
}
else {
if( huds_top(options) ) {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye - 4);
}
else {
drawOneLine( marker_xs, marker_ys + 4,
marker_xs, marker_ye);
}
}
}
}
}
if( div_max()) {
if( !(i%(int)div_max()) ) {
if(modulo()) {
if( disp_val < 0) {
while( disp_val < 0 ) {
disp_val += modulo();
}
}
disp_val = i % (int)modulo();
} else {
disp_val = i;
}
sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/* +.5*/ ));
lenstr = getStringWidth( TextScale);
// Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) &&
( (marker_xs + 10) < width )){
if( huds_both(options) ) {
drawOneLine( marker_xs, scrn_rect.top,
marker_xs, marker_ys);
drawOneLine( marker_xs, marker_ye,
marker_xs, height);
if( !huds_notext(options) ) {
textString ( marker_xs - lenstr, marker_ys + 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
if( !huds_notext(options) ) {
if( huds_top(options) ) {
textString ( marker_xs - lenstr,
height - 10,
TextScale, GLUT_BITMAP_8_BY_13 );
}
else {
textString( marker_xs - lenstr, scrn_rect.top,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
}
}
}
}
}
}
if( !huds_notext(options) ) {
textString ( marker_xs - lenstr, marker_ys + 4,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
else {
drawOneLine( marker_xs, marker_ys,
marker_xs, marker_ye );
if( !huds_notext(options) ) {
if( huds_top(options) ) {
textString ( marker_xs - lenstr,
height - 10,
TextScale, GLUT_BITMAP_8_BY_13 );
}
else {
textString( marker_xs - lenstr, scrn_rect.top,
TextScale, GLUT_BITMAP_8_BY_13 );
}
}
}
}
}
}
}
}
}
}

View file

@ -19,7 +19,9 @@
#include "hud.hxx"
#ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y )
#define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif
//======================= Top of instr_label class =========================
@ -105,9 +107,9 @@ instr_label & instr_label ::operator = (const instr_label & rhs )
justify = rhs.justify;
pre_str = rhs.pre_str;
post_str = rhs.post_str;
strcpy(format_buffer,rhs.format_buffer);
strcpy(format_buffer,rhs.format_buffer);
}
return *this;
return *this;
}
//
@ -123,45 +125,33 @@ draw( void ) // Required method in base class
int lenstr;
RECT scrn_rect = get_location();
// if( pre_str != NULL) {
// if( post_str != NULL ) {
// sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
// }
// 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.
if( data_available() ) {
lenstr = sprintf( label_buffer, format_buffer, get_value() );
sprintf( label_buffer, format_buffer, get_value() );
}
else {
lenstr = sprintf( label_buffer, format_buffer );
sprintf( label_buffer, format_buffer );
}
lenstr = getStringWidth( label_buffer );
#ifdef DEBUGHUD
fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
#endif
// lenstr = strlen( label_buffer );
posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8;
if( justify == CENTER_JUST ) {
posincr = - (lenstr << 2); // -lenstr*4;
}
else {
if( justify == LEFT_JUST ) {
posincr = - (lenstr << 8); // 0;
}
}
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 == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13);

View file

@ -14,7 +14,7 @@
#include <Math/polar3d.hxx>
#include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx>
#include <GUI/gui.h>
#include "hud.hxx"
//====================== Top of HudLadder Class =======================
@ -83,251 +83,157 @@ HudLadder & HudLadder :: operator = ( const HudLadder & rhs )
//
// Draws a climb ladder in the center of the HUD
//
inline static void _strokeString(float xx, float yy, char *msg, void *font)
{
int c;
if(*msg)
{
glTranslatef( xx, yy, 0);
glScalef(.075, .075, 0.0);
while ((c=*msg++)) {
glutStrokeCharacter( font, c);
}
}
}
void HudLadder :: draw( void )
{
float roll_value;
float pitch_value;
float marker_y;
float x_ini;
float x_end;
float y_ini;
float y_end;
float x_ini;
float x_end;
float y;
int i;
POINT centroid = get_centroid();
RECT box = get_location();
POINT centroid = get_centroid();
RECT box = get_location();
int half_span = box.right >> 1;
char TextLadder[80];
int label_length;
roll_value = current_ch2();
float half_span = box.right / 2.0;
float roll_value = current_ch2();
float hole = (float)((scr_hole)/2);
GLfloat mat[16];
pitch_value = current_ch1() * RAD_TO_DEG;
float pitch_value = current_ch1() * RAD_TO_DEG;
vmin = pitch_value - (float)width_units/2.0;
vmax = pitch_value + (float)width_units/2.0;
// We will do everything with glLoadMatrix :-)
// to avoid multiple pushing and popping matrix stack
glPushMatrix();
// glTranslatef( centroid.x, centroid.y, 0);
// glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0);
// glGetFloatv(GL_MODELVIEW_MATRIX, mat);
// this is the same as above
float sinx = sin(roll_value);
float cosx = cos(roll_value);
mat[0] = cosx;
mat[1] = sinx;
mat[2] = mat[3] = 0.0;
mat[4] = -sinx;
mat[5] = cosx;
mat[6] = mat[7] = mat[8] = mat[9];
mat[10] = 1.0;
mat[11] = 0.0;
mat[12] = centroid.x;
mat[13] = centroid.y;
mat[14] = 0;
mat[15] = 1.0;
glLoadMatrixf( mat );
glTranslatef( centroid.x, centroid.y, 0);
glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0);
// Draw the target spot.
#define CENTER_DIAMOND_SIZE 5.0
#define CENTER_DIAMOND_SIZE 6.0
glBegin(GL_LINE_LOOP);
glVertex2f( -CENTER_DIAMOND_SIZE, 0.0);
glVertex2f(0.0, CENTER_DIAMOND_SIZE);
glVertex2f( CENTER_DIAMOND_SIZE, 0.0);
glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
glEnd();
#if 0
glBegin(GL_LINES);
glVertex2f( -CENTER_DIAMOND_SIZE, 0);
glVertex2f( -(CENTER_DIAMOND_SIZE*2), 0);
glVertex2f(0, CENTER_DIAMOND_SIZE);
glVertex2f(0, (CENTER_DIAMOND_SIZE*2));
glVertex2f( CENTER_DIAMOND_SIZE, 0);
glVertex2f( (CENTER_DIAMOND_SIZE*2), 0);
glVertex2f(0, -CENTER_DIAMOND_SIZE);
glVertex2f(0, -(CENTER_DIAMOND_SIZE*2));
glEnd();
#endif // 0
#undef CENTER_DIAMOND_SIZE
int last =FloatToInt(vmax)+1;
i = FloatToInt(vmin);
if( div_units ) {
char TextLadder[8] ;
float label_length ;
float label_height ;
float left ;
float right ;
float bot ;
float top ;
float text_offset = 4.0f ;
float zero_offset = 10.0f ;
fntFont *font = HUDtext->getFont();
float pointsize = HUDtext->getPointSize();
float italic = HUDtext->getSlant();
TextList.setFont( HUDtext );
TextList.erase();
LineList.erase();
StippleLineList.erase();
int last = FloatToInt(vmax)+1;
int i = FloatToInt(vmin);
if( !scr_hole ) {
for( ; i <last ; i++ ) {
for( ; i<last ; i++ ) {
marker_y = /*(int)*/(((float)(i - pitch_value) * factor) + .5);
y = (((float)(i - pitch_value) * factor) + .5f);
if( !(i % div_units )) { // At integral multiple of div
label_length = sprintf( TextLadder, "%d", i );
sprintf( TextLadder, "%d", i );
font->getBBox ( TextLadder, pointsize, italic,
&left, &right, &bot, &top ) ;
label_length = right - left;
label_length += text_offset;
label_height = (top - bot)/2.0f;
if( i ) {
x_ini = -half_span;
} else { // Make zero point wider on left
x_ini = -half_span - 10;
}
x_end = half_span;
x_ini = -half_span;
x_end = half_span;
y_ini = marker_y;
y_end = marker_y;
// printf("(%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end);
if( i >= 0 ) { // Above zero draw solid lines
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
} else { // Below zero draw dashed lines.
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0x00FF );
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
glDisable(GL_LINE_STIPPLE);
if( i >= 0 ) {
// Make zero point wider on left
if( i == 0 )
x_ini -= zero_offset;
// Zero or above draw solid lines
Line(x_ini, y, x_end, y);
} else {
// Below zero draw dashed lines.
StippleLine(x_ini, y, x_end, y);
}
// Calculate the position of the left text and write it.
x_ini -= ( 8*label_length - 4);
y_ini -= 4;
_strokeString(x_ini, y_ini,
TextLadder, GLUT_STROKE_ROMAN );
glLoadMatrixf( mat );
// Calculate the position of the right text and write it.
x_end -= (24 - 8 * label_length);
y_end -= 4;
_strokeString(x_end, y_end,
TextLadder, GLUT_STROKE_ROMAN );
glLoadMatrixf( mat );
Text( x_ini-label_length, y-label_height, TextLadder );
Text( x_end+text_offset, y-label_height, TextLadder );
}
}
}
else // if(scr_hole )
{ // Draw ladder with space in the middle of the lines
last =FloatToInt(vmax)+1;
i = FloatToInt(vmin);
for( ; i <last ; i++ ) {
marker_y = /*(int)*/(((float)(i - pitch_value) * factor) + .5);
float hole = (float)((scr_hole)/2.0f);
for( ; i<last ; i++ ) {
y = (((float)(i - pitch_value) * factor) + .5);
if( !(i % div_units )) { // At integral multiple of div
label_length = sprintf( TextLadder, "%d", i );
sprintf( TextLadder, "%d", i );
font->getBBox ( TextLadder, pointsize, italic,
&left, &right, &bot, &top ) ;
label_length = right - left;
label_length += text_offset;
label_height = (top - bot)/2.0f;
// printf("l %f r %f b %f t %f\n",left, right, bot, top );
// Start by calculating the points and drawing the
// left side lines.
if( i != 0 ) {
x_ini = -half_span;
x_ini = -half_span;
x_end = -half_span + hole;
if( i >= 0 ) {
// Make zero point wider on left
if( i == 0 )
x_ini -= zero_offset;
// Zero or above draw solid lines
Line(x_ini, y, x_end, y);
} else {
x_ini = -half_span - 10;
}
x_end = -half_span + hole;
y_ini = marker_y;
y_end = marker_y;
// printf("half_span(%d) scr_hole(%d)\n", half_span, scr_hole);
// printf("x_end(%f) %f\n",x_end,(float)(-half_span + scr_hole/2));
// printf("L: (%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end);
if( i >= 0 ) { // Above zero draw solid lines
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
} else { // Below zero draw dashed lines.
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0x00FF );
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
glDisable(GL_LINE_STIPPLE);
// Below zero draw dashed lines.
StippleLine(x_ini, y, x_end, y);
}
// Now calculate the location of the left side label using
// the previously calculated start of the left side line.
x_ini -= (label_length + 32);
if( i < 0) {
x_ini -= 8;
} else {
if( i == 0 ) {
x_ini += 15; //20;
}
}
y_ini -= 4;
_strokeString(x_ini, y_ini,
TextLadder, GLUT_STROKE_MONO_ROMAN );
glLoadMatrixf( mat );
Text( x_ini-label_length, y-label_height, TextLadder );
// Now calculate and draw the right side line location
x_ini = half_span - hole;
y_ini = marker_y;
if( i != 0 ) {
x_end = half_span;
x_end = half_span;
if( i >= 0 ) {
if( i == 0 )
x_end += zero_offset;
// Zero or above draw solid lines
Line(x_ini, y, x_end, y);
} else {
x_end = half_span + 10;
}
y_end = marker_y;
// printf("R: (%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end);
if( i >= 0 ) { // Above zero draw solid lines
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
} else { // Below zero draw dashed lines.
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0x00FF );
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
glDisable(GL_LINE_STIPPLE);
// Below zero draw dashed lines.
StippleLine(x_ini, y, x_end, y);
}
// Calculate the location and draw the right side label
// using the end of the line as previously calculated.
x_end -= (label_length - 24);
if( i <= 0 ) {
x_end -= 8;
} // else if( i==0)
// {
// x_end -=4;
// }
y_end = marker_y - 4;
_strokeString(x_end, y_end,
TextLadder, GLUT_STROKE_MONO_ROMAN );
glLoadMatrixf( mat );
Text( x_end+text_offset, y-label_height, TextLadder );
}
}
}
TextList.draw();
glLineWidth(0.2);
LineList.draw();
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0x00FF );
StippleLineList.draw( );
glDisable(GL_LINE_STIPPLE);
}
glPopMatrix();
}

View file

@ -20,7 +20,9 @@
#ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y )
#define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif
//======================= Top of instr_label class =========================
@ -30,12 +32,10 @@ lat_label ::
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,
@ -108,9 +108,9 @@ lat_label & lat_label ::operator = (const lat_label & rhs )
justify = rhs.justify;
pre_str = rhs.pre_str;
post_str = rhs.post_str;
strcpy(format_buffer,rhs.format_buffer);
strcpy(format_buffer,rhs.format_buffer);
}
return *this;
return *this;
}
//
@ -120,40 +120,37 @@ lat_label & lat_label ::operator = (const lat_label & rhs )
void lat_label ::
draw( void ) // Required method in base class
{
// char format_buffer[80];
char label_buffer[80];
int posincr;
int lenstr;
RECT scrn_rect = get_location();
float lat = get_value();
// double lat = get_value();
if( data_available() ) {
// char *latstring = coord_format_lat(lat);
lenstr = sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
}
else {
lenstr = sprintf( label_buffer, format_buffer );
sprintf( label_buffer, format_buffer );
}
#ifdef DEBUGHUD
fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
#endif
// lenstr = strlen( label_buffer );
posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8;
if( justify == CENTER_JUST ) {
posincr = - (lenstr << 2); // -lenstr*4;
}
else {
if( justify == LEFT_JUST ) {
posincr = - (lenstr << 8); // 0;
}
}
lenstr = getStringWidth(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 == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13);

View file

@ -20,7 +20,9 @@
#include "hud.hxx"
#ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y )
#define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif
//======================= Top of instr_label class =========================
@ -30,12 +32,12 @@ lon_label ::
UINT width,
UINT height,
FLTFNPTR data_source,
// DBLFNPTR 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,
// double scale_data,
UINT options,
fgLabelJust justification,
int font_size,
@ -108,9 +110,9 @@ lon_label & lon_label ::operator = (const lon_label & rhs )
justify = rhs.justify;
pre_str = rhs.pre_str;
post_str = rhs.post_str;
strcpy(format_buffer,rhs.format_buffer);
strcpy(format_buffer,rhs.format_buffer);
}
return *this;
return *this;
}
//
@ -128,7 +130,7 @@ draw( void ) // Required method in base class
float lon = get_value();
// double lon = get_value();
if( data_available() ) {
// char *lonstring = coord_format_lon(lon);
// char *lonstring = coord_format_lon(lon);
lenstr = sprintf( label_buffer, format_buffer, coord_format_lon(lon) );
}
else {
@ -136,23 +138,23 @@ draw( void ) // Required method in base class
}
#ifdef DEBUGHUD
fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
#endif
// lenstr = strlen( label_buffer );
posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8;
if( justify == CENTER_JUST ) {
posincr = - (lenstr << 2); // -lenstr*4;
}
else {
if( justify == LEFT_JUST ) {
posincr = - (lenstr << 8); // 0;
}
}
lenstr = getStringWidth(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 == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13);

View file

@ -61,7 +61,6 @@
#include "gui.h"
FG_USING_STD(cout);
FG_USING_STD(string);
puFont guiFnt = 0;
@ -82,8 +81,22 @@ static puText *YNdialogBoxMessage = 0;
static puOneShot *YNdialogBoxOkButton = 0;
static puOneShot *YNdialogBoxNoButton = 0;
// extern void NewAltitude( puObject *cb );
// extern void NewHeading( puObject *cb );
static char msg_OK[] = "OK";
static char msg_NO[] = "NO";
static char msg_YES[] = "YES";
static char msg_CANCEL[] = "Cancel";
static char msg_RESET[] = "Reset";
char *gui_msg_OK; // "OK"
char *gui_msg_NO; // "NO"
char *gui_msg_YES; // "YES"
char *gui_msg_CANCEL; // "CANCEL"
char *gui_msg_RESET; // "RESET"
static char global_dialog_string[256];
extern void NewAltitude( puObject *cb );
extern void NewHeading( puObject *cb );
extern void fgAPAdjust( puObject * );
extern void fgLatLonFormatToggle( puObject *);
@ -105,7 +118,6 @@ void guiMotionFunc ( int x, int y )
glutPostRedisplay () ;
}
void guiMouseFunc(int button, int updown, int x, int y)
{
_mX = x;
@ -114,7 +126,6 @@ void guiMouseFunc(int button, int updown, int x, int y)
last_buttons |= ( 1 << button ) ;
else
last_buttons &= ~( 1 << button ) ;
puMouse (button, updown, x,y);
glutPostRedisplay ();
}
@ -147,14 +158,15 @@ static inline void TurnCursorOff( void )
#if defined ( WIN32 ) || defined(__CYGWIN32__)
glutSetCursor(GLUT_CURSOR_NONE);
#else // I guess this is what we want to do ??
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT));
#endif
#endif
#endif
}
void maybeToggleMouse( void )
{
#ifdef WIN32
static int first_time = ~0;
static int mouse_changed = 0;
@ -172,6 +184,7 @@ void maybeToggleMouse( void )
}
}
first_time = ~first_time;
#endif // #ifdef WIN32
}
// Call with FALSE to init and TRUE to restore
@ -182,7 +195,9 @@ void BusyCursor( int restore )
glutSetCursor(cursor);
} else {
cursor = glutGet( GLUT_WINDOW_CURSOR );
#ifdef WIN32
TurnCursorOn();
#endif
glutSetCursor( GLUT_CURSOR_WAIT );
}
}
@ -191,20 +206,14 @@ void BusyCursor( int restore )
// Intercept the Escape Key
void ConfirmExitDialog(void)
{
string Msg("Really Quit");
YNdialogBoxMessage -> setLabel(Msg.c_str());
YNdialogBoxNoButton-> makeReturnDefault (TRUE );
FG_PUSH_PUI_DIALOG( YNdialogBox );
}
// General Purpose Message Box
void mkDialog (char *txt)
void mkDialog (const char *txt)
{
void goAwayCb(puObject *);
dialogBoxMessage->setLabel(txt);
dialogBoxOkButton -> setLegend ("OK");
dialogBoxOkButton -> makeReturnDefault (TRUE );
dialogBoxOkButton -> setCallback (goAwayCb);
strncpy(global_dialog_string, txt, 256);
dialogBoxMessage->setLabel(global_dialog_string);
FG_PUSH_PUI_DIALOG( dialogBox );
}
@ -212,22 +221,21 @@ void mkDialog (char *txt)
void guiFixPanel( void )
{
int toggle_pause;
if ( current_options.get_panel_status() ) {
FGView *v = &current_view;
FGTime *t = FGTime::cur_time_params;
if( (toggle_pause = !t->getPause()) )
t->togglePauseMode();
// this seems to be the only way to do this :-(
// problem is the viewport has been mucked with
xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
if(toggle_pause)
t->togglePauseMode();
if ( current_options.get_panel_status() ) {
FGView *v = &current_view;
FGTime *t = FGTime::cur_time_params;
if( (toggle_pause = !t->getPause()) )
t->togglePauseMode();
// this seems to be the only way to do this :-(
// problem is the viewport has been mucked with
xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
if(toggle_pause)
t->togglePauseMode();
}
}
@ -235,13 +243,17 @@ void guiFixPanel( void )
void guiToggleMenu(void)
{
if( menu_on ) {
// printf("Hiding Menu\n");
mainMenuBar->hide ();
TurnCursorOff();
// printf("Hiding Menu\n");
mainMenuBar->hide ();
#ifdef WIN32
TurnCursorOff();
#endif // #ifdef WIN32
} else {
// printf("Showing Menu\n");
mainMenuBar->reveal();
TurnCursorOn();
// printf("Showing Menu\n");
mainMenuBar->reveal();
#ifdef WIN32
TurnCursorOn();
#endif // #ifdef WIN32
}
menu_on = ~menu_on;
}
@ -272,12 +284,12 @@ void hideMenuCb (puObject *cb)
void goodBye(puObject *)
{
// FG_LOG( FG_INPUT, FG_ALERT,
// "Program exiting normally at user request." );
// "Program exiting normally at user request." );
cout << "Program exiting normally at user request." << endl;
// if(gps_bug)
// fclose(gps_bug);
// if(gps_bug)
// fclose(gps_bug);
exit(-1);
}
@ -289,15 +301,18 @@ void goAwayCb (puObject *me)
void mkDialogInit (void)
{
// printf("mkDialogInit\n");
// printf("mkDialogInit\n");
int x = (current_options.get_xsize()/2 - 400/2);
int y = (current_options.get_ysize()/2 - 100/2);
dialogBox = new puDialogBox (x, y); // 150, 50
{
dialogFrame = new puFrame (0,0,400,100);
dialogBoxMessage = new puText (10, 70);
dialogBoxMessage -> setLabel ("");
dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
dialogFrame = new puFrame (0,0,400,100);
dialogBoxMessage = new puText (10, 70);
dialogBoxMessage -> setLabel ("");
dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
dialogBoxOkButton -> setLegend (gui_msg_OK);
dialogBoxOkButton -> makeReturnDefault (TRUE );
dialogBoxOkButton -> setCallback (goAwayCb);
}
FG_FINALIZE_PUI_DIALOG( dialogBox );
}
@ -314,30 +329,33 @@ void goAwayYesNoCb(puObject *me)
void ConfirmExitDialogInit(void)
{
// printf("ConfirmExitDialogInit\n");
string Msg("Really Quit");
// int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2;
int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), Msg.c_str() )/2;
char msg[] = "Really Quit";
char *s;
// printf("ConfirmExitDialogInit\n");
int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
int x = (current_options.get_xsize()/2 - 400/2);
int y = (current_options.get_ysize()/2 - 100/2);
YNdialogBox = new puDialogBox (x, y); // 150, 50
// YNdialogBox = new puDialogBox (150, 50);
// YNdialogBox = new puDialogBox (150, 50);
{
YNdialogFrame = new puFrame (0,0,400, 100);
YNdialogBoxMessage = new puText (len, 70);
YNdialogBoxMessage -> setLabel (Msg.c_str());
YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
YNdialogBoxOkButton -> setLegend ("OK");
YNdialogBoxOkButton -> setCallback (goodBye);
YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
YNdialogBoxNoButton -> setLegend ("NO");
// YNdialogBoxNoButton -> makeReturnDefault (TRUE );
YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
YNdialogFrame = new puFrame (0,0,400, 100);
YNdialogBoxMessage = new puText (len, 70);
YNdialogBoxMessage -> setDefaultValue (msg);
YNdialogBoxMessage -> getDefaultValue (&s);
YNdialogBoxMessage -> setLabel (s);
YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
YNdialogBoxOkButton -> setLegend (gui_msg_OK);
YNdialogBoxOkButton -> setCallback (goodBye);
YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
YNdialogBoxNoButton -> setLegend (gui_msg_NO);
// YNdialogBoxNoButton -> makeReturnDefault (TRUE );
YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
}
FG_FINALIZE_PUI_DIALOG( YNdialogBox );
}
@ -354,8 +372,8 @@ void helpCb (puObject *)
#if defined(FX) && !defined(WIN32)
# if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
if ( global_fullscreen ) {
global_fullscreen = false;
XMesaSetFXmode( XMESA_FX_WINDOW );
global_fullscreen = false;
XMesaSetFXmode( XMESA_FX_WINDOW );
}
# endif
#endif
@ -364,18 +382,19 @@ void helpCb (puObject *)
string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
command = "netscape -remote \"openURL(" + url + ")\" &";
command = "netscape -remote \"openURL(" + url + ")\" &";
} else {
command = "netscape " + url + " &";
command = "netscape " + url + " &";
}
#else
command = "webrun.bat";
#endif
system( command.c_str() );
string text = "Help started in netscape window.";
mkDialog (text.c_str());
//string text = "Help started in netscape window.";
//mkDialog (text.c_str());
mkDialog ("Help started in netscape window.");
}
/// The beginnings of teleportation :-)
@ -386,14 +405,15 @@ static puFrame *AptDialogFrame = 0;
static puText *AptDialogMessage = 0;
static puInput *AptDialogInput = 0;
static char NewAirportId[16];
static char NewAirportLabel[] = "Enter New Airport ID";
static puOneShot *AptDialogOkButton = 0;
static puOneShot *AptDialogCancelButton = 0;
static puOneShot *AptDialogResetButton = 0;
void AptDialog_Cancel(puObject *)
{
AptDialogOkButton->makeReturnDefault(FALSE);
AptDialogInput->rejectInput();
FG_POP_PUI_DIALOG( AptDialog );
}
@ -404,7 +424,7 @@ void AptDialog_OK (puObject *)
FGTime *t = FGTime::cur_time_params;
int PauseMode = t->getPause();
if(!PauseMode)
t->togglePauseMode();
t->togglePauseMode();
char *s;
AptDialogInput->getValue(&s);
@ -413,74 +433,75 @@ void AptDialog_OK (puObject *)
AptDialog_Cancel( NULL );
if ( AptId.length() ) {
// set initial position from airport id
fgAIRPORTS airports;
fgAIRPORT a;
FG_LOG( FG_GENERAL, FG_INFO,
"Attempting to set starting position from airport code "
<< s );
airports.load("apt_simple");
if ( airports.search( AptId, &a ) )
{
current_options.set_airport_id( AptId.c_str() );
BusyCursor(0);
fgReInitSubsystems();
BusyCursor(1);
} else {
AptId += " not in database.";
mkDialog(AptId.c_str());
}
// set initial position from airport id
fgAIRPORTS airports;
fgAIRPORT a;
FG_LOG( FG_GENERAL, FG_INFO,
"Attempting to set starting position from airport code "
<< s );
airports.load("apt_simple");
if ( airports.search( AptId, &a ) )
{
current_options.set_airport_id( AptId.c_str() );
BusyCursor(0);
fgReInitSubsystems();
BusyCursor(1);
} else {
AptId += " not in database.";
mkDialog(AptId.c_str());
}
}
if( PauseMode != t->getPause() )
t->togglePauseMode();
t->togglePauseMode();
}
void AptDialog_Reset(puObject *)
{
AptDialogInput->setValue ( current_options.get_airport_id().c_str() );
// strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
AptDialogInput->setValue ( NewAirportId );
AptDialogInput->setCursor( 0 ) ;
}
void NewAirport(puObject *cb)
{
string AptLabel("Enter New Airport ID");
AptDialogMessage ->setLabel( AptLabel.c_str() );
AptDialogInput ->setValue( current_options.get_airport_id().c_str() );
AptDialogInput ->acceptInput();
AptDialogOkButton->makeReturnDefault(TRUE);
// strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
AptDialogInput->setValue( NewAirportId );
FG_PUSH_PUI_DIALOG( AptDialog );
}
static void NewAirportInit(void)
{
cout << "NewAirportInit" << endl;
sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
NewAirportLabel ) / 2;
string AptLabel("Enter New Airport ID");
// int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2;
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel.c_str() )/2;
AptDialog = new puDialogBox (150, 50);
{
AptDialogFrame = new puFrame (0,0,350, 150);
AptDialogMessage = new puText (len, 110);
AptDialogInput = new puInput ( 50, 70, 300, 100 );
AptDialogOkButton = new puOneShot (50, 10, 110, 50);
AptDialogOkButton -> setLegend ("OK");
AptDialogOkButton -> setCallback (AptDialog_OK);
AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
AptDialogCancelButton -> setLegend ("Cancel");
AptDialogCancelButton -> setCallback (AptDialog_Cancel);
AptDialogResetButton = new puOneShot (240, 10, 300, 50);
AptDialogResetButton -> setLegend ("Reset");
AptDialogResetButton -> setCallback (AptDialog_Reset);
AptDialogFrame = new puFrame (0,0,350, 150);
AptDialogMessage = new puText (len, 110);
AptDialogMessage -> setLabel (NewAirportLabel);
AptDialogInput = new puInput (50, 70, 300, 100);
AptDialogInput -> setValue (NewAirportId);
AptDialogInput -> acceptInput();
AptDialogOkButton = new puOneShot (50, 10, 110, 50);
AptDialogOkButton -> setLegend (gui_msg_OK);
AptDialogOkButton -> setCallback (AptDialog_OK);
AptDialogOkButton -> makeReturnDefault(TRUE);
AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
AptDialogCancelButton -> setLegend (gui_msg_CANCEL);
AptDialogCancelButton -> setCallback (AptDialog_Cancel);
AptDialogResetButton = new puOneShot (240, 10, 300, 50);
AptDialogResetButton -> setLegend (gui_msg_RESET);
AptDialogResetButton -> setCallback (AptDialog_Reset);
}
FG_FINALIZE_PUI_DIALOG( AptDialog );
}
@ -490,59 +511,87 @@ static void NewAirportInit(void)
The menu stuff
---------------------------------------------------------------------*/
char *fileSubmenu [] = {
"Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL };
"Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL
};
puCallback fileSubmenuCb [] = {
MayBeGoodBye, hideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL};
MayBeGoodBye, hideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL
};
char *editSubmenu [] = {
"Edit text", NULL };
"Edit text", NULL
};
puCallback editSubmenuCb [] = {
notCb, NULL };
notCb, NULL
};
char *viewSubmenu [] = {
"Cockpit View > ", "View >","------------", "Toggle Panel...", NULL };
"Cockpit View > ", "View >","------------", "Toggle Panel...", NULL
};
puCallback viewSubmenuCb [] = {
notCb, notCb, NULL, guiTogglePanel, NULL };
notCb, notCb, NULL, guiTogglePanel, NULL
};
char *aircraftSubmenu [] = {
"Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL};
"Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL
};
puCallback aircraftSubmenuCb [] = {
fgAPAdjust, notCb, notCb, fgLatLonFormatToggle, notCb, NULL };
fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, notCb, NULL
};
char *environmentSubmenu [] = {
"Airport", "Terrain", "Weather", NULL};
"Airport", "Terrain", "Weather", NULL
};
puCallback environmentSubmenuCb [] = {
NewAirport, notCb, notCb, NULL };
NewAirport, notCb, notCb, NULL
};
char *optionsSubmenu [] = {
"Preferences", "Realism & Reliablity...", NULL};
"Preferences", "Realism & Reliablity...", NULL
};
puCallback optionsSubmenuCb [] = {
notCb, notCb, NULL};
notCb, notCb, NULL
};
char *helpSubmenu [] = {
"About...", "Help", NULL };
"About...", "Help", NULL
};
puCallback helpSubmenuCb [] = {
notCb, helpCb, NULL };
notCb, helpCb, NULL
};
/* -------------------------------------------------------------------------
init the gui
_____________________________________________________________________*/
init the gui
_____________________________________________________________________*/
void guiInit()
{
char *mesa_win_state;
string fntpath;
// Initialize PUI
puInit();
puSetDefaultStyle ( PUSTYLE_DEFAULT );
puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4);
// Initialize our GLOBAL GUI STRINGS
gui_msg_OK = msg_OK; // "OK"
gui_msg_NO = msg_NO; // "NO"
gui_msg_YES = msg_YES; // "YES"
gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
gui_msg_RESET = msg_RESET; // "RESET"
// Next check home directory
char* envp = ::getenv( "FG_FONTS" );
if ( envp != NULL ) {
fntpath = envp;
} else {
fntpath = current_options.get_fg_root() + "/Fonts";
}
// Install our fast fonts
string fntpath = current_options.get_fg_root() + "/Fonts/" +
"typewriter" + ".txf";
fntpath += "/typewriter.txf";
guiFntHandle = new fntTexFont ;
guiFntHandle -> load ( fntpath.c_str() ) ;
puFont GuiFont ( guiFntHandle, 15 ) ;
@ -550,26 +599,26 @@ void guiInit()
guiFnt = puGetDefaultLabelFont();
if ( current_options.get_mouse_pointer() == 0 ) {
// no preference specified for mouse pointer, attempt to autodetect...
// Determine if we need to render the cursor, or if the windowing
// system will do it. First test if we are rendering with glide.
if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
// Test for the MESA_GLX_FX env variable
if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
// test if we are fullscreen mesa/glide
if ( (mesa_win_state[0] == 'f') ||
(mesa_win_state[0] == 'F') ) {
puShowCursor ();
}
}
}
mouse_active = ~mouse_active;
// no preference specified for mouse pointer, attempt to autodetect...
// Determine if we need to render the cursor, or if the windowing
// system will do it. First test if we are rendering with glide.
if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
// Test for the MESA_GLX_FX env variable
if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
// test if we are fullscreen mesa/glide
if ( (mesa_win_state[0] == 'f') ||
(mesa_win_state[0] == 'F') ) {
puShowCursor ();
}
}
}
mouse_active = ~mouse_active;
} else if ( current_options.get_mouse_pointer() == 1 ) {
// don't show pointer
// don't show pointer
} else if ( current_options.get_mouse_pointer() == 2 ) {
// force showing pointer
puShowCursor();
mouse_active = ~mouse_active;
// force showing pointer
puShowCursor();
mouse_active = ~mouse_active;
}
// Set up our Dialog Boxes

View file

@ -34,13 +34,19 @@ extern void maybeToggleMouse( void );
extern void BusyCursor( int restore );
extern void guiToggleMenu(void);
extern void mkDialog(char *txt);
extern void mkDialog(const char *txt);
extern void ConfirmExitDialog(void);
extern void guiFixPanel( void );
extern puFont guiFnt;
extern fntTexFont *guiFntHandle;
// GLOBAL COMMON DIALOG BOX TEXT STRINGS
extern char *gui_msg_OK; // "OK"
extern char *gui_msg_NO; // "NO"
extern char *gui_msg_YES; // "YES"
extern char *gui_msg_CANCEL; // "CANCEL"
extern char *gui_msg_RESET; // "RESET"
// MACROS TO HELP KEEP PUI LIVE INTERFACE STACK IN SYNC
// These insure that the mouse is active when dialog is shown

View file

@ -47,8 +47,10 @@
#include <Cockpit/hud.hxx>
#include <GUI/gui.h>
#include <Include/fg_constants.h>
#include <Scenery/tilemgr.hxx>
#include <Objects/materialmgr.hxx>
#include <plib/pu.h>
#include <Time/fg_time.hxx>
#include <Time/light.hxx>
#include <Weather/weather.hxx>
@ -56,8 +58,8 @@
#include "options.hxx"
#include "views.hxx"
// extern void NewAltitude( puObject *cb );
// extern void NewHeading( puObject *cb );
extern void NewAltitude( puObject *cb );
extern void NewHeading( puObject *cb );
// Force an update of the sky and lighting parameters
static void local_update_sky_and_lighting_params( void ) {
@ -344,7 +346,22 @@ void GLUTspecialkey(int k, int x, int y) {
} else {
FG_LOG( FG_INPUT, FG_DEBUG, "" );
switch (k) {
case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest...
case GLUT_KEY_F2: // F2 Reload Tile Cache...
{
int toggle_pause;
FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
FGTime *t = FGTime::cur_time_params;
if( (toggle_pause = !t->getPause()) )
t->togglePauseMode();
BusyCursor(0);
fgTileMgrInit();
fgTileMgrUpdate();
BusyCursor(1);
if(toggle_pause)
t->togglePauseMode();
return;
}
case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest...
current_options.cycle_fog();
if ( current_options.get_fog() == fgOPTIONS::FG_FOG_DISABLED ) {
@ -379,12 +396,11 @@ void GLUTspecialkey(int k, int x, int y) {
return;
case GLUT_KEY_F11: // F11 Altitude Dialog.
FG_LOG(FG_INPUT, FG_INFO, "Invoking Altitude call back function");
// NewAltitude( NULL );
//exit(1);
NewAltitude( NULL );
return;
case GLUT_KEY_F12: // F12 Heading Dialog...
FG_LOG(FG_INPUT, FG_INFO, "Invoking Heading call back function");
// NewHeading( NULL );
NewHeading( NULL );
return;
case GLUT_KEY_UP:
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {