1
0
Fork 0

View-manager binds like a normal subsystem.

- no longer need the unusual init-bind order
This commit is contained in:
James Turner 2016-01-20 22:38:34 -05:00
parent 00a4f1ecbb
commit 27d739084a
3 changed files with 35 additions and 63 deletions

View file

@ -251,9 +251,16 @@ View::bind ()
_tiedProperties.Tie("field-of-view", this,
&View::get_fov, &View::set_fov);
&View::get_fov, &View::set_fov,
false);
fgSetArchivable("/sim/current-view/field-of-view");
_tiedProperties.Tie("aspect-ratio-multiplier", this,
&View::get_aspect_ratio_multiplier,
&View::set_aspect_ratio_multiplier,
false);
// expose various quaternions under the debug/ subtree
_tiedProperties.Tie("debug/orientation-w", this, &View::getOrientation_w);
_tiedProperties.Tie("debug/orientation-x", this, &View::getOrientation_x);

View file

@ -61,9 +61,6 @@ FGViewMgr::init ()
}
inited = true;
for (unsigned int i = 0; i < config_list.size(); i++) {
SGPropertyNode *n = config_list[i];
@ -75,8 +72,6 @@ FGViewMgr::init ()
}
}
do_bind();
get_current_view()->bind();
}
@ -113,8 +108,33 @@ typedef double (FGViewMgr::*double_getter)() const;
void
FGViewMgr::bind()
{
// view-manager code was designed to init before bind, so
// this is a no-op; init() calls the real bind() impl below
// these are bound to the current view properties
_tiedProperties.setRoot(fgGetNode("/sim/current-view", true));
_tiedProperties.Tie("view-number", this,
&FGViewMgr::getView, &FGViewMgr::setView, false);
_viewNumberProp = _tiedProperties.getRoot()->getNode("view-number");
_viewNumberProp->setAttribute(SGPropertyNode::ARCHIVE, false);
_viewNumberProp->setAttribute(SGPropertyNode::PRESERVE, true);
_tiedProperties.Tie("axes/long", this,
(double_getter)0, &FGViewMgr::setViewAxisLong);
fgSetArchivable("/sim/current-view/axes/long");
_tiedProperties.Tie("axes/lat", this,
(double_getter)0, &FGViewMgr::setViewAxisLat);
fgSetArchivable("/sim/current-view/axes/lat");
_tiedProperties.Tie("ground-level-nearplane-m", this,
&FGViewMgr::getNear_m, &FGViewMgr::setNear_m);
fgSetArchivable("/sim/current-view/ground-level-nearplane-m");
_tiedProperties.Tie("viewer-lon-deg", this, &FGViewMgr::getViewLon_deg);
_tiedProperties.Tie("viewer-lat-deg", this, &FGViewMgr::getViewLat_deg);
_tiedProperties.Tie("viewer-elev-ft", this, &FGViewMgr::getViewElev_ft);
current_x_offs = fgGetNode("/sim/current-view/x-offset-m", true);
current_y_offs = fgGetNode("/sim/current-view/y-offset-m", true);
@ -122,44 +142,8 @@ FGViewMgr::bind()
target_x_offs = fgGetNode("/sim/current-view/target-x-offset-m", true);
target_y_offs = fgGetNode("/sim/current-view/target-y-offset-m", true);
target_z_offs = fgGetNode("/sim/current-view/target-z-offset-m", true);
}
void
FGViewMgr::do_bind()
{
// these are bound to the current view properties
_tiedProperties.setRoot(fgGetNode("/sim/current-view", true));
_tiedProperties.Tie("view-number", this,
&FGViewMgr::getView, &FGViewMgr::setView);
_viewNumberProp = _tiedProperties.getRoot()->getNode("view-number");
_viewNumberProp->setAttribute(SGPropertyNode::ARCHIVE, false);
_viewNumberProp->setAttribute(SGPropertyNode::PRESERVE, true);
_tiedProperties.Tie("axes/long", this,
(double_getter)0, &FGViewMgr::setViewAxisLong);
fgSetArchivable("/sim/current-view/axes/long");
_tiedProperties.Tie("axes/lat", this,
(double_getter)0, &FGViewMgr::setViewAxisLat);
fgSetArchivable("/sim/current-view/axes/lat");
_tiedProperties.Tie("aspect-ratio-multiplier", this,
&FGViewMgr::getARM_deg, &FGViewMgr::setARM_deg);
fgSetArchivable("/sim/current-view/field-of-view");
_tiedProperties.Tie("ground-level-nearplane-m", this,
&FGViewMgr::getNear_m, &FGViewMgr::setNear_m);
fgSetArchivable("/sim/current-view/ground-level-nearplane-m");
_tiedProperties.Tie("viewer-lon-deg", this, &FGViewMgr::getViewLon_deg);
_tiedProperties.Tie("viewer-lat-deg", this, &FGViewMgr::getViewLat_deg);
_tiedProperties.Tie("viewer-elev-ft", this, &FGViewMgr::getViewElev_ft);
}
void
FGViewMgr::unbind ()
@ -447,21 +431,6 @@ FGViewMgr::setView (int newview)
update(0.0);
}
double
FGViewMgr::getARM_deg () const
{
const flightgear::View * view = get_current_view();
return (view == 0 ? 0 : view->get_aspect_ratio_multiplier());
}
void
FGViewMgr::setARM_deg (double aspect_ratio_multiplier)
{
flightgear::View * view = get_current_view();
if (view != 0)
view->set_aspect_ratio_multiplier(aspect_ratio_multiplier);
}
double
FGViewMgr::getNear_m () const
{

View file

@ -79,8 +79,6 @@ public:
static const char* subsystemName() { return "view-manager"; }
private:
void do_bind();
simgear::TiedPropertyList _tiedProperties;
double axis_long;
@ -103,8 +101,6 @@ private:
double getViewTargetZOffset_m () const;
void setViewTargetZOffset_m (double z);
double getARM_deg () const; // Aspect Ratio Multiplier
void setARM_deg (double fov);
double getNear_m () const;
void setNear_m (double near_m);
void setViewAxisLong (double axis);