Move Edit with Symbol Editor to modern toolset context menu.
This commit is contained in:
parent
f81007f74b
commit
1ff7869ec3
|
@ -167,14 +167,6 @@ void AddMenusForComponent( wxMenu* PopMenu, SCH_COMPONENT* Component, SYMBOL_LIB
|
|||
AddMenuItem( editmenu, sel_unit_menu, ID_POPUP_SCH_SELECT_UNIT_CMP,
|
||||
_( "Unit" ), KiBitmap( component_select_unit_xpm ) );
|
||||
}
|
||||
|
||||
if( !Component->GetEditFlags() )
|
||||
{
|
||||
msg = AddHotkeyName( _( "Edit with Library Editor" ), g_Schematic_Hotkeys_Descr,
|
||||
HK_EDIT_COMPONENT_WITH_LIBEDIT );
|
||||
AddMenuItem( editmenu, ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP,
|
||||
msg, KiBitmap( libedit_xpm ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -235,7 +235,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, SCH_EDIT_FRAME::OnConfigurePaths )
|
||||
|
||||
EVT_TOOL( ID_RUN_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
||||
EVT_TOOL( ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP, SCH_EDIT_FRAME::OnOpenLibraryEditor )
|
||||
EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
|
||||
EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject )
|
||||
EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols )
|
||||
|
@ -1076,44 +1075,6 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
|
|||
|
||||
void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = GetToolManager()->GetTool<SCH_SELECTION_TOOL>();
|
||||
SCH_COMPONENT* component = NULL;
|
||||
|
||||
if( event.GetId() == ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP )
|
||||
{
|
||||
// We want to edit a component with Libedit.
|
||||
// we are here by a hot key, or by a popup menu
|
||||
SCH_ITEM* item = GetScreen()->GetCurItem();
|
||||
|
||||
if( !item )
|
||||
{
|
||||
// If we didn't get here by a hot key, then something has gone wrong.
|
||||
if( event.GetInt() == 0 )
|
||||
return;
|
||||
|
||||
EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) event.GetClientObject();
|
||||
|
||||
wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );
|
||||
|
||||
// Set the locat filter, according to the edit command
|
||||
const KICAD_T* filterList = SCH_COLLECTOR::ComponentsOnly;
|
||||
item = selTool->SelectPoint( data->GetPosition(), filterList );
|
||||
|
||||
// Exit if no item found at the current location or the item is already being edited.
|
||||
if( item == NULL || item->GetEditFlags() != 0 )
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( !item || item->GetEditFlags() != 0 || item->Type() != SCH_COMPONENT_T )
|
||||
{
|
||||
wxMessageBox( _( "Error: not a symbol or no symbol." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
component = (SCH_COMPONENT*) item;
|
||||
}
|
||||
|
||||
LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
|
||||
|
||||
if( !libeditFrame )
|
||||
|
@ -1129,34 +1090,6 @@ void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
|
|||
libeditFrame->Iconize( false );
|
||||
|
||||
libeditFrame->Raise();
|
||||
|
||||
if( component )
|
||||
{
|
||||
LIB_ID id = component->GetLibId();
|
||||
LIB_ALIAS* entry = nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
entry = Prj().SchSymbolLibTable()->LoadSymbol( id );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( _( "Error occurred loading symbol \"%s\" from library \"%s\"." ),
|
||||
id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
|
||||
DisplayErrorMessage( this, msg, ioe.What() );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !entry ) // Should not occur
|
||||
return;
|
||||
|
||||
libeditFrame->LoadComponentAndSelectLib( id, component->GetUnit(), component->GetConvert() );
|
||||
}
|
||||
|
||||
SchematicCleanUp();
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -647,6 +647,8 @@ public:
|
|||
|
||||
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
|
||||
|
||||
void OnOpenLibraryEditor( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Import a KiCad schematic into the current page.
|
||||
*
|
||||
|
@ -825,7 +827,6 @@ private:
|
|||
void OnOpenPcbnew( wxCommandEvent& event );
|
||||
void OnOpenPcbModuleEditor( wxCommandEvent& event );
|
||||
void OnOpenCvpcb( wxCommandEvent& event );
|
||||
void OnOpenLibraryEditor( wxCommandEvent& event );
|
||||
void OnRescueProject( wxCommandEvent& event );
|
||||
void OnRemapSymbols( wxCommandEvent& aEvent );
|
||||
|
||||
|
|
|
@ -247,6 +247,9 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
|||
|
||||
case ID_POPUP_SCH_DISPLAYDOC_CMP:
|
||||
return SCH_ACTIONS::showDatasheet.MakeEvent();
|
||||
|
||||
case ID_POPUP_SCH_CALL_LIBEDIT_AND_LOAD_CMP:
|
||||
return SCH_ACTIONS::editWithSymbolEditor.MakeEvent();
|
||||
}
|
||||
|
||||
return OPT<TOOL_EVENT>();
|
||||
|
|
|
@ -146,6 +146,7 @@ public:
|
|||
/// Inspection
|
||||
static TOOL_ACTION showDatasheet;
|
||||
static TOOL_ACTION showMarkerInfo;
|
||||
static TOOL_ACTION editWithSymbolEditor;
|
||||
|
||||
/// Clipboard
|
||||
static TOOL_ACTION cut;
|
||||
|
|
|
@ -551,7 +551,7 @@ int SCH_DRAWING_TOOL::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( image->Clone() );
|
||||
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, aComponent );
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectItem, true, image );
|
||||
|
||||
m_controls->SetCursorPosition( cursorPos, false );
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <sch_legacy_plugin.h>
|
||||
#include <class_library.h>
|
||||
#include <confirm.h>
|
||||
#include <lib_edit_frame.h>
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview",
|
||||
AS_GLOBAL, 0, "", "" );
|
||||
|
@ -83,6 +84,11 @@ TOOL_ACTION SCH_ACTIONS::paste( "eeschema.EditorControl.paste",
|
|||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_PASTE ),
|
||||
_( "Paste" ), _( "Paste clipboard into schematic" ), paste_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::editWithSymbolEditor( "eeschema.EditorControl.editWithSymbolEditor",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_COMPONENT_WITH_LIBEDIT ),
|
||||
_( "Edit with Symbol Editor" ), _( "Open the symbol editor to edit the symbol" ),
|
||||
libedit_xpm );
|
||||
|
||||
|
||||
SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL() :
|
||||
TOOL_INTERACTIVE( "eeschema.EditorControl" ),
|
||||
|
@ -650,6 +656,34 @@ int SCH_EDITOR_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_EDITOR_CONTROL::EditWithSymbolEditor( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_SELECTION_TOOL* selTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
|
||||
SELECTION& selection = selTool->RequestSelection( SCH_COLLECTOR::ComponentsOnly );
|
||||
SCH_COMPONENT* comp = nullptr;
|
||||
wxString msg;
|
||||
|
||||
if( selection.GetSize() >= 1 )
|
||||
comp = (SCH_COMPONENT*) selection.GetItem( 0 );
|
||||
|
||||
if( !comp || comp->GetEditFlags() != 0 )
|
||||
return 0;
|
||||
|
||||
wxCommandEvent dummy;
|
||||
m_frame->OnOpenLibraryEditor( dummy );
|
||||
|
||||
auto libeditFrame = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
|
||||
|
||||
if( libeditFrame )
|
||||
{
|
||||
const LIB_ID& id = comp->GetLibId();
|
||||
libeditFrame->LoadComponentAndSelectLib( id, comp->GetUnit(), comp->GetConvert() );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDITOR_CONTROL::setTransitions()
|
||||
{
|
||||
/*
|
||||
|
@ -682,4 +716,6 @@ void SCH_EDITOR_CONTROL::setTransitions()
|
|||
Go( &SCH_EDITOR_CONTROL::Cut, SCH_ACTIONS::cut.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::Copy, SCH_ACTIONS::copy.MakeEvent() );
|
||||
Go( &SCH_EDITOR_CONTROL::Paste, SCH_ACTIONS::paste.MakeEvent() );
|
||||
|
||||
Go( &SCH_EDITOR_CONTROL::EditWithSymbolEditor, SCH_ACTIONS::editWithSymbolEditor.MakeEvent() );
|
||||
}
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
int Copy( const TOOL_EVENT& aEvent );
|
||||
int Paste( const TOOL_EVENT& aEvent );
|
||||
|
||||
int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
|
||||
|
||||
private:
|
||||
///> copy selection to clipboard
|
||||
bool doCopy();
|
||||
|
|
Loading…
Reference in New Issue