- catch sg_exception instead of sg_io_exception
- use guiErrorMessage - added new properties /sim/view/pilot/x-offset-m, /sim/view/pilot/y-offset-m, and /sim/view/pilot/z-offset-m to control pilot-position offset from CG
This commit is contained in:
parent
c6711fb877
commit
ff91dbfd7b
1 changed files with 66 additions and 16 deletions
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
#include "fgfs.hxx"
|
#include "fgfs.hxx"
|
||||||
#include "fg_props.hxx"
|
#include "fg_props.hxx"
|
||||||
#include "viewer.hxx"
|
#include "viewmgr.hxx"
|
||||||
|
|
||||||
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
|
||||||
SG_USING_STD(istream);
|
SG_USING_STD(istream);
|
||||||
|
@ -206,6 +206,58 @@ setGoalViewOffset (double offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pilot position offset from CG.
|
||||||
|
*/
|
||||||
|
static float
|
||||||
|
getPilotPositionXOffset ()
|
||||||
|
{
|
||||||
|
FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
|
||||||
|
float * offset = pilot_view->get_pilot_offset();
|
||||||
|
return offset[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setPilotPositionXOffset (float x)
|
||||||
|
{
|
||||||
|
FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
|
||||||
|
float * offset = pilot_view->get_pilot_offset();
|
||||||
|
pilot_view->set_pilot_offset(x, offset[1], offset[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static float
|
||||||
|
getPilotPositionYOffset ()
|
||||||
|
{
|
||||||
|
FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
|
||||||
|
float * offset = pilot_view->get_pilot_offset();
|
||||||
|
return offset[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setPilotPositionYOffset (float y)
|
||||||
|
{
|
||||||
|
FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
|
||||||
|
float * offset = pilot_view->get_pilot_offset();
|
||||||
|
pilot_view->set_pilot_offset(offset[0], y, offset[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static float
|
||||||
|
getPilotPositionZOffset ()
|
||||||
|
{
|
||||||
|
FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
|
||||||
|
float * offset = pilot_view->get_pilot_offset();
|
||||||
|
return offset[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setPilotPositionZOffset (float z)
|
||||||
|
{
|
||||||
|
FGViewer * pilot_view = globals->get_viewmgr()->get_view(0);
|
||||||
|
float * offset = pilot_view->get_pilot_offset();
|
||||||
|
pilot_view->set_pilot_offset(offset[0], offset[1], z);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current Zulu time.
|
* Return the current Zulu time.
|
||||||
*/
|
*/
|
||||||
|
@ -922,7 +974,6 @@ setFDMDataLogging (bool state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Tie the properties.
|
// Tie the properties.
|
||||||
|
@ -938,6 +989,15 @@ fgInitProps ()
|
||||||
fgSetArchivable("/sim/view/offset-deg");
|
fgSetArchivable("/sim/view/offset-deg");
|
||||||
fgTie("/sim/view/goal-offset-deg", getGoalViewOffset, setGoalViewOffset);
|
fgTie("/sim/view/goal-offset-deg", getGoalViewOffset, setGoalViewOffset);
|
||||||
fgSetArchivable("/sim/view/goal-offset-deg");
|
fgSetArchivable("/sim/view/goal-offset-deg");
|
||||||
|
fgTie("/sim/view/pilot/x-offset-m",
|
||||||
|
getPilotPositionXOffset, setPilotPositionXOffset);
|
||||||
|
fgSetArchivable("/sim/view/pilot/x-offset-m");
|
||||||
|
fgTie("/sim/view/pilot/y-offset-m",
|
||||||
|
getPilotPositionYOffset, setPilotPositionYOffset);
|
||||||
|
fgSetArchivable("/sim/view/pilot/y-offset-m");
|
||||||
|
fgTie("/sim/view/pilot/z-offset-m",
|
||||||
|
getPilotPositionZOffset, setPilotPositionZOffset);
|
||||||
|
fgSetArchivable("/sim/view/pilot/z-offset-m");
|
||||||
fgTie("/sim/time/gmt", getDateString, setDateString);
|
fgTie("/sim/time/gmt", getDateString, setDateString);
|
||||||
fgSetArchivable("/sim/time/gmt");
|
fgSetArchivable("/sim/time/gmt");
|
||||||
fgTie("/sim/time/gmt-string", getGMTString);
|
fgTie("/sim/time/gmt-string", getGMTString);
|
||||||
|
@ -1044,13 +1104,8 @@ fgSaveFlight (ostream &output)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
writeProperties(output, globals->get_props());
|
writeProperties(output, globals->get_props());
|
||||||
} catch (const sg_io_exception &e) {
|
} catch (const sg_exception &e) {
|
||||||
string message = "Error saving flight: ";
|
guiErrorMessage("Error saving flight: ", e);
|
||||||
message += e.getMessage();
|
|
||||||
message += "\n at ";
|
|
||||||
message += e.getLocation().asString();
|
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, message);
|
|
||||||
mkDialog(message.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1066,13 +1121,8 @@ fgLoadFlight (istream &input)
|
||||||
SGPropertyNode props;
|
SGPropertyNode props;
|
||||||
try {
|
try {
|
||||||
readProperties(input, &props);
|
readProperties(input, &props);
|
||||||
} catch (const sg_io_exception &e) {
|
} catch (const sg_exception &e) {
|
||||||
string message = "Error reading saved flight: ";
|
guiErrorMessage("Error reading saved flight: ", e);
|
||||||
message += e.getMessage();
|
|
||||||
message += "\n at ";
|
|
||||||
message += e.getLocation().asString();
|
|
||||||
SG_LOG(SG_INPUT, SG_ALERT, message);
|
|
||||||
mkDialog(message.c_str());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
copyProperties(&props, globals->get_props());
|
copyProperties(&props, globals->get_props());
|
||||||
|
|
Loading…
Add table
Reference in a new issue