Commit 5a0869f2 authored by Maciej Suminski's avatar Maciej Suminski

Added 'required layers' option for drawn items.

parent d51b8a87
...@@ -454,13 +454,21 @@ struct VIEW::drawItem ...@@ -454,13 +454,21 @@ struct VIEW::drawItem
{ {
GAL* gal = view->GetGAL(); GAL* gal = view->GetGAL();
aItem->ViewGetRequiredLayers( layers, layersCount );
// Conditions that have te be fulfilled for an item to be drawn
bool drawCondition = aItem->ViewIsVisible() &&
aItem->ViewGetLOD( currentLayer->id ) < view->m_scale &&
view->isEveryLayerEnabled( layers, layersCount );
if( !drawCondition )
return;
if( currentLayer->cached ) if( currentLayer->cached )
{ {
// Draw using cached information or create one // Draw using cached information or create one
int group = aItem->getGroup( currentLayer->id ); int group = aItem->getGroup( currentLayer->id );
if( group >= 0 && aItem->ViewIsVisible() && if( group >= 0 )
aItem->ViewGetLOD( currentLayer->id ) < view->m_scale )
{ {
gal->DrawGroup( group ); gal->DrawGroup( group );
} }
...@@ -472,8 +480,7 @@ struct VIEW::drawItem ...@@ -472,8 +480,7 @@ struct VIEW::drawItem
gal->EndGroup(); gal->EndGroup();
} }
} }
else if( aItem->ViewIsVisible() && else
aItem->ViewGetLOD( currentLayer->id ) < view->m_scale )
{ {
// Immediate mode // Immediate mode
view->m_painter->Draw( aItem, currentLayer->id ); view->m_painter->Draw( aItem, currentLayer->id );
...@@ -482,6 +489,7 @@ struct VIEW::drawItem ...@@ -482,6 +489,7 @@ struct VIEW::drawItem
const VIEW_LAYER* currentLayer; const VIEW_LAYER* currentLayer;
VIEW* view; VIEW* view;
int layersCount, layers[VIEW_MAX_LAYERS];
}; };
...@@ -652,6 +660,18 @@ void VIEW::clearGroupCache() ...@@ -652,6 +660,18 @@ void VIEW::clearGroupCache()
} }
bool VIEW::isEveryLayerEnabled( const int aLayers[], int aCount ) const
{
for( int i = 0; i < aCount; ++i )
{
if( !m_layers.at( aLayers[i] ).enabled )
return false;
}
return true;
}
void VIEW::RecacheAllItems( bool aImmediately ) void VIEW::RecacheAllItems( bool aImmediately )
{ {
BOX2I r; BOX2I r;
......
...@@ -48,6 +48,13 @@ void VIEW_ITEM::ViewSetVisible( bool aIsVisible ) ...@@ -48,6 +48,13 @@ void VIEW_ITEM::ViewSetVisible( bool aIsVisible )
} }
void VIEW_ITEM::ViewGetRequiredLayers( int aLayers[], int& aCount ) const
{
// By default there is no layer required
aCount = 0;
}
void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ) void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw )
{ {
m_view->invalidateItem( this, aUpdateFlags ); m_view->invalidateItem( this, aUpdateFlags );
......
...@@ -403,6 +403,9 @@ private: ...@@ -403,6 +403,9 @@ private:
return i->renderingOrder > j->renderingOrder; return i->renderingOrder > j->renderingOrder;
} }
/// Checks if every layer stored in aLayers array is enabled.
bool isEveryLayerEnabled( const int aLayers[], int aCount ) const;
/// Contains set of possible displayed layers and its properties /// Contains set of possible displayed layers and its properties
LayerMap m_layers; LayerMap m_layers;
......
...@@ -207,6 +207,16 @@ public: ...@@ -207,6 +207,16 @@ public:
*/ */
virtual void ViewGetLayers( int aLayers[], int& aCount ) const = 0; virtual void ViewGetLayers( int aLayers[], int& aCount ) const = 0;
/**
* Function ViewGetRequiredLayers()
* Returns the all the layers that are required for an item to be drawn. Eg. there is no point
* to draw netnames, when the track is not visible - so track layer should be marked as
* required.
* @param aLayers[]: output layer index array
* @param aCount: number of layer indices in aLayers[]
*/
virtual void ViewGetRequiredLayers( int aLayers[], int& aCount ) const;
/** /**
* Function ViewSetVisible() * Function ViewSetVisible()
* Sets the item visibility. * Sets the item visibility.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment