Commit 87a9964c authored by Maciej Suminski's avatar Maciej Suminski

VIEW_GROUP now does not change depth during drawing. Introduced functions for...

VIEW_GROUP now does not change depth during drawing. Introduced functions for manipulating stored items.
FIxed problem of overlay being covered by other layers while panning.
Few minor fixes.
parent e013f3e8
......@@ -71,16 +71,6 @@ void VIEW_GROUP::Clear()
}
void VIEW_GROUP::FreeItems()
{
BOOST_FOREACH( VIEW_ITEM* item, m_items )
{
delete item;
}
m_items.clear();
}
unsigned int VIEW_GROUP::GetSize() const
{
return m_items.size();
......@@ -98,6 +88,7 @@ const BOX2I VIEW_GROUP::ViewBBox() const
void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal ) const
{
PAINTER* painter = m_view->GetPainter();
aGal->PushDepth();
// Draw all items immediately (without caching)
BOOST_FOREACH( VIEW_ITEM* item, m_items )
......@@ -110,13 +101,15 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal ) const
{
if( m_view->IsCached( layers[i] ) && m_view->IsLayerVisible( layers[i] ) )
{
aGal->SetLayerDepth( m_view->GetLayerOrder( layers[i] ) );
aGal->AdvanceDepth();
if( !painter->Draw( item, layers[i] ) )
item->ViewDraw( layers[i], aGal ); // Alternative drawing method
}
}
}
aGal->PopDepth();
}
......@@ -128,6 +121,34 @@ void VIEW_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const
}
void VIEW_GROUP::FreeItems()
{
BOOST_FOREACH( VIEW_ITEM* item, m_items )
{
delete item;
}
m_items.clear();
}
void VIEW_GROUP::ItemsSetVisibility( bool aVisible )
{
std::set<VIEW_ITEM*>::const_iterator it, it_end;
for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it )
(*it)->ViewSetVisible( aVisible );
}
void VIEW_GROUP::ItemsViewUpdate( VIEW_ITEM::ViewUpdateFlags aFlags )
{
std::set<VIEW_ITEM*>::const_iterator it, it_end;
for( it = m_items.begin(), it_end = m_items.end(); it != it_end; ++it )
(*it)->ViewUpdate( aFlags );
}
void VIEW_GROUP::updateBbox()
{
// Save the used VIEW, as it used nulled during Remove()
......@@ -137,3 +158,5 @@ void VIEW_GROUP::updateBbox()
view->Remove( this );
view->Add( this );
}
......@@ -38,13 +38,11 @@ namespace KiGfx
*/
enum RenderTarget
{
TARGET_CACHED, ///< Main rendering target (cached)
TARGET_CACHED = 0, ///< Main rendering target (cached)
TARGET_NONCACHED, ///< Auxiliary rendering target (noncached)
TARGET_OVERLAY ///< Items that may change while the view stays the same (noncached)
TARGET_OVERLAY, ///< Items that may change while the view stays the same (noncached)
TARGETS_NUMBER ///< Number of available rendering targets
};
/// Number of available rendering targets
static const int TARGETS_NUMBER = 3;
}
#endif /* DEFINITIONS_H_ */
......@@ -798,7 +798,7 @@ public:
*/
inline void AdvanceDepth()
{
layerDepth -= std::numeric_limits<double>::epsilon();
layerDepth -= 0.001;
}
/**
......
......@@ -147,6 +147,22 @@ public:
return m_view;
}
/**
* Function ItemsSetVisibility()
* Sets visibility of items stored in the VIEW_GROUP.
*
* @param aVisible decides if items should be visible or not.
*/
virtual void ItemsSetVisibility( bool aVisible );
/**
* Function ItemsViewUpdate()
* Updates items stored in the VIEW_GROUP.
*
* @param aFlags determines the way in which items will be updated.
*/
virtual void ItemsViewUpdate( VIEW_ITEM::ViewUpdateFlags aFlags );
protected:
/// These functions cannot be used with VIEW_GROUP as they are intended only to work with
/// singular VIEW_ITEMs (there is only one-to-one relation between item/layer combination and
......
......@@ -790,7 +790,8 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
LAYER_NUM layers[] = {
GetNetnameLayer( aLayer ), ITEM_GAL_LAYER( VIAS_VISIBLE ),
ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ),
ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE )
ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
ITEM_GAL_LAYER( SELECTION ), ITEM_GAL_LAYER( GP_OVERLAY )
};
for( unsigned int i = 0; i < sizeof( layers ) / sizeof( LAYER_NUM ); ++i )
......@@ -830,7 +831,7 @@ void PCB_EDIT_FRAME::setTopLayer( LAYER_NUM aLayer )
GetNetnameLayer( aLayer ), ITEM_GAL_LAYER( VIAS_VISIBLE ),
ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ),
ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ),
ITEM_GAL_LAYER( SELECTION )
ITEM_GAL_LAYER( SELECTION ), ITEM_GAL_LAYER( GP_OVERLAY )
};
for( unsigned int i = 0; i < sizeof( layers ) / sizeof( LAYER_NUM ); ++i )
......
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