From 3777c5270b277f30d9c288eb9491033966b39f41 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 1 Jun 2019 16:28:39 +0100 Subject: [PATCH] Move some more Eeschema operations to ACTIONs. --- eeschema/ee_hotkeys.cpp | 3 +- eeschema/eeschema_id.h | 6 -- eeschema/help_common_strings.h | 50 ---------- eeschema/menubar.cpp | 129 +++++++++----------------- eeschema/sch_edit_frame.cpp | 69 +------------- eeschema/sch_edit_frame.h | 35 +++---- eeschema/toolbars_sch_editor.cpp | 24 ++--- eeschema/tools/ee_actions.h | 14 ++- eeschema/tools/ee_inspection_tool.cpp | 24 ++++- eeschema/tools/ee_inspection_tool.h | 2 + eeschema/tools/sch_editor_control.cpp | 99 ++++++++++++++++++++ eeschema/tools/sch_editor_control.h | 8 ++ include/id.h | 3 - 13 files changed, 211 insertions(+), 255 deletions(-) diff --git a/eeschema/ee_hotkeys.cpp b/eeschema/ee_hotkeys.cpp index f52f737ce6..ace2d3f6d3 100644 --- a/eeschema/ee_hotkeys.cpp +++ b/eeschema/ee_hotkeys.cpp @@ -182,8 +182,7 @@ static EDA_HOTKEY HkViewDoc( _HKI( "Show Datasheet" ), HK_LIBEDIT_VIEW_DOC, 'D' // Autoplace fields static EDA_HOTKEY HkAutoplaceFields( _HKI( "Autoplace Fields" ), HK_AUTOPLACE_FIELDS, 'O' ); -static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), HK_UPDATE_PCB_FROM_SCH, WXK_F8, - ID_UPDATE_PCB_FROM_SCH ); +static EDA_HOTKEY HkUpdatePcbFromSch( _HKI( "Update PCB from Schematic" ), HK_UPDATE_PCB_FROM_SCH, WXK_F8 ); // Selection static EDA_HOTKEY HkSelectNode( _HKI( "Select Node" ), HK_SELECT_NODE, GR_KB_ALT + '3' ); diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 25d398ba2a..571a7bc158 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -59,17 +59,13 @@ enum id_eeschema_frm /* Schematic editor main menubar IDs. */ ID_RESCUE_CACHED, ID_EDIT_SYM_LIB_TABLE, - ID_BUS_MANAGER, ID_REMAP_SYMBOLS, ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, /* Schematic editor horizontal toolbar IDs */ ID_TO_LIBVIEW, - ID_GET_ANNOTATE, - ID_GET_ERC, ID_BACKANNO_ITEMS, ID_UPDATE_FIELDS, - ID_GEN_PLOT_SCHEMATIC, /* Schematic editor vertical toolbar IDs */ ID_HIGHLIGHT_TOOL, @@ -155,8 +151,6 @@ enum id_eeschema_frm ID_LIBVIEW_CMP_LIST, ID_SET_RELATIVE_OFFSET, - ID_UPDATE_PCB_FROM_SCH, - ID_SIM_RUN, ID_SIM_TUNE, ID_SIM_PROBE, diff --git a/eeschema/help_common_strings.h b/eeschema/help_common_strings.h index f7c28fa692..8d51f1cd05 100644 --- a/eeschema/help_common_strings.h +++ b/eeschema/help_common_strings.h @@ -22,11 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file eeschema/help_common_strings.h - * strings common to toolbars and menubar - */ - /** * These strings are used in menus and tools, that do the same command * But they are internationalized, and therefore must be created @@ -36,57 +31,12 @@ * Therefore they are defined by \#define, used inside menu constructors */ -// Common to schematic editor and component editor -#define HELP_UNDO _( "Undo last command" ) -#define HELP_REDO _( "Redo last command" ) - #define HELP_ZOOM_IN _( "Zoom in" ) #define HELP_ZOOM_OUT _( "Zoom out" ) #define HELP_ZOOM_FIT _( "Zoom to fit schematic page" ) #define HELP_ZOOM_REDRAW _( "Redraw schematic view" ) -#define HELP_DELETE_ITEMS _( "Delete item" ) - // Schematic editor: -#define HELP_SELECT _( "Select item" ) -#define HELP_HIGHLIGHT _( "Highlight net" ) -#define HELP_FIND _( "Find symbols and text" ) -#define HELP_REPLACE _( "Find and replace text in schematic items" ) -#define HELP_PLACE_COMPONENTS _( "Place symbol" ) -#define HELP_PLACE_POWERPORT _( "Place power port" ) -#define HELP_PLACE_WIRE _( "Place wire" ) -#define HELP_PLACE_BUS _( "Place bus" ) -#define HELP_PLACE_WIRE2BUS_ENTRY _( "Place wire to bus entry" ) -#define HELP_PLACE_BUS2BUS_ENTRY _( "Place bus to bus entry" ) -#define HELP_PLACE_NC_FLAG _( "Place no connection flag" ) - -#define HELP_PLACE_NETLABEL _( "Place net label" ) -#define HELP_PLACE_GLOBALLABEL \ - _( "Place global label.\nAll global labels with same name are connected throughout the sheet hierarchy" ) -#define HELP_PLACE_HIER_LABEL \ - _( "Place a hierarchical label.\nHierarchical labels are exposed to other sheets through sheet pins" ) - -#define HELP_PLACE_JUNCTION _( "Place junction" ) -#define HELP_PLACE_SHEET _( "Create hierarchical sheet" ) -#define HELP_IMPORT_SHEETPIN \ - _( "Place hierarchical sheet pin corresponding to a hierarchical label in the sheet" ) -#define HELP_PLACE_SHEETPIN _( "Place hierarchical sheet pin" ) -#define HELP_PLACE_GRAPHICLINES _( "Place graphic lines or polygons" ) -#define HELP_PLACE_GRAPHICTEXTS _( "Place text" ) - -#define HELP_ANNOTATE _( "Annotate schematic symbols" ) -#define HELP_RUN_LIB_EDITOR _( "Create, delete, and edit symbols" ) -#define HELP_RUN_LIB_VIEWER _( "Browse symbol libraries" ) -#define HELP_GENERATE_BOM _( "Generate bill of materials" ) -#define HELP_BUS_MANAGER _( "Manage bus definitions" ) #define HELP_IMPORT_FOOTPRINTS \ _( "Back-import symbol footprint association fields from the .cmp back import file created by Pcbnew" ) -// Component editor: -#define HELP_ADD_PIN _( "Add pins to symbol" ) -#define HELP_ADD_BODYTEXT _( "Add text to symbol body" ) -#define HELP_ADD_BODYRECT _( "Add graphic rectangle to symbol body" ) -#define HELP_ADD_BODYCIRCLE _( "Add circles to symbol body" ) -#define HELP_ADD_BODYARC _( "Add arcs to symbol body" ) -#define HELP_ADD_BODYPOLYGON _( "Add lines and polygons to symbol body" ) -#define HELP_PLACE_GRAPHICIMAGES _("Add bitmap image") diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 1e297d6f24..3618a7217a 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -40,11 +40,6 @@ class CONDITIONAL_MENU; -// helper functions that build specific submenus: - -// Build the tools menu -static void prepareToolsMenu( wxMenu* aParentMenu ); - void SCH_EDIT_FRAME::ReCreateMenuBar() { @@ -253,14 +248,55 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() //-- Inspect menu ----------------------------------------------- // - wxMenu* inspectMenu = new wxMenu; - AddMenuItem( inspectMenu, ID_GET_ERC, _( "Electrical Rules &Checker" ), - _( "Perform electrical rules check" ), KiBitmap( erc_xpm ) ); + CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); + + inspectMenu->AddItem( EE_ACTIONS::runERC, EE_CONDITIONS::ShowAlways ); //-- Tools menu ----------------------------------------------- // - wxMenu* toolsMenu = new wxMenu; - prepareToolsMenu( toolsMenu ); + CONDITIONAL_MENU* toolsMenu = new CONDITIONAL_MENU( false, selTool ); + + auto remapSymbolsCondition = [] ( const SELECTION& aSel ) { + SCH_SCREENS schematic; + + // The remapping can only be performed on legacy projects. + return schematic.HasNoFullyDefinedLibIds(); + }; + + toolsMenu->AddItem( EE_ACTIONS::updatePcbFromSchematic, EE_CONDITIONS::ShowAlways ); + toolsMenu->AddItem( EE_ACTIONS::showPcbNew, EE_CONDITIONS::ShowAlways ); + + toolsMenu->AddSeparator(); + toolsMenu->AddItem( EE_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 ); + + toolsMenu->AddItem( ID_REMAP_SYMBOLS, _( "Remap S&ymbols..." ), + _( "Remap legacy library symbols to symbol library table" ), + rescue_xpm, remapSymbolsCondition ); + + toolsMenu->AddSeparator(); + toolsMenu->AddItem( EE_ACTIONS::editSymbolFields, EE_CONDITIONS::ShowAlways ); + + toolsMenu->AddItem( ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, + _( "Edit Symbol &Library References..." ), + _( "Edit links between schematic symbols and library symbols" ), + edit_cmp_symb_links_xpm, EE_CONDITIONS::ShowAlways ); + + toolsMenu->AddSeparator(); + toolsMenu->AddItem( EE_ACTIONS::annotate, EE_CONDITIONS::ShowAlways ); + toolsMenu->AddItem( EE_ACTIONS::showBusManager, EE_CONDITIONS::ShowAlways ); + + toolsMenu->AddSeparator(); + toolsMenu->AddItem( EE_ACTIONS::assignFootprints, EE_CONDITIONS::ShowAlways ); + toolsMenu->AddItem( EE_ACTIONS::generateBOM, EE_CONDITIONS::ShowAlways ); + +#ifdef KICAD_SPICE + toolsMenu->AddSeparator(); + toolsMenu->AddItem( ID_SIM_SHOW, _("Simula&tor"), _( "Simulate circuit" ), + simulator_xpm, EE_CONDITIONS::ShowAlways ); +#endif /* KICAD_SPICE */ //-- Preferences menu ----------------------------------------------- // @@ -309,76 +345,3 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() } -void prepareToolsMenu( wxMenu* aParentMenu ) -{ - wxString text; - - text = AddHotkeyName( _( "Update PCB from Schematic..." ), g_Schematic_Hotkeys_Descr, - HK_UPDATE_PCB_FROM_SCH ); - - AddMenuItem( aParentMenu, - ID_UPDATE_PCB_FROM_SCH, - text, _( "Update PCB design with current schematic." ), - KiBitmap( update_pcb_from_sch_xpm ) ); - - // Run Pcbnew - AddMenuItem( aParentMenu, ID_RUN_PCB, _( "&Open PCB Editor" ), - _( "Run Pcbnew" ), - KiBitmap( pcbnew_xpm ) ); - - aParentMenu->AppendSeparator(); - - AddMenuItem( aParentMenu, ID_RUN_LIBRARY, _( "Symbol Library &Editor" ), - HELP_RUN_LIB_EDITOR, - KiBitmap( libedit_xpm ) ); - - AddMenuItem( aParentMenu, ID_RESCUE_CACHED, _( "&Rescue Symbols..." ), - _( "Find old symbols in project and rename/rescue them" ), - KiBitmap( rescue_xpm ) ); - - AddMenuItem( aParentMenu, ID_REMAP_SYMBOLS, _( "Remap S&ymbols..." ), - _( "Remap legacy library symbols to symbol library table" ), - KiBitmap( rescue_xpm ) ); - - aParentMenu->AppendSeparator(); - - AddMenuItem( aParentMenu, ID_OPEN_CMP_TABLE, _( "Edit Symbol Field&s..." ), - KiBitmap( spreadsheet_xpm ) ); - - AddMenuItem( aParentMenu, ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, - _( "Edit Symbol &Library References..." ), - _( "Edit links between schematic symbols and library symbols" ), - KiBitmap( edit_cmp_symb_links_xpm ) ); - - aParentMenu->AppendSeparator(); - - AddMenuItem( aParentMenu, ID_GET_ANNOTATE, _( "&Annotate Schematic..." ), - HELP_ANNOTATE, - KiBitmap( annotate_xpm ) ); - - AddMenuItem( aParentMenu, ID_BUS_MANAGER, _( "Bus &Definitions..." ), - HELP_BUS_MANAGER, - KiBitmap( bus_definition_tool_xpm ) ); - - aParentMenu->AppendSeparator(); - - // Run CvPcb - AddMenuItem( aParentMenu, ID_RUN_CVPCB, _( "A&ssign Footprints..." ), - _( "Assign PCB footprints to schematic symbols" ), - KiBitmap( cvpcb_xpm ) ); - - AddMenuItem( aParentMenu, ID_GET_TOOLS, _( "Generate Bill of &Materials..." ), - HELP_GENERATE_BOM, - KiBitmap( bom_xpm ) ); - - aParentMenu->AppendSeparator(); - -#ifdef KICAD_SPICE - // Simulator - AddMenuItem( aParentMenu, ID_SIM_SHOW, _("Simula&tor"), - _( "Simulate circuit" ), - KiBitmap( simulator_xpm ) ); -#endif /* KICAD_SPICE */ - -} - diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 3aed303e74..b8f52c8e33 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -71,7 +71,6 @@ #include #include #include -#include #include #include @@ -231,23 +230,13 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnPreferencesOptions ) EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, SCH_EDIT_FRAME::OnConfigurePaths ) - EVT_TOOL( ID_RUN_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor ) EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject ) EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols ) EVT_MENU( ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, SCH_EDIT_FRAME::OnEditComponentSymbolsId ) - EVT_TOOL( ID_RUN_PCB, SCH_EDIT_FRAME::OnOpenPcbnew ) - EVT_TOOL( ID_RUN_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenPcbModuleEditor ) + EVT_TOOL( ID_RUN_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenFootprintEditor ) - EVT_TOOL( ID_RUN_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb ) - - EVT_TOOL( ID_GET_ANNOTATE, SCH_EDIT_FRAME::OnAnnotate ) - EVT_TOOL( ID_GET_ERC, SCH_EDIT_FRAME::OnErc ) EVT_TOOL( ID_GET_NETLIST, SCH_EDIT_FRAME::OnCreateNetlist ) - EVT_TOOL( ID_UPDATE_PCB_FROM_SCH, SCH_EDIT_FRAME::OnUpdatePCB ) - EVT_TOOL( ID_GET_TOOLS, SCH_EDIT_FRAME::OnCreateBillOfMaterials ) - EVT_TOOL( ID_OPEN_CMP_TABLE, SCH_EDIT_FRAME::OnLaunchBomManager ) - EVT_TOOL( ID_BUS_MANAGER, SCH_EDIT_FRAME::OnLaunchBusManager ) EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile ) EVT_TOOL( ID_UPDATE_FIELDS, SCH_EDIT_FRAME::OnUpdateFields ) EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings ) @@ -256,9 +245,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate ) #endif /* KICAD_SPICE */ - /* Handle user interface update events. */ - EVT_UPDATE_UI( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnUpdateRemapSymbols ) - END_EVENT_TABLE() @@ -672,38 +658,6 @@ void SCH_EDIT_FRAME::OnModify() } -void SCH_EDIT_FRAME::OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent ) -{ - SCH_SCREENS schematic; - - // The remapping can only be performed on legacy projects. - aEvent.Enable( schematic.HasNoFullyDefinedLibIds() ); -} - - -void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) -{ - // See if it's already open... - wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this ); - - if( erc ) - // Bring it to the top if already open. Dual monitor users need this. - erc->Raise(); - else - InvokeDialogERC( this ); -} - - -void SCH_EDIT_FRAME::CloseErc() -{ - // Find the ERC dialog if it's open and close it - wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this ); - - if( erc ) - erc->Close( false ); -} - - void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event ) { wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() ); @@ -755,25 +709,6 @@ void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event ) } -void SCH_EDIT_FRAME::OnCreateBillOfMaterials( wxCommandEvent& ) -{ - InvokeDialogCreateBOM( this ); -} - - -void SCH_EDIT_FRAME::OnLaunchBomManager( wxCommandEvent& event ) -{ - DIALOG_FIELDS_EDITOR_GLOBAL dlg( this ); - dlg.ShowQuasiModal(); -} - - -void SCH_EDIT_FRAME::OnLaunchBusManager( wxCommandEvent& ) -{ - InvokeDialogBusManager( this ); -} - - wxFindReplaceData* SCH_EDIT_FRAME::GetFindReplaceData() { if( m_findReplaceDialog && m_findReplaceDialog->IsVisible() @@ -961,7 +896,7 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event ) } -void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event ) +void SCH_EDIT_FRAME::OnOpenFootprintEditor( wxCommandEvent& event ) { wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index a3aa352037..2b38148554 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -314,7 +314,7 @@ public: */ void OnModify() override; - virtual wxString GetScreenDesc() const override; + wxString GetScreenDesc() const override; /** * Execute a remote command send by Pcbnew via a socket, @@ -322,7 +322,7 @@ public: * this is a virtual function called by EDA_DRAW_FRAME::OnSockRequest(). * @param cmdline = received command from socket */ - virtual void ExecuteRemoteCommand( const char* cmdline ) override; + void ExecuteRemoteCommand( const char* cmdline ) override; void KiwayMailIn( KIWAY_EXPRESS& aEvent ) override; @@ -748,30 +748,27 @@ 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 ); + void OnUpdatePCB( wxCommandEvent& event ); + void OnAnnotate( wxCommandEvent& event ); + private: // Sets up the tool framework void setupTools(); void OnExit( wxCommandEvent& event ); - void OnAnnotate( wxCommandEvent& event ); - void OnErc( wxCommandEvent& event ); void OnCreateNetlist( wxCommandEvent& event ); - void OnUpdatePCB( wxCommandEvent& event ); void OnSimulate( wxCommandEvent& event ); - void OnCreateBillOfMaterials( wxCommandEvent& event ); - void OnLaunchBomManager( wxCommandEvent& event ); - void OnLaunchBusManager( wxCommandEvent& event ); void OnLoadFile( wxCommandEvent& event ); void OnLoadCmpToFootprintLinkFile( wxCommandEvent& event ); void OnUpdateFields( wxCommandEvent& event ); void OnAppendProject( wxCommandEvent& event ); void OnImportProject( wxCommandEvent& event ); - void OnOpenPcbnew( wxCommandEvent& event ); - void OnOpenPcbModuleEditor( wxCommandEvent& event ); - void OnOpenCvpcb( wxCommandEvent& event ); - void OnRescueProject( wxCommandEvent& event ); - void OnRemapSymbols( wxCommandEvent& aEvent ); // a helper function to run the dialog that allows to rename the symbol library Id of // groups of components, for instance after a symbol has moved from a library to @@ -779,14 +776,6 @@ private: void OnEditComponentSymbolsId( wxCommandEvent& aEvent ); void OnPreferencesOptions( wxCommandEvent& event ); - /* User interface update event handlers. */ - void OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent ); - - /** - * Close the ERC dialog if it is open. - */ - void CloseErc(); - /** * Set the main window title bar text. * @@ -1128,9 +1117,9 @@ public: void SyncMenusAndToolbars() override; - virtual void SetScreen( BASE_SCREEN* aScreen ) override; + void SetScreen( BASE_SCREEN* aScreen ) override; - virtual const BOX2I GetDocumentExtents() const override; + const BOX2I GetDocumentExtents() const override; DECLARE_EVENT_TABLE() }; diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index d5a324c3a5..3ac396eb6d 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -94,26 +94,14 @@ void SCH_EDIT_FRAME::ReCreateHToolbar() _( "Footprint Editor - Create/edit footprints" ) ); KiScaledSeparator( m_mainToolBar, this ); - - m_mainToolBar->AddTool( ID_GET_ANNOTATE, wxEmptyString, KiScaledBitmap( annotate_xpm, this ), - HELP_ANNOTATE ); - - m_mainToolBar->AddTool( ID_GET_ERC, wxEmptyString, KiScaledBitmap( erc_xpm, this ), - _( "Perform electrical rules check" ) ); - - m_mainToolBar->AddTool( ID_RUN_CVPCB, wxEmptyString, KiScaledBitmap( cvpcb_xpm, this ), - _( "Assign PCB footprints to schematic symbols" ) ); - - m_mainToolBar->AddTool( ID_OPEN_CMP_TABLE, wxEmptyString, - KiScaledBitmap( spreadsheet_xpm, this ), _( "Edit symbol fields" ) ); - - m_mainToolBar->AddTool( ID_GET_TOOLS, wxEmptyString, KiScaledBitmap( bom_xpm, this ), - HELP_GENERATE_BOM ); + m_mainToolBar->Add( EE_ACTIONS::annotate ); + m_mainToolBar->Add( EE_ACTIONS::runERC ); + m_mainToolBar->Add( EE_ACTIONS::assignFootprints ); + m_mainToolBar->Add( EE_ACTIONS::editSymbolFields ); + m_mainToolBar->Add( EE_ACTIONS::generateBOM ); KiScaledSeparator( m_mainToolBar, this ); - - m_mainToolBar->AddTool( ID_RUN_PCB, wxEmptyString, KiScaledBitmap( pcbnew_xpm, this ), - _( "Run Pcbnew to layout printed circuit board" ) ); + m_mainToolBar->Add( EE_ACTIONS::showPcbNew ); m_mainToolBar->AddTool( ID_BACKANNO_ITEMS, wxEmptyString, KiScaledBitmap( import_footprint_names_xpm, this ), diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 77649271b8..06cd662a83 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -112,7 +112,7 @@ public: static TOOL_ACTION placeSymbolAnchor; static TOOL_ACTION finishDrawing; - // Editing + // Interactive Editing static TOOL_ACTION moveActivate; static TOOL_ACTION move; static TOOL_ACTION drag; @@ -145,12 +145,22 @@ public: static TOOL_ACTION pointEditorAddCorner; static TOOL_ACTION pointEditorRemoveCorner; - /// Inspection + /// Inspection and Editing static TOOL_ACTION showDatasheet; + static TOOL_ACTION runERC; static TOOL_ACTION showMarkerInfo; + static TOOL_ACTION annotate; + static TOOL_ACTION editSymbolFields; + static TOOL_ACTION assignFootprints; + static TOOL_ACTION showBusManager; + + // Suite operations static TOOL_ACTION showSymbolEditor; static TOOL_ACTION editWithLibEdit; static TOOL_ACTION showLibraryBrowser; + static TOOL_ACTION showPcbNew; + static TOOL_ACTION updatePcbFromSchematic; + static TOOL_ACTION generateBOM; // Miscellaneous static TOOL_ACTION enterSheet; diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 617f487f11..8dce019c10 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -36,13 +37,18 @@ #include #include #include - +#include TOOL_ACTION EE_ACTIONS::showDatasheet( "eeschema.InspectionTool.showDatasheet", AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SHOW_COMPONENT_DATASHEET ), _( "Show Datasheet" ), _( "Opens the datasheet in a browser" ), datasheet_xpm ); +TOOL_ACTION EE_ACTIONS::runERC( "eeschame.InspectionTool.runERC", + AS_GLOBAL, 0, + _( "Electrical Rules &Checker" ), _( "Perform electrical rules check" ), + erc_xpm ); + TOOL_ACTION EE_ACTIONS::showMarkerInfo( "eeschema.InspectionTool.showMarkerInfo", AS_GLOBAL, 0, _( "Show Marker Info" ), _( "Display the marker's info in a dialog" ), @@ -73,6 +79,21 @@ bool EE_INSPECTION_TOOL::Init() } +int EE_INSPECTION_TOOL::RunERC( const TOOL_EVENT& aEvent ) +{ + SCH_EDIT_FRAME* editFrame = dynamic_cast( m_frame ); + wxWindow* erc = wxWindow::FindWindowById( ID_DIALOG_ERC, m_frame ); + + if( erc ) + // Bring it to the top if already open. Dual monitor users need this. + erc->Raise(); + else if( editFrame ) + InvokeDialogERC( editFrame ); + + return 0; +} + + int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent ) { SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly ); @@ -130,6 +151,7 @@ int EE_INSPECTION_TOOL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) void EE_INSPECTION_TOOL::setTransitions() { + Go( &EE_INSPECTION_TOOL::RunERC, EE_ACTIONS::runERC.MakeEvent() ); Go( &EE_INSPECTION_TOOL::ShowDatasheet, EE_ACTIONS::showDatasheet.MakeEvent() ); Go( &EE_INSPECTION_TOOL::ShowMarkerInfo, EE_ACTIONS::showMarkerInfo.MakeEvent() ); diff --git a/eeschema/tools/ee_inspection_tool.h b/eeschema/tools/ee_inspection_tool.h index 7cc4ce6499..0d1a5d8b5f 100644 --- a/eeschema/tools/ee_inspection_tool.h +++ b/eeschema/tools/ee_inspection_tool.h @@ -42,6 +42,8 @@ public: /// @copydoc TOOL_INTERACTIVE::Init() bool Init() override; + int RunERC( const TOOL_EVENT& aEvent ); + int ShowDatasheet( const TOOL_EVENT& aEvent ); int ShowMarkerInfo( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 5e820d9945..044de813a9 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -48,6 +48,8 @@ #include #include #include +#include +#include TOOL_ACTION EE_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview", AS_GLOBAL, 0, "", "" ); @@ -89,6 +91,41 @@ TOOL_ACTION EE_ACTIONS::showLibraryBrowser( "eeschema.EditorControl.showLibraryB _( "Symbol Library Browser" ), _( "Browse symbol libraries" ), library_browse_xpm ); +TOOL_ACTION EE_ACTIONS::editSymbolFields( "eeschema.EditorControl.editSymbolFields", + AS_GLOBAL, 0, + _( "Edit Symbol Fields..." ), _( "Bulk-edit fields of all symbols in schematic" ), + spreadsheet_xpm ); + +TOOL_ACTION EE_ACTIONS::assignFootprints( "eeschema.EditorControl.assignFootprints", + AS_GLOBAL, 0, + _( "Assign Footprints..." ), _( "Run Cvpcb" ), + cvpcb_xpm ); + +TOOL_ACTION EE_ACTIONS::annotate( "eeschema.EditorControl.annotate", + AS_GLOBAL, 0, + _( "Annotate Schematic..." ), _( "Fill in schematic symbol reference designators" ), + annotate_xpm ); + +TOOL_ACTION EE_ACTIONS::showBusManager( "eeschema.EditorControl.showBusManager", + AS_GLOBAL, 0, + _( "Bus Definitions..." ), _( "Manage bus definitions" ), + bus_definition_tool_xpm ); + +TOOL_ACTION EE_ACTIONS::showPcbNew( "eeschema.EditorControl.showPcbNew", + AS_GLOBAL, 0, + _( "Open PCB Editor" ), _( "Run Pcbnew" ), + pcbnew_xpm ); + +TOOL_ACTION EE_ACTIONS::updatePcbFromSchematic( "eeschema.EditorControl.updatePcbFromSchematic", + AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_UPDATE_PCB_FROM_SCH ), + _( "Update PCB from Schematic..." ), _( "Push changes from schematic to PCB" ), + update_pcb_from_sch_xpm ); + +TOOL_ACTION EE_ACTIONS::generateBOM( "eeschema.EditorControl.generateBOM", + AS_GLOBAL, 0, + _( "Generate BOM..." ), _( "Generate a bill of materials for the current schematic" ), + bom_xpm ); + TOOL_ACTION EE_ACTIONS::enterSheet( "eeschema.EditorControl.enterSheet", AS_GLOBAL, 0, _( "Enter Sheet" ), _( "Display the selected sheet's contents in the Eeschema window" ), @@ -1053,6 +1090,60 @@ int SCH_EDITOR_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent ) } +int SCH_EDITOR_CONTROL::Annotate( const TOOL_EVENT& aEvent ) +{ + wxCommandEvent dummy; + m_frame->OnAnnotate( dummy ); + return 0; +} + + +int SCH_EDITOR_CONTROL::ShowCvpcb( const TOOL_EVENT& aEvent ) +{ + wxCommandEvent dummy; + m_frame->OnOpenCvpcb( dummy ); + return 0; +} + + +int SCH_EDITOR_CONTROL::EditSymbolFields( const TOOL_EVENT& aEvent ) +{ + DIALOG_FIELDS_EDITOR_GLOBAL dlg( m_frame ); + dlg.ShowQuasiModal(); + return 0; +} + + +int SCH_EDITOR_CONTROL::ShowPcbNew( const TOOL_EVENT& aEvent ) +{ + wxCommandEvent dummy; + m_frame->OnOpenPcbnew( dummy ); + return 0; +} + + +int SCH_EDITOR_CONTROL::UpdatePCB( const TOOL_EVENT& aEvent ) +{ + wxCommandEvent dummy; + m_frame->OnUpdatePCB( dummy ); + return 0; +} + + +int SCH_EDITOR_CONTROL::GenerateBOM( const TOOL_EVENT& aEvent ) +{ + InvokeDialogCreateBOM( m_frame ); + return 0; +} + + +int SCH_EDITOR_CONTROL::ShowBusManager( const TOOL_EVENT& aEvent ) +{ + InvokeDialogBusManager( m_frame ); + return 0; +} + + int SCH_EDITOR_CONTROL::EnterSheet( const TOOL_EVENT& aEvent ) { EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); @@ -1155,6 +1246,14 @@ void SCH_EDITOR_CONTROL::setTransitions() Go( &SCH_EDITOR_CONTROL::EditWithLibEdit, EE_ACTIONS::editWithLibEdit.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ShowSymbolEditor, EE_ACTIONS::showSymbolEditor.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::ShowLibraryBrowser, EE_ACTIONS::showLibraryBrowser.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() ); + Go( &SCH_EDITOR_CONTROL::ShowPcbNew, EE_ACTIONS::showPcbNew.MakeEvent() ); + Go( &SCH_EDITOR_CONTROL::UpdatePCB, EE_ACTIONS::updatePcbFromSchematic.MakeEvent() ); + Go( &SCH_EDITOR_CONTROL::GenerateBOM, EE_ACTIONS::generateBOM.MakeEvent() ); + + Go( &SCH_EDITOR_CONTROL::ShowBusManager, EE_ACTIONS::showBusManager.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::EnterSheet, EE_ACTIONS::enterSheet.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::LeaveSheet, EE_ACTIONS::leaveSheet.MakeEvent() ); diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index 9db5d9a4ea..f139adcb7d 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -104,6 +104,14 @@ public: 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 ); + int ShowPcbNew( const TOOL_EVENT& aEvent ); + int UpdatePCB( const TOOL_EVENT& aEvent ); + int GenerateBOM( const TOOL_EVENT& aEvent ); + + int ShowBusManager( const TOOL_EVENT& aEvent ); int EnterSheet( const TOOL_EVENT& aEvent ); int LeaveSheet( const TOOL_EVENT& aEvent ); diff --git a/include/id.h b/include/id.h index e961d0535f..c71e00ab5e 100644 --- a/include/id.h +++ b/include/id.h @@ -73,7 +73,6 @@ enum main_id { ID_RUN_PCB = wxID_HIGHEST, ID_RUN_PCB_MODULE_EDITOR, - ID_RUN_CVPCB, ID_RUN_LIBRARY, // pcbnew & eeschema each use this internally to load their respective lib editors ID_LOAD_PROJECT, @@ -256,8 +255,6 @@ enum main_id ID_DRAG_POINT, ID_GET_NETLIST, - ID_OPEN_CMP_TABLE, - ID_GET_TOOLS, ID_FIND_ITEMS, ID_EDA_SOCKET_EVENT_SERV,