]> git.mxchange.org Git - flightgear.git/commitdiff
View-manager binds like a normal subsystem.
authorJames Turner <zakalawe@mac.com>
Thu, 21 Jan 2016 03:38:34 +0000 (22:38 -0500)
committerJames Turner <zakalawe@mac.com>
Wed, 17 Feb 2016 21:25:39 +0000 (21:25 +0000)
- no longer need the unusual init-bind order

src/Viewer/viewer.cxx
src/Viewer/viewmgr.cxx
src/Viewer/viewmgr.hxx

index 1421ab652ce6cbaafabef4cef6935210bf824043..e7a90b22d6e95bc4da08caab00ab2f877905f314 100644 (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);
index 503db730c8441077f1562a5bd70cdd120439b245..588bbf2e587ad4a8992eb546913ce841f6b1161d 100644 (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,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
 {
index f13ffeee867453ebbe64e4f68515cf849b554131..9dd6ed33c0513109cdd35af2bdea29df25e60825 100644 (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);