- move auto_gui's addWaypoint to routemgr.cxx
- add command interface property (monitored by listener) - remove all traces of auto_gui.[ch]xx - remove some trailing spaces, fix indentation
This commit is contained in:
parent
f9edbf3620
commit
f9959b7f2c
9 changed files with 223 additions and 1028 deletions
|
@ -1,7 +1,6 @@
|
||||||
noinst_LIBRARIES = libAutopilot.a
|
noinst_LIBRARIES = libAutopilot.a
|
||||||
|
|
||||||
libAutopilot_a_SOURCES = \
|
libAutopilot_a_SOURCES = \
|
||||||
auto_gui.cxx auto_gui.hxx \
|
|
||||||
route_mgr.cxx route_mgr.hxx \
|
route_mgr.cxx route_mgr.hxx \
|
||||||
xmlauto.cxx xmlauto.hxx
|
xmlauto.cxx xmlauto.hxx
|
||||||
|
|
||||||
|
|
|
@ -1,898 +0,0 @@
|
||||||
// auto_gui.cxx -- autopilot gui interface
|
|
||||||
//
|
|
||||||
// Written by Norman Vine <nhv@cape.com>
|
|
||||||
// Arranged by Curt Olson <http://www.flightgear.org/~curt>
|
|
||||||
//
|
|
||||||
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include STL_STRING
|
|
||||||
|
|
||||||
#include <Aircraft/aircraft.hxx>
|
|
||||||
#include <FDM/flight.hxx>
|
|
||||||
#include <Scenery/scenery.hxx>
|
|
||||||
|
|
||||||
#include <simgear/constants.h>
|
|
||||||
#include <simgear/sg_inlines.h>
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
|
||||||
#include <simgear/misc/sg_path.hxx>
|
|
||||||
|
|
||||||
#include <Airports/simple.hxx>
|
|
||||||
#include <GUI/gui.h>
|
|
||||||
#include <Main/fg_init.hxx>
|
|
||||||
#include <Main/globals.hxx>
|
|
||||||
#include <Main/fg_props.hxx>
|
|
||||||
#include <Navaids/fixlist.hxx>
|
|
||||||
#include <Navaids/navlist.hxx>
|
|
||||||
#include <Navaids/navrecord.hxx>
|
|
||||||
|
|
||||||
#include "auto_gui.hxx"
|
|
||||||
#include "route_mgr.hxx"
|
|
||||||
#include "xmlauto.hxx"
|
|
||||||
|
|
||||||
SG_USING_STD(string);
|
|
||||||
|
|
||||||
|
|
||||||
#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;
|
|
||||||
static puListBox *TgtAptDialogWPList = 0;
|
|
||||||
static puSlider *TgtAptDialogSlider = 0;
|
|
||||||
static puArrowButton *TgtAptDialogUPArrow = 0;
|
|
||||||
static puArrowButton *TgtAptDialogDNArrow = 0;
|
|
||||||
static char** WPList;
|
|
||||||
static int WPListsize;
|
|
||||||
|
|
||||||
static char NewTgtAirportId[16];
|
|
||||||
static char NewTgtAirportLabel[] = "New Apt/Fix ID";
|
|
||||||
|
|
||||||
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 ) ) {
|
|
||||||
fgSetString( "/autopilot/locks/heading", "dg-heading-hold" );
|
|
||||||
fgSetDouble( "/autopilot/settings/heading-bug-deg",
|
|
||||||
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());
|
|
||||||
float heading = fgGetDouble( "/autopilot/settings/heading-bug-deg" );
|
|
||||||
while ( heading < 0.0 ) { heading += 360.0; }
|
|
||||||
ApHeadingDialogInput -> setValue ( heading );
|
|
||||||
ApHeadingDialogInput -> acceptInput();
|
|
||||||
FG_PUSH_PUI_DIALOG( ApHeadingDialog );
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewHeadingInit()
|
|
||||||
{
|
|
||||||
// printf("NewHeadingInit\n");
|
|
||||||
char NewHeadingLabel[] = "Enter New Heading";
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
float heading = fgGetDouble("/orientation/heading-deg");
|
|
||||||
int len = 260/2 -
|
|
||||||
(puGetDefaultLabelFont().getStringWidth( 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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
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) ) {
|
|
||||||
fgSetString( "/autopilot/locks/altitude", "altitude-hold" );
|
|
||||||
fgSetDouble( "/autopilot/settings/altitude-ft", 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)
|
|
||||||
{
|
|
||||||
float altitude = fgGetDouble("/autopilot/settings/altitude-ft")
|
|
||||||
* SG_METER_TO_FEET;
|
|
||||||
ApAltitudeDialogInput -> setValue( altitude );
|
|
||||||
ApAltitudeDialogInput -> acceptInput();
|
|
||||||
FG_PUSH_PUI_DIALOG( ApAltitudeDialog );
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewAltitudeInit()
|
|
||||||
{
|
|
||||||
// printf("NewAltitudeInit\n");
|
|
||||||
char NewAltitudeLabel[] = "Enter New Altitude";
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
float alt = cur_fdm_state->get_Altitude();
|
|
||||||
|
|
||||||
if ( !strcmp(fgGetString("/sim/startup/units"), "meters")) {
|
|
||||||
alt *= SG_FEET_TO_METER;
|
|
||||||
}
|
|
||||||
|
|
||||||
int len = 260/2 -
|
|
||||||
(puGetDefaultLabelFont().getStringWidth( NewAltitudeLabel ) / 2);
|
|
||||||
|
|
||||||
// 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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void maxroll_adj( puObject *hs ) {
|
|
||||||
float val ;
|
|
||||||
|
|
||||||
hs-> getValue ( &val ) ;
|
|
||||||
SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
|
|
||||||
// printf ( "maxroll_adj( %p ) %f %f\n", hs, val, MaxRollAdjust * val ) ;
|
|
||||||
fgSetDouble( "/autopilot/config/max-roll-deg", MaxRollAdjust * val );
|
|
||||||
sprintf( SliderText[ 0 ], "%05.2f",
|
|
||||||
fgGetDouble("/autopilot/config/max-roll-deg") );
|
|
||||||
APAdjustMaxRollText -> setLabel ( SliderText[ 0 ] ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rollout_adj( puObject *hs ) {
|
|
||||||
float val ;
|
|
||||||
|
|
||||||
hs-> getValue ( &val ) ;
|
|
||||||
SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
|
|
||||||
// printf ( "rollout_adj( %p ) %f %f\n", hs, val, RollOutAdjust * val ) ;
|
|
||||||
fgSetDouble( "/autopilot/config/roll-out-deg", RollOutAdjust * val );
|
|
||||||
sprintf( SliderText[ 1 ], "%05.2f",
|
|
||||||
fgGetDouble("/autopilot/config/roll-out-deg") );
|
|
||||||
APAdjustRollOutText -> setLabel ( SliderText[ 1 ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void maxaileron_adj( puObject *hs ) {
|
|
||||||
float val ;
|
|
||||||
|
|
||||||
hs-> getValue ( &val ) ;
|
|
||||||
SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
|
|
||||||
// printf ( "maxaileron_adj( %p ) %f %f\n", hs, val, MaxAileronAdjust * val ) ;
|
|
||||||
fgSetDouble( "/autopilot/config/max-aileron", MaxAileronAdjust * val );
|
|
||||||
sprintf( SliderText[ 3 ], "%05.2f",
|
|
||||||
fgGetDouble("/autopilot/config/max-aileron") );
|
|
||||||
APAdjustMaxAileronText -> setLabel ( SliderText[ 3 ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rolloutsmooth_adj( puObject *hs ) {
|
|
||||||
float val ;
|
|
||||||
|
|
||||||
hs -> getValue ( &val ) ;
|
|
||||||
SG_CLAMP_RANGE ( val, 0.1f, 1.0f ) ;
|
|
||||||
// printf ( "rolloutsmooth_adj( %p ) %f %f\n", hs, val, RollOutSmoothAdjust * val ) ;
|
|
||||||
fgSetDouble( "/autopilot/config/roll-out-smooth-deg",
|
|
||||||
RollOutSmoothAdjust * val );
|
|
||||||
sprintf( SliderText[ 2 ], "%5.2f",
|
|
||||||
fgGetDouble("/autopilot/config/roll-out-smooth-deg") );
|
|
||||||
APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void goAwayAPAdjust (puObject *)
|
|
||||||
{
|
|
||||||
FG_POP_PUI_DIALOG( APAdjustDialog );
|
|
||||||
}
|
|
||||||
|
|
||||||
void cancelAPAdjust( puObject *self ) {
|
|
||||||
fgSetDouble( "/autopilot/config/max-roll-deg", TmpMaxRollValue );
|
|
||||||
fgSetDouble( "/autopilot/config/roll-out-deg", TmpRollOutValue );
|
|
||||||
fgSetDouble( "/autopilot/config/max-aileron", TmpMaxAileronValue );
|
|
||||||
fgSetDouble( "/autopilot/config/roll-out-smooth-deg",
|
|
||||||
TmpRollOutSmoothValue );
|
|
||||||
|
|
||||||
goAwayAPAdjust(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
void resetAPAdjust( puObject *self ) {
|
|
||||||
fgSetDouble( "/autopilot/config/max-roll-deg", MaxRollAdjust / 2 );
|
|
||||||
fgSetDouble( "/autopilot/config/roll-out-deg", RollOutAdjust / 2 );
|
|
||||||
fgSetDouble( "/autopilot/config/max-aileron", MaxAileronAdjust / 2 );
|
|
||||||
fgSetDouble( "/autopilot/config/roll-out-smooth-deg",
|
|
||||||
RollOutSmoothAdjust / 2 );
|
|
||||||
|
|
||||||
FG_POP_PUI_DIALOG( APAdjustDialog );
|
|
||||||
|
|
||||||
fgAPAdjust( self );
|
|
||||||
}
|
|
||||||
|
|
||||||
void fgAPAdjust( puObject *self ) {
|
|
||||||
TmpMaxRollValue = fgGetDouble("/autopilot/config/max-roll-deg");
|
|
||||||
TmpRollOutValue = fgGetDouble("/autopilot/config/roll-out-deg");
|
|
||||||
TmpMaxAileronValue = fgGetDouble("/autopilot/config/max-aileron");
|
|
||||||
TmpRollOutSmoothValue = fgGetDouble("/autopilot/config/roll-out-smooth-deg");
|
|
||||||
|
|
||||||
MaxRollValue = fgGetDouble("/autopilot/config/max-roll-deg")
|
|
||||||
/ MaxRollAdjust;
|
|
||||||
RollOutValue = fgGetDouble("/autopilot/config/roll-out-deg")
|
|
||||||
/ RollOutAdjust;
|
|
||||||
MaxAileronValue = fgGetDouble("/autopilot/config/max-aileron")
|
|
||||||
/ MaxAileronAdjust;
|
|
||||||
RollOutSmoothValue = fgGetDouble("/autopilot/config/roll-out-smooth-deg")
|
|
||||||
/ RollOutSmoothAdjust;
|
|
||||||
|
|
||||||
APAdjustHS0-> setValue ( MaxRollValue ) ;
|
|
||||||
APAdjustHS1-> setValue ( RollOutValue ) ;
|
|
||||||
APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
|
|
||||||
APAdjustHS3-> setValue ( MaxAileronValue ) ;
|
|
||||||
|
|
||||||
FG_PUSH_PUI_DIALOG( APAdjustDialog );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done once at system initialization
|
|
||||||
void fgAPAdjustInit() {
|
|
||||||
|
|
||||||
// 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) -
|
|
||||||
(puGetDefaultLabelFont().getStringWidth( 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 = fgGetDouble("/autopilot/config/max-roll-deg");
|
|
||||||
TmpRollOutValue = fgGetDouble("/autopilot/config/roll-out-deg");
|
|
||||||
TmpMaxAileronValue = fgGetDouble("/autopilot/config/max-aileron");
|
|
||||||
TmpRollOutSmoothValue = fgGetDouble("/autopilot/config/roll-out-smooth-deg");
|
|
||||||
MaxRollAdjust = 2 * fgGetDouble("/autopilot/config/max-roll-deg");
|
|
||||||
RollOutAdjust = 2 * fgGetDouble("/autopilot/config/roll-out-deg");
|
|
||||||
MaxAileronAdjust = 2 * fgGetDouble("/autopilot/config/max-aileron");
|
|
||||||
RollOutSmoothAdjust = 2 * fgGetDouble("/autopilot/config/roll-out-smooth-deg");
|
|
||||||
|
|
||||||
MaxRollValue = fgGetDouble("/autopilot/config/max-roll-deg")
|
|
||||||
/ MaxRollAdjust;
|
|
||||||
RollOutValue = fgGetDouble("/autopilot/config/roll-out-deg")
|
|
||||||
/ RollOutAdjust;
|
|
||||||
MaxAileronValue = fgGetDouble("/autopilot/config/max-aileron")
|
|
||||||
/ MaxAileronAdjust;
|
|
||||||
RollOutSmoothValue = fgGetDouble("/autopilot/config/roll-out-smooth-deg")
|
|
||||||
/ RollOutSmoothAdjust;
|
|
||||||
|
|
||||||
puGetDefaultFonts ( &APAdjustLegendFont, &APAdjustLabelFont );
|
|
||||||
APAdjustDialog = new puDialogBox ( DialogX, DialogY ); {
|
|
||||||
int horiz_slider_height = APAdjustLabelFont.getStringHeight() +
|
|
||||||
APAdjustLabelFont.getStringDescender() +
|
|
||||||
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 ) ;
|
|
||||||
|
|
||||||
sprintf( SliderText[ 0 ], "%05.2f",
|
|
||||||
fgGetDouble("/autopilot/config/max-roll-deg") );
|
|
||||||
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 ) ;
|
|
||||||
|
|
||||||
sprintf( SliderText[ 1 ], "%05.2f",
|
|
||||||
fgGetDouble("/autopilot/config/roll-out-deg") );
|
|
||||||
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",
|
|
||||||
fgGetDouble("/autopilot/config/roll-out-smooth-deg") );
|
|
||||||
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",
|
|
||||||
fgGetDouble("/autopilot/config/max-aileron") );
|
|
||||||
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
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
string tmp = s;
|
|
||||||
unsigned int pos = tmp.find( "@" );
|
|
||||||
if ( pos != string::npos ) {
|
|
||||||
TgtAptId = tmp.substr( 0, pos );
|
|
||||||
} else {
|
|
||||||
TgtAptId = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
TgtAptDialog_Cancel( NULL );
|
|
||||||
|
|
||||||
/* s = input string, either 'FIX' or FIX@4000' */
|
|
||||||
/* TgtAptId is name of fix only; may get appended to below */
|
|
||||||
|
|
||||||
if ( NewWaypoint( TgtAptId ) == 0)
|
|
||||||
{
|
|
||||||
TgtAptId += " not in database.";
|
|
||||||
mkDialog(TgtAptId.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* add new waypoint (either from above popup window 'ok button or telnet session) */
|
|
||||||
|
|
||||||
int NewWaypoint( const string& Tgt_Alt )
|
|
||||||
{
|
|
||||||
string TgtAptId;
|
|
||||||
FGFix f;
|
|
||||||
|
|
||||||
double alt = 0.0;
|
|
||||||
unsigned int pos = Tgt_Alt.find( "@" );
|
|
||||||
if ( pos != string::npos ) {
|
|
||||||
TgtAptId = Tgt_Alt.substr( 0, pos );
|
|
||||||
string alt_str = Tgt_Alt.substr( pos + 1 );
|
|
||||||
alt = atof( alt_str.c_str() );
|
|
||||||
if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
|
|
||||||
alt *= SG_FEET_TO_METER;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
TgtAptId = Tgt_Alt;
|
|
||||||
}
|
|
||||||
|
|
||||||
FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
|
|
||||||
const FGAirport *a = fgFindAirportID( TgtAptId);
|
|
||||||
if (a) {
|
|
||||||
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO,
|
|
||||||
"Adding waypoint (airport) = " << TgtAptId );
|
|
||||||
|
|
||||||
sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
|
|
||||||
|
|
||||||
SGWayPoint wp( a->getLongitude(), a->getLatitude(), alt,
|
|
||||||
SGWayPoint::WGS84, TgtAptId );
|
|
||||||
rm->add_waypoint( wp );
|
|
||||||
|
|
||||||
/* and turn on the autopilot */
|
|
||||||
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
} else if ( globals->get_fixlist()->query( TgtAptId, &f ) ) {
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO,
|
|
||||||
"Adding waypoint (fix) = " << TgtAptId );
|
|
||||||
|
|
||||||
sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
|
|
||||||
|
|
||||||
SGWayPoint wp( f.get_lon(), f.get_lat(), alt,
|
|
||||||
SGWayPoint::WGS84, TgtAptId );
|
|
||||||
rm->add_waypoint( wp );
|
|
||||||
|
|
||||||
/* and turn on the autopilot */
|
|
||||||
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
|
|
||||||
return 2;
|
|
||||||
} else {
|
|
||||||
// Try finding a nav matching the ID
|
|
||||||
double lat, lon;
|
|
||||||
// The base lon/lat are determined by the last WP,
|
|
||||||
// or the current pos if the WP list is empty.
|
|
||||||
const int wps = rm->size();
|
|
||||||
if (wps > 0) {
|
|
||||||
SGWayPoint wp = rm->get_waypoint(wps-1);
|
|
||||||
lat = wp.get_target_lat();
|
|
||||||
lon = wp.get_target_lon();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lat = fgGetNode("/position/latitude-deg")->getDoubleValue();
|
|
||||||
lon = fgGetNode("/position/longitude-deg")->getDoubleValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
lat *= SGD_DEGREES_TO_RADIANS;
|
|
||||||
lon *= SGD_DEGREES_TO_RADIANS;
|
|
||||||
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO,
|
|
||||||
"Looking for nav " << TgtAptId << " at " << lon << " " << lat);
|
|
||||||
if (FGNavRecord* nav =
|
|
||||||
globals->get_navlist()->findByIdent(TgtAptId.c_str(), lon, lat))
|
|
||||||
{
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO,
|
|
||||||
"Adding waypoint (nav) = " << TgtAptId );
|
|
||||||
|
|
||||||
sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
|
|
||||||
|
|
||||||
SGWayPoint wp( nav->get_lon(), nav->get_lat(), alt,
|
|
||||||
SGWayPoint::WGS84, TgtAptId );
|
|
||||||
rm->add_waypoint( wp );
|
|
||||||
|
|
||||||
/* and turn on the autopilot */
|
|
||||||
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TgtAptDialog_Reset(puObject *)
|
|
||||||
{
|
|
||||||
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/presets/airport-id") );
|
|
||||||
TgtAptDialogInput->setValue ( NewTgtAirportId );
|
|
||||||
TgtAptDialogInput->setCursor( 0 ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddWayPoint(puObject *cb)
|
|
||||||
{
|
|
||||||
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/presets/airport-id") );
|
|
||||||
TgtAptDialogInput->setValue( NewTgtAirportId );
|
|
||||||
|
|
||||||
/* refresh waypoint list */
|
|
||||||
char WPString[100];
|
|
||||||
|
|
||||||
int i;
|
|
||||||
if ( WPList != NULL ) {
|
|
||||||
for (i = 0; i < WPListsize; i++ ) {
|
|
||||||
delete WPList[i];
|
|
||||||
}
|
|
||||||
delete [] WPList[i];
|
|
||||||
}
|
|
||||||
FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
|
|
||||||
WPListsize = rm->size();
|
|
||||||
if ( WPListsize > 0 ) {
|
|
||||||
WPList = new char* [ WPListsize + 1 ];
|
|
||||||
for (i = 0; i < WPListsize; i++ ) {
|
|
||||||
SGWayPoint wp = rm->get_waypoint(i);
|
|
||||||
sprintf( WPString, "%5s %3.2flon %3.2flat",
|
|
||||||
wp.get_id().c_str(),
|
|
||||||
wp.get_target_lon(),
|
|
||||||
wp.get_target_lat() );
|
|
||||||
WPList [i] = new char[ strlen(WPString)+1 ];
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
FG_PUSH_PUI_DIALOG( TgtAptDialog );
|
|
||||||
}
|
|
||||||
|
|
||||||
void PopWayPoint(puObject *cb)
|
|
||||||
{
|
|
||||||
FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
|
|
||||||
rm->pop_waypoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClearRoute(puObject *cb)
|
|
||||||
{
|
|
||||||
FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
|
|
||||||
rm->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewTgtAirportInit()
|
|
||||||
{
|
|
||||||
SG_LOG( SG_AUTOPILOT, SG_INFO, " enter NewTgtAirportInit()" );
|
|
||||||
sprintf( NewTgtAirportId, "%s", fgGetString("/sim/presets/airport-id") );
|
|
||||||
SG_LOG( SG_AUTOPILOT, SG_INFO, " NewTgtAirportId " << NewTgtAirportId );
|
|
||||||
|
|
||||||
TgtAptDialog = new puDialogBox (150, 350);
|
|
||||||
{
|
|
||||||
TgtAptDialogFrame = new puFrame (0,0,350, 350);
|
|
||||||
|
|
||||||
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 ) ;
|
|
||||||
|
|
||||||
|
|
||||||
TgtAptDialogInput = new puInput (50, 70, 300, 100);
|
|
||||||
TgtAptDialogInput -> setLabel ( NewTgtAirportLabel );
|
|
||||||
TgtAptDialogInput -> setLabelPlace ( PUPLACE_ABOVE ) ;
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
FG_FINALIZE_PUI_DIALOG( TgtAptDialog );
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "leave NewTgtAirportInit()");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
// auto_gui.hxx -- autopilot gui interface
|
|
||||||
//
|
|
||||||
// Written by Norman Vine <nhv@cape.com>
|
|
||||||
// Arranged by Curt Olson <http://www.flightgear.org/~curt>
|
|
||||||
//
|
|
||||||
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _AUTO_GUI_HXX
|
|
||||||
#define _AUTO_GUI_HXX
|
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
|
||||||
|
|
||||||
#include STL_STRING
|
|
||||||
|
|
||||||
SG_USING_STD( string );
|
|
||||||
|
|
||||||
// Defines
|
|
||||||
#define AP_CURRENT_HEADING -1
|
|
||||||
|
|
||||||
// prototypes
|
|
||||||
|
|
||||||
class puObject;
|
|
||||||
// void fgAPAdjust( puObject * );
|
|
||||||
void NewHeading(puObject *cb);
|
|
||||||
void NewAltitude(puObject *cb);
|
|
||||||
void AddWayPoint(puObject *cb);
|
|
||||||
void PopWayPoint(puObject *cb);
|
|
||||||
void ClearRoute(puObject *cb);
|
|
||||||
|
|
||||||
void NewTgtAirportInit();
|
|
||||||
void fgAPAdjustInit() ;
|
|
||||||
void NewHeadingInit();
|
|
||||||
void NewAltitudeInit();
|
|
||||||
|
|
||||||
int NewWaypoint( const string& Tgt_Alt );
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _AUTO_GUI_HXX
|
|
|
@ -1,6 +1,8 @@
|
||||||
// route_mgr.cxx - manage a route (i.e. a collection of waypoints)
|
// route_mgr.cxx - manage a route (i.e. a collection of waypoints)
|
||||||
//
|
//
|
||||||
// Written by Curtis Olson, started January 2004.
|
// Written by Curtis Olson, started January 2004.
|
||||||
|
// Norman Vine
|
||||||
|
// Melchior FRANZ
|
||||||
//
|
//
|
||||||
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
|
// Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||||
//
|
//
|
||||||
|
@ -27,12 +29,16 @@
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
|
||||||
|
#include <Airports/simple.hxx>
|
||||||
#include <FDM/flight.hxx>
|
#include <FDM/flight.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
#include <Navaids/fixlist.hxx>
|
||||||
|
#include <Navaids/navlist.hxx>
|
||||||
|
|
||||||
#include "auto_gui.hxx" // FIXME temporary dependency (NewWaypoint)
|
|
||||||
#include "route_mgr.hxx"
|
#include "route_mgr.hxx"
|
||||||
|
|
||||||
|
#define RM "/autopilot/route-manager/"
|
||||||
|
|
||||||
|
|
||||||
FGRouteMgr::FGRouteMgr() :
|
FGRouteMgr::FGRouteMgr() :
|
||||||
route( new SGRoute ),
|
route( new SGRoute ),
|
||||||
|
@ -48,13 +54,19 @@ FGRouteMgr::FGRouteMgr() :
|
||||||
wp1_eta( NULL ),
|
wp1_eta( NULL ),
|
||||||
wpn_id( NULL ),
|
wpn_id( NULL ),
|
||||||
wpn_dist( NULL ),
|
wpn_dist( NULL ),
|
||||||
wpn_eta( NULL )
|
wpn_eta( NULL ),
|
||||||
|
input(fgGetNode( RM "input", true )),
|
||||||
|
listener(new Listener(this)),
|
||||||
|
mirror(fgGetNode( RM "route", true ))
|
||||||
{
|
{
|
||||||
|
input->setStringValue("");
|
||||||
|
input->addChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FGRouteMgr::~FGRouteMgr() {
|
FGRouteMgr::~FGRouteMgr() {
|
||||||
delete route;
|
delete route;
|
||||||
|
input->removeChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,19 +77,20 @@ void FGRouteMgr::init() {
|
||||||
|
|
||||||
true_hdg_deg = fgGetNode( "/autopilot/settings/true-heading-deg", true );
|
true_hdg_deg = fgGetNode( "/autopilot/settings/true-heading-deg", true );
|
||||||
|
|
||||||
wp0_id = fgGetNode( "/autopilot/route-manager/wp[0]/id", true );
|
wp0_id = fgGetNode( RM "wp[0]/id", true );
|
||||||
wp0_dist = fgGetNode( "/autopilot/route-manager/wp[0]/dist", true );
|
wp0_dist = fgGetNode( RM "wp[0]/dist", true );
|
||||||
wp0_eta = fgGetNode( "/autopilot/route-manager/wp[0]/eta", true );
|
wp0_eta = fgGetNode( RM "wp[0]/eta", true );
|
||||||
|
|
||||||
wp1_id = fgGetNode( "/autopilot/route-manager/wp[1]/id", true );
|
wp1_id = fgGetNode( RM "wp[1]/id", true );
|
||||||
wp1_dist = fgGetNode( "/autopilot/route-manager/wp[1]/dist", true );
|
wp1_dist = fgGetNode( RM "wp[1]/dist", true );
|
||||||
wp1_eta = fgGetNode( "/autopilot/route-manager/wp[1]/eta", true );
|
wp1_eta = fgGetNode( RM "wp[1]/eta", true );
|
||||||
|
|
||||||
wpn_id = fgGetNode( "/autopilot/route-manager/wp-last/id", true );
|
wpn_id = fgGetNode( RM "wp-last/id", true );
|
||||||
wpn_dist = fgGetNode( "/autopilot/route-manager/wp-last/dist", true );
|
wpn_dist = fgGetNode( RM "wp-last/dist", true );
|
||||||
wpn_eta = fgGetNode( "/autopilot/route-manager/wp-last/eta", true );
|
wpn_eta = fgGetNode( RM "wp-last/eta", true );
|
||||||
|
|
||||||
route->clear();
|
route->clear();
|
||||||
|
update_mirror();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +101,7 @@ void FGRouteMgr::postinit() {
|
||||||
|
|
||||||
vector<string>::iterator it;
|
vector<string>::iterator it;
|
||||||
for (it = waypoints->begin(); it != waypoints->end(); ++it)
|
for (it = waypoints->begin(); it != waypoints->end(); ++it)
|
||||||
NewWaypoint(*it);
|
new_waypoint(*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,7 +113,7 @@ static double get_ground_speed() {
|
||||||
// starts in ft/s so we convert to kts
|
// starts in ft/s so we convert to kts
|
||||||
static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up");
|
static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up");
|
||||||
|
|
||||||
double ft_s = cur_fdm_state->get_V_ground_speed()
|
double ft_s = cur_fdm_state->get_V_ground_speed()
|
||||||
* speedup_node->getIntValue();
|
* speedup_node->getIntValue();
|
||||||
double kts = ft_s * SG_FEET_TO_METER * 3600 * SG_METER_TO_NM;
|
double kts = ft_s * SG_FEET_TO_METER * 3600 * SG_METER_TO_NM;
|
||||||
|
|
||||||
|
@ -137,15 +150,15 @@ void FGRouteMgr::update( double dt ) {
|
||||||
wp0_dist->setDoubleValue( accum * SG_METER_TO_NM );
|
wp0_dist->setDoubleValue( accum * SG_METER_TO_NM );
|
||||||
|
|
||||||
double eta = accum * SG_METER_TO_NM / get_ground_speed();
|
double eta = accum * SG_METER_TO_NM / get_ground_speed();
|
||||||
if ( eta >= 100.0 ) { eta = 99.999; }
|
if ( eta >= 100.0 ) { eta = 99.999; }
|
||||||
int major, minor;
|
int major, minor;
|
||||||
if ( eta < (1.0/6.0) ) {
|
if ( eta < (1.0/6.0) ) {
|
||||||
// within 10 minutes, bump up to min/secs
|
// within 10 minutes, bump up to min/secs
|
||||||
eta *= 60.0;
|
eta *= 60.0;
|
||||||
}
|
}
|
||||||
major = (int)eta;
|
major = (int)eta;
|
||||||
minor = (int)((eta - (int)eta) * 60.0);
|
minor = (int)((eta - (int)eta) * 60.0);
|
||||||
snprintf( eta_str, 128, "%d:%02d", major, minor );
|
snprintf( eta_str, 128, "%d:%02d", major, minor );
|
||||||
wp0_eta->setStringValue( eta_str );
|
wp0_eta->setStringValue( eta_str );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,25 +174,25 @@ void FGRouteMgr::update( double dt ) {
|
||||||
wp1_dist->setDoubleValue( accum * SG_METER_TO_NM );
|
wp1_dist->setDoubleValue( accum * SG_METER_TO_NM );
|
||||||
|
|
||||||
double eta = accum * SG_METER_TO_NM / get_ground_speed();
|
double eta = accum * SG_METER_TO_NM / get_ground_speed();
|
||||||
if ( eta >= 100.0 ) { eta = 99.999; }
|
if ( eta >= 100.0 ) { eta = 99.999; }
|
||||||
int major, minor;
|
int major, minor;
|
||||||
if ( eta < (1.0/6.0) ) {
|
if ( eta < (1.0/6.0) ) {
|
||||||
// within 10 minutes, bump up to min/secs
|
// within 10 minutes, bump up to min/secs
|
||||||
eta *= 60.0;
|
eta *= 60.0;
|
||||||
}
|
}
|
||||||
major = (int)eta;
|
major = (int)eta;
|
||||||
minor = (int)((eta - (int)eta) * 60.0);
|
minor = (int)((eta - (int)eta) * 60.0);
|
||||||
snprintf( eta_str, 128, "%d:%02d", major, minor );
|
snprintf( eta_str, 128, "%d:%02d", major, minor );
|
||||||
wp1_eta->setStringValue( eta_str );
|
wp1_eta->setStringValue( eta_str );
|
||||||
}
|
}
|
||||||
|
|
||||||
// summarize remaining way points
|
// summarize remaining way points
|
||||||
if ( route->size() > 2 ) {
|
if ( route->size() > 2 ) {
|
||||||
SGWayPoint wp;
|
SGWayPoint wp;
|
||||||
for ( int i = 2; i < route->size(); ++i ) {
|
for ( int i = 2; i < route->size(); ++i ) {
|
||||||
wp = route->get_waypoint( i );
|
wp = route->get_waypoint( i );
|
||||||
accum += wp.get_distance();
|
accum += wp.get_distance();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the property tree info
|
// update the property tree info
|
||||||
|
|
||||||
|
@ -188,26 +201,34 @@ void FGRouteMgr::update( double dt ) {
|
||||||
wpn_dist->setDoubleValue( accum * SG_METER_TO_NM );
|
wpn_dist->setDoubleValue( accum * SG_METER_TO_NM );
|
||||||
|
|
||||||
double eta = accum * SG_METER_TO_NM / get_ground_speed();
|
double eta = accum * SG_METER_TO_NM / get_ground_speed();
|
||||||
if ( eta >= 100.0 ) { eta = 99.999; }
|
if ( eta >= 100.0 ) { eta = 99.999; }
|
||||||
int major, minor;
|
int major, minor;
|
||||||
if ( eta < (1.0/6.0) ) {
|
if ( eta < (1.0/6.0) ) {
|
||||||
// within 10 minutes, bump up to min/secs
|
// within 10 minutes, bump up to min/secs
|
||||||
eta *= 60.0;
|
eta *= 60.0;
|
||||||
}
|
}
|
||||||
major = (int)eta;
|
major = (int)eta;
|
||||||
minor = (int)((eta - (int)eta) * 60.0);
|
minor = (int)((eta - (int)eta) * 60.0);
|
||||||
snprintf( eta_str, 128, "%d:%02d", major, minor );
|
snprintf( eta_str, 128, "%d:%02d", major, minor );
|
||||||
wpn_eta->setStringValue( eta_str );
|
wpn_eta->setStringValue( eta_str );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SGWayPoint FGRouteMgr::pop_waypoint() {
|
void FGRouteMgr::add_waypoint( const SGWayPoint& wp, int n ) {
|
||||||
|
route->add_waypoint( wp, n );
|
||||||
|
update_mirror();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SGWayPoint FGRouteMgr::pop_waypoint( int n ) {
|
||||||
SGWayPoint wp;
|
SGWayPoint wp;
|
||||||
|
|
||||||
if ( route->size() > 0 ) {
|
if ( route->size() > 0 ) {
|
||||||
wp = route->get_first();
|
if ( n < 0 )
|
||||||
route->delete_first();
|
n = route->size() - 1;
|
||||||
|
wp = route->get_waypoint(n);
|
||||||
|
route->delete_waypoint(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( route->size() <= 2 ) {
|
if ( route->size() <= 2 ) {
|
||||||
|
@ -228,6 +249,7 @@ SGWayPoint FGRouteMgr::pop_waypoint() {
|
||||||
wp0_eta->setStringValue( "" );
|
wp0_eta->setStringValue( "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_mirror();
|
||||||
return wp;
|
return wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,3 +257,136 @@ SGWayPoint FGRouteMgr::pop_waypoint() {
|
||||||
bool FGRouteMgr::build() {
|
bool FGRouteMgr::build() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int FGRouteMgr::new_waypoint( const string& Tgt_Alt, int n ) {
|
||||||
|
double alt = 0.0;
|
||||||
|
string target = Tgt_Alt;
|
||||||
|
|
||||||
|
// make upper case
|
||||||
|
for (unsigned int i = 0; i < target.size(); i++)
|
||||||
|
if (target[i] >= 'a' && target[i] <= 'z')
|
||||||
|
target[i] -= 'a' - 'A';
|
||||||
|
|
||||||
|
// extract altitude
|
||||||
|
unsigned int pos = target.find( '@' );
|
||||||
|
if ( pos != string::npos ) {
|
||||||
|
alt = atof( target.c_str() + pos + 1 );
|
||||||
|
target = target.substr( 0, pos );
|
||||||
|
if ( !strcmp(fgGetString("/sim/startup/units"), "feet") )
|
||||||
|
alt *= SG_FEET_TO_METER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for lon,lat
|
||||||
|
pos = target.find(',');
|
||||||
|
if ( pos != string::npos ) {
|
||||||
|
double lon = atof( target.substr(0, pos).c_str());
|
||||||
|
double lat = atof( target.c_str() + pos + 1);
|
||||||
|
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, "Adding waypoint lon = " << lon << ", lat = " << lat );
|
||||||
|
SGWayPoint wp( lon, lat, alt, SGWayPoint::WGS84, target );
|
||||||
|
add_waypoint( wp, n );
|
||||||
|
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for airport id
|
||||||
|
const FGAirport *apt = fgFindAirportID( target );
|
||||||
|
if (apt) {
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, "Adding waypoint (airport) = " << target );
|
||||||
|
SGWayPoint wp( apt->getLongitude(), apt->getLatitude(), alt, SGWayPoint::WGS84, target );
|
||||||
|
add_waypoint( wp, n );
|
||||||
|
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for fix id
|
||||||
|
FGFix f;
|
||||||
|
if ( globals->get_fixlist()->query( target, &f ) ) {
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, "Adding waypoint (fix) = " << target );
|
||||||
|
SGWayPoint wp( f.get_lon(), f.get_lat(), alt, SGWayPoint::WGS84, target );
|
||||||
|
add_waypoint( wp, n );
|
||||||
|
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try finding a nav matching the ID
|
||||||
|
double lat, lon;
|
||||||
|
// The base lon/lat are determined by the last WP,
|
||||||
|
// or the current pos if the WP list is empty.
|
||||||
|
const int wps = this->size();
|
||||||
|
|
||||||
|
if (wps > 0) {
|
||||||
|
SGWayPoint wp = get_waypoint(wps-1);
|
||||||
|
lat = wp.get_target_lat();
|
||||||
|
lon = wp.get_target_lon();
|
||||||
|
} else {
|
||||||
|
lat = fgGetNode("/position/latitude-deg")->getDoubleValue();
|
||||||
|
lon = fgGetNode("/position/longitude-deg")->getDoubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
lat *= SGD_DEGREES_TO_RADIANS;
|
||||||
|
lon *= SGD_DEGREES_TO_RADIANS;
|
||||||
|
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, "Looking for nav " << target << " at " << lon << " " << lat);
|
||||||
|
|
||||||
|
if (FGNavRecord* nav = globals->get_navlist()->findByIdent(target.c_str(), lon, lat)) {
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, "Adding waypoint (nav) = " << target );
|
||||||
|
SGWayPoint wp( nav->get_lon(), nav->get_lat(), alt, SGWayPoint::WGS84, target );
|
||||||
|
add_waypoint( wp, n );
|
||||||
|
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// target not identified
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// mirror internal route to the property system for inspection by other subsystems
|
||||||
|
void FGRouteMgr::update_mirror() {
|
||||||
|
mirror->removeChildren("wp");
|
||||||
|
for (int i = 0; i < route->size(); i++) {
|
||||||
|
SGWayPoint wp = route->get_waypoint(i);
|
||||||
|
SGPropertyNode *prop = mirror->getChild("wp", i, 1);
|
||||||
|
|
||||||
|
prop->setStringValue("id", wp.get_id().c_str());
|
||||||
|
prop->setStringValue("name", wp.get_name().c_str());
|
||||||
|
prop->setDoubleValue("longitude-deg", wp.get_target_lon());
|
||||||
|
prop->setDoubleValue("latitude-deg", wp.get_target_lat());
|
||||||
|
prop->setDoubleValue("altitude-m", wp.get_target_alt());
|
||||||
|
prop->setDoubleValue("altitude-ft", wp.get_target_alt() * SG_METER_TO_FEET);
|
||||||
|
}
|
||||||
|
// set number as listener attachment point
|
||||||
|
mirror->setIntValue("num", route->size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// command interface /autopilot/route-manager/input:
|
||||||
|
//
|
||||||
|
// @clear ... clear route
|
||||||
|
// @pop ... remove first entry
|
||||||
|
// @delete3 ... delete 4th entry
|
||||||
|
// @insert2:ksfo@900 ... insert "ksfo@900" as 3rd entry
|
||||||
|
// ksfo@900 ... append "ksfo@900"
|
||||||
|
//
|
||||||
|
void FGRouteMgr::Listener::valueChanged(SGPropertyNode *prop)
|
||||||
|
{
|
||||||
|
const char *s = prop->getStringValue();
|
||||||
|
if (!strcmp(s, "@clear"))
|
||||||
|
mgr->init();
|
||||||
|
else if (!strcmp(s, "@pop"))
|
||||||
|
mgr->pop_waypoint(0);
|
||||||
|
else if (!strncmp(s, "@delete", 7))
|
||||||
|
mgr->pop_waypoint(atoi(s + 7));
|
||||||
|
else if (!strncmp(s, "@insert", 7)) {
|
||||||
|
char *r;
|
||||||
|
int pos = strtol(s + 7, &r, 10);
|
||||||
|
if (*r++ == ':' && *r)
|
||||||
|
mgr->new_waypoint(r, pos);
|
||||||
|
} else
|
||||||
|
mgr->new_waypoint(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,18 @@ private:
|
||||||
SGPropertyNode_ptr wpn_eta;
|
SGPropertyNode_ptr wpn_eta;
|
||||||
|
|
||||||
|
|
||||||
|
class Listener : public SGPropertyChangeListener {
|
||||||
|
public:
|
||||||
|
Listener(FGRouteMgr *m) : mgr(m) {}
|
||||||
|
virtual void valueChanged (SGPropertyNode * prop);
|
||||||
|
private:
|
||||||
|
FGRouteMgr *mgr;
|
||||||
|
};
|
||||||
|
|
||||||
|
SGPropertyNode_ptr input;
|
||||||
|
Listener *listener;
|
||||||
|
SGPropertyNode_ptr mirror;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGRouteMgr();
|
FGRouteMgr();
|
||||||
|
@ -91,19 +103,19 @@ public:
|
||||||
|
|
||||||
bool build ();
|
bool build ();
|
||||||
|
|
||||||
void add_waypoint( const SGWayPoint& wp ) {
|
int new_waypoint( const string& tgt_alt, int n = -1 );
|
||||||
route->add_waypoint( wp );
|
void add_waypoint( const SGWayPoint& wp, int n = -1 );
|
||||||
}
|
SGWayPoint pop_waypoint( int i = 0 );
|
||||||
|
|
||||||
SGWayPoint get_waypoint( int i ) const {
|
SGWayPoint get_waypoint( int i ) const {
|
||||||
return route->get_waypoint(i);
|
return route->get_waypoint(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
SGWayPoint pop_waypoint();
|
|
||||||
|
|
||||||
int size() const {
|
int size() const {
|
||||||
return route->size();
|
return route->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void update_mirror();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,6 @@
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Aircraft/controls.hxx>
|
#include <Aircraft/controls.hxx>
|
||||||
#include <Airports/simple.hxx>
|
#include <Airports/simple.hxx>
|
||||||
#include <Autopilot/auto_gui.hxx>
|
|
||||||
#include <Cockpit/panel.hxx>
|
#include <Cockpit/panel.hxx>
|
||||||
#include <FDM/flight.hxx>
|
#include <FDM/flight.hxx>
|
||||||
#include <Main/main.hxx>
|
#include <Main/main.hxx>
|
||||||
|
@ -141,12 +140,12 @@ const __fg_gui_fn_t __fg_gui_fn[] = {
|
||||||
{"fgPresetCommit", fgPresetCommit},
|
{"fgPresetCommit", fgPresetCommit},
|
||||||
|
|
||||||
// Autopilot
|
// Autopilot
|
||||||
{"NewAltitude", NewAltitude},
|
/*
|
||||||
{"NewHeading", NewHeading},
|
|
||||||
{"AddWayPoint", AddWayPoint},
|
{"AddWayPoint", AddWayPoint},
|
||||||
{"PopWayPoint", PopWayPoint},
|
{"PopWayPoint", PopWayPoint},
|
||||||
{"ClearRoute", ClearRoute},
|
{"ClearRoute", ClearRoute},
|
||||||
{"fgLatLonFormatToggle", fgLatLonFormatToggle},
|
{"fgLatLonFormatToggle", fgLatLonFormatToggle},
|
||||||
|
*/
|
||||||
|
|
||||||
// Help
|
// Help
|
||||||
{"helpCb", helpCb},
|
{"helpCb", helpCb},
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <plib/pu.h>
|
#include <plib/pu.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
|
||||||
#include <Autopilot/auto_gui.hxx>
|
|
||||||
#include <Input/input.hxx>
|
#include <Input/input.hxx>
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
|
|
||||||
|
@ -63,6 +62,7 @@ do_properties_dialog (const SGPropertyNode * arg)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
extern void AddWayPoint (puObject *);
|
extern void AddWayPoint (puObject *);
|
||||||
static bool
|
static bool
|
||||||
do_ap_add_waypoint_dialog (const SGPropertyNode * arg)
|
do_ap_add_waypoint_dialog (const SGPropertyNode * arg)
|
||||||
|
@ -87,7 +87,6 @@ do_ap_clear_route_dialog (const SGPropertyNode * arg)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
extern void fgAPAdjust (puObject *);
|
extern void fgAPAdjust (puObject *);
|
||||||
static bool
|
static bool
|
||||||
do_ap_adjust_dialog (const SGPropertyNode * arg)
|
do_ap_adjust_dialog (const SGPropertyNode * arg)
|
||||||
|
@ -125,9 +124,6 @@ static struct {
|
||||||
{ "old-print-dialog", do_print_dialog },
|
{ "old-print-dialog", do_print_dialog },
|
||||||
#endif
|
#endif
|
||||||
{ "old-properties-dialog", do_properties_dialog },
|
{ "old-properties-dialog", do_properties_dialog },
|
||||||
{ "old-ap-add-waypoint-dialog", do_ap_add_waypoint_dialog },
|
|
||||||
{ "old-ap-pop-waypoint-dialog", do_ap_pop_waypoint_dialog },
|
|
||||||
{ "old-ap-clear-route-dialog", do_ap_clear_route_dialog },
|
|
||||||
{ "old-lat-lon-format-dialog", do_lat_lon_format_dialog },
|
{ "old-lat-lon-format-dialog", do_lat_lon_format_dialog },
|
||||||
{ "old-help-dialog", do_help_dialog },
|
{ "old-help-dialog", do_help_dialog },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Aircraft/controls.hxx>
|
#include <Aircraft/controls.hxx>
|
||||||
#include <Airports/simple.hxx>
|
#include <Airports/simple.hxx>
|
||||||
#include <Autopilot/auto_gui.hxx>
|
|
||||||
#include <Cockpit/panel.hxx>
|
#include <Cockpit/panel.hxx>
|
||||||
#include <FDM/flight.hxx>
|
#include <FDM/flight.hxx>
|
||||||
#include <Main/fg_init.hxx>
|
#include <Main/fg_init.hxx>
|
||||||
|
|
|
@ -70,7 +70,6 @@
|
||||||
#include <ATC/ATCdisplay.hxx>
|
#include <ATC/ATCdisplay.hxx>
|
||||||
#include <ATC/ATCmgr.hxx>
|
#include <ATC/ATCmgr.hxx>
|
||||||
#include <ATC/AIMgr.hxx>
|
#include <ATC/AIMgr.hxx>
|
||||||
#include <Autopilot/auto_gui.hxx>
|
|
||||||
#include <Autopilot/route_mgr.hxx>
|
#include <Autopilot/route_mgr.hxx>
|
||||||
#include <Autopilot/xmlauto.hxx>
|
#include <Autopilot/xmlauto.hxx>
|
||||||
#include <Cockpit/cockpit.hxx>
|
#include <Cockpit/cockpit.hxx>
|
||||||
|
@ -1715,17 +1714,6 @@ bool fgInitSubsystems() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Initialize the autopilot subsystem.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// FIXME: these should go in the
|
|
||||||
// GUI initialization code, not here.
|
|
||||||
// fgAPAdjustInit();
|
|
||||||
NewTgtAirportInit();
|
|
||||||
NewHeadingInit();
|
|
||||||
NewAltitudeInit();
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Initialize I/O subsystem.
|
// Initialize I/O subsystem.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1743,7 +1731,7 @@ bool fgInitSubsystems() {
|
||||||
|
|
||||||
globals->set_current_panel( fgReadPanel(panel_path) );
|
globals->set_current_panel( fgReadPanel(panel_path) );
|
||||||
if (globals->get_current_panel() == 0) {
|
if (globals->get_current_panel() == 0) {
|
||||||
SG_LOG( SG_INPUT, SG_ALERT,
|
SG_LOG( SG_INPUT, SG_ALERT,
|
||||||
"Error reading new panel from " << panel_path );
|
"Error reading new panel from " << panel_path );
|
||||||
} else {
|
} else {
|
||||||
SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
|
SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
|
||||||
|
@ -1751,7 +1739,7 @@ bool fgInitSubsystems() {
|
||||||
globals->get_current_panel()->bind();
|
globals->get_current_panel()->bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Initialize the controls subsystem.
|
// Initialize the controls subsystem.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in a new issue