Add action to edit symbol from Library

Analog of ea4e06124e for symbol editor.  Allows scripting to open
library symbol
This commit is contained in:
Seth Hillbrand 2021-10-26 12:59:59 -07:00
parent 0c99c99e12
commit dd99b2dc2f
4 changed files with 25 additions and 3 deletions

View File

@ -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;

View File

@ -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",

View File

@ -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;

View File

@ -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() );