Added 'required layers' option for drawn items.
This commit is contained in:
parent
d51b8a8744
commit
5a0869f2e2
|
@ -454,13 +454,21 @@ struct VIEW::drawItem
|
|||
{
|
||||
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 )
|
||||
{
|
||||
// Draw using cached information or create one
|
||||
int group = aItem->getGroup( currentLayer->id );
|
||||
|
||||
if( group >= 0 && aItem->ViewIsVisible() &&
|
||||
aItem->ViewGetLOD( currentLayer->id ) < view->m_scale )
|
||||
if( group >= 0 )
|
||||
{
|
||||
gal->DrawGroup( group );
|
||||
}
|
||||
|
@ -472,8 +480,7 @@ struct VIEW::drawItem
|
|||
gal->EndGroup();
|
||||
}
|
||||
}
|
||||
else if( aItem->ViewIsVisible() &&
|
||||
aItem->ViewGetLOD( currentLayer->id ) < view->m_scale )
|
||||
else
|
||||
{
|
||||
// Immediate mode
|
||||
view->m_painter->Draw( aItem, currentLayer->id );
|
||||
|
@ -482,6 +489,7 @@ struct VIEW::drawItem
|
|||
|
||||
const VIEW_LAYER* currentLayer;
|
||||
VIEW* view;
|
||||
int layersCount, layers[VIEW_MAX_LAYERS];
|
||||
};
|
||||
|
||||
|
||||
|
@ -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 )
|
||||
{
|
||||
BOX2I r;
|
||||
|
|
|
@ -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 )
|
||||
{
|
||||
m_view->invalidateItem( this, aUpdateFlags );
|
||||
|
|
|
@ -403,6 +403,9 @@ private:
|
|||
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
|
||||
LayerMap m_layers;
|
||||
|
||||
|
|
|
@ -207,6 +207,16 @@ public:
|
|||
*/
|
||||
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()
|
||||
* Sets the item visibility.
|
||||
|
|
Loading…
Reference in New Issue