From 27d739084a1ad107d0de323df7705def9fb40fa5 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 20 Jan 2016 22:38:34 -0500 Subject: [PATCH] View-manager binds like a normal subsystem. - no longer need the unusual init-bind order --- src/Viewer/viewer.cxx | 9 ++++- src/Viewer/viewmgr.cxx | 77 +++++++++++++----------------------------- src/Viewer/viewmgr.hxx | 4 --- 3 files changed, 31 insertions(+), 59 deletions(-) diff --git a/src/Viewer/viewer.cxx b/src/Viewer/viewer.cxx index 1421ab652..e7a90b22d 100644 --- a/src/Viewer/viewer.cxx +++ b/src/Viewer/viewer.cxx @@ -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); diff --git a/src/Viewer/viewmgr.cxx b/src/Viewer/viewmgr.cxx index 503db730c..588bbf2e5 100644 --- a/src/Viewer/viewmgr.cxx +++ b/src/Viewer/viewmgr.cxx @@ -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,54 +108,43 @@ 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 - - current_x_offs = fgGetNode("/sim/current-view/x-offset-m", true); - current_y_offs = fgGetNode("/sim/current-view/y-offset-m", true); - current_z_offs = fgGetNode("/sim/current-view/z-offset-m", true); - 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)); + // these are bound to the current view properties + _tiedProperties.setRoot(fgGetNode("/sim/current-view", true)); _tiedProperties.Tie("view-number", this, - &FGViewMgr::getView, &FGViewMgr::setView); + &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/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("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("aspect-ratio-multiplier", this, - &FGViewMgr::getARM_deg, &FGViewMgr::setARM_deg); - fgSetArchivable("/sim/current-view/field-of-view"); + _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); - _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); + current_z_offs = fgGetNode("/sim/current-view/z-offset-m", true); + 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::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 { diff --git a/src/Viewer/viewmgr.hxx b/src/Viewer/viewmgr.hxx index f13ffeee8..9dd6ed33c 100644 --- a/src/Viewer/viewmgr.hxx +++ b/src/Viewer/viewmgr.hxx @@ -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); -- 2.39.5