kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #30123
Speed improvements for SELECT / DESELECT in GAL
When I was working on speed improvements for DUPLICATE action in GAL, I
also discovered that the select / deselect functions were very slow.
Ref: https://lists.launchpad.net/kicad-developers/msg29539.html
The attached patch reduces time taken to select / deselect items by ~75%
Test Case: ~500 SSOP footprints, select all / deselect all
Essentially, selecting and deselecting forced an invalidation of the item
layer set, which quickly adds up in terms of time taken to regenerate layer
data.
Now only KIGFX::COLOR is invalidated.
Cheers,
Oliver
From c4dad0faa6671014cffd1466d8cd73f06d9bf62c Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@xxxxxxxxx>
Date: Tue, 25 Jul 2017 00:18:09 +1000
Subject: [PATCH] Speed improvement for select / deselect in GAL
- No longer invalidates the item layers
- For multiple items, this results in a drastic speed improvement
---
common/view/view.cpp | 4 ++++
pcbnew/tools/selection_tool.cpp | 14 +++++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/common/view/view.cpp b/common/view/view.cpp
index f46c147..cc6c740 100644
--- a/common/view/view.cpp
+++ b/common/view/view.cpp
@@ -1081,9 +1081,13 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
{
// updateLayers updates geometry too, so we do not have to update both of them at the same time
if( aUpdateFlags & LAYERS )
+ {
updateLayers( aItem );
+ }
else if( aUpdateFlags & GEOMETRY )
+ {
updateBbox( aItem );
+ }
int layers[VIEW_MAX_LAYERS], layers_count;
aItem->ViewGetLayers( layers, layers_count );
diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp
index 1d73d25..b9e2e30 100644
--- a/pcbnew/tools/selection_tool.cpp
+++ b/pcbnew/tools/selection_tool.cpp
@@ -426,7 +426,9 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag )
{
case 0:
if( !m_additive && anyCollected )
+ {
clearSelection();
+ }
return false;
@@ -449,7 +451,9 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag )
else if( collector.GetCount() > 1 )
{
if( aOnDrag )
+ {
Wait( TOOL_EVENT( TC_ANY, TA_MOUSE_UP, BUT_LEFT ) );
+ }
item = disambiguationMenu( &collector );
@@ -1517,7 +1521,7 @@ void SELECTION_TOOL::selectVisually( BOARD_ITEM* aItem )
// Hide the original item, so it is shown only on overlay
aItem->SetSelected();
view()->Hide( aItem, true );
- view()->Update( aItem, KIGFX::GEOMETRY );
+ view()->Update( aItem, KIGFX::COLOR );
// Modules are treated in a special way - when they are selected, we have to
// unselect all the parts that make the module, not the module itself
@@ -1528,8 +1532,8 @@ void SELECTION_TOOL::selectVisually( BOARD_ITEM* aItem )
{
item->SetSelected();
view()->Hide( item, true );
- view()->Update( item, KIGFX::GEOMETRY );
- } );
+ view()->Update( item, KIGFX::COLOR );
+ });
}
view()->Update( &m_selection );
@@ -1541,7 +1545,7 @@ void SELECTION_TOOL::unselectVisually( BOARD_ITEM* aItem )
// Restore original item visibility
aItem->ClearSelected();
view()->Hide( aItem, false );
- view()->Update( aItem, KIGFX::ALL );
+ view()->Update( aItem, KIGFX::COLOR );
// Modules are treated in a special way - when they are selected, we have to
// unselect all the parts that make the module, not the module itself
@@ -1552,7 +1556,7 @@ void SELECTION_TOOL::unselectVisually( BOARD_ITEM* aItem )
{
item->ClearSelected();
view()->Hide( item, false );
- view()->Update( item, KIGFX::ALL );
+ view()->Update( item, KIGFX::COLOR );
});
}
--
2.7.4
Follow ups