From e5df4304a6c3bc57c169ef58ced5c37ebc945333 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 24 Sep 2017 21:12:58 -0400 Subject: [PATCH] Minor tweaks to GerbView for performance --- gerbview/files.cpp | 3 +++ gerbview/gerbview_frame.cpp | 5 ++--- gerbview/tools/selection_tool.cpp | 12 +++++++----- gerbview/tools/selection_tool.h | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 3634ac705a..f3de9a57bd 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -220,6 +220,9 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) m_mruPath = currentPath; } + // Set the busy cursor + wxBusyCursor wait; + // Read gerber files: each file is loaded on a new GerbView layer bool success = true; int layer = GetActiveLayer(); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index c28893b93a..d938237e0e 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -820,12 +820,11 @@ void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate ) m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere + // NOTE(JE) The next two calls are slow (scales with number of items) GetGalCanvas()->SetTopLayer( GERBER_DRAW_LAYER( aLayer ) ); - GetGalCanvas()->SetHighContrastLayer( GERBER_DRAW_LAYER( aLayer ) ); - GetGalCanvas()->Refresh(); - GetGalCanvas()->GetView()->RecacheAllItems(); + GetGalCanvas()->Refresh(); } } diff --git a/gerbview/tools/selection_tool.cpp b/gerbview/tools/selection_tool.cpp index d12fd893cc..f094f12c11 100644 --- a/gerbview/tools/selection_tool.cpp +++ b/gerbview/tools/selection_tool.cpp @@ -704,7 +704,6 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec getView()->Remove( &highlightGroup ); - return current; } @@ -732,9 +731,9 @@ void GERBVIEW_SELECTION_TOOL::select( EDA_ITEM* aItem ) return; } - selectVisually( aItem ); m_selection.Add( aItem ); getView()->Add( &m_selection ); + selectVisually( aItem ); if( m_selection.Size() == 1 ) { @@ -765,7 +764,7 @@ void GERBVIEW_SELECTION_TOOL::unselect( EDA_ITEM* aItem ) } -void GERBVIEW_SELECTION_TOOL::selectVisually( EDA_ITEM* aItem ) const +void GERBVIEW_SELECTION_TOOL::selectVisually( EDA_ITEM* aItem ) { // Move the item's layer to the front int layer = static_cast( aItem )->GetLayer(); @@ -774,16 +773,19 @@ void GERBVIEW_SELECTION_TOOL::selectVisually( EDA_ITEM* aItem ) const // Hide the original item, so it is shown only on overlay aItem->SetSelected(); getView()->Hide( aItem, true ); - getView()->Update( aItem, KIGFX::GEOMETRY ); + + getView()->Update( &m_selection ); } -void GERBVIEW_SELECTION_TOOL::unselectVisually( EDA_ITEM* aItem ) const +void GERBVIEW_SELECTION_TOOL::unselectVisually( EDA_ITEM* aItem ) { // Restore original item visibility aItem->ClearSelected(); getView()->Hide( aItem, false ); getView()->Update( aItem, KIGFX::ALL ); + + getView()->Update( &m_selection ); } diff --git a/gerbview/tools/selection_tool.h b/gerbview/tools/selection_tool.h index dc0956f96b..06a693a577 100644 --- a/gerbview/tools/selection_tool.h +++ b/gerbview/tools/selection_tool.h @@ -203,14 +203,14 @@ private: * Marks item as selected, but does not add it to the ITEMS_PICKED_LIST. * @param aItem is an item to be be marked. */ - void selectVisually( EDA_ITEM* aItem ) const; + void selectVisually( EDA_ITEM* aItem ); /** * Function unselectVisually() * Marks item as selected, but does not add it to the ITEMS_PICKED_LIST. * @param aItem is an item to be be marked. */ - void unselectVisually( EDA_ITEM* aItem ) const; + void unselectVisually( EDA_ITEM* aItem ); /** * Function selectionContains()