]> git.mxchange.org Git - simgear.git/commitdiff
Expose reloading Canvas placements
authorThomas Geymayer <tomgey@gmail.com>
Wed, 6 Feb 2013 00:19:24 +0000 (01:19 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Wed, 6 Feb 2013 00:19:24 +0000 (01:19 +0100)
simgear/canvas/Canvas.cxx
simgear/canvas/Canvas.hxx

index 5ab19006048b4c575777454d85f09f1bd0286be6..4117c7afcba133df326fb34688abf3d4d2d03d9b 100644 (file)
@@ -168,11 +168,7 @@ namespace canvas
       {
         // Resizing causes a new texture to be created so we need to reapply all
         // existing placements
-        for(size_t i = 0; i < _placements.size(); ++i)
-        {
-          if( !_placements[i].empty() )
-            _dirty_placements.push_back( _placements[i].front()->getProps() );
-        }
+        reloadPlacements();
       }
 
       osg::Camera* camera = _texture.getCamera();
@@ -491,6 +487,24 @@ namespace canvas
     return _cull_callback;
   }
 
+  //----------------------------------------------------------------------------
+  void Canvas::reloadPlacements(const std::string& type)
+  {
+    for(size_t i = 0; i < _placements.size(); ++i)
+    {
+      if( _placements[i].empty() )
+        continue;
+
+      SGPropertyNode* child = _placements[i].front()->getProps();
+      if(    type.empty()
+             // reload if type matches or no type specified
+          || child->getStringValue("type", type.c_str()) == type )
+      {
+        _dirty_placements.push_back(child);
+      }
+    }
+  }
+
   //----------------------------------------------------------------------------
   void Canvas::addPlacementFactory( const std::string& type,
                                     PlacementFactory factory )
index 4d8239c3bb79939f1069280ea661d17ef666d689..efb5bdc2d32ef3f99ff8af67181f971c346763fb 100644 (file)
@@ -130,6 +130,7 @@ namespace canvas
 
       CullCallbackPtr getCullCallback() const;
 
+      void reloadPlacements( const std::string& type = std::string() );
       static void addPlacementFactory( const std::string& type,
                                        PlacementFactory factory );