2000-04-30 06:51:49 +00:00
|
|
|
// auto_gui.cxx -- autopilot gui interface
|
|
|
|
//
|
|
|
|
// Written by Norman Vine <nhv@cape.com>
|
|
|
|
// Arranged by Curt Olson <curt@flightgear.org>
|
|
|
|
//
|
|
|
|
// Copyright (C) 1998 - 2000
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2002-02-05 20:54:08 +00:00
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
2002-03-16 00:18:38 +00:00
|
|
|
#include <simgear/route/route.hxx>
|
|
|
|
|
2000-04-30 06:51:49 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
2002-02-05 20:54:08 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include STL_STRING
|
2000-04-30 06:51:49 +00:00
|
|
|
|
2002-02-05 20:54:08 +00:00
|
|
|
#include <Aircraft/aircraft.hxx>
|
|
|
|
#include <FDM/flight.hxx>
|
|
|
|
#include <Controls/controls.hxx>
|
2000-04-30 06:51:49 +00:00
|
|
|
#include <Scenery/scenery.hxx>
|
|
|
|
|
|
|
|
#include <simgear/constants.h>
|
2002-02-05 20:54:08 +00:00
|
|
|
#include <simgear/sg_inlines.h>
|
2000-04-30 06:51:49 +00:00
|
|
|
#include <simgear/debug/logstream.hxx>
|
2000-09-27 20:16:22 +00:00
|
|
|
#include <simgear/math/sg_geodesy.hxx>
|
2001-03-25 14:20:12 +00:00
|
|
|
#include <simgear/misc/sg_path.hxx>
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
#include <Airports/simple.hxx>
|
|
|
|
#include <GUI/gui.h>
|
|
|
|
#include <Main/fg_init.hxx>
|
2000-10-12 01:06:07 +00:00
|
|
|
#include <Main/globals.hxx>
|
2001-01-13 22:06:39 +00:00
|
|
|
#include <Main/fg_props.hxx>
|
2000-10-12 01:06:07 +00:00
|
|
|
#include <Navaids/fixlist.hxx>
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
#include "auto_gui.hxx"
|
|
|
|
#include "newauto.hxx"
|
|
|
|
|
2002-02-05 20:54:08 +00:00
|
|
|
SG_USING_STD(string);
|
|
|
|
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
#define mySlider puSlider
|
|
|
|
|
|
|
|
// Climb speed constants
|
|
|
|
const double min_climb = 70.0; // kts
|
|
|
|
const double best_climb = 75.0; // kts
|
|
|
|
const double ideal_climb_rate = 500.0; // fpm
|
|
|
|
|
|
|
|
/// These statics will eventually go into the class
|
|
|
|
/// they are just here while I am experimenting -- NHV :-)
|
|
|
|
// AutoPilot Gain Adjuster members
|
|
|
|
static double MaxRollAdjust; // MaxRollAdjust = 2 * APData->MaxRoll;
|
|
|
|
static double RollOutAdjust; // RollOutAdjust = 2 * APData->RollOut;
|
|
|
|
static double MaxAileronAdjust; // MaxAileronAdjust = 2 * APData->MaxAileron;
|
|
|
|
static double RollOutSmoothAdjust; // RollOutSmoothAdjust = 2 * APData->RollOutSmooth;
|
|
|
|
|
|
|
|
static float MaxRollValue; // 0.1 -> 1.0
|
|
|
|
static float RollOutValue;
|
|
|
|
static float MaxAileronValue;
|
|
|
|
static float RollOutSmoothValue;
|
|
|
|
|
|
|
|
static float TmpMaxRollValue; // for cancel operation
|
|
|
|
static float TmpRollOutValue;
|
|
|
|
static float TmpMaxAileronValue;
|
|
|
|
static float TmpRollOutSmoothValue;
|
|
|
|
|
|
|
|
static puDialogBox *APAdjustDialog;
|
|
|
|
static puFrame *APAdjustFrame;
|
|
|
|
static puText *APAdjustDialogMessage;
|
|
|
|
static puFont APAdjustLegendFont;
|
|
|
|
static puFont APAdjustLabelFont;
|
|
|
|
|
|
|
|
static puOneShot *APAdjustOkButton;
|
|
|
|
static puOneShot *APAdjustResetButton;
|
|
|
|
static puOneShot *APAdjustCancelButton;
|
|
|
|
|
|
|
|
//static puButton *APAdjustDragButton;
|
|
|
|
|
|
|
|
static puText *APAdjustMaxRollTitle;
|
|
|
|
static puText *APAdjustRollOutTitle;
|
|
|
|
static puText *APAdjustMaxAileronTitle;
|
|
|
|
static puText *APAdjustRollOutSmoothTitle;
|
|
|
|
|
|
|
|
static puText *APAdjustMaxAileronText;
|
|
|
|
static puText *APAdjustMaxRollText;
|
|
|
|
static puText *APAdjustRollOutText;
|
|
|
|
static puText *APAdjustRollOutSmoothText;
|
|
|
|
|
|
|
|
static mySlider *APAdjustHS0;
|
|
|
|
static mySlider *APAdjustHS1;
|
|
|
|
static mySlider *APAdjustHS2;
|
|
|
|
static mySlider *APAdjustHS3;
|
|
|
|
|
|
|
|
static char SliderText[ 4 ][ 8 ];
|
|
|
|
|
|
|
|
///////// AutoPilot New Heading Dialog
|
|
|
|
|
|
|
|
static puDialogBox *ApHeadingDialog;
|
|
|
|
static puFrame *ApHeadingDialogFrame;
|
|
|
|
static puText *ApHeadingDialogMessage;
|
|
|
|
static puInput *ApHeadingDialogInput;
|
|
|
|
static puOneShot *ApHeadingDialogOkButton;
|
|
|
|
static puOneShot *ApHeadingDialogCancelButton;
|
|
|
|
|
|
|
|
|
|
|
|
///////// 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;
|
|
|
|
|
|
|
|
|
|
|
|
/// The beginnings of Lock AutoPilot to target location :-)
|
|
|
|
// Needs cleaning up but works
|
|
|
|
// These statics should disapear when this is a class
|
|
|
|
static puDialogBox *TgtAptDialog = 0;
|
|
|
|
static puFrame *TgtAptDialogFrame = 0;
|
|
|
|
static puText *TgtAptDialogMessage = 0;
|
|
|
|
static puInput *TgtAptDialogInput = 0;
|
2002-03-04 00:03:25 +00:00
|
|
|
static puListBox *TgtAptDialogWPList = 0;
|
|
|
|
static puSlider *TgtAptDialogSlider = 0;
|
|
|
|
static puArrowButton *TgtAptDialogUPArrow = 0;
|
|
|
|
static puArrowButton *TgtAptDialogDNArrow = 0;
|
|
|
|
static char** WPList;
|
|
|
|
static int WPListsize;
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
static char NewTgtAirportId[16];
|
2002-03-04 00:03:25 +00:00
|
|
|
static char NewTgtAirportLabel[] = "New Apt/Fix ID";
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
static puOneShot *TgtAptDialogOkButton = 0;
|
|
|
|
static puOneShot *TgtAptDialogCancelButton = 0;
|
|
|
|
static puOneShot *TgtAptDialogResetButton = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// extern char *coord_format_lat(float);
|
|
|
|
// extern char *coord_format_lon(float);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
|
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 ) )
|
|
|
|
{
|
2002-03-13 16:31:21 +00:00
|
|
|
if ( !globals->get_autopilot()->get_HeadingEnabled() ) {
|
|
|
|
globals->get_autopilot()->set_HeadingEnabled( true );
|
2000-04-30 06:51:49 +00:00
|
|
|
}
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->HeadingSet( NewHeading );
|
2000-04-30 06:51:49 +00:00
|
|
|
} 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());
|
2002-03-13 16:31:21 +00:00
|
|
|
float heading = globals->get_autopilot()->get_DGTargetHeading();
|
2002-02-27 18:05:17 +00:00
|
|
|
while ( heading < 0.0 ) { heading += 360.0; }
|
2002-02-13 20:12:31 +00:00
|
|
|
ApHeadingDialogInput -> setValue ( heading );
|
2000-04-30 06:51:49 +00:00
|
|
|
ApHeadingDialogInput -> acceptInput();
|
|
|
|
FG_PUSH_PUI_DIALOG( ApHeadingDialog );
|
|
|
|
}
|
|
|
|
|
2002-02-05 20:54:08 +00:00
|
|
|
void NewHeadingInit()
|
2000-04-30 06:51:49 +00:00
|
|
|
{
|
|
|
|
// printf("NewHeadingInit\n");
|
|
|
|
char NewHeadingLabel[] = "Enter New Heading";
|
|
|
|
char *s;
|
|
|
|
|
2001-07-02 22:27:24 +00:00
|
|
|
float heading = fgGetDouble("/orientation/heading-deg");
|
2000-04-30 06:51:49 +00:00
|
|
|
int len = 260/2 -
|
2001-10-24 21:24:53 +00:00
|
|
|
(puGetDefaultLabelFont().getStringWidth( NewHeadingLabel ) / 2 );
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
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) )
|
|
|
|
{
|
2002-03-13 16:31:21 +00:00
|
|
|
if ( !globals->get_autopilot()->get_AltitudeEnabled() ) {
|
|
|
|
globals->get_autopilot()->set_AltitudeEnabled( true );
|
2000-04-30 06:51:49 +00:00
|
|
|
}
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->AltitudeSet( NewAltitude );
|
2000-04-30 06:51:49 +00:00
|
|
|
} else {
|
|
|
|
error = 1;
|
|
|
|
s = c;
|
|
|
|
s += " is not a valid number.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ApAltitudeDialog_Cancel(me);
|
|
|
|
if( error ) mkDialog(s.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewAltitude(puObject *cb)
|
|
|
|
{
|
2002-03-13 16:31:21 +00:00
|
|
|
float altitude = globals->get_autopilot()->get_TargetAltitude() * SG_METER_TO_FEET;
|
2002-02-13 20:12:31 +00:00
|
|
|
ApAltitudeDialogInput -> setValue( altitude );
|
2000-04-30 06:51:49 +00:00
|
|
|
ApAltitudeDialogInput -> acceptInput();
|
|
|
|
FG_PUSH_PUI_DIALOG( ApAltitudeDialog );
|
|
|
|
}
|
|
|
|
|
2002-02-05 20:54:08 +00:00
|
|
|
void NewAltitudeInit()
|
2000-04-30 06:51:49 +00:00
|
|
|
{
|
|
|
|
// printf("NewAltitudeInit\n");
|
|
|
|
char NewAltitudeLabel[] = "Enter New Altitude";
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
float alt = cur_fdm_state->get_Altitude();
|
|
|
|
|
2002-03-26 02:38:11 +00:00
|
|
|
if ( !strcmp(fgGetString("/sim/startup/units"), "meters")) {
|
2001-03-24 04:56:46 +00:00
|
|
|
alt *= SG_FEET_TO_METER;
|
2000-04-30 06:51:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int len = 260/2 -
|
2001-10-24 21:24:53 +00:00
|
|
|
(puGetDefaultLabelFont().getStringWidth( NewAltitudeLabel ) / 2);
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
// ApAltitudeDialog = new puDialogBox (150, 50);
|
|
|
|
ApAltitudeDialog = new puDialogBox (150, 200);
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void maxroll_adj( puObject *hs ) {
|
|
|
|
float val ;
|
|
|
|
|
|
|
|
hs-> getValue ( &val ) ;
|
2002-02-05 20:54:08 +00:00
|
|
|
SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
|
2000-04-30 06:51:49 +00:00
|
|
|
// printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_MaxRoll( MaxRollAdjust * val );
|
|
|
|
sprintf( SliderText[ 0 ], "%05.2f", globals->get_autopilot()->get_MaxRoll() );
|
2000-04-30 06:51:49 +00:00
|
|
|
APAdjustMaxRollText -> setLabel ( SliderText[ 0 ] ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rollout_adj( puObject *hs ) {
|
|
|
|
float val ;
|
|
|
|
|
|
|
|
hs-> getValue ( &val ) ;
|
2002-02-05 20:54:08 +00:00
|
|
|
SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
|
2000-04-30 06:51:49 +00:00
|
|
|
// printf ( "rollout_adj( %p ) %f %f\n", hs, val, RollOutAdjust * val ) ;
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_RollOut( RollOutAdjust * val );
|
|
|
|
sprintf( SliderText[ 1 ], "%05.2f", globals->get_autopilot()->get_RollOut() );
|
2000-04-30 06:51:49 +00:00
|
|
|
APAdjustRollOutText -> setLabel ( SliderText[ 1 ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void maxaileron_adj( puObject *hs ) {
|
|
|
|
float val ;
|
|
|
|
|
|
|
|
hs-> getValue ( &val ) ;
|
2002-02-05 20:54:08 +00:00
|
|
|
SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
|
2000-04-30 06:51:49 +00:00
|
|
|
// printf ( "maxaileron_adj( %p ) %f %f\n", hs, val, MaxAileronAdjust * val ) ;
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_MaxAileron( MaxAileronAdjust * val );
|
|
|
|
sprintf( SliderText[ 3 ], "%05.2f", globals->get_autopilot()->get_MaxAileron() );
|
2000-04-30 06:51:49 +00:00
|
|
|
APAdjustMaxAileronText -> setLabel ( SliderText[ 3 ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rolloutsmooth_adj( puObject *hs ) {
|
|
|
|
float val ;
|
|
|
|
|
|
|
|
hs -> getValue ( &val ) ;
|
2002-02-05 20:54:08 +00:00
|
|
|
SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
|
2000-04-30 06:51:49 +00:00
|
|
|
// printf ( "rolloutsmooth_adj( %p ) %f %f\n", hs, val, RollOutSmoothAdjust * val ) ;
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_RollOutSmooth( RollOutSmoothAdjust * val );
|
|
|
|
sprintf( SliderText[ 2 ], "%5.2f", globals->get_autopilot()->get_RollOutSmooth() );
|
2000-04-30 06:51:49 +00:00
|
|
|
APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void goAwayAPAdjust (puObject *)
|
|
|
|
{
|
|
|
|
FG_POP_PUI_DIALOG( APAdjustDialog );
|
|
|
|
}
|
|
|
|
|
|
|
|
void cancelAPAdjust( puObject *self ) {
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_MaxRoll( TmpMaxRollValue );
|
|
|
|
globals->get_autopilot()->set_RollOut( TmpRollOutValue );
|
|
|
|
globals->get_autopilot()->set_MaxAileron( TmpMaxAileronValue );
|
|
|
|
globals->get_autopilot()->set_RollOutSmooth( TmpRollOutSmoothValue );
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
goAwayAPAdjust(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetAPAdjust( puObject *self ) {
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_MaxRoll( MaxRollAdjust / 2 );
|
|
|
|
globals->get_autopilot()->set_RollOut( RollOutAdjust / 2 );
|
|
|
|
globals->get_autopilot()->set_MaxAileron( MaxAileronAdjust / 2 );
|
|
|
|
globals->get_autopilot()->set_RollOutSmooth( RollOutSmoothAdjust / 2 );
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
FG_POP_PUI_DIALOG( APAdjustDialog );
|
|
|
|
|
|
|
|
fgAPAdjust( self );
|
|
|
|
}
|
|
|
|
|
2002-02-05 20:54:08 +00:00
|
|
|
void fgAPAdjust( puObject *self ) {
|
2002-03-13 16:31:21 +00:00
|
|
|
TmpMaxRollValue = globals->get_autopilot()->get_MaxRoll();
|
|
|
|
TmpRollOutValue = globals->get_autopilot()->get_RollOut();
|
|
|
|
TmpMaxAileronValue = globals->get_autopilot()->get_MaxAileron();
|
|
|
|
TmpRollOutSmoothValue = globals->get_autopilot()->get_RollOutSmooth();
|
|
|
|
|
|
|
|
MaxRollValue = globals->get_autopilot()->get_MaxRoll() / MaxRollAdjust;
|
|
|
|
RollOutValue = globals->get_autopilot()->get_RollOut() / RollOutAdjust;
|
|
|
|
MaxAileronValue = globals->get_autopilot()->get_MaxAileron() / MaxAileronAdjust;
|
|
|
|
RollOutSmoothValue = globals->get_autopilot()->get_RollOutSmooth()
|
2000-04-30 06:51:49 +00:00
|
|
|
/ RollOutSmoothAdjust;
|
|
|
|
|
|
|
|
APAdjustHS0-> setValue ( MaxRollValue ) ;
|
|
|
|
APAdjustHS1-> setValue ( RollOutValue ) ;
|
|
|
|
APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
|
|
|
|
APAdjustHS3-> setValue ( MaxAileronValue ) ;
|
|
|
|
|
|
|
|
FG_PUSH_PUI_DIALOG( APAdjustDialog );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done once at system initialization
|
2002-02-05 20:54:08 +00:00
|
|
|
void fgAPAdjustInit() {
|
2000-04-30 06:51:49 +00:00
|
|
|
|
|
|
|
// printf("fgAPAdjustInit\n");
|
|
|
|
#define HORIZONTAL FALSE
|
|
|
|
|
|
|
|
int DialogX = 40;
|
|
|
|
int DialogY = 100;
|
|
|
|
int DialogWidth = 230;
|
|
|
|
|
|
|
|
char Label[] = "AutoPilot Adjust";
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
int labelX = (DialogWidth / 2) -
|
2001-10-24 21:24:53 +00:00
|
|
|
(puGetDefaultLabelFont().getStringWidth( Label ) / 2);
|
2000-04-30 06:51:49 +00:00
|
|
|
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;
|
|
|
|
|
2002-03-13 16:31:21 +00:00
|
|
|
TmpMaxRollValue = globals->get_autopilot()->get_MaxRoll();
|
|
|
|
TmpRollOutValue = globals->get_autopilot()->get_RollOut();
|
|
|
|
TmpMaxAileronValue = globals->get_autopilot()->get_MaxAileron();
|
|
|
|
TmpRollOutSmoothValue = globals->get_autopilot()->get_RollOutSmooth();
|
2000-04-30 06:51:49 +00:00
|
|
|
|
2002-03-13 16:31:21 +00:00
|
|
|
MaxRollAdjust = 2 * globals->get_autopilot()->get_MaxRoll();
|
|
|
|
RollOutAdjust = 2 * globals->get_autopilot()->get_RollOut();
|
|
|
|
MaxAileronAdjust = 2 * globals->get_autopilot()->get_MaxAileron();
|
|
|
|
RollOutSmoothAdjust = 2 * globals->get_autopilot()->get_RollOutSmooth();
|
2000-05-04 17:09:42 +00:00
|
|
|
|
2002-03-13 16:31:21 +00:00
|
|
|
MaxRollValue = globals->get_autopilot()->get_MaxRoll() / MaxRollAdjust;
|
|
|
|
RollOutValue = globals->get_autopilot()->get_RollOut() / RollOutAdjust;
|
|
|
|
MaxAileronValue = globals->get_autopilot()->get_MaxAileron() / MaxAileronAdjust;
|
|
|
|
RollOutSmoothValue = globals->get_autopilot()->get_RollOutSmooth()
|
2000-04-30 06:51:49 +00:00
|
|
|
/ RollOutSmoothAdjust;
|
|
|
|
|
|
|
|
puGetDefaultFonts ( &APAdjustLegendFont, &APAdjustLabelFont );
|
|
|
|
APAdjustDialog = new puDialogBox ( DialogX, DialogY ); {
|
2001-10-24 21:24:53 +00:00
|
|
|
int horiz_slider_height = APAdjustLabelFont.getStringHeight() +
|
|
|
|
APAdjustLabelFont.getStringDescender() +
|
2000-04-30 06:51:49 +00:00
|
|
|
PUSTR_TGAP + PUSTR_BGAP + 5;
|
|
|
|
|
|
|
|
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 ) ;
|
|
|
|
|
2002-03-13 16:31:21 +00:00
|
|
|
sprintf( SliderText[ 0 ], "%05.2f", globals->get_autopilot()->get_MaxRoll() );
|
2000-04-30 06:51:49 +00:00
|
|
|
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 ( slider_x, slider_y, slider_width,
|
|
|
|
HORIZONTAL ) ;
|
|
|
|
APAdjustHS1-> setDelta ( slider_delta ) ;
|
|
|
|
APAdjustHS1-> setValue ( RollOutValue ) ;
|
|
|
|
APAdjustHS1-> setCBMode ( PUSLIDER_DELTA ) ;
|
|
|
|
APAdjustHS1-> setCallback ( rollout_adj ) ;
|
|
|
|
|
2002-03-13 16:31:21 +00:00
|
|
|
sprintf( SliderText[ 1 ], "%05.2f", globals->get_autopilot()->get_RollOut() );
|
2000-04-30 06:51:49 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
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",
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->get_RollOutSmooth() );
|
2000-04-30 06:51:49 +00:00
|
|
|
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",
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->get_MaxAileron() );
|
2000-04-30 06:51:49 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
FG_FINALIZE_PUI_DIALOG( APAdjustDialog );
|
|
|
|
|
|
|
|
#undef HORIZONTAL
|
|
|
|
}
|
|
|
|
|
|
|
|
// Simple Dialog to input Target Airport
|
|
|
|
void TgtAptDialog_Cancel(puObject *)
|
|
|
|
{
|
|
|
|
FG_POP_PUI_DIALOG( TgtAptDialog );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TgtAptDialog_OK (puObject *)
|
|
|
|
{
|
|
|
|
string TgtAptId;
|
|
|
|
|
|
|
|
// FGTime *t = FGTime::cur_time_params;
|
|
|
|
// int PauseMode = t->getPause();
|
|
|
|
// if(!PauseMode)
|
|
|
|
// t->togglePauseMode();
|
|
|
|
|
|
|
|
char *s;
|
|
|
|
TgtAptDialogInput->getValue(&s);
|
2000-10-12 01:06:07 +00:00
|
|
|
|
|
|
|
string tmp = s;
|
|
|
|
double alt = 0.0;
|
2001-04-22 22:04:25 +00:00
|
|
|
unsigned int pos = tmp.find( "@" );
|
2000-10-12 01:06:07 +00:00
|
|
|
if ( pos != string::npos ) {
|
|
|
|
TgtAptId = tmp.substr( 0, pos );
|
|
|
|
string alt_str = tmp.substr( pos + 1 );
|
|
|
|
alt = atof( alt_str.c_str() );
|
2002-03-26 02:38:11 +00:00
|
|
|
if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
|
2001-03-24 04:56:46 +00:00
|
|
|
alt *= SG_FEET_TO_METER;
|
2000-10-12 01:06:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TgtAptId = tmp;
|
|
|
|
}
|
|
|
|
|
2000-04-30 06:51:49 +00:00
|
|
|
TgtAptDialog_Cancel( NULL );
|
|
|
|
|
2000-10-12 01:06:07 +00:00
|
|
|
FGAirport a;
|
|
|
|
FGFix f;
|
|
|
|
double t1, t2;
|
|
|
|
if ( fgFindAirportID( TgtAptId, &a ) ) {
|
|
|
|
|
2001-03-24 06:03:11 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_INFO,
|
2000-10-12 01:06:07 +00:00
|
|
|
"Adding waypoint (airport) = " << TgtAptId );
|
2000-04-30 06:51:49 +00:00
|
|
|
|
2000-10-12 01:06:07 +00:00
|
|
|
sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
|
|
|
|
|
|
|
|
SGWayPoint wp( a.longitude, a.latitude, alt,
|
|
|
|
SGWayPoint::WGS84, TgtAptId );
|
|
|
|
globals->get_route()->add_waypoint( wp );
|
2002-03-04 00:03:25 +00:00
|
|
|
|
|
|
|
/* and turn on the autopilot */
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_HeadingEnabled( true );
|
|
|
|
globals->get_autopilot()->set_HeadingMode( FGAutopilot::FG_HEADING_WAYPOINT );
|
2002-03-04 00:03:25 +00:00
|
|
|
|
2000-10-12 01:06:07 +00:00
|
|
|
} else if ( current_fixlist->query( TgtAptId, 0.0, 0.0, 0.0,
|
|
|
|
&f, &t1, &t2 ) )
|
|
|
|
{
|
2001-03-24 06:03:11 +00:00
|
|
|
SG_LOG( SG_GENERAL, SG_INFO,
|
2000-10-12 01:06:07 +00:00
|
|
|
"Adding waypoint (fix) = " << TgtAptId );
|
2000-04-30 06:51:49 +00:00
|
|
|
|
2000-10-12 01:06:07 +00:00
|
|
|
sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
|
|
|
|
|
|
|
|
SGWayPoint wp( f.get_lon(), f.get_lat(), alt,
|
|
|
|
SGWayPoint::WGS84, TgtAptId );
|
|
|
|
globals->get_route()->add_waypoint( wp );
|
2002-03-04 00:03:25 +00:00
|
|
|
|
|
|
|
/* and turn on the autopilot */
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_HeadingEnabled( true );
|
|
|
|
globals->get_autopilot()->set_HeadingMode( FGAutopilot::FG_HEADING_WAYPOINT );
|
2000-10-12 01:06:07 +00:00
|
|
|
} else {
|
|
|
|
TgtAptId += " not in database.";
|
|
|
|
mkDialog(TgtAptId.c_str());
|
2000-04-30 06:51:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TgtAptDialog_Reset(puObject *)
|
|
|
|
{
|
2002-11-15 21:13:29 +00:00
|
|
|
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/presets/airport-id") );
|
2000-04-30 06:51:49 +00:00
|
|
|
TgtAptDialogInput->setValue ( NewTgtAirportId );
|
|
|
|
TgtAptDialogInput->setCursor( 0 ) ;
|
|
|
|
}
|
|
|
|
|
2002-03-04 00:03:25 +00:00
|
|
|
void TgtAptDialog_HandleSlider ( puObject * slider )
|
|
|
|
{
|
|
|
|
float val ;
|
|
|
|
slider -> getValue ( &val ) ;
|
|
|
|
val = 1.0f - val ;
|
|
|
|
|
|
|
|
int index = int ( TgtAptDialogWPList -> getNumItems () * val ) ;
|
|
|
|
TgtAptDialogWPList -> setTopItem ( index ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TgtAptDialog_HandleArrow( puObject *arrow )
|
|
|
|
{
|
|
|
|
int type = ((puArrowButton *)arrow)->getArrowType() ;
|
|
|
|
int inc = ( type == PUARROW_DOWN ) ? 1 :
|
|
|
|
( type == PUARROW_UP ) ? -1 :
|
|
|
|
( type == PUARROW_FASTDOWN ) ? 10 :
|
|
|
|
( type == PUARROW_FASTUP ) ? -10 : 0 ;
|
|
|
|
|
|
|
|
float val ;
|
|
|
|
TgtAptDialogSlider -> getValue ( &val ) ;
|
|
|
|
val = 1.0f - val ;
|
|
|
|
int num_items = TgtAptDialogWPList->getNumItems () - 1 ;
|
|
|
|
if ( num_items > 0 )
|
|
|
|
{
|
|
|
|
int index = int ( num_items * val + 0.5 ) + inc ;
|
|
|
|
if ( index > num_items ) index = num_items ;
|
|
|
|
if ( index < 0 ) index = 0 ;
|
|
|
|
|
|
|
|
TgtAptDialogSlider -> setValue ( 1.0f - (float)index / num_items ) ;
|
|
|
|
TgtAptDialogWPList -> setTopItem ( index ) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-10-12 01:06:07 +00:00
|
|
|
void AddWayPoint(puObject *cb)
|
2000-04-30 06:51:49 +00:00
|
|
|
{
|
2002-11-15 21:13:29 +00:00
|
|
|
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/presets/airport-id") );
|
2000-04-30 06:51:49 +00:00
|
|
|
TgtAptDialogInput->setValue( NewTgtAirportId );
|
|
|
|
|
2002-03-04 00:03:25 +00:00
|
|
|
/* refresh waypoint list */
|
|
|
|
char WPString[100];
|
|
|
|
|
|
|
|
int i;
|
|
|
|
if ( WPList != NULL ) {
|
|
|
|
for (i = 0; i < WPListsize; i++ ) {
|
|
|
|
delete WPList[i];
|
|
|
|
}
|
|
|
|
delete [] WPList[i];
|
|
|
|
}
|
|
|
|
if ( globals->get_route()->size() > 0 ) {
|
|
|
|
WPListsize = globals->get_route()->size();
|
|
|
|
WPList = new char* [ WPListsize + 1 ];
|
|
|
|
for (i = 0; i < globals->get_route()->size(); i++ ) {
|
|
|
|
sprintf(WPString, "%5s %3.2flon %3.2flat", globals->get_route()->get_waypoint(i).get_id().c_str(), globals->get_route()->get_waypoint(i).get_target_lon(), globals->get_route()->get_waypoint(i).get_target_lat());
|
|
|
|
WPList [i] = new char[ strlen(WPString) ];
|
|
|
|
strcpy ( WPList [i], WPString );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
WPListsize = 1;
|
|
|
|
WPList = new char* [ 2 ];
|
|
|
|
WPList [0] = new char[18];
|
|
|
|
strcpy ( WPList [0], "** List Empty **");
|
|
|
|
}
|
|
|
|
WPList [ WPListsize ] = NULL;
|
|
|
|
TgtAptDialogWPList->newList( WPList );
|
|
|
|
|
|
|
|
// if non-empty list, adjust the size of the slider...
|
|
|
|
TgtAptDialogSlider->setSliderFraction (0.9999f) ;
|
|
|
|
TgtAptDialogSlider->hide();
|
|
|
|
TgtAptDialogUPArrow->hide();
|
|
|
|
TgtAptDialogDNArrow->hide();
|
|
|
|
if (WPListsize > 10) {
|
|
|
|
TgtAptDialogSlider->setSliderFraction (10.0f/(WPListsize-1)) ;
|
|
|
|
TgtAptDialogSlider->reveal();
|
|
|
|
TgtAptDialogUPArrow->reveal();
|
|
|
|
TgtAptDialogDNArrow->reveal();
|
|
|
|
}
|
|
|
|
|
2000-04-30 06:51:49 +00:00
|
|
|
FG_PUSH_PUI_DIALOG( TgtAptDialog );
|
|
|
|
}
|
|
|
|
|
2000-10-12 01:06:07 +00:00
|
|
|
void PopWayPoint(puObject *cb)
|
|
|
|
{
|
|
|
|
globals->get_route()->delete_first();
|
2000-10-13 23:34:54 +00:00
|
|
|
|
|
|
|
// see if there are more waypoints on the list
|
|
|
|
if ( globals->get_route()->size() ) {
|
|
|
|
// more waypoints
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_HeadingMode( FGAutopilot::FG_HEADING_WAYPOINT );
|
2000-10-13 23:34:54 +00:00
|
|
|
} else {
|
|
|
|
// end of the line
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()->set_HeadingMode( FGAutopilot::FG_TC_HEADING_LOCK );
|
2000-10-13 23:34:54 +00:00
|
|
|
|
|
|
|
// use current heading
|
2002-03-13 16:31:21 +00:00
|
|
|
globals->get_autopilot()
|
2001-07-02 22:27:24 +00:00
|
|
|
->set_TargetHeading(fgGetDouble("/orientation/heading-deg"));
|
2000-10-13 23:34:54 +00:00
|
|
|
}
|
2000-10-12 01:06:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ClearRoute(puObject *cb)
|
|
|
|
{
|
|
|
|
globals->get_route()->clear();
|
|
|
|
}
|
|
|
|
|
2002-02-05 20:54:08 +00:00
|
|
|
void NewTgtAirportInit()
|
2000-04-30 06:51:49 +00:00
|
|
|
{
|
2001-03-24 06:03:11 +00:00
|
|
|
SG_LOG( SG_AUTOPILOT, SG_INFO, " enter NewTgtAirportInit()" );
|
2002-11-15 21:13:29 +00:00
|
|
|
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/presets/airport-id") );
|
2001-03-24 06:03:11 +00:00
|
|
|
SG_LOG( SG_AUTOPILOT, SG_INFO, " NewTgtAirportId " << NewTgtAirportId );
|
2000-04-30 06:51:49 +00:00
|
|
|
|
2002-03-04 00:03:25 +00:00
|
|
|
TgtAptDialog = new puDialogBox (150, 350);
|
2000-04-30 06:51:49 +00:00
|
|
|
{
|
2002-03-04 00:03:25 +00:00
|
|
|
TgtAptDialogFrame = new puFrame (0,0,350, 350);
|
2000-04-30 06:51:49 +00:00
|
|
|
|
2002-03-04 00:03:25 +00:00
|
|
|
TgtAptDialogWPList = new puListBox ( 50, 130, 300, 320 ) ;
|
|
|
|
TgtAptDialogWPList -> setLabel ( "Flight Plan" );
|
|
|
|
TgtAptDialogWPList -> setLabelPlace ( PUPLACE_ABOVE ) ;
|
|
|
|
TgtAptDialogWPList -> setStyle ( -PUSTYLE_SMALL_SHADED ) ;
|
|
|
|
TgtAptDialogWPList -> setValue ( 0 ) ;
|
|
|
|
|
|
|
|
TgtAptDialogSlider = new puSlider (300, 150, 150 ,TRUE,20);
|
|
|
|
TgtAptDialogSlider->setValue(1.0f);
|
|
|
|
TgtAptDialogSlider->setSliderFraction (0.2f) ;
|
|
|
|
TgtAptDialogSlider->setDelta(0.1f);
|
|
|
|
TgtAptDialogSlider->setCBMode( PUSLIDER_DELTA );
|
|
|
|
TgtAptDialogSlider->setCallback( TgtAptDialog_HandleSlider );
|
|
|
|
|
|
|
|
TgtAptDialogUPArrow = new puArrowButton ( 300, 300, 320, 320, PUARROW_UP ) ;
|
|
|
|
TgtAptDialogUPArrow->setCallback ( TgtAptDialog_HandleArrow ) ;
|
|
|
|
|
|
|
|
TgtAptDialogDNArrow = new puArrowButton ( 300, 130, 320, 150, PUARROW_DOWN ) ;
|
|
|
|
TgtAptDialogDNArrow->setCallback ( TgtAptDialog_HandleArrow ) ;
|
|
|
|
|
|
|
|
|
2000-04-30 06:51:49 +00:00
|
|
|
TgtAptDialogInput = new puInput (50, 70, 300, 100);
|
2002-03-04 00:03:25 +00:00
|
|
|
TgtAptDialogInput -> setLabel ( NewTgtAirportLabel );
|
|
|
|
TgtAptDialogInput -> setLabelPlace ( PUPLACE_ABOVE ) ;
|
2000-04-30 06:51:49 +00:00
|
|
|
TgtAptDialogInput -> setValue (NewTgtAirportId);
|
|
|
|
TgtAptDialogInput -> acceptInput();
|
|
|
|
|
|
|
|
TgtAptDialogOkButton = new puOneShot (50, 10, 110, 50);
|
|
|
|
TgtAptDialogOkButton -> setLegend (gui_msg_OK);
|
|
|
|
TgtAptDialogOkButton -> setCallback (TgtAptDialog_OK);
|
|
|
|
TgtAptDialogOkButton -> makeReturnDefault(TRUE);
|
|
|
|
|
|
|
|
TgtAptDialogCancelButton = new puOneShot (140, 10, 210, 50);
|
|
|
|
TgtAptDialogCancelButton -> setLegend (gui_msg_CANCEL);
|
|
|
|
TgtAptDialogCancelButton -> setCallback (TgtAptDialog_Cancel);
|
|
|
|
|
|
|
|
TgtAptDialogResetButton = new puOneShot (240, 10, 300, 50);
|
|
|
|
TgtAptDialogResetButton -> setLegend (gui_msg_RESET);
|
|
|
|
TgtAptDialogResetButton -> setCallback (TgtAptDialog_Reset);
|
2002-03-04 00:03:25 +00:00
|
|
|
|
2000-04-30 06:51:49 +00:00
|
|
|
}
|
2002-03-04 00:03:25 +00:00
|
|
|
|
2000-04-30 06:51:49 +00:00
|
|
|
FG_FINALIZE_PUI_DIALOG( TgtAptDialog );
|
|
|
|
printf("leave NewTgtAirportInit()");
|
|
|
|
}
|
2002-03-04 00:03:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|