1
0
Fork 0

Data logging patches from Jon Berndt

Fix for model loading under plib-1.2.x in main.cxx
This commit is contained in:
curt 2001-04-05 15:39:37 +00:00
parent 96fbc75b7c
commit 397a83d69f
7 changed files with 84 additions and 37 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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:

View file

@ -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();
}

View file

@ -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

View file

@ -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;

View file

@ -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() );