From dd99b2dc2fafe9b3c80e200970d9df3f597415ed Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 26 Oct 2021 12:59:59 -0700 Subject: [PATCH] Add action to edit symbol from Library Analog of ea4e06124e for symbol editor. Allows scripting to open library symbol --- eeschema/symbol_editor/symbol_editor.cpp | 3 ++- eeschema/tools/ee_actions.cpp | 8 +++++++- eeschema/tools/ee_actions.h | 1 + eeschema/tools/sch_editor_control.cpp | 16 +++++++++++++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index 53e306a135..6dc9214307 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -251,7 +251,8 @@ bool SYMBOL_EDIT_FRAME::saveCurrentSymbol() bool SYMBOL_EDIT_FRAME::LoadSymbol( const LIB_ID& aLibId, int aUnit, int aConvert ) { - if( GetCurSymbol() && GetCurSymbol()->GetLibId() == aLibId + if( !IsSymbolFromSchematic() + && GetCurSymbol() && GetCurSymbol()->GetLibId() == aLibId && GetUnit() == aUnit && GetConvert() == aConvert ) { return true; diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 0921e02850..b5e4ec85b4 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -548,7 +548,13 @@ TOOL_ACTION EE_ACTIONS::highlightNetTool( "eeschema.EditorControl.highlightNetTo TOOL_ACTION EE_ACTIONS::editWithLibEdit( "eeschema.EditorControl.editWithSymbolEditor", AS_GLOBAL, MD_CTRL + 'E', LEGACY_HK_NAME( "Edit with Symbol Editor" ), - _( "Edit with Symbol Editor" ), _( "Open the symbol editor to edit the symbol" ), + _( "Edit with Symbol Editor" ), _( "Open the selected symbol in the Symbol Editor" ), + BITMAPS::libedit ); + +TOOL_ACTION EE_ACTIONS::editLibSymbolWithLibEdit( "eeschema.EditorControl.editLibSymbolWithSymbolEditor", + AS_GLOBAL, + MD_CTRL + MD_SHIFT + 'E', "", + _( "Edit Library Symbol..." ), _( "Open the library symbol in the Symbol Editor" ), BITMAPS::libedit ); TOOL_ACTION EE_ACTIONS::editSymbolFields( "eeschema.EditorControl.editSymbolFields", diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 9cab0883c6..8a4c5c5953 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -159,6 +159,7 @@ public: // Suite operations static TOOL_ACTION editWithLibEdit; + static TOOL_ACTION editLibSymbolWithLibEdit; static TOOL_ACTION showPcbNew; static TOOL_ACTION importFPAssignments; static TOOL_ACTION exportNetlist; diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 040210feb6..5993f78b97 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1948,7 +1948,20 @@ int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent ) symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false ); if( symbolEditor ) - symbolEditor->LoadSymbolFromSchematic( symbol ); + { + if( aEvent.IsAction( &EE_ACTIONS::editWithLibEdit ) ) + symbolEditor->LoadSymbolFromSchematic( symbol ); + else if( aEvent.IsAction( &EE_ACTIONS::editLibSymbolWithLibEdit ) ) + { + symbolEditor->LoadSymbol( symbol->GetLibId(), symbol->GetConvert(), symbol->GetUnit() ); + + if( !symbolEditor->IsSymbolTreeShown() ) + { + wxCommandEvent evt; + symbolEditor->OnToggleSymbolTree( evt ); + } + } + } return 0; } @@ -2184,6 +2197,7 @@ void SCH_EDITOR_CONTROL::setTransitions() Go( &SCH_EDITOR_CONTROL::Duplicate, ACTIONS::duplicate.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::EditWithSymbolEditor, EE_ACTIONS::editWithLibEdit.MakeEvent() ); + Go( &SCH_EDITOR_CONTROL::EditWithSymbolEditor, EE_ACTIONS::editLibSymbolWithLibEdit.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ShowCvpcb, EE_ACTIONS::assignFootprints.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ImportFPAssignments, EE_ACTIONS::importFPAssignments.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Annotate, EE_ACTIONS::annotate.MakeEvent() );