From c611f62adec0508bebcb99c9047709420107f7c4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 8 Dec 2020 15:27:50 +0000 Subject: [PATCH] Get rid of annoying double-draw when choosing a new symbol. --- eeschema/symbol_editor/symbol_edit_frame.cpp | 25 +++++++++++++------ eeschema/symbol_editor/symbol_edit_frame.h | 2 +- eeschema/symbol_editor/symbol_editor.cpp | 3 +-- .../symbol_editor/symbol_editor_undo_redo.cpp | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 6a85a9a360..dc017104ac 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -669,7 +669,7 @@ wxString SYMBOL_EDIT_FRAME::SetCurLib( const wxString& aLibNickname ) } -void SYMBOL_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) +void SYMBOL_EDIT_FRAME::SetCurPart( LIB_PART* aPart, bool aUpdateZoom ) { m_toolManager->RunAction( EE_ACTIONS::clearSelection, true ); GetCanvas()->GetView()->Clear(); @@ -690,6 +690,7 @@ void SYMBOL_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) } wxString partName = m_my_part ? m_my_part->GetName() : wxString(); + bool isAlias = !IsSymbolFromSchematic() && m_my_part && m_my_part->IsAlias(); // retain in case this wxFrame is re-opened later on the same PROJECT Prj().SetRString( PROJECT::SCH_LIBEDIT_CUR_PART, partName ); @@ -698,7 +699,18 @@ void SYMBOL_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) m_SyncPinEdit = aPart && aPart->IsRoot() && aPart->IsMulti() && !aPart->UnitsLocked(); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); - RebuildView(); + + GetRenderSettings()->m_ShowUnit = m_unit; + GetRenderSettings()->m_ShowConvert = m_convert; + GetRenderSettings()->m_ShowDisabled = isAlias; + GetCanvas()->DisplayComponent( m_my_part ); + GetCanvas()->GetView()->HideWorksheet(); + GetCanvas()->GetView()->ClearHiddenFlags(); + + if( aUpdateZoom ) + m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); + + GetCanvas()->Refresh(); WX_INFOBAR* infobar = GetInfoBar(); @@ -711,7 +723,7 @@ void SYMBOL_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) infobar->RemoveAllButtons(); infobar->ShowMessage( msg, wxICON_INFORMATION ); } - else if( m_my_part && m_my_part->IsAlias() ) + else if( isAlias ) { wxString parentPartName = m_my_part->GetParent().lock()->GetName(); wxString msg; @@ -1041,7 +1053,7 @@ void SYMBOL_EDIT_FRAME::emptyScreen() { m_treePane->GetLibTree()->Unselect(); SetCurLib( wxEmptyString ); - SetCurPart( nullptr ); + SetCurPart( nullptr, false ); SetScreen( m_dummyScreen ); ClearUndoRedoList(); m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); @@ -1259,7 +1271,7 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( const std::unique_ptr wxCHECK( symbol, /* void */ ); if( m_my_part ) - SetCurPart( nullptr ); + SetCurPart( nullptr, false ); m_isSymbolFromSchematic = true; m_reference = aReference; @@ -1270,9 +1282,8 @@ void SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic( const std::unique_ptr SCH_SCREEN* tmpScreen = new SCH_SCREEN(); SetScreen( tmpScreen ); - SetCurPart( symbol.release() ); + SetCurPart( symbol.release(), true ); - m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); ReCreateMenuBar(); ReCreateHToolbar(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index c67f8e9e54..2767521447 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -151,7 +151,7 @@ public: /** * Take ownership of aPart and notes that it is the one currently being edited. */ - void SetCurPart( LIB_PART* aPart ); + void SetCurPart( LIB_PART* aPart, bool aUpdateZoom ); SYMBOL_LIBRARY_MANAGER& GetLibManager(); diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index aaa27d0dd8..b681f0c409 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -247,7 +247,7 @@ bool SYMBOL_EDIT_FRAME::LoadOneLibraryPartAux( LIB_PART* aEntry, const wxString& SCH_SCREEN* part_screen = m_libMgr->GetScreen( lib_part->GetName(), aLibrary ); SetScreen( part_screen ); - SetCurPart( new LIB_PART( *lib_part ) ); + SetCurPart( new LIB_PART( *lib_part ), true ); SetCurLib( aLibrary ); if( rebuildMenuAndToolbar ) @@ -257,7 +257,6 @@ bool SYMBOL_EDIT_FRAME::LoadOneLibraryPartAux( LIB_PART* aEntry, const wxString& GetInfoBar()->Dismiss(); } - m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); updateTitle(); RebuildSymbolUnitsList(); SetShowDeMorgan( GetCurPart()->HasConversion() ); diff --git a/eeschema/symbol_editor/symbol_editor_undo_redo.cpp b/eeschema/symbol_editor/symbol_editor_undo_redo.cpp index eec7a3b22c..efdbb4d8dd 100644 --- a/eeschema/symbol_editor/symbol_editor_undo_redo.cpp +++ b/eeschema/symbol_editor/symbol_editor_undo_redo.cpp @@ -168,7 +168,7 @@ void SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo() delete undoCommand; LIB_PART* part = (LIB_PART*) undoWrapper.GetItem(); part->ClearFlags( UR_TRANSIENT ); - SetCurPart( part ); + SetCurPart( part, false ); EE_SELECTION_TOOL* selTool = m_toolManager->GetTool(); selTool->RebuildSelection();