diff --git a/common/view/view.cpp b/common/view/view.cpp index 4bf71ec638..5e213c0c1d 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -1019,3 +1019,38 @@ void VIEW::UpdateItems() m_needsUpdate.clear(); } + +struct VIEW::extentsVisitor { + BOX2I extents; + bool first; + + extentsVisitor() + { + first = true; + } + + bool operator()( VIEW_ITEM* aItem ) + { + if(first) + extents = aItem->ViewBBox(); + else + extents.Merge ( aItem->ViewBBox() ); + return false; + } + }; + +const BOX2I VIEW::CalculateExtents() +{ + + extentsVisitor v; + BOX2I fullScene; + fullScene.SetMaximum(); + + + BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers ) + { + l->items->Query( fullScene, v ); + } + + return v.extents; +} diff --git a/include/view/view.h b/include/view/view.h index 694042724f..2930af1844 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -507,6 +507,8 @@ public: */ void UpdateItems(); + const BOX2I CalculateExtents() ; + static const int VIEW_MAX_LAYERS = 128; ///< maximum number of layers that may be shown private: @@ -534,6 +536,8 @@ private: struct unlinkItem; struct updateItemsColor; struct changeItemsDepth; + struct extentsVisitor; + ///* Redraws contents within rect aRect void redrawRect( const BOX2I& aRect );