1
0
Fork 0

src/GUI/gui.cxx:

- removed Toggle Clouds menu item

src/Main/options.cxx:
- (minor) added some code to sync up options with properties

src/Main/bfi.[ch]xx:
- removed (get|set)Clouds(ASL)?
- removed setSpeedNorth, setSpeedEast, and setSpeedDown -- these are
  all read-only now
- added setAirspeed (for calibrated kt)
- extensive rewrite to support Tony's FDM changes
- rearranged everything in bfi.hxx to mess up Curt's ediff examination
- added properties for setting initial panel position

src/Main/save.cxx:
- reinit the tile cache after restore
This commit is contained in:
curt 2000-11-01 04:51:55 +00:00
parent 8aab71034a
commit 6786cf9da4
5 changed files with 335 additions and 263 deletions

View file

@ -732,11 +732,6 @@ void reInit(puObject *cb)
BusyCursor(1);
}
static void toggleClouds(puObject *cb)
{
FGBFI::setClouds( !FGBFI::getClouds() );
}
// This is the accessor function
void guiTogglePanel(puObject *cb)
{
@ -1445,11 +1440,9 @@ puCallback autopilotSubmenuCb [] = {
};
char *environmentSubmenu [] = {
"Toggle Clouds",
"Goto Airport", /* "Terrain", "Weather", */ NULL
};
puCallback environmentSubmenuCb [] = {
toggleClouds,
NewAirport, /* notCb, notCb, */ NULL
};

View file

@ -48,6 +48,7 @@
#include <Time/sunpos.hxx>
#include <Time/tmp.hxx>
#include <Cockpit/radiostack.hxx>
#include <Cockpit/panel.hxx>
#ifndef FG_OLD_WEATHER
# include <WeatherCM/FGLocalWeatherDatabase.h>
#else
@ -70,7 +71,80 @@ FG_USING_NAMESPACE(std);
// Static variables.
////////////////////////////////////////////////////////////////////////
bool FGBFI::_needReinit = false;
// Yech -- not thread-safe, etc. etc.
static bool _needReinit = false;
static string _temp;
static inline void needReinit ()
{
_needReinit = true;
}
/**
* Reinitialize FGFS to use the new BFI settings.
*/
static inline void
reinit ()
{
// Save the state of everything
// that's going to get clobbered
// when we reinit the subsystems.
cout << "BFI: start reinit\n";
// TODO: add more AP stuff
double elevator = FGBFI::getElevator();
double aileron = FGBFI::getAileron();
double rudder = FGBFI::getRudder();
double throttle = FGBFI::getThrottle();
double elevator_trim = FGBFI::getElevatorTrim();
double flaps = FGBFI::getFlaps();
double brake = FGBFI::getBrakes();
bool apHeadingLock = FGBFI::getAPHeadingLock();
double apHeadingMag = FGBFI::getAPHeadingMag();
bool apAltitudeLock = FGBFI::getAPAltitudeLock();
double apAltitude = FGBFI::getAPAltitude();
const string &targetAirport = FGBFI::getTargetAirport();
bool gpsLock = FGBFI::getGPSLock();
double gpsLatitude = FGBFI::getGPSTargetLatitude();
double gpsLongitude = FGBFI::getGPSTargetLongitude();
FGBFI::setTargetAirport("");
cout << "Target airport is " << globals->get_options()->get_airport_id() << endl;
fgReInitSubsystems();
// FIXME: this is wrong.
// All of these are scheduled events,
// and it should be possible to force
// them all to run once.
fgUpdateSunPos();
fgUpdateMoonPos();
cur_light_params.Update();
fgUpdateLocalTime();
fgUpdateWeatherDatabase();
fgRadioSearch();
// Restore all of the old states.
FGBFI::setElevator(elevator);
FGBFI::setAileron(aileron);
FGBFI::setRudder(rudder);
FGBFI::setThrottle(throttle);
FGBFI::setElevatorTrim(elevator_trim);
FGBFI::setFlaps(flaps);
FGBFI::setBrakes(brake);
FGBFI::setAPHeadingLock(apHeadingLock);
FGBFI::setAPHeadingMag(apHeadingMag);
FGBFI::setAPAltitudeLock(apAltitudeLock);
FGBFI::setAPAltitude(apAltitude);
FGBFI::setTargetAirport(targetAirport);
FGBFI::setGPSLock(gpsLock);
_needReinit = false;
cout << "BFI: end reinit\n";
}
@ -92,8 +166,10 @@ FGBFI::init ()
// Simulation
current_properties.tieInt("/sim/flight-model",
getFlightModel, setFlightModel);
// current_properties.tieString("/sim/aircraft",
// getAircraft, setAircraft);
current_properties.tieString("/sim/aircraft",
getAircraft, setAircraft);
current_properties.tieString("/sim/aircraft-dir",
getAircraftDir, setAircraftDir);
// TODO: timeGMT
current_properties.tieString("/sim/time/gmt-string",
getGMTString, 0);
@ -101,6 +177,10 @@ FGBFI::init ()
getHUDVisible, setHUDVisible);
current_properties.tieBool("/sim/panel/visibility",
getPanelVisible, setPanelVisible);
current_properties.tieInt("/sim/panel/x-offset",
getPanelXOffset, setPanelXOffset);
current_properties.tieInt("/sim/panel/y-offset",
getPanelYOffset, setPanelYOffset);
// Position
current_properties.tieString("/position/airport-id",
@ -137,17 +217,17 @@ FGBFI::init ()
// Velocities
current_properties.tieDouble("/velocities/airspeed",
getAirspeed, 0);
getAirspeed, setAirspeed);
current_properties.tieDouble("/velocities/side-slip",
getSideSlip, 0);
current_properties.tieDouble("/velocities/vertical-speed",
getVerticalSpeed, 0);
current_properties.tieDouble("/velocities/speed-north",
getSpeedNorth, setSpeedNorth);
getSpeedNorth, 0);
current_properties.tieDouble("/velocities/speed-east",
getSpeedEast, setSpeedEast);
getSpeedEast, 0);
current_properties.tieDouble("/velocities/speed-down",
getSpeedDown, setSpeedDown);
getSpeedDown, 0);
// Controls
current_properties.tieDouble("/controls/throttle",
@ -261,72 +341,6 @@ FGBFI::update ()
}
/**
* Reinitialize FGFS to use the new BFI settings.
*/
void
FGBFI::reinit ()
{
// Save the state of everything
// that's going to get clobbered
// when we reinit the subsystems.
cout << "BFI: start reinit\n";
// TODO: add more AP stuff
double elevator = getElevator();
double aileron = getAileron();
double rudder = getRudder();
double throttle = getThrottle();
double elevator_trim = getElevatorTrim();
double flaps = getFlaps();
double brake = getBrakes();
bool apHeadingLock = getAPHeadingLock();
double apHeadingMag = getAPHeadingMag();
bool apAltitudeLock = getAPAltitudeLock();
double apAltitude = getAPAltitude();
const string &targetAirport = getTargetAirport();
bool gpsLock = getGPSLock();
double gpsLatitude = getGPSTargetLatitude();
double gpsLongitude = getGPSTargetLongitude();
setTargetAirport("");
cout << "Target airport is " << globals->get_options()->get_airport_id() << endl;
fgReInitSubsystems();
// FIXME: this is wrong.
// All of these are scheduled events,
// and it should be possible to force
// them all to run once.
fgUpdateSunPos();
fgUpdateMoonPos();
cur_light_params.Update();
fgUpdateLocalTime();
fgUpdateWeatherDatabase();
fgRadioSearch();
// Restore all of the old states.
setElevator(elevator);
setAileron(aileron);
setRudder(rudder);
setThrottle(throttle);
setElevatorTrim(elevator_trim);
setFlaps(flaps);
setBrakes(brake);
setAPHeadingLock(apHeadingLock);
setAPHeadingMag(apHeadingMag);
setAPAltitudeLock(apAltitudeLock);
setAPAltitude(apAltitude);
setTargetAirport(targetAirport);
setGPSLock(gpsLock);
_needReinit = false;
cout << "BFI: end reinit\n";
}
////////////////////////////////////////////////////////////////////////
// Simulation.
@ -348,20 +362,22 @@ FGBFI::getFlightModel ()
/**
* Return the current aircraft as a string.
*/
const string
const string &
FGBFI::getAircraft ()
{
return globals->get_options()->get_aircraft();
_temp = globals->get_options()->get_aircraft();
return _temp;
}
/**
* Return the current aircraft directory (UIUC) as a string.
*/
const string
const string &
FGBFI::getAircraftDir ()
{
return aircraft_dir;
_temp = aircraft_dir;
return _temp;
}
@ -493,6 +509,56 @@ FGBFI::setPanelVisible (bool visible)
}
/**
* Get the panel's current x-shift.
*/
int
FGBFI::getPanelXOffset ()
{
if (current_panel != 0)
return current_panel->getXOffset();
else
return 0;
}
/**
* Set the panel's current x-shift.
*/
void
FGBFI::setPanelXOffset (int offset)
{
if (current_panel != 0)
current_panel->setXOffset(offset);
}
/**
* Get the panel's current y-shift.
*/
int
FGBFI::getPanelYOffset ()
{
if (current_panel != 0)
return current_panel->getYOffset();
else
return 0;
}
/**
* Set the panel's current y-shift.
*/
void
FGBFI::setPanelYOffset (int offset)
{
if (current_panel != 0)
current_panel->setYOffset(offset);
}
////////////////////////////////////////////////////////////////////////
// Position
@ -515,11 +581,7 @@ FGBFI::getLatitude ()
void
FGBFI::setLatitude (double latitude)
{
if (getLatitude() != latitude) {
globals->get_options()->set_lat(latitude);
current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
needReinit();
}
current_aircraft.fdm_state->set_Latitude(latitude * DEG_TO_RAD);
}
@ -539,11 +601,7 @@ FGBFI::getLongitude ()
void
FGBFI::setLongitude (double longitude)
{
if (getLongitude() != longitude) {
globals->get_options()->set_lon(longitude);
current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
needReinit();
}
current_aircraft.fdm_state->set_Longitude(longitude * DEG_TO_RAD);
}
@ -575,11 +633,7 @@ FGBFI::getAGL ()
void
FGBFI::setAltitude (double altitude)
{
if (getAltitude() != altitude) {
fgFDMForceAltitude(getFlightModel(), altitude);
globals->get_options()->set_altitude(altitude);
current_aircraft.fdm_state->set_Altitude(altitude);
}
current_aircraft.fdm_state->set_Altitude(altitude);
}
@ -615,13 +669,9 @@ FGBFI::getHeadingMag ()
void
FGBFI::setHeading (double heading)
{
if (getHeading() != heading) {
globals->get_options()->set_heading(heading);
current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
getPitch() * DEG_TO_RAD,
heading * DEG_TO_RAD);
needReinit();
}
FGInterface * fdm = current_aircraft.fdm_state;
fdm->set_Euler_Angles(fdm->get_Phi(), fdm->get_Theta(),
heading * DEG_TO_RAD);
}
@ -641,13 +691,8 @@ FGBFI::getPitch ()
void
FGBFI::setPitch (double pitch)
{
if (getPitch() != pitch) {
globals->get_options()->set_pitch(pitch);
current_aircraft.fdm_state->set_Euler_Angles(getRoll() * DEG_TO_RAD,
pitch * DEG_TO_RAD,
getHeading() * DEG_TO_RAD);
needReinit();
}
FGInterface * fdm = current_aircraft.fdm_state;
fdm->set_Euler_Angles(fdm->get_Phi(), pitch * DEG_TO_RAD, fdm->get_Psi());
}
@ -667,13 +712,8 @@ FGBFI::getRoll ()
void
FGBFI::setRoll (double roll)
{
if (getRoll() != roll) {
globals->get_options()->set_roll(roll);
current_aircraft.fdm_state->set_Euler_Angles(roll * DEG_TO_RAD,
getPitch() * DEG_TO_RAD,
getHeading() * DEG_TO_RAD);
needReinit();
}
FGInterface * fdm = current_aircraft.fdm_state;
fdm->set_Euler_Angles(roll * DEG_TO_RAD, fdm->get_Theta(), fdm->get_Psi());
}
@ -758,6 +798,16 @@ FGBFI::getAirspeed ()
}
/**
* Set the calibrated airspeed in knots.
*/
void
FGBFI::setAirspeed (double speed)
{
current_aircraft.fdm_state->set_V_calibrated_kts(speed);
}
/**
* Return the current sideslip (FIXME: units unknown).
*/
@ -789,19 +839,15 @@ FGBFI::getSpeedNorth ()
}
/**
* Set the current north velocity (units??).
*/
void
FGBFI::setSpeedNorth (double speed)
{
if (getSpeedNorth() != speed) {
current_aircraft.fdm_state->set_Velocities_Local(speed,
getSpeedEast(),
getSpeedDown());
needReinit();
}
}
// /**
// * Set the current north velocity (units??).
// */
// void
// FGBFI::setSpeedNorth (double speed)
// {
// FGInterface * fdm = current_aircraft.fdm_state;
// // fdm->set_Velocities_Local(speed, fdm->get_V_east(), fdm->get_V_down());
// }
/**
@ -814,19 +860,15 @@ FGBFI::getSpeedEast ()
}
/**
* Set the current east velocity (units??).
*/
void
FGBFI::setSpeedEast (double speed)
{
if (getSpeedEast() != speed) {
current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
speed,
getSpeedDown());
needReinit();
}
}
// /**
// * Set the current east velocity (units??).
// */
// void
// FGBFI::setSpeedEast (double speed)
// {
// FGInterface * fdm = current_aircraft.fdm_state;
// // fdm->set_Velocities_Local(fdm->get_V_north(), speed, fdm->get_V_down());
// }
/**
@ -839,19 +881,15 @@ FGBFI::getSpeedDown ()
}
/**
* Set the current down velocity (units??).
*/
void
FGBFI::setSpeedDown (double speed)
{
if (getSpeedDown() != speed) {
current_aircraft.fdm_state->set_Velocities_Local(getSpeedNorth(),
getSpeedEast(),
speed);
needReinit();
}
}
// /**
// * Set the current down velocity (units??).
// */
// void
// FGBFI::setSpeedDown (double speed)
// {
// FGInterface * fdm = current_aircraft.fdm_state;
// // fdm->set_Velocities_Local(fdm->get_V_north(), fdm->get_V_east(), speed);
// }
@ -1622,26 +1660,6 @@ FGBFI::getVisibility ()
}
/**
* Check whether clouds are enabled.
*/
bool
FGBFI::getClouds ()
{
return globals->get_options()->get_clouds();
}
/**
* Check the height of the clouds ASL (units?).
*/
double
FGBFI::getCloudsASL ()
{
return globals->get_options()->get_clouds_asl();
}
/**
* Set the current visibility (units??).
*/
@ -1656,33 +1674,6 @@ FGBFI::setVisibility (double visibility)
}
/**
* Switch clouds on or off.
*/
void
FGBFI::setClouds (bool clouds)
{
if (getClouds() != clouds) {
cout << "Set clouds to " << clouds << endl;
globals->get_options()->set_clouds(clouds);
needReinit();
}
}
/**
* Set the cloud height.
*/
void
FGBFI::setCloudsASL (double cloudsASL)
{
if (getCloudsASL() != cloudsASL) {
globals->get_options()->set_clouds_asl(cloudsASL);
needReinit();
}
}
////////////////////////////////////////////////////////////////////////
// Time

View file

@ -54,101 +54,136 @@ public:
// Simulation
static int getFlightModel ();
static const string getAircraft ();
static const string getAircraftDir ();
static time_t getTimeGMT ();
static const string &getGMTString ();
static bool getHUDVisible ();
static bool getPanelVisible ();
static void setFlightModel (int flightModel);
static const string &getAircraft ();
static void setAircraft (const string &aircraft);
static const string &getAircraftDir ();
static void setAircraftDir (const string &aircraftDir);
static time_t getTimeGMT ();
static void setTimeGMT (time_t time);
static const string &getGMTString ();
static bool getHUDVisible ();
static void setHUDVisible (bool hudVisible);
static bool getPanelVisible ();
static void setPanelVisible (bool panelVisible);
static int getPanelXOffset ();
static void setPanelXOffset (int i);
static int getPanelYOffset ();
static void setPanelYOffset (int i);
// Position
static double getLatitude ();
static double getLongitude ();
static double getAltitude ();
static double getAGL ();
static void setLatitude (double latitude);
static double getLongitude ();
static void setLongitude (double longitude);
static double getAltitude ();
static void setAltitude (double altitude);
static double getAGL ();
// Attitude
static double getHeading (); // true heading
static double getHeadingMag (); // exact magnetic heading
static double getPitch ();
static double getRoll ();
static void setHeading (double heading);
static double getHeadingMag (); // exact magnetic heading
static double getPitch ();
static void setPitch (double pitch);
static double getRoll ();
static void setRoll (double roll);
// Engine
static double getRPM ();
static void setRPM ( double rpm );
static double getEGT ();
static double getCHT ();
static double getMP ();
// Velocities
static double getAirspeed ();
static void setAirspeed (double speed);
static double getSideSlip ();
static double getVerticalSpeed ();
static double getSpeedNorth ();
static double getSpeedEast ();
static double getSpeedDown ();
static void setSpeedNorth (double speed);
static void setSpeedEast (double speed);
static void setSpeedDown (double speed);
// static void setSpeedNorth (double speed);
// static void setSpeedEast (double speed);
// static void setSpeedDown (double speed);
// Controls
static double getThrottle ();
static double getMixture ();
static double getPropAdvance ();
static double getFlaps ();
static double getAileron ();
static double getRudder ();
static double getElevator ();
static double getElevatorTrim ();
static double getBrakes ();
static double getLeftBrake ();
static double getRightBrake ();
static double getCenterBrake ();
static void setThrottle (double throttle);
static double getMixture ();
static void setMixture (double mixture);
static double getPropAdvance ();
static void setPropAdvance (double pitch);
static double getFlaps ();
static void setFlaps (double flaps);
static double getAileron ();
static void setAileron (double aileron);
static double getRudder ();
static void setRudder (double rudder);
static double getElevator ();
static void setElevator (double elevator);
static double getElevatorTrim ();
static void setElevatorTrim (double trim);
static double getBrakes ();
static void setBrakes (double brake);
static double getLeftBrake ();
static void setLeftBrake (double brake);
static double getRightBrake ();
static void setRightBrake (double brake);
static double getCenterBrake ();
static void setCenterBrake (double brake);
// Autopilot
static bool getAPAltitudeLock ();
static double getAPAltitude ();
static bool getAPHeadingLock ();
static double getAPHeading ();
static double getAPHeadingMag ();
static void setAPAltitudeLock (bool lock);
static double getAPAltitude ();
static void setAPAltitude (double altitude);
static bool getAPHeadingLock ();
static void setAPHeadingLock (bool lock);
static double getAPHeading ();
static void setAPHeading (double heading);
static double getAPHeadingMag ();
static void setAPHeadingMag (double heading);
static bool getAPNAV1Lock ();
@ -156,58 +191,71 @@ public:
// Radio Navigation
static double getNAV1Freq ();
static void setNAV1Freq (double freq);
static double getNAV1AltFreq ();
static void setNAV1AltFreq (double freq);
static double getNAV1Radial ();
static double getNAV1SelRadial ();
static void setNAV1SelRadial (double radial);
static double getNAV1DistDME ();
static bool getNAV1TO ();
static bool getNAV1FROM ();
static bool getNAV1InRange ();
static bool getNAV1DMEInRange ();
static double getNAV2Freq ();
static void setNAV2Freq (double freq);
static double getNAV2AltFreq ();
static void setNAV2AltFreq (double freq);
static double getNAV2Radial ();
static double getNAV2SelRadial ();
static void setNAV2SelRadial (double radial);
static double getNAV2DistDME ();
static bool getNAV2TO ();
static bool getNAV2FROM ();
static bool getNAV2InRange ();
static bool getNAV2DMEInRange ();
static double getADFFreq ();
static double getADFAltFreq ();
static double getADFRotation ();
static void setNAV1Freq (double freq);
static void setNAV1AltFreq (double freq);
static void setNAV1SelRadial (double radial);
static void setNAV2Freq (double freq);
static void setNAV2AltFreq (double freq);
static void setNAV2SelRadial (double radial);
static void setADFFreq (double freq);
static double getADFAltFreq ();
static void setADFAltFreq (double freq);
static double getADFRotation ();
static void setADFRotation (double rot);
// GPS
static const string &getTargetAirport ();
static void setTargetAirport (const string &targetAirport);
static bool getGPSLock ();
static void setGPSLock (bool lock);
static double getGPSTargetLatitude ();
static double getGPSTargetLongitude ();
static void setTargetAirport (const string &targetAirport);
static void setGPSLock (bool lock);
// Weather
static double getVisibility ();
static bool getClouds ();
static double getCloudsASL ();
static void setVisibility (double visiblity);
static void setClouds (bool clouds);
static void setCloudsASL (double cloudsASL);
// Time (this varies with time) huh, huh
@ -219,9 +267,6 @@ private:
// Will cause a linking error if invoked.
FGBFI ();
static void reinit ();
static void needReinit () { _needReinit = true; }
static bool _needReinit;
};
// end of bfi.hxx

View file

@ -663,14 +663,18 @@ int FGOptions::parse_option( const string& arg ) {
auto_coordination = FG_AUTO_COORD_ENABLED;
} else if ( arg == "--disable-hud" ) {
hud_status = false;
current_properties.setBoolValue("/sim/hud/visibility", false);
} else if ( arg == "--enable-hud" ) {
hud_status = true;
current_properties.setBoolValue("/sim/hud/visibility", true);
} else if ( arg == "--disable-panel" ) {
panel_status = false;
current_properties.setBoolValue("/sim/panel/visibility", false);
if ( current_panel != NULL )
current_panel->setVisibility(false);
} else if ( arg == "--enable-panel" ) {
panel_status = true;
current_properties.setBoolValue("/sim/panel/visibility", true);
if ( current_panel != NULL )
current_panel->setVisibility(true);
// fov *= 0.4232; /* NO!!! */

View file

@ -30,6 +30,16 @@
#include <simgear/misc/props.hxx>
// FIXME: just for the temporary
// tile cache update stuff.
#include <simgear/debug/logstream.hxx>
#include <simgear/constants.h>
#include <Aircraft/aircraft.hxx>
#include <GUI/gui.h>
#include <Scenery/tilemgr.hxx>
#include "globals.hxx"
// end FIXME
using std::istream;
using std::ostream;
@ -50,7 +60,36 @@ fgSaveFlight (ostream &output)
bool
fgLoadFlight (istream &input)
{
return readPropertyList(input, &current_properties);
bool retval = readPropertyList(input, &current_properties);
// FIXME: from keyboard.cxx
// this makes sure that the tile
// cache is updated after a restore;
// it would be better if FGFS just
// noticed the new lat/lon.
if (retval) {
bool freeze;
FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
if ( !freeze )
globals->set_freeze( true );
BusyCursor(0);
if ( global_tile_mgr.init() ) {
// Load the local scenery data
global_tile_mgr.update(
cur_fdm_state->get_Longitude() * RAD_TO_DEG,
cur_fdm_state->get_Latitude() * RAD_TO_DEG );
} else {
FG_LOG( FG_GENERAL, FG_ALERT,
"Error in Tile Manager initialization!" );
exit(-1);
}
BusyCursor(1);
if ( !freeze )
globals->set_freeze( false );
}
// end FIXME
return retval;
}
// end of save.cxx