diff Framework/Scene2D/Scene2D.cpp @ 1374:1e4878ed1d77

added GetBoundingBox to Scene2D
author Alain Mazy <alain@mazy.be>
date Mon, 20 Apr 2020 18:20:47 +0200
parents 8a0a62189f46
children 6ea4062c1a0d
line wrap: on
line diff
--- a/Framework/Scene2D/Scene2D.cpp	Wed Apr 08 14:14:51 2020 +0200
+++ b/Framework/Scene2D/Scene2D.cpp	Mon Apr 20 18:20:47 2020 +0200
@@ -222,22 +222,29 @@
     canvasToScene_ = inverse;
   }
 
+  void Scene2D::GetBoundingBox(Extent2D &target) const
+  {
+    target.Reset();
+
+    for (Content::const_iterator it = content_.begin();
+         it != content_.end(); ++it)
+    {
+      assert(it->second != NULL);
+
+      Extent2D tmp;
+      if (it->second->GetLayer().GetBoundingBox(tmp))
+      {
+        target.Union(tmp);
+      }
+    }
+  }
+
   void Scene2D::FitContent(unsigned int canvasWidth,
                            unsigned int canvasHeight)
   {
     Extent2D extent;
 
-    for (Content::const_iterator it = content_.begin(); 
-         it != content_.end(); ++it)
-    {
-      assert(it->second != NULL);
-      
-      Extent2D tmp;
-      if (it->second->GetLayer().GetBoundingBox(tmp))
-      {
-        extent.Union(tmp);
-      }
-    }
+    GetBoundingBox(extent);
 
     if (!extent.IsEmpty())
     {