Fixed layers caching settings. Added some comments.

This commit is contained in:
Maciej Suminski 2013-08-07 10:52:50 +02:00
parent e050133c07
commit 62ea71fcae
6 changed files with 40 additions and 27 deletions

View File

@ -212,6 +212,7 @@ TOOL_ID TOOL_MANAGER::MakeToolId( const std::string& aToolName )
return currentId++; return currentId++;
} }
void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView, void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KiGfx::VIEW* aView,
KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame ) KiGfx::VIEW_CONTROLS* aViewControls, wxWindow* aFrame )
{ {

View File

@ -544,7 +544,8 @@ void VIEW::redrawRect( const BOX2I& aRect )
} }
} }
bool VIEW::IsDirty()
bool VIEW::IsDirty() const
{ {
BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers ) BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers )
{ {
@ -554,6 +555,7 @@ bool VIEW::IsDirty()
return false; return false;
} }
struct VIEW::unlinkItem struct VIEW::unlinkItem
{ {
void operator()( VIEW_ITEM* aItem ) void operator()( VIEW_ITEM* aItem )
@ -644,28 +646,32 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
for( int i = 0; i < layer_count; i++ ) for( int i = 0; i < layer_count; i++ )
{ {
if(m_layers.find(layer_indices[i]) != m_layers.end()) // Iterate through the layers used by the item
if( m_layers.find( layer_indices[i] ) != m_layers.end() )
{ {
VIEW_LAYER* l = &m_layers[layer_indices[i]]; VIEW_LAYER* l = &m_layers[layer_indices[i]];
// Mark the area occupied by the item as dirty
l->dirtyExtents = l->dirtyExtents =
l->isDirty ? aItem->ViewBBox() : l->dirtyExtents.Merge( aItem->ViewBBox() ); l->isDirty ? aItem->ViewBBox() : l->dirtyExtents.Merge( aItem->ViewBBox() );
l->isDirty = true; l->isDirty = true;
// If geometry has to be updated, then we need to reinsert the item
if( aUpdateFlags & VIEW_ITEM::GEOMETRY ) if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
{ {
l->items->Remove( aItem ); l->items->Remove( aItem );
l->items->Insert( aItem ); /* reinsert */ l->items->Insert( aItem );
aItem->deleteGroups();
} }
} }
} }
// Remove all the groups, so the item will be recached
if( aItem->storesGroups() ) if( aItem->storesGroups() )
{ {
// Clear the cached groups stored in GAL
std::vector<int> groups = aItem->getAllGroups(); std::vector<int> groups = aItem->getAllGroups();
for(std::vector<int>::iterator i = groups.begin(); i != groups.end(); i++ ) for( std::vector<int>::iterator i = groups.begin(); i != groups.end(); i++ )
{ {
m_gal->DeleteGroup( *i ); m_gal->DeleteGroup( *i );
} }

View File

@ -50,7 +50,7 @@ void VIEW_ITEM::ViewSetVisible( bool aIsVisible )
void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw ) void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw )
{ {
if(!m_view) if( !m_view )
return; return;
m_view->invalidateItem( this, aUpdateFlags ); m_view->invalidateItem( this, aUpdateFlags );
@ -124,11 +124,8 @@ void VIEW_ITEM::setGroup( int aLayer, int aId )
void VIEW_ITEM::deleteGroups() void VIEW_ITEM::deleteGroups()
{ {
if( m_groupsSize > 0 ) delete[] m_groups;
{ m_groupsSize = 0;
delete[] m_groups;
m_groupsSize = 0;
}
} }

View File

@ -99,8 +99,7 @@ protected:
///< using GAL ///< using GAL
KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.) KiGfx::WX_VIEW_CONTROLS* m_viewControls; ///< Control for VIEW (moving, zooming, etc.)
GalType m_currentGal; ///< Currently used GAL GalType m_currentGal; ///< Currently used GAL
wxLongLong m_timeStamp; TOOL_DISPATCHER* m_eventDispatcher;
TOOL_DISPATCHER* m_eventDispatcher;
}; };
#endif #endif

View File

@ -371,7 +371,12 @@ public:
*/ */
bool IsDynamic() const { return m_dynamic; } bool IsDynamic() const { return m_dynamic; }
bool IsDirty(); /**
* Function IsDirty()
* Returns true if any of the VIEW layers needs to be refreshened.
* @return True in case if any of layers is marked as dirty.
*/
bool IsDirty() const;
static const int VIEW_MAX_LAYERS = 128; ///* maximum number of layers that may be shown static const int VIEW_MAX_LAYERS = 128; ///* maximum number of layers that may be shown

View File

@ -178,6 +178,9 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
// Load module's texts (name and value) // Load module's texts (name and value)
view->Add( &module->Reference() ); view->Add( &module->Reference() );
view->Add( &module->Value() ); view->Add( &module->Value() );
// Add the module itself
view->Add( module );
} }
// Segzones (equivalent of ZONE_CONTAINER for legacy boards) // Segzones (equivalent of ZONE_CONTAINER for legacy boards)
@ -191,8 +194,8 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
m_galCanvas->Refresh(); m_galCanvas->Refresh();
// update the tool manager with the new board and its view. // update the tool manager with the new board and its view.
if(m_toolManager) if( m_toolManager )
m_toolManager->SetEnvironment( m_Pcb, view, m_galCanvas->GetViewControls(), this); m_toolManager->SetEnvironment( m_Pcb, view, m_galCanvas->GetViewControls(), this );
} }
} }
@ -799,31 +802,33 @@ void PCB_BASE_FRAME::LoadSettings()
// Apply display settings for GAL // Apply display settings for GAL
KiGfx::VIEW* view = m_galCanvas->GetView(); KiGfx::VIEW* view = m_galCanvas->GetView();
// Set rendering order of layers
for( LAYER_NUM i = 0; i < sizeof(GalLayerOrder) / sizeof(LAYER_NUM); ++i ) // Set rendering order and properties of layers
for( LAYER_NUM i = 0; (unsigned) i < sizeof(GalLayerOrder) / sizeof(LAYER_NUM); ++i )
{ {
wxASSERT( i < KiGfx::VIEW::VIEW_MAX_LAYERS ); LAYER_NUM layer = GalLayerOrder[i];
wxASSERT( layer < KiGfx::VIEW::VIEW_MAX_LAYERS );
view->SetLayerOrder( GalLayerOrder[i], i ); view->SetLayerOrder( layer, i );
view->SetLayerTarget( i, KiGfx::TARGET_NONCACHED );
if( IsCopperLayer( i ) ) if( IsCopperLayer( layer ) )
{ {
// Copper layers are required for netname layers // Copper layers are required for netname layers
view->SetRequired( GetNetnameLayer( i ), i ); view->SetRequired( GetNetnameLayer( layer ), layer );
view->SetLayerTarget( layer, KiGfx::TARGET_CACHED );
} }
else else if( IsNetnameLayer( layer ) )
if( IsNetnameLayer( i ) )
{ {
// Netnames are drawn only when scale is sufficient (level of details) // Netnames are drawn only when scale is sufficient (level of details)
// so there is no point in caching them // so there is no point in caching them
view->SetLayerTarget( i, KiGfx::TARGET_NONCACHED ); view->SetLayerTarget( layer, KiGfx::TARGET_NONCACHED );
} }
} }
// Some more required layers settings // Some more required layers settings
view->SetRequired( ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( VIAS_VISIBLE ) ); view->SetRequired( ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( VIAS_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) ); view->SetRequired( ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) ); view->SetRequired( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); view->SetRequired( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );