From 397a83d69f4203abc2cc90519814d268bc23f4bd Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 5 Apr 2001 15:39:37 +0000 Subject: [PATCH] Data logging patches from Jon Berndt Fix for model loading under plib-1.2.x in main.cxx --- src/FDM/JSBSim.cxx | 16 ++++++++ src/FDM/JSBSim.hxx | 2 + src/FDM/JSBSim/FGOutput.h | 1 + src/FDM/flight.cxx | 5 +++ src/FDM/flight.hxx | 5 +++ src/Main/keyboard.cxx | 85 ++++++++++++++++++++++----------------- src/Main/main.cxx | 7 +++- 7 files changed, 84 insertions(+), 37 deletions(-) diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx index d8defe1a3..bc31e1a17 100644 --- a/src/FDM/JSBSim.cxx +++ b/src/FDM/JSBSim.cxx @@ -431,6 +431,22 @@ void FGJSBsim::snap_shot(void) { } +bool FGJSBsim::ToggleDataLogging(void) { + return fdmex->GetOutput()->Toggle(); +} + + +bool FGJSBsim::ToggleDataLogging(bool state) { + if (state) { + fdmex->GetOutput()->Enable(); + return true; + } else { + fdmex->GetOutput()->Disable(); + return false; + } +} + + //Positions void FGJSBsim::set_Latitude(double lat) { double sea_level_radius_meters,lat_geoc; diff --git a/src/FDM/JSBSim.hxx b/src/FDM/JSBSim.hxx index b6f50b435..3c749c4c8 100644 --- a/src/FDM/JSBSim.hxx +++ b/src/FDM/JSBSim.hxx @@ -194,6 +194,8 @@ public: @param multiloop number of times to loop through the FDM @return true if successful */ bool update( int multiloop ); + bool ToggleDataLogging(bool state); + bool ToggleDataLogging(void); private: FGFDMExec *fdmex; diff --git a/src/FDM/JSBSim/FGOutput.h b/src/FDM/JSBSim/FGOutput.h index 5d5c91c27..96aafb63f 100644 --- a/src/FDM/JSBSim/FGOutput.h +++ b/src/FDM/JSBSim/FGOutput.h @@ -79,6 +79,7 @@ public: void SetSubsystems(int tt) {SubSystems = tt;} inline void Enable(void) { enabled = true; } inline void Disable(void) { enabled = false; } + inline bool Toggle(void) {enabled = !enabled; return enabled;} protected: diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index 7d7f97233..a53a6680c 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -577,3 +577,8 @@ void FGInterface::_busdump(void) { SG_LOG(SG_FLIGHT,SG_INFO,"altitude_agl: " << altitude_agl ); } + +void fgToggleFDMdataLogging(void) { + cur_fdm_state->ToggleDataLogging(); +} + diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 86d2ca523..1017127d1 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -447,6 +447,8 @@ public: virtual void unbind (); virtual void update (); virtual bool update( int multi_loop ); + virtual bool ToggleDataLogging(bool state) {}; + virtual bool ToggleDataLogging(void) {}; // Define the various supported flight models (many not yet implemented) enum { @@ -1134,5 +1136,8 @@ void fgFDMForceAltitude(const string &model, double alt_meters); // Set the local ground elevation void fgFDMSetGroundElevation(const string &model, double alt_meters); +// Toggle data logging on/off +void fgToggleFDMdataLogging(void); + #endif // _FLIGHT_HXX diff --git a/src/Main/keyboard.cxx b/src/Main/keyboard.cxx index f9763949a..b1dea16f0 100644 --- a/src/Main/keyboard.cxx +++ b/src/Main/keyboard.cxx @@ -449,53 +449,66 @@ void GLUTspecialkey(int k, int x, int y) { return; } case GLUT_KEY_F3: { - string panel_path = - fgGetString("/sim/panel/path", "Panels/Default/default.xml"); - FGPanel * new_panel = fgReadPanel(panel_path); - if (new_panel == 0) { - SG_LOG(SG_INPUT, SG_ALERT, - "Error reading new panel from " << panel_path); - return; - } - SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path); - current_panel->unbind(); - delete current_panel; - current_panel = new_panel; - return; + string panel_path = + fgGetString("/sim/panel/path", "Panels/Default/default.xml"); + FGPanel * new_panel = fgReadPanel(panel_path); + if (new_panel == 0) { + SG_LOG(SG_INPUT, SG_ALERT, + "Error reading new panel from " << panel_path); + return; + } + SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path); + current_panel->unbind(); + delete current_panel; + current_panel = new_panel; + return; } case GLUT_KEY_F4: { - SGPath props_path(globals->get_fg_root()); - props_path.append("preferences.xml"); - SG_LOG(SG_INPUT, SG_INFO, "Rereading global preferences"); - if (!readProperties(props_path.str(), globals->get_props())) { - SG_LOG(SG_INPUT, SG_ALERT, - "Failed to reread global preferences from " - << props_path.str()); - } else { - SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences"); - } - return; + SGPath props_path(globals->get_fg_root()); + props_path.append("preferences.xml"); + SG_LOG(SG_INPUT, SG_INFO, "Rereading global preferences"); + if (!readProperties(props_path.str(), globals->get_props())) { + SG_LOG(SG_INPUT, SG_ALERT, + "Failed to reread global preferences from " + << props_path.str()); + } else { + SG_LOG(SG_INPUT, SG_INFO, "Finished Reading global preferences"); + } + return; } case GLUT_KEY_F5: { - current_panel->setYOffset(current_panel->getYOffset() - 5); - fgReshape(fgGetInt("/sim/startup/xsize"), - fgGetInt("/sim/startup/ysize")); - return; + current_panel->setYOffset(current_panel->getYOffset() - 5); + fgReshape(fgGetInt("/sim/startup/xsize"), + fgGetInt("/sim/startup/ysize")); + return; } case GLUT_KEY_F6: { - current_panel->setYOffset(current_panel->getYOffset() + 5); - fgReshape(fgGetInt("/sim/startup/xsize"), - fgGetInt("/sim/startup/ysize")); - return; + current_panel->setYOffset(current_panel->getYOffset() + 5); + fgReshape(fgGetInt("/sim/startup/xsize"), + fgGetInt("/sim/startup/ysize")); + return; } case GLUT_KEY_F7: { - current_panel->setXOffset(current_panel->getXOffset() - 5); - return; + current_panel->setXOffset(current_panel->getXOffset() - 5); + return; } case GLUT_KEY_F8: { - current_panel->setXOffset(current_panel->getXOffset() + 5); - return; + current_panel->setXOffset(current_panel->getXOffset() + 5); + return; } + // case GLUT_KEY_F9: { + // return; + // } + case GLUT_KEY_F10: { + fgToggleFDMdataLogging(); + return; + } + // case GLUT_KEY_F11: { + // return; + // } + // case GLUT_KEY_F12: { + // return; + // } case GLUT_KEY_END: // numeric keypad 1 v->set_goal_view_offset( SGD_PI * 0.75 ); return; diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 30caafe1f..c4b6cd0de 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -1577,8 +1577,13 @@ int main( int argc, char **argv ) { fgGetString("/sim/model/path", "Models/Geometry/glider.ac"); SGPath full_model = globals->get_fg_root(); full_model.append(acmodel_path); - // this should be redundant... + +#if !defined( PLIB_1_2_X ) + // this should be redundant ... but it breaks for relative paths + // w/ plib-1.2.0 ssgModelPath( (char *)full_model.dir().c_str() ); +#endif + ssgTexturePath( (char *)full_model.dir().c_str() ); ssgEntity *acmodel_obj = ssgLoad( (char *)full_model.c_str() );