From 87a9964c780720ede33e73ce83afa898220ff4fe Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 1 Oct 2013 16:55:33 +0200 Subject: [PATCH] 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. --- common/view/view_group.cpp | 45 ++++++++++++++++++------ include/gal/definitions.h | 8 ++--- include/gal/graphics_abstraction_layer.h | 2 +- include/view/view_group.h | 16 +++++++++ pcbnew/pcbframe.cpp | 5 +-- 5 files changed, 57 insertions(+), 19 deletions(-) diff --git a/common/view/view_group.cpp b/common/view/view_group.cpp index dfaf595c5c..996350b1f3 100644 --- a/common/view/view_group.cpp +++ b/common/view/view_group.cpp @@ -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::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::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 ); } + + diff --git a/include/gal/definitions.h b/include/gal/definitions.h index ce18235bd1..8a506852c2 100644 --- a/include/gal/definitions.h +++ b/include/gal/definitions.h @@ -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_ */ diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 77cb3c48a8..098635d96c 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -798,7 +798,7 @@ public: */ inline void AdvanceDepth() { - layerDepth -= std::numeric_limits::epsilon(); + layerDepth -= 0.001; } /** diff --git a/include/view/view_group.h b/include/view/view_group.h index 54dbd16521..5414b041f2 100644 --- a/include/view/view_group.h +++ b/include/view/view_group.h @@ -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 diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 082ffb7bed..67f905f5fc 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -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 )