// auto_gui.cxx -- autopilot gui interface
//
// Written by Norman Vine <nhv@cape.com>
-// Arranged by Curt Olson <curt@flightgear.org>
+// Arranged by Curt Olson <http://www.flightgear.org/~curt>
//
// Copyright (C) 1998 - 2000
//
#include <Aircraft/aircraft.hxx>
#include <FDM/flight.hxx>
-#include <Controls/controls.hxx>
#include <Scenery/scenery.hxx>
#include <simgear/constants.h>
#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"
#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
+// 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 ];
+// 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
// These statics should disapear when this is a class
static puDialogBox *TgtAptDialog = 0;
static puFrame *TgtAptDialogFrame = 0;
-static puText *TgtAptDialogMessage = 0;
+// static puText *TgtAptDialogMessage = 0;
static puInput *TgtAptDialogInput = 0;
static puListBox *TgtAptDialogWPList = 0;
static puSlider *TgtAptDialogSlider = 0;
}
+#if 0
static void maxroll_adj( puObject *hs ) {
float val ;
#undef HORIZONTAL
}
+#endif
// Simple Dialog to input Target Airport
void TgtAptDialog_Cancel(puObject *)
/* add new waypoint (either from above popup window 'ok button or telnet session) */
-int NewWaypoint( string Tgt_Alt )
+int NewWaypoint( const string& Tgt_Alt )
{
string TgtAptId;
FGAirport a;
sprintf( NewTgtAirportId, "%s", TgtAptId.c_str() );
- SGWayPoint wp( a.longitude, a.latitude, alt,
+ SGWayPoint wp( a.getLongitude(), a.getLatitude(), alt,
SGWayPoint::WGS84, TgtAptId );
rm->add_waypoint( wp );
return 1;
- } else if ( current_fixlist->query( TgtAptId, &f ) ) {
+ } else if ( globals->get_fixlist()->query( TgtAptId, &f ) ) {
SG_LOG( SG_GENERAL, SG_INFO,
"Adding waypoint (fix) = " << TgtAptId );
fgSetString( "/autopilot/locks/heading", "true-heading-hold" );
return 2;
} else {
- return 0;
+ // 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;
+ }
}
}