VIEW: added CalculateExtents() method

This commit is contained in:
Tomasz Włostowski 2014-05-14 13:48:29 +02:00
parent 922bf1ddea
commit 5bf50ee910
2 changed files with 39 additions and 0 deletions

View File

@ -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;
}

View File

@ -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 );