Move remaining Symbol Tree ctx menu cmds to ACTIONS.

Also moves the various Player instantiators down into COMMON_TOOLS
for better sharing.
This commit is contained in:
Jeff Young 2019-06-06 12:45:28 +01:00
parent 720889edd0
commit e606587ff6
36 changed files with 266 additions and 341 deletions

View File

@ -363,11 +363,21 @@ TOOL_ACTION ACTIONS::showSymbolBrowser( "common.Control.showSymbolBrowser",
_( "Symbol Library Browser" ), _( "Browse symbol libraries" ),
library_browse_xpm );
TOOL_ACTION ACTIONS::showSymbolEditor( "common.Control.showSymbolEditor",
AS_GLOBAL, 0,
_( "Symbol Editor" ), _( "Create, delete and edit symbols" ),
libedit_xpm );
TOOL_ACTION ACTIONS::showFootprintBrowser( "common.Control.showFootprintBrowser",
AS_GLOBAL, 0,
_( "Footprint Library Browser" ), _( "Browse footprint libraries" ),
modview_icon_xpm );
TOOL_ACTION ACTIONS::showFootprintEditor( "common.Control.showFootprintEditor",
AS_GLOBAL, 0,
_( "Footprint Editor" ), _( "Create, delete and edit footprints" ),
module_editor_xpm );
TOOL_ACTION ACTIONS::updatePcbFromSchematic( "common.Control.updatePcbFromSchematic",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_UPDATE_PCB_FROM_SCH ),
_( "Update PCB from Schematic..." ), _( "Push changes from schematic to PCB" ),

View File

@ -532,6 +532,38 @@ int COMMON_TOOLS::SwitchCanvas( const TOOL_EVENT& aEvent )
}
int COMMON_TOOLS::ShowPlayer( const TOOL_EVENT& aEvent )
{
FRAME_T playerType = FRAME_SCH_VIEWER;
if( aEvent.IsAction( &ACTIONS::showSymbolBrowser ) )
playerType = FRAME_SCH_VIEWER;
else if( aEvent.IsAction( &ACTIONS::showSymbolEditor ) )
playerType = FRAME_SCH_LIB_EDITOR;
else if( aEvent.IsAction( &ACTIONS::showFootprintBrowser ) )
playerType = FRAME_PCB_MODULE_VIEWER;
else if( aEvent.IsAction( &ACTIONS::showFootprintEditor ) )
playerType = FRAME_PCB_MODULE_EDITOR;
else
wxFAIL_MSG( "ShowPlayer(): unexpected request" );
KIWAY_PLAYER* editor = m_frame->Kiway().Player( playerType, true );
// Needed on Windows, other platforms do not use it, but it creates no issue
if( editor->IsIconized() )
editor->Iconize( false );
editor->Raise();
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != editor )
editor->SetFocus();
return 0;
}
void COMMON_TOOLS::setTransitions()
{
// Cursor control
@ -585,6 +617,10 @@ void COMMON_TOOLS::setTransitions()
Go( &COMMON_TOOLS::ShowLibraryTable, ACTIONS::showFootprintLibTable.MakeEvent() );
Go( &COMMON_TOOLS::SwitchCanvas, ACTIONS::acceleratedGraphics.MakeEvent() );
Go( &COMMON_TOOLS::SwitchCanvas, ACTIONS::standardGraphics.MakeEvent() );
Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showSymbolBrowser.MakeEvent() );
Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showSymbolEditor.MakeEvent() );
Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showFootprintBrowser.MakeEvent() );
Go( &COMMON_TOOLS::ShowPlayer, ACTIONS::showFootprintEditor.MakeEvent() );
}

View File

@ -411,6 +411,7 @@ void LIB_TREE::onContextMenu( wxDataViewEvent& aEvent )
if( tool )
{
tool->Activate();
tool->GetManager()->VetoContextMenuMouseWarp();
tool->GetToolMenu().ShowContextMenu();
TOOL_EVENT evt( TC_MOUSE, TA_MOUSE_CLICK, BUT_RIGHT );

View File

@ -62,7 +62,6 @@ enum id_eeschema_frm
ID_REMAP_SYMBOLS,
/* Schematic editor horizontal toolbar IDs */
ID_TO_LIBVIEW,
ID_BACKANNO_ITEMS,
/* Schematic editor vertical toolbar IDs */

View File

@ -83,7 +83,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_SIZE( LIB_EDIT_FRAME::OnSize )
// Main horizontal toolbar.
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnSyncPinEditClick )
EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_EDIT_FRAME::OnAddPartToSchematic )

View File

@ -274,7 +274,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
toolsMenu->AddItem( EE_ACTIONS::showPcbNew, EE_CONDITIONS::ShowAlways );
toolsMenu->AddSeparator();
toolsMenu->AddItem( EE_ACTIONS::showSymbolEditor, EE_CONDITIONS::ShowAlways );
toolsMenu->AddItem( ACTIONS::showSymbolEditor, EE_CONDITIONS::ShowAlways );
toolsMenu->AddItem( ID_RESCUE_CACHED, _( "&Rescue Symbols..." ),
_( "Find old symbols in project and rename/rescue them" ),
rescue_xpm, EE_CONDITIONS::ShowAlways );

View File

@ -104,19 +104,6 @@ SCH_BASE_FRAME::~SCH_BASE_FRAME()
}
void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
{
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, true );
// On Windows, Raise() does not bring the window on screen, when iconized
if( viewlibFrame->IsIconized() )
viewlibFrame->Iconize( false );
viewlibFrame->Show( true );
viewlibFrame->Raise();
}
SCH_SCREEN* SCH_BASE_FRAME::GetScreen() const
{
return (SCH_SCREEN*) EDA_DRAW_FRAME::GetScreen();

View File

@ -330,13 +330,6 @@ public:
*/
virtual void OnModify() {}
/**
* Open the library viewer only to browse library contents.
* If the viewed is already opened from this, raise the viewer
* If the viewed is already opened from another window, close it and reopen
*/
void OnOpenLibraryViewer( wxCommandEvent& event );
protected:
/**
* Saves Symbol Library Tables to disk.

View File

@ -232,8 +232,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject )
EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols )
EVT_TOOL( ID_RUN_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenFootprintEditor )
EVT_TOOL( ID_GET_NETLIST, SCH_EDIT_FRAME::OnCreateNetlist )
EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile )
EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
@ -867,24 +865,6 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
}
void SCH_EDIT_FRAME::OnOpenFootprintEditor( wxCommandEvent& event )
{
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
if( fn.IsOk() )
{
KIWAY_PLAYER* fp_editor = Kiway().Player( FRAME_PCB_MODULE_EDITOR );
// On Windows, Raise() does not bring the window on screen, when iconized
if( fp_editor->IsIconized() )
fp_editor->Iconize( false );
fp_editor->Show( true );
fp_editor->Raise();
}
}
void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
{
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
@ -915,24 +895,6 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
}
void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
{
LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
if( !libeditFrame )
{
libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
libeditFrame->Show( true );
}
// On Windows, Raise() does not bring the window on screen, when iconized
if( libeditFrame->IsIconized() )
libeditFrame->Iconize( false );
libeditFrame->Raise();
}
void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
{
SCH_SCREENS schematic;

View File

@ -621,8 +621,6 @@ public:
bool OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl = 0 ) override;
void OnOpenLibraryEditor( wxCommandEvent& event );
/**
* Import a KiCad schematic into the current page.
*
@ -749,7 +747,6 @@ public:
void GetSchematicConnections( std::vector< wxPoint >& aConnections );
void OnOpenPcbnew( wxCommandEvent& event );
void OnOpenFootprintEditor( wxCommandEvent& event );
void OnOpenCvpcb( wxCommandEvent& event );
void OnRescueProject( wxCommandEvent& event );
void OnRemapSymbols( wxCommandEvent& aEvent );

View File

@ -82,14 +82,9 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->Add( EE_ACTIONS::leaveSheet );
m_mainToolBar->AddSeparator();
m_mainToolBar->Add( EE_ACTIONS::showSymbolEditor );
m_mainToolBar->Add( ACTIONS::showSymbolEditor );
m_mainToolBar->Add( ACTIONS::showSymbolBrowser );
// modedit is with libedit in a "library section" because the user must have footprints before
// they can be assigned.
m_mainToolBar->AddTool( ID_RUN_PCB_MODULE_EDITOR, wxEmptyString,
KiScaledBitmap( module_editor_xpm, this ),
_( "Footprint Editor - Create/edit footprints" ) );
m_mainToolBar->Add( ACTIONS::showFootprintEditor );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->Add( EE_ACTIONS::annotate );

View File

@ -159,7 +159,6 @@ public:
static TOOL_ACTION showBusManager;
// Suite operations
static TOOL_ACTION showSymbolEditor;
static TOOL_ACTION editWithLibEdit;
static TOOL_ACTION showPcbNew;
static TOOL_ACTION generateBOM;

View File

@ -272,15 +272,6 @@ int LIB_CONTROL::OnDeMorgan( const TOOL_EVENT& aEvent )
}
int LIB_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
m_frame->OnOpenLibraryViewer( dummy );
return 0;
}
int LIB_CONTROL::ShowComponentTree( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_LIB_EDITOR ) )
@ -330,7 +321,6 @@ void LIB_CONTROL::setTransitions()
Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganStandard.MakeEvent() );
Go( &LIB_CONTROL::OnDeMorgan, EE_ACTIONS::showDeMorganAlternate.MakeEvent() );
Go( &LIB_CONTROL::ShowLibraryBrowser, ACTIONS::showSymbolBrowser.MakeEvent() );
Go( &LIB_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() );
Go( &LIB_CONTROL::ShowComponentTree, EE_ACTIONS::showComponentTree.MakeEvent() );
}

View File

@ -60,7 +60,6 @@ public:
int OnDeMorgan( const TOOL_EVENT& aEvent );
int ShowLibraryBrowser( const TOOL_EVENT& aEvent );
int ShowElectricalTypes( const TOOL_EVENT& aEvent );
int ShowComponentTree( const TOOL_EVENT& aEvent );

View File

@ -76,11 +76,6 @@ TOOL_ACTION EE_ACTIONS::highlightNetCursor( "eeschema.EditorControl.highlightNet
_( "Highlight Nets" ), _( "Highlight wires and pins of a net" ),
net_highlight_schematic_xpm, AF_ACTIVATE );
TOOL_ACTION EE_ACTIONS::showSymbolEditor( "eeschema.EditorControl.showSymbolEditor",
AS_GLOBAL, 0,
_( "Show Symbol Editor" ), _( "Create, delete and edit symbols" ),
libedit_xpm );
TOOL_ACTION EE_ACTIONS::editWithLibEdit( "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" ),
@ -1048,41 +1043,21 @@ int SCH_EDITOR_CONTROL::EditWithLibEdit( const TOOL_EVENT& aEvent )
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::ComponentsOnly );
SCH_COMPONENT* comp = nullptr;
SCH_COMPONENT* sym = nullptr;
LIB_EDIT_FRAME* libEdit;
if( selection.GetSize() >= 1 )
comp = (SCH_COMPONENT*) selection.Front();
sym = (SCH_COMPONENT*) selection.Front();
if( !comp || comp->GetEditFlags() != 0 )
if( !sym || sym->GetEditFlags() != 0 )
return 0;
wxCommandEvent dummy;
m_frame->OnOpenLibraryEditor( dummy );
m_toolMgr->RunAction( ACTIONS::showSymbolEditor, true );
libEdit = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
auto libeditFrame = (LIB_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
if( libEdit )
libEdit->LoadComponentAndSelectLib( sym->GetLibId(), sym->GetUnit(), sym->GetConvert() );
if( libeditFrame )
{
const LIB_ID& id = comp->GetLibId();
libeditFrame->LoadComponentAndSelectLib( id, comp->GetUnit(), comp->GetConvert() );
}
return 0;
}
int SCH_EDITOR_CONTROL::ShowSymbolEditor( const TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
m_frame->OnOpenLibraryEditor( dummy );
return 0;
}
int SCH_EDITOR_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent )
{
wxCommandEvent dummy;
m_frame->OnOpenLibraryViewer( dummy );
return 0;
}
@ -1249,8 +1224,6 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::EditWithLibEdit, EE_ACTIONS::editWithLibEdit.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ShowSymbolEditor, EE_ACTIONS::showSymbolEditor.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ShowLibraryBrowser, ACTIONS::showSymbolBrowser.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::ShowCvpcb, EE_ACTIONS::assignFootprints.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Annotate, EE_ACTIONS::annotate.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::EditSymbolFields, EE_ACTIONS::editSymbolFields.MakeEvent() );

View File

@ -102,8 +102,6 @@ public:
int Paste( const TOOL_EVENT& aEvent );
int EditWithLibEdit( const TOOL_EVENT& aEvent );
int ShowSymbolEditor( const TOOL_EVENT& aEvent );
int ShowLibraryBrowser( const TOOL_EVENT& aEvent );
int ShowCvpcb( const TOOL_EVENT& aEvent );
int Annotate( const TOOL_EVENT& aEvent );
int EditSymbolFields( const TOOL_EVENT& aEvent );

View File

@ -72,8 +72,6 @@
enum main_id
{
ID_RUN_PCB = wxID_HIGHEST,
ID_RUN_PCB_MODULE_EDITOR,
ID_RUN_LIBRARY, // pcbnew & eeschema each use this internally to load their respective lib editors
ID_LOAD_PROJECT,
ID_APPEND_PROJECT,

View File

@ -142,7 +142,9 @@ public:
// Misc
static TOOL_ACTION show3DViewer;
static TOOL_ACTION showSymbolBrowser;
static TOOL_ACTION showSymbolEditor;
static TOOL_ACTION showFootprintBrowser;
static TOOL_ACTION showFootprintEditor;
static TOOL_ACTION updatePcbFromSchematic;
static TOOL_ACTION configurePaths;
static TOOL_ACTION showSymbolLibTable;

View File

@ -82,6 +82,8 @@ public:
int ConfigurePaths( const TOOL_EVENT& aEvent );
int ShowLibraryTable( const TOOL_EVENT& aEvent );
int SwitchCanvas( const TOOL_EVENT& aEvent );
int ShowPlayer( const TOOL_EVENT& aEvent );
///> Sets up handlers for various events.
void setTransitions() override;

View File

@ -85,32 +85,6 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case 0:
break;
case ID_OPEN_MODULE_EDITOR:
{
FOOTPRINT_EDIT_FRAME* editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, false );
if( !editor )
{
editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
editor->Zoom_Automatique( false );
}
else
{
// Needed on Windows, other platforms do not use it,
// but it creates no issue
if( editor->IsIconized() )
editor->Iconize( false );
editor->Raise();
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != editor )
editor->SetFocus();
}
}
break;
case ID_TOOLBARH_PCB_SELECT_LAYER:
SetActiveLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) );

View File

@ -82,19 +82,10 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_TOOL( ID_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng )
EVT_TOOL( ID_MODEDIT_CUT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_COPY_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_PASTE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EDIT_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard )
EVT_TOOL( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, FOOTPRINT_EDIT_FRAME::OnToggleSearchTree )
// Preferences and option menus
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, FOOTPRINT_EDIT_FRAME::ProcessPreferences )
EVT_MENU( wxID_PREFERENCES, FOOTPRINT_EDIT_FRAME::ProcessPreferences )
@ -271,7 +262,7 @@ void FOOTPRINT_EDIT_FRAME::HardRedraw()
}
void FOOTPRINT_EDIT_FRAME::OnToggleSearchTree( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::ToggleSearchTree()
{
auto& treePane = m_auimgr.GetPane( m_treePane );
treePane.Show( !IsSearchTreeShown() );
@ -726,10 +717,9 @@ void FOOTPRINT_EDIT_FRAME::SyncLibraryTree( bool aProgress )
}
void FOOTPRINT_EDIT_FRAME::FocusOnLibrary( const wxString& aLibName )
void FOOTPRINT_EDIT_FRAME::FocusOnLibID( const LIB_ID& aLibID )
{
LIB_ID libID( aLibName, wxEmptyString );
m_treePane->GetLibTree()->SelectLibId( libID );
m_treePane->GetLibTree()->SelectLibId( aLibID );
}

View File

@ -42,7 +42,6 @@ class FOOTPRINT_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
FOOTPRINT_TREE_PANE* m_treePane;
LIB_TREE_MODEL_ADAPTER::PTR m_adapter;
std::unique_ptr<MODULE> m_copiedModule;
std::unique_ptr<MODULE> m_revertModule;
wxString m_footprintNameWhenLoaded;
@ -128,11 +127,10 @@ public:
// The Tool Framework initalization, for GAL mode
void setupTools();
void OnToggleSearchTree( wxCommandEvent& event );
void OnSaveFootprintAsPng( wxCommandEvent& event );
bool IsSearchTreeShown();
void ToggleSearchTree();
/**
* Save a library to a new name and/or library type.
@ -174,6 +172,7 @@ public:
bool SaveFootprint( MODULE* aModule );
bool SaveFootprintAs( MODULE* aModule );
bool SaveFootprintToBoard( bool aAddNew );
bool SaveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );
bool RevertFootprint();
/**
@ -339,7 +338,7 @@ public:
* @param aProgress
*/
void SyncLibraryTree( bool aProgress );
void FocusOnLibrary( const wxString& aLibName );
void FocusOnLibID( const LIB_ID& aLibID );
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;
@ -374,14 +373,10 @@ protected:
void restoreLastFootprint();
void retainLastFootprint();
private:
/**
* Run the Footprint Properties dialog and handle changes made in it.
*/
void editFootprintProperties( MODULE* aFootprint );
bool saveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );
};
#endif // FOOTPRINT_EDIT_FRAME_H

View File

@ -317,84 +317,10 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
m_treePane->GetLibTree()->Refresh();
break;
case ID_MODEDIT_CUT_PART:
case ID_MODEDIT_COPY_PART:
if( GetTargetFPID().IsValid() )
{
LIB_ID fpID = GetTargetFPID();
if( fpID == GetLoadedFPID() )
m_copiedModule.reset( new MODULE( *GetBoard()->GetFirstModule() ) );
else
m_copiedModule.reset( LoadFootprint( fpID ) );
if( id == ID_MODEDIT_CUT_PART )
{
if( fpID == GetLoadedFPID() )
Clear_Pcb( false );
DeleteModuleFromLibrary( fpID, false );
}
SyncLibraryTree( true );
}
break;
case ID_MODEDIT_PASTE_PART:
if( m_copiedModule && !GetTargetFPID().GetLibNickname().empty() )
{
wxString newLib = GetTargetFPID().GetLibNickname();
MODULE* newModule( m_copiedModule.get() );
wxString newName = newModule->GetFPID().GetLibItemName();
while( Prj().PcbFootprintLibs()->FootprintExists( newLib, newName ) )
newName += _( "_copy" );
newModule->SetFPID( LIB_ID( newLib, newName ) );
saveFootprintInLibrary( newModule, newLib );
SyncLibraryTree( true );
m_treePane->GetLibTree()->SelectLibId( newModule->GetFPID() );
}
break;
case ID_ADD_FOOTPRINT_TO_BOARD:
SaveFootprintToBoard( true );
break;
case ID_MODEDIT_IMPORT_PART:
if( ! Clear_Pcb( true ) )
break; // this command is aborted
SetCrossHairPosition( wxPoint( 0, 0 ) );
Import_Module();
if( GetBoard()->GetFirstModule() )
GetBoard()->GetFirstModule()->ClearFlags();
GetScreen()->SetModify();
// Clear undo and redo lists because we don't have handling to in
// FP editor to undo across imports (the module _is_ the board with the stack)
// todo: Abstract undo/redo stack to a higher element or keep consistent board item in fpeditor
GetScreen()->ClearUndoRedoList();
Zoom_Automatique( false );
GetGalCanvas()->Refresh();
Update3DView( true );
break;
case ID_MODEDIT_EXPORT_PART:
if( GetTargetFPID() == GetLoadedFPID() )
Export_Module( GetBoard()->GetFirstModule() );
else
Export_Module( LoadFootprint( GetTargetFPID() ) );
break;
case ID_MODEDIT_EDIT_MODULE:
LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() );
break;
case ID_MODEDIT_CHECK:
// Currently: not implemented
break;

View File

@ -572,8 +572,9 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename )
if( editor )
{
LIB_ID libID( libName, wxEmptyString );
editor->SyncLibraryTree( true );
editor->FocusOnLibrary( libName );
editor->FocusOnLibID( libID );
}
auto viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
@ -749,7 +750,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule )
DeleteModuleFromLibrary( oldFPID, false );
}
if( !saveFootprintInLibrary( aModule, libraryName ) )
if( !SaveFootprintInLibrary( aModule, libraryName ) )
return false;
if( nameChanged )
@ -762,7 +763,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule )
}
bool FOOTPRINT_EDIT_FRAME::saveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName )
bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName )
{
try
{
@ -978,7 +979,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintAs( MODULE* aModule )
return false;
}
if( !saveFootprintInLibrary( aModule, libraryName ) )
if( !SaveFootprintInLibrary( aModule, libraryName ) )
return false;
// Once saved-as a board footprint is no longer a board footprint

View File

@ -63,9 +63,7 @@ void FOOTPRINT_TREE_PANE::Regenerate()
void FOOTPRINT_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent )
{
wxCommandEvent evt( wxEVT_COMMAND_TOOL_CLICKED, ID_MODEDIT_EDIT_MODULE );
m_frame->Process_Special_Functions( evt );
m_frame->LoadModuleFromLibrary( GetLibTree()->GetSelectedLibId() );
// Make sure current-part highlighting doesn't get lost in seleciton highlighting
m_tree->Unselect();
}

View File

@ -84,11 +84,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( import_xpm );
submenuImport->Add( _( "&Footprint..." ),
_( "Import a footprint from file" ),
ID_MODEDIT_IMPORT_PART, import_module_xpm );
submenuImport->Add( _( "&Graphics..." ),
submenuImport->Add( PCB_ACTIONS::importFootprint );
submenuImport->Add( _( "&Impot Graphics..." ),
_( "Import 2D Drawing file to Footprint Editor on Drawings layer" ),
ID_GEN_IMPORT_GRAPHICS_FILE, import_vector_xpm );
@ -98,11 +95,8 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( export_xpm );
submenuExport->AddItem( ID_MODEDIT_EXPORT_PART, _( "&Footprint..." ),
_( "Export current footprint to a file" ),
export_module_xpm, modifiedDocumentCondition );
submenuExport->AddItem( ID_MODEDIT_SAVE_PNG, _( "View as &PNG..." ),
submenuExport->AddItem( PCB_ACTIONS::exportFootprint, modifiedDocumentCondition );
submenuExport->AddItem( ID_MODEDIT_SAVE_PNG, _( "Export View as &PNG..." ),
_( "Create a PNG file from the current view" ),
plot_xpm, SELECTION_CONDITIONS::ShowAlways );
@ -224,9 +218,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
viewMenu->AddMenu( contrastModeSubMenu );
viewMenu->AddSeparator();
viewMenu->AddCheckItem( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE,
_( "&Search Tree" ), _( "Toggles the search tree visibility" ),
search_tree_xpm, searchTreeShownCondition );
viewMenu->AddCheckItem( PCB_ACTIONS::toggleFootprintTree, searchTreeShownCondition );
viewMenu->Resolve();

View File

@ -119,7 +119,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_TOOL( ID_MENU_READ_BOARD_BACKUP_FILE, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_MENU_RECOVER_BOARD_AUTOSAVE, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_OPEN_MODULE_EDITOR, PCB_EDIT_FRAME::Process_Special_Functions )
// Menu Files:
EVT_MENU( ID_MAIN_MENUBAR, PCB_EDIT_FRAME::Process_Special_Functions )
@ -148,7 +147,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_PCB_GEN_CMP_FILE, PCB_EDIT_FRAME::RecreateCmpFileFromBoard )
// Horizontal toolbar
EVT_TOOL( ID_RUN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_GEN_PLOT_SVG, PCB_EDIT_FRAME::ExportSVG )
EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )

View File

@ -15,7 +15,6 @@ enum pcbnew_ids
{
ID_MAIN_MENUBAR = ID_END_LIST,
ID_MICROWAVE_V_TOOLBAR,
ID_OPEN_MODULE_EDITOR,
ID_SET_RELATIVE_OFFSET,
ID_COPY_BOARD_AS,
ID_IMPORT_NON_KICAD_BOARD,
@ -148,17 +147,9 @@ enum pcbnew_ids
ID_MODEDIT_SAVE,
ID_MODEDIT_SAVE_AS,
ID_MODEDIT_SAVE_PNG,
ID_MODEDIT_COPY_PART,
ID_MODEDIT_CUT_PART,
ID_MODEDIT_PASTE_PART,
ID_MODEDIT_NEW_MODULE,
ID_MODEDIT_NEW_MODULE_FROM_WIZARD,
ID_MODEDIT_SHEET_SET,
ID_MODEDIT_EDIT_MODULE,
ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
ID_MODEDIT_IMPORT_PART,
ID_MODEDIT_EXPORT_PART,
ID_MODEDIT_SHOW_HIDE_SEARCH_TREE,
ID_MODVIEW_LIB_LIST,
ID_MODVIEW_FOOTPRINT_LIST,

View File

@ -154,21 +154,19 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleGrid, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::togglePolarCoords, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::imperialUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::metricUnits, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::toggleCursorStyle, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddSeparator();
m_optionsToolBar->Add( PCB_ACTIONS::padDisplayMode, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::moduleEdgeOutlines, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::highContrastMode, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::padDisplayMode, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( PCB_ACTIONS::moduleEdgeOutlines, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Add( ACTIONS::highContrastMode, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->AddSeparator();
m_optionsToolBar->AddTool( ID_MODEDIT_SHOW_HIDE_SEARCH_TREE, wxEmptyString,
KiScaledBitmap( search_tree_xpm, this ),
_( "Toggles the search tree" ), wxITEM_CHECK );
m_optionsToolBar->Add( PCB_ACTIONS::toggleFootprintTree, ACTION_TOOLBAR::TOGGLE );
m_optionsToolBar->Realize();
}
@ -189,13 +187,14 @@ void FOOTPRINT_EDIT_FRAME::SyncMenusAndToolbars()
m_mainToolBar->Toggle( PCB_ACTIONS::footprintProperties, GetBoard()->GetFirstModule() );
m_mainToolBar->Refresh();
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES );
m_optionsToolBar->Toggle( ACTIONS::togglePolarCoords, GetShowPolarCoords() );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts->m_DisplayPadFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::moduleEdgeOutlines, !opts->m_DisplayModEdgeFill );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts->m_ContrastModeDisplay );
m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() );
m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != INCHES );
m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == INCHES );
m_optionsToolBar->Toggle( ACTIONS::togglePolarCoords, GetShowPolarCoords() );
m_optionsToolBar->Toggle( PCB_ACTIONS::padDisplayMode, !opts->m_DisplayPadFill );
m_optionsToolBar->Toggle( PCB_ACTIONS::moduleEdgeOutlines, !opts->m_DisplayModEdgeFill );
m_optionsToolBar->Toggle( ACTIONS::highContrastMode, opts->m_ContrastModeDisplay );
m_optionsToolBar->Toggle( PCB_ACTIONS::toggleFootprintTree, IsSearchTreeShown() );
m_optionsToolBar->Refresh();
m_drawToolBar->Toggle( ACTIONS::selectionTool, GetToolId() == ID_NO_TOOL_SELECTED );

View File

@ -267,7 +267,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->Add( ACTIONS::zoomTool, ACTION_TOOLBAR::TOGGLE );
KiScaledSeparator( m_mainToolBar, this );
ADD_TOOL( ID_OPEN_MODULE_EDITOR, module_editor_xpm, _( "Open footprint editor" ) );
m_mainToolBar->Add( ACTIONS::showFootprintEditor );
m_mainToolBar->Add( ACTIONS::showFootprintBrowser );
KiScaledSeparator( m_mainToolBar, this );

View File

@ -4,7 +4,7 @@
* Copyright (C) 2013-2017 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* Copyright (C) 2017 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014-2019 CERN
* Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
@ -47,14 +48,19 @@
#include <class_module.h>
#include <class_edge_mod.h>
#include <board_commit.h>
#include <project.h>
#include <tools/tool_event_utils.h>
#include <fp_lib_table.h>
#include <functional>
using namespace std::placeholders;
#include <wx/defs.h>
TOOL_ACTION PCB_ACTIONS::toggleFootprintTree( "pcbnew.ModuleEditor.toggleFootprintTree",
AS_GLOBAL, 0,
_( "Show Footprint Tree" ), _( "Toggles the footprint tree visibility" ),
search_tree_xpm );
TOOL_ACTION PCB_ACTIONS::newFootprint( "pcbnew.ModuleEditor.newFootprint",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_NEW ),
_( "New Footprint..." ), _( "Create a new, empty footprint" ),
@ -75,17 +81,47 @@ TOOL_ACTION PCB_ACTIONS::saveToLibrary( "pcbnew.ModuleEditor.saveToLibrary",
_( "Save to Library" ), _( "Save changes to library" ),
save_xpm );
// Module editor tools
TOOL_ACTION PCB_ACTIONS::footprintProperties( "pcbnew.ModuleEditor.footprintProperties",
TOOL_ACTION PCB_ACTIONS::editFootprint( "pcbnew.ModuleEditor.editFootprint",
AS_GLOBAL, 0,
_( "Footprint Properties..." ), "",
module_options_xpm );
_( "Edit Footprint" ), _( "Show selected footprint on editor canvas" ),
edit_xpm );
TOOL_ACTION PCB_ACTIONS::deleteFootprint( "pcbnew.ModuleEditor.deleteFootprint",
AS_GLOBAL, 0,
_( "Delete Footprint from Library" ), "",
delete_xpm );
TOOL_ACTION PCB_ACTIONS::cutFootprint( "pcbnew.ModuleEditor.cutFootprint",
AS_GLOBAL, 0,
_( "Cut Footprint" ), "",
cut_xpm );
TOOL_ACTION PCB_ACTIONS::copyFootprint( "pcbnew.ModuleEditor.copyFootprint",
AS_GLOBAL, 0,
_( "Copy Footprint" ), "",
copy_xpm );
TOOL_ACTION PCB_ACTIONS::pasteFootprint( "pcbnew.ModuleEditor.pasteFootprint",
AS_GLOBAL, 0,
_( "Paste Footprint" ), "",
paste_xpm );
TOOL_ACTION PCB_ACTIONS::importFootprint( "pcbnew.ModuleEditor.importFootprint",
AS_GLOBAL, 0,
_( "Import Footprint..." ), "",
import_module_xpm );
TOOL_ACTION PCB_ACTIONS::exportFootprint( "pcbnew.ModuleEditor.exportFootprint",
AS_GLOBAL, 0,
_( "Export Footprint..." ), "",
export_module_xpm );
// Module editor tools
TOOL_ACTION PCB_ACTIONS::footprintProperties( "pcbnew.ModuleEditor.footprintProperties",
AS_GLOBAL, 0,
_( "Footprint Properties..." ), "",
module_options_xpm );
TOOL_ACTION PCB_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad",
AS_GLOBAL, 0,
_( "Add Pad" ), _( "Add a pad" ),
@ -158,9 +194,7 @@ bool MODULE_EDITOR_TOOLS::Init()
#ifdef KICAD_SCRIPTING
ctxMenu.AddItem( PCB_ACTIONS::createFootprint, SELECTION_CONDITIONS::ShowAlways );
#endif
ctxMenu.AddItem( ID_MODEDIT_EDIT_MODULE,
_( "Edit Footprint" ), _( "Show selected footprint on editor canvas" ),
edit_xpm, fpSelectedCondition );
ctxMenu.AddItem( PCB_ACTIONS::editFootprint, fpSelectedCondition );
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways );
ctxMenu.AddItem( ACTIONS::save, fpSelectedCondition );
@ -169,18 +203,13 @@ bool MODULE_EDITOR_TOOLS::Init()
ctxMenu.AddItem( ACTIONS::revert, fpSelectedCondition );
ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways );
ctxMenu.AddItem( ID_MODEDIT_CUT_PART, _( "Cut Footprint" ), "",
cut_xpm, fpSelectedCondition );
ctxMenu.AddItem( ID_MODEDIT_COPY_PART, _( "Copy Footprint" ), "",
copy_xpm, fpSelectedCondition );
ctxMenu.AddItem( ID_MODEDIT_PASTE_PART, _( "Paste Footprint" ), "",
paste_xpm, SELECTION_CONDITIONS::ShowAlways );
ctxMenu.AddItem( PCB_ACTIONS::cutFootprint, fpSelectedCondition );
ctxMenu.AddItem( PCB_ACTIONS::copyFootprint, fpSelectedCondition );
ctxMenu.AddItem( PCB_ACTIONS::pasteFootprint, SELECTION_CONDITIONS::ShowAlways );
ctxMenu.AddSeparator( fpSelectedCondition );
ctxMenu.AddItem( ID_MODEDIT_IMPORT_PART, _( "Import Footprint..." ), "",
import_module_xpm, SELECTION_CONDITIONS::ShowAlways );
ctxMenu.AddItem( ID_MODEDIT_EXPORT_PART, _( "Export Footprint..." ), "",
export_module_xpm, fpSelectedCondition );
ctxMenu.AddItem( PCB_ACTIONS::importFootprint, SELECTION_CONDITIONS::ShowAlways );
ctxMenu.AddItem( PCB_ACTIONS::exportFootprint, fpSelectedCondition );
return true;
}
@ -225,7 +254,45 @@ int MODULE_EDITOR_TOOLS::Revert( const TOOL_EVENT& aEvent )
}
int MODULE_EDITOR_TOOLS::Delete( const TOOL_EVENT& aEvent )
int MODULE_EDITOR_TOOLS::CutCopyFootprint( const TOOL_EVENT& aEvent )
{
LIB_ID fpID = m_frame->GetTreeFPID();
if( fpID == m_frame->GetLoadedFPID() )
m_copiedModule.reset( new MODULE( *m_frame->GetBoard()->GetFirstModule() ) );
else
m_copiedModule.reset( m_frame->LoadFootprint( fpID ) );
if( aEvent.IsAction( &PCB_ACTIONS::cutFootprint ) )
DeleteFootprint(aEvent );
return 0;
}
int MODULE_EDITOR_TOOLS::PasteFootprint( const TOOL_EVENT& aEvent )
{
if( m_copiedModule && !m_frame->GetTreeFPID().GetLibNickname().empty() )
{
wxString newLib = m_frame->GetTreeFPID().GetLibNickname();
MODULE* newModule( m_copiedModule.get() );
wxString newName = newModule->GetFPID().GetLibItemName();
while( m_frame->Prj().PcbFootprintLibs()->FootprintExists( newLib, newName ) )
newName += _( "_copy" );
newModule->SetFPID( LIB_ID( newLib, newName ) );
m_frame->SaveFootprintInLibrary( newModule, newLib );
m_frame->SyncLibraryTree( true );
m_frame->FocusOnLibID( newModule->GetFPID() );
}
return 0;
}
int MODULE_EDITOR_TOOLS::DeleteFootprint( const TOOL_EVENT& aEvent )
{
FOOTPRINT_EDIT_FRAME* frame = getEditFrame<FOOTPRINT_EDIT_FRAME>();
@ -241,6 +308,57 @@ int MODULE_EDITOR_TOOLS::Delete( const TOOL_EVENT& aEvent )
}
int MODULE_EDITOR_TOOLS::ImportFootprint( const TOOL_EVENT& aEvent )
{
if( !m_frame->Clear_Pcb( true ) )
return -1; // this command is aborted
m_frame->SetCrossHairPosition( wxPoint( 0, 0 ) );
m_frame->Import_Module();
if( m_frame->GetBoard()->GetFirstModule() )
m_frame->GetBoard()->GetFirstModule()->ClearFlags();
// Clear undo and redo lists because we don't have handling to in
// FP editor to undo across imports (the module _is_ the board with the stack)
// todo: Abstract undo/redo stack to a higher element or keep consistent board item in fpeditor
frame()->GetScreen()->ClearUndoRedoList();
m_toolMgr->RunAction( ACTIONS::zoomFitScreen, true );
m_frame->OnModify();
return 0;
}
int MODULE_EDITOR_TOOLS::ExportFootprint( const TOOL_EVENT& aEvent )
{
LIB_ID fpID = m_frame->GetTreeFPID();
MODULE* fp;
if( fpID == m_frame->GetLoadedFPID() )
fp = m_frame->GetBoard()->GetFirstModule();
else
fp = m_frame->LoadFootprint( fpID );
m_frame->Export_Module( fp );
return 0;
}
int MODULE_EDITOR_TOOLS::EditFootprint( const TOOL_EVENT& aEvent )
{
m_frame->LoadModuleFromLibrary( m_frame->GetTreeFPID() );
return 0;
}
int MODULE_EDITOR_TOOLS::ToggleFootprintTree( const TOOL_EVENT& aEvent )
{
m_frame->ToggleSearchTree();
return 0;
}
int MODULE_EDITOR_TOOLS::Properties( const TOOL_EVENT& aEvent )
{
MODULE* footprint = m_frame->GetBoard()->GetFirstModule();
@ -711,8 +829,17 @@ void MODULE_EDITOR_TOOLS::setTransitions()
Go( &MODULE_EDITOR_TOOLS::SaveAs, ACTIONS::saveAs.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::SaveAs, ACTIONS::saveCopyAs.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::Revert, ACTIONS::revert.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::Delete, PCB_ACTIONS::deleteFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::DeleteFootprint, PCB_ACTIONS::deleteFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::EditFootprint, PCB_ACTIONS::editFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::CutCopyFootprint, PCB_ACTIONS::cutFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::CutCopyFootprint, PCB_ACTIONS::copyFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::PasteFootprint, PCB_ACTIONS::pasteFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::ImportFootprint, PCB_ACTIONS::importFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::ExportFootprint, PCB_ACTIONS::exportFootprint.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::ToggleFootprintTree, PCB_ACTIONS::toggleFootprintTree.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::Properties, PCB_ACTIONS::footprintProperties.MakeEvent() );
Go( &MODULE_EDITOR_TOOLS::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.MakeEvent() );

View File

@ -54,8 +54,15 @@ public:
int Save( const TOOL_EVENT& aEvent );
int SaveAs( const TOOL_EVENT& aEvent );
int Revert( const TOOL_EVENT& aEvent );
int Delete( const TOOL_EVENT& aEvent );
int EditFootprint( const TOOL_EVENT& aEvent );
int CutCopyFootprint( const TOOL_EVENT& aEvent );
int PasteFootprint( const TOOL_EVENT& aEvent );
int DeleteFootprint( const TOOL_EVENT& aEvent );
int ImportFootprint( const TOOL_EVENT& aEvent );
int ExportFootprint( const TOOL_EVENT& aEvent );
int ToggleFootprintTree( const TOOL_EVENT& aEvent );
int Properties( const TOOL_EVENT& aEvent );
/**
@ -101,7 +108,10 @@ private:
void setTransitions() override;
private:
FOOTPRINT_EDIT_FRAME* m_frame;
FOOTPRINT_EDIT_FRAME* m_frame;
// A private clipboard for cut/copy/past of an entire footprint
std::unique_ptr<MODULE> m_copiedModule;
};
#endif

View File

@ -287,6 +287,8 @@ public:
// Module editor tools
static TOOL_ACTION toggleFootprintTree;
// We don't use ACTION::new here because we need to distinguish between New Library
// and New Footprint.
static TOOL_ACTION newFootprint;
@ -299,7 +301,13 @@ public:
static TOOL_ACTION saveToBoard;
static TOOL_ACTION saveToLibrary;
static TOOL_ACTION editFootprint;
static TOOL_ACTION deleteFootprint;
static TOOL_ACTION cutFootprint;
static TOOL_ACTION copyFootprint;
static TOOL_ACTION pasteFootprint;
static TOOL_ACTION importFootprint;
static TOOL_ACTION exportFootprint;
static TOOL_ACTION footprintProperties;
static TOOL_ACTION defaultPadProperties;

View File

@ -1001,28 +1001,6 @@ int PCBNEW_CONTROL::Show3DViewer( const TOOL_EVENT& aEvent )
}
int PCBNEW_CONTROL::ShowFootprintBrowser( const TOOL_EVENT& aEvent )
{
auto* viewer = (FOOTPRINT_VIEWER_FRAME*) m_frame->Kiway().Player( FRAME_PCB_MODULE_VIEWER );
viewer->Show( true );
// On Windows, Raise() does not bring the window on screen, when iconized
if( viewer->IsIconized() )
viewer->Iconize( false );
viewer->Raise();
// Raising the window does not set the focus on Linux. This should work on
// any platform.
if( wxWindow::FindFocus() != viewer )
viewer->SetFocus();
return 0;
}
int PCBNEW_CONTROL::ToBeDone( const TOOL_EVENT& aEvent )
{
DisplayInfoMessage( m_frame, _( "Not available in OpenGL/Cairo canvases." ) );
@ -1119,7 +1097,6 @@ void PCBNEW_CONTROL::setTransitions()
Go( &PCBNEW_CONTROL::DeleteItemCursor, PCB_ACTIONS::deleteTool.MakeEvent() );
Go( &PCBNEW_CONTROL::ShowHelp, PCB_ACTIONS::showHelp.MakeEvent() );
Go( &PCBNEW_CONTROL::Show3DViewer, ACTIONS::show3DViewer.MakeEvent() );
Go( &PCBNEW_CONTROL::ShowFootprintBrowser, ACTIONS::showFootprintBrowser.MakeEvent() );
Go( &PCBNEW_CONTROL::ToBeDone, PCB_ACTIONS::toBeDone.MakeEvent() );
// Append control

View File

@ -98,7 +98,6 @@ public:
int AppendBoard( PLUGIN& pi, wxString& fileName );
int ShowHelp( const TOOL_EVENT& aEvent );
int Show3DViewer( const TOOL_EVENT& aEvent );
int ShowFootprintBrowser( const TOOL_EVENT& aEvent );
int ToBeDone( const TOOL_EVENT& aEvent );
int UpdateMessagePanel( const TOOL_EVENT& aEvent );