From 39b91c90dd35af5cf1df55060673f8ea5022ab22 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 1 Jun 2019 19:36:49 +0100 Subject: [PATCH] Moved more operations to ACTIONs. --- eeschema/CMakeLists.txt | 1 - eeschema/ee_hotkeys.cpp | 8 +- eeschema/ee_hotkeys.h | 3 +- eeschema/eeschema_id.h | 4 - eeschema/libedit/lib_edit_frame.cpp | 54 ------------- eeschema/libedit/lib_edit_frame.h | 4 +- eeschema/libedit/libedit.cpp | 2 +- eeschema/libedit/menubar_libedit.cpp | 21 +++-- eeschema/libedit/toolbars_libedit.cpp | 29 +++---- eeschema/menubar.cpp | 15 +--- eeschema/sch_edit_frame.cpp | 18 ----- eeschema/sch_edit_frame.h | 1 - eeschema/sim/simulate.cpp | 39 ---------- eeschema/toolbars_viewlib.cpp | 49 +++++++----- eeschema/tools/ee_actions.h | 2 + eeschema/tools/ee_inspection_tool.cpp | 106 ++++++++++++++++++++++---- eeschema/tools/ee_inspection_tool.h | 1 + eeschema/tools/lib_control.cpp | 8 ++ eeschema/tools/lib_control.h | 1 + eeschema/tools/sch_editor_control.cpp | 14 ++++ eeschema/tools/sch_editor_control.h | 1 + eeschema/viewlib_frame.cpp | 26 +++---- eeschema/viewlib_frame.h | 10 +-- eeschema/viewlibs.cpp | 23 +----- 24 files changed, 196 insertions(+), 244 deletions(-) delete mode 100644 eeschema/sim/simulate.cpp diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 022f8a234c..28f067c6cd 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -259,7 +259,6 @@ if( KICAD_SPICE ) sim/sim_plot_frame.cpp sim/sim_plot_frame_base.cpp sim/sim_plot_panel.cpp - sim/simulate.cpp sim/spice_simulator.cpp sim/spice_value.cpp simulation_cursors.cpp diff --git a/eeschema/ee_hotkeys.cpp b/eeschema/ee_hotkeys.cpp index ace2d3f6d3..5f22fe09ab 100644 --- a/eeschema/ee_hotkeys.cpp +++ b/eeschema/ee_hotkeys.cpp @@ -155,7 +155,7 @@ static EDA_HOTKEY HkEdit( _HKI( "Edit Item" ), HK_EDIT, 'E' ); static EDA_HOTKEY HkEditValue( _HKI( "Edit Symbol Value" ), HK_EDIT_COMPONENT_VALUE, 'V' ); static EDA_HOTKEY HkEditReference( _HKI( "Edit Symbol Reference" ), HK_EDIT_COMPONENT_REFERENCE, 'U' ); static EDA_HOTKEY HkEditFootprint( _HKI( "Edit Symbol Footprint" ), HK_EDIT_COMPONENT_FOOTPRINT, 'F' ); -static EDA_HOTKEY HkShowDatasheet( _HKI( "Show Symbol Datasheet" ), HK_SHOW_COMPONENT_DATASHEET, 'D' ); +static EDA_HOTKEY HkShowDatasheet( _HKI( "Show Datasheet" ), HK_SHOW_DATASHEET, 'D' ); static EDA_HOTKEY HkEditWithLibedit( _HKI( "Edit with Symbol Editor" ), HK_EDIT_COMPONENT_WITH_LIBEDIT, 'E' + GR_KB_CTRL ); static EDA_HOTKEY HkDuplicateItem( _HKI( "Duplicate" ), HK_DUPLICATE, 'D' + GR_KB_CTRL ); @@ -176,8 +176,6 @@ static EDA_HOTKEY HkZoomSelection( _HKI( "Zoom to Selection" ), HK_ZOOM_SELECTIO // Special keys for library editor: static EDA_HOTKEY HkCreatePin( _HKI( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P' ); static EDA_HOTKEY HkInsertPin( _HKI( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT ); -static EDA_HOTKEY HkViewDoc( _HKI( "Show Datasheet" ), HK_LIBEDIT_VIEW_DOC, 'D' + GR_KB_ALT, - ID_LIBEDIT_VIEW_DOC ); // Autoplace fields static EDA_HOTKEY HkAutoplaceFields( _HKI( "Autoplace Fields" ), HK_AUTOPLACE_FIELDS, 'O' ); @@ -323,11 +321,11 @@ static EDA_HOTKEY* libEdit_Hotkey_List[] = { &HkCreatePin, &HkInsertPin, - &HkViewDoc, + &HkShowDatasheet, NULL }; -// List of hotkey descriptors for library viewer (currently empty +// List of hotkey descriptors for library viewer (currently empty) static EDA_HOTKEY* viewlib_Hotkey_List[] = { NULL diff --git a/eeschema/ee_hotkeys.h b/eeschema/ee_hotkeys.h index 2fb2094e7a..51e7eeadaf 100644 --- a/eeschema/ee_hotkeys.h +++ b/eeschema/ee_hotkeys.h @@ -36,13 +36,12 @@ enum hotkey_id_command { HK_REPEAT_LAST = HK_COMMON_END, HK_LIBEDIT_CREATE_PIN, - HK_LIBEDIT_VIEW_DOC, + HK_SHOW_DATASHEET, HK_ROTATE, HK_EDIT, HK_EDIT_COMPONENT_VALUE, HK_EDIT_COMPONENT_REFERENCE, HK_EDIT_COMPONENT_FOOTPRINT, - HK_SHOW_COMPONENT_DATASHEET, HK_EDIT_COMPONENT_WITH_LIBEDIT, HK_MIRROR_X, HK_MIRROR_Y, diff --git a/eeschema/eeschema_id.h b/eeschema/eeschema_id.h index 571a7bc158..576faece39 100644 --- a/eeschema/eeschema_id.h +++ b/eeschema/eeschema_id.h @@ -60,7 +60,6 @@ enum id_eeschema_frm ID_RESCUE_CACHED, ID_EDIT_SYM_LIB_TABLE, ID_REMAP_SYMBOLS, - ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, /* Schematic editor horizontal toolbar IDs */ ID_TO_LIBVIEW, @@ -119,7 +118,6 @@ enum id_eeschema_frm ID_DE_MORGAN_NORMAL_BUTT, ID_DE_MORGAN_CONVERT_BUTT, ID_LIBEDIT_SYNC_PIN_EDIT, - ID_LIBEDIT_VIEW_DOC, ID_LIBEDIT_CHECK_PART, ID_LIBEDIT_SELECT_PART_NUMBER, @@ -143,7 +141,6 @@ enum id_eeschema_frm ID_LIBVIEW_SELECT_PART, ID_LIBVIEW_NEXT, ID_LIBVIEW_PREVIOUS, - ID_LIBVIEW_VIEWDOC, ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, ID_LIBVIEW_SELECT_PART_NUMBER, @@ -155,7 +152,6 @@ enum id_eeschema_frm ID_SIM_TUNE, ID_SIM_PROBE, ID_SIM_ADD_SIGNALS, - ID_SIM_SHOW, ID_END_EESCHEMA_ID_LIST, // End of IDs specific to Eeschema diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index ea0ca001ad..41aeec3a28 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -88,7 +88,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) // Actions EVT_TOOL( ID_LIBEDIT_NEW_LIBRARY, LIB_EDIT_FRAME::OnCreateNewLibrary ) EVT_TOOL( ID_LIBEDIT_ADD_LIBRARY, LIB_EDIT_FRAME::OnAddLibrary ) - EVT_TOOL( ID_LIBEDIT_REVERT, LIB_EDIT_FRAME::OnRevert ) EVT_TOOL( ID_LIBEDIT_NEW_PART, LIB_EDIT_FRAME::OnCreateNewPart ) EVT_TOOL( ID_LIBEDIT_EDIT_PART, LIB_EDIT_FRAME::OnEditPart ) EVT_TOOL( ID_LIBEDIT_IMPORT_PART, LIB_EDIT_FRAME::OnImportPart ) @@ -104,7 +103,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnCheckComponent ) EVT_TOOL( ID_DE_MORGAN_NORMAL_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle ) EVT_TOOL( ID_DE_MORGAN_CONVERT_BUTT, LIB_EDIT_FRAME::OnSelectBodyStyle ) - EVT_TOOL( ID_LIBEDIT_VIEW_DOC, LIB_EDIT_FRAME::OnViewEntryDoc ) EVT_TOOL( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnSyncPinEditClick ) EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_EDIT_FRAME::OnAddPartToSchematic ) @@ -127,7 +125,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME ) // Update user interface elements. EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateHavePart ) EVT_UPDATE_UI( ID_LIBEDIT_SAVE_AS, LIB_EDIT_FRAME::OnUpdateHavePart ) - EVT_UPDATE_UI( ID_LIBEDIT_REVERT, LIB_EDIT_FRAME::OnUpdateRevert ) EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart ) EVT_UPDATE_UI( ID_LIBEDIT_SYNC_PIN_EDIT, LIB_EDIT_FRAME::OnUpdateSyncPinEdit ) EVT_UPDATE_UI( ID_LIBEDIT_SELECT_PART_NUMBER, LIB_EDIT_FRAME::OnUpdatePartNumber ) @@ -386,19 +383,6 @@ void LIB_EDIT_FRAME::ClearSearchTreeSelection() } -void LIB_EDIT_FRAME::OnUpdateRevert( wxUpdateUIEvent& aEvent ) -{ - LIB_ID libId = getTargetLibId(); - const wxString& libName = libId.GetLibNickname(); - const wxString& partName = libId.GetLibItemName(); - - if( partName.IsEmpty() ) - aEvent.Enable( !libName.IsEmpty() && m_libMgr->IsLibraryModified( libName ) ); - else - aEvent.Enable( !libName.IsEmpty() && m_libMgr->IsPartModified( partName, libName ) ); -} - - void LIB_EDIT_FRAME::OnUpdateHavePart( wxUpdateUIEvent& aEvent ) { aEvent.Enable( getTargetLibId().IsValid() ); @@ -472,44 +456,6 @@ void LIB_EDIT_FRAME::OnSelectUnit( wxCommandEvent& event ) } -void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event ) -{ - LIB_PART* part = GetCurPart(); - - if( !part ) - return; - - wxString filename; - - if( part->GetAliasCount() > 1 ) - { - ACTION_MENU popup; - wxString msg; - int id = 0; - - for( LIB_ALIAS* alias : part->GetAliases() ) - { - msg.Printf( wxT( "%s (%s)" ), alias->GetName(), alias->GetDocFileName() ); - popup.Append( id++, msg ); - } - - PopupMenu( &popup ); - - if( popup.GetSelected() >= 0 ) - filename = part->GetAlias( (unsigned) popup.GetSelected() )->GetDocFileName(); - } - else - filename = part->GetAlias( 0 )->GetDocFileName(); - - if( !filename.IsEmpty() && filename != wxT( "~" ) ) - { - SEARCH_STACK* lib_search = Prj().SchSearchS(); - - GetAssociatedDocument( this, filename, lib_search ); - } -} - - void LIB_EDIT_FRAME::OnSelectBodyStyle( wxCommandEvent& event ) { m_toolManager->RunAction( ACTIONS::cancelInteractive, true ); diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index c4bc69c38f..5dab1d0f99 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -267,7 +267,7 @@ public: /** * Reverts unsaved changes in a part, restoring to the last saved state. */ - void OnRevert( wxCommandEvent& aEvent ); + void OnRevert(); /** * Removes a part from the working copy of a library. @@ -286,13 +286,11 @@ public: bool IsSearchTreeShown(); void ClearSearchTreeSelection(); - void OnViewEntryDoc( wxCommandEvent& event ); void OnCheckComponent( wxCommandEvent& event ); void OnSelectBodyStyle( wxCommandEvent& event ); void OnUpdateEditingPart( wxUpdateUIEvent& event ); void OnUpdateHavePart( wxUpdateUIEvent& aEvent ); - void OnUpdateRevert( wxUpdateUIEvent& aEvent ); void OnUpdateSyncPinEdit( wxUpdateUIEvent& event ); void OnUpdatePartNumber( wxUpdateUIEvent& event ); void OnUpdateDeMorganNormal( wxUpdateUIEvent& event ); diff --git a/eeschema/libedit/libedit.cpp b/eeschema/libedit/libedit.cpp index b983565bef..1f92f431d5 100644 --- a/eeschema/libedit/libedit.cpp +++ b/eeschema/libedit/libedit.cpp @@ -666,7 +666,7 @@ void LIB_EDIT_FRAME::fixDuplicateAliases( LIB_PART* aPart, const wxString& aLibr } -void LIB_EDIT_FRAME::OnRevert( wxCommandEvent& aEvent ) +void LIB_EDIT_FRAME::OnRevert() { LIB_ID libId = getTargetLibId(); const wxString& libName = libId.GetLibNickname(); diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index d1e8e01177..e34b693b57 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -78,10 +78,7 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition ); fileMenu->AddItem( ACTIONS::saveAs, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::saveAll, EE_CONDITIONS::ShowAlways ); - fileMenu->AddItem( ID_LIBEDIT_REVERT, - _( "Revert" ), - _( "Throw away changes" ), - undo_xpm, EE_CONDITIONS::ShowAlways ); + fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition ); fileMenu->AddSeparator(); fileMenu->AddItem( ID_LIBEDIT_IMPORT_PART, @@ -197,18 +194,18 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() //-- Inspect menu ----------------------------------------------- // - wxMenu* inspectMenu = new wxMenu; + CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); - AddMenuItem( inspectMenu, - ID_LIBEDIT_VIEW_DOC, - AddHotkeyName( _( "Show Datasheet" ), g_Libedit_Hotkeys_Descr, HK_LIBEDIT_VIEW_DOC ), - _( "Open associated datasheet in web browser" ), - KiBitmap( datasheet_xpm ) ); + auto datasheetAvailableCondition = [ this ] ( const SELECTION& aSel ) { + return GetCurPart() != nullptr; + }; + + inspectMenu->AddItem( EE_ACTIONS::showDatasheet, datasheetAvailableCondition ); AddMenuItem( inspectMenu, ID_LIBEDIT_CHECK_PART, - _( "Electrical Rules &Checker" ), - _( "Check duplicate and off grid pins" ), + _( "Electrical Rules Checker" ), + _( "Check for duplicate and off-grid pins" ), KiBitmap( erc_xpm ) ); //-- Preferences menu ----------------------------------------------- diff --git a/eeschema/libedit/toolbars_libedit.cpp b/eeschema/libedit/toolbars_libedit.cpp index fc57b5e413..1dd30564ff 100644 --- a/eeschema/libedit/toolbars_libedit.cpp +++ b/eeschema/libedit/toolbars_libedit.cpp @@ -78,8 +78,6 @@ void LIB_EDIT_FRAME::ReCreateVToolbar() void LIB_EDIT_FRAME::ReCreateHToolbar() { - wxString msg; - if( m_mainToolBar ) m_mainToolBar->Clear(); else @@ -110,9 +108,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() KiScaledSeparator( m_mainToolBar, this ); - m_mainToolBar->AddTool( ID_LIBEDIT_VIEW_DOC, wxEmptyString, - KiScaledBitmap( datasheet_xpm, this ), - _( "Show associated datasheet or document" ) ); + m_mainToolBar->Add( EE_ACTIONS::showDatasheet ); m_mainToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, KiScaledBitmap( erc_xpm, this ), _( "Check duplicate and off grid pins" ) ); @@ -127,25 +123,20 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() _( "Show as \"De Morgan\" convert symbol" ), wxITEM_CHECK ); KiScaledSeparator( m_mainToolBar, this ); - - m_partSelectBox = new wxComboBox( m_mainToolBar, - ID_LIBEDIT_SELECT_PART_NUMBER, - wxEmptyString, - wxDefaultPosition, - wxSize( LISTBOX_WIDTH, -1 ), - 0, nullptr, wxCB_READONLY ); + m_partSelectBox = new wxComboBox( m_mainToolBar, ID_LIBEDIT_SELECT_PART_NUMBER, wxEmptyString, + wxDefaultPosition, wxSize( LISTBOX_WIDTH, -1 ), 0, nullptr, + wxCB_READONLY ); m_mainToolBar->AddControl( m_partSelectBox ); KiScaledSeparator( m_mainToolBar, this ); - - msg = _( "Synchronized pin edit mode\n" - "Synchronized pin edit mode propagates to other units all pin changes except pin number modification.\n" - "Enabled by default for multiunit parts with interchangeable units." ); m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString, - KiScaledBitmap( pin2pin_xpm, this ), msg, wxITEM_CHECK ); + KiScaledBitmap( pin2pin_xpm, this ), + _( "Synchronized pin edit mode\n" + "Propagates all changes (except pin numbers) to other units.\n" + "Enabled by default for multiunit parts with interchangeable units." ), + wxITEM_CHECK ); KiScaledSeparator( m_mainToolBar, this ); - m_mainToolBar->AddTool( ID_ADD_PART_TO_SCHEMATIC, wxEmptyString, KiScaledBitmap( export_xpm, this ), _( "Add symbol to schematic" ) ); @@ -184,6 +175,8 @@ void LIB_EDIT_FRAME::SyncMenusAndToolbars() m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); + m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, GetCurPart() != nullptr ); + // JEY TODO: deMorgan buttons... m_mainToolBar->Refresh(); m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 3618a7217a..4716f2efb7 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -251,6 +251,9 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); inspectMenu->AddItem( EE_ACTIONS::runERC, EE_CONDITIONS::ShowAlways ); +#ifdef KICAD_SPICE + inspectMenu->AddItem( EE_ACTIONS::runSimulation, EE_CONDITIONS::ShowAlways ); +#endif //-- Tools menu ----------------------------------------------- // @@ -278,11 +281,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() 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->AddItem( EE_ACTIONS::editSymbolLibraryLinks, EE_CONDITIONS::ShowAlways ); toolsMenu->AddSeparator(); toolsMenu->AddItem( EE_ACTIONS::annotate, EE_CONDITIONS::ShowAlways ); @@ -292,12 +291,6 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() 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 ----------------------------------------------- // CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index b8f52c8e33..d6a38038ea 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -232,7 +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_MENU( ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, SCH_EDIT_FRAME::OnEditComponentSymbolsId ) EVT_TOOL( ID_RUN_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenFootprintEditor ) @@ -240,11 +239,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) 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 ) - -#ifdef KICAD_SPICE - EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate ) -#endif /* KICAD_SPICE */ - END_EVENT_TABLE() @@ -983,18 +977,6 @@ void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event ) } -// This method is not the same as OnRemapSymbols. -// It allows renaming the lib id of groups of components when a symbol -// has moved from a library to another library. -// For instance to rename libname1::mysymbol to libname2::mysymbol -// or any other lib id name -void SCH_EDIT_FRAME::OnEditComponentSymbolsId( wxCommandEvent& event ) -{ - InvokeDialogEditComponentsLibId( this ); - GetCanvas()->Refresh( true ); -} - - void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event ) { Close( false ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 2b38148554..ae2a57ee69 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -773,7 +773,6 @@ private: // 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 // another library - void OnEditComponentSymbolsId( wxCommandEvent& aEvent ); void OnPreferencesOptions( wxCommandEvent& event ); /** diff --git a/eeschema/sim/simulate.cpp b/eeschema/sim/simulate.cpp deleted file mode 100644 index 5dd6dcbf88..0000000000 --- a/eeschema/sim/simulate.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2016 CERN - * @author Tomasz Wlostowski - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * https://www.gnu.org/licenses/gpl-3.0.html - * or you may search the http://www.gnu.org website for the version 3 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include "sim_plot_frame.h" - -void SCH_EDIT_FRAME::OnSimulate( wxCommandEvent& event ) -{ - SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, true ); - simFrame->Show( true ); - - // On Windows, Raise() does not bring the window on screen, when iconized - if( simFrame->IsIconized() ) - simFrame->Iconize( false ); - - simFrame->Raise(); -} \ No newline at end of file diff --git a/eeschema/toolbars_viewlib.cpp b/eeschema/toolbars_viewlib.cpp index 5a9a30243b..cdaf399ec5 100644 --- a/eeschema/toolbars_viewlib.cpp +++ b/eeschema/toolbars_viewlib.cpp @@ -49,17 +49,17 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() wxString msg; m_mainToolBar->AddTool( ID_LIBVIEW_SELECT_PART, wxEmptyString, - KiScaledBitmap( add_component_xpm, this ), - _( "Select symbol to browse" ) ); + KiScaledBitmap( add_component_xpm, this ), + _( "Select symbol to browse" ) ); KiScaledSeparator( m_mainToolBar, this ); m_mainToolBar->AddTool( ID_LIBVIEW_PREVIOUS, wxEmptyString, - KiScaledBitmap( lib_previous_xpm, this ), - _( "Display previous symbol" ) ); + KiScaledBitmap( lib_previous_xpm, this ), + _( "Display previous symbol" ) ); m_mainToolBar->AddTool( ID_LIBVIEW_NEXT, wxEmptyString, - KiScaledBitmap( lib_next_xpm, this ), - _( "Display next symbol" ) ); + KiScaledBitmap( lib_next_xpm, this ), + _( "Display next symbol" ) ); toolbar->AddSeparator(); toolbar->Add( ACTIONS::zoomRedraw ); @@ -69,33 +69,30 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() KiScaledSeparator( m_mainToolBar, this ); m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, wxEmptyString, - KiScaledBitmap( morgan1_xpm, this ), - _( "Show as \"De Morgan\" normal symbol" ), - wxITEM_CHECK ); + KiScaledBitmap( morgan1_xpm, this ), + _( "Show as \"De Morgan\" normal symbol" ), + wxITEM_CHECK ); m_mainToolBar->AddTool( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, wxEmptyString, - KiScaledBitmap( morgan2_xpm, this ), - _( "Show as \"De Morgan\" convert symbol" ), - wxITEM_CHECK ); + KiScaledBitmap( morgan2_xpm, this ), + _( "Show as \"De Morgan\" convert symbol" ), + wxITEM_CHECK ); KiScaledSeparator( m_mainToolBar, this ); - m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, - wxDefaultPosition, wxSize( 150, -1 ) ); + m_unitChoice = new wxChoice( m_mainToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, wxDefaultPosition, + wxSize( 150, -1 ) ); m_mainToolBar->AddControl( m_unitChoice ); KiScaledSeparator( m_mainToolBar, this ); - m_mainToolBar->AddTool( ID_LIBVIEW_VIEWDOC, wxEmptyString, - KiScaledBitmap( datasheet_xpm, this ), - _( "View symbol documents" ) ); + m_mainToolBar->Add( EE_ACTIONS::showDatasheet ); KiScaledSeparator( m_mainToolBar, this ); m_mainToolBar->AddTool( ID_ADD_PART_TO_SCHEMATIC, wxEmptyString, - KiScaledBitmap( export_xpm, this ), - _( "Add symbol to schematic" ) ); + KiScaledBitmap( export_xpm, this ), + _( "Add symbol to schematic" ) ); - // after adding the buttons to the toolbar, must call Realize() to - // reflect the changes + // after adding the buttons to the toolbar, must call Realize() to reflect the changes m_mainToolBar->Realize(); m_mainToolBar->Refresh(); @@ -159,3 +156,13 @@ void LIB_VIEW_FRAME::ReCreateMenuBar() SetMenuBar( menuBar ); delete oldMenuBar; } + + +void LIB_VIEW_FRAME::SyncMenusAndToolbars() +{ + LIB_ALIAS* alias = GetSelectedAlias(); + + m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, alias && !alias->GetDocFileName().IsEmpty() ); + // JEY TODO: deMorgan buttons... + m_mainToolBar->Refresh(); +} diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 06cd662a83..571378d88c 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -151,6 +151,7 @@ public: static TOOL_ACTION showMarkerInfo; static TOOL_ACTION annotate; static TOOL_ACTION editSymbolFields; + static TOOL_ACTION editSymbolLibraryLinks; static TOOL_ACTION assignFootprints; static TOOL_ACTION showBusManager; @@ -161,6 +162,7 @@ public: static TOOL_ACTION showPcbNew; static TOOL_ACTION updatePcbFromSchematic; static TOOL_ACTION generateBOM; + static TOOL_ACTION runSimulation; // Miscellaneous static TOOL_ACTION enterSheet; diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 8dce019c10..673613f792 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -28,27 +28,38 @@ #include #include #include +#include #include #include #include #include #include #include +#include +#include #include #include +#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 ); +#include TOOL_ACTION EE_ACTIONS::runERC( "eeschame.InspectionTool.runERC", AS_GLOBAL, 0, _( "Electrical Rules &Checker" ), _( "Perform electrical rules check" ), erc_xpm ); +TOOL_ACTION EE_ACTIONS::runSimulation( "eeschema.EditorControl.runSimulation", + AS_GLOBAL, 0, + _( "Simulator..." ), _( "Simulate circuit in SPICE" ), + simulator_xpm ); + +TOOL_ACTION EE_ACTIONS::showDatasheet( "eeschema.InspectionTool.showDatasheet", + AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SHOW_DATASHEET ), + _( "Show Datasheet" ), _( "Opens the datasheet in a browser" ), + datasheet_xpm ); + TOOL_ACTION EE_ACTIONS::showMarkerInfo( "eeschema.InspectionTool.showMarkerInfo", AS_GLOBAL, 0, _( "Show Marker Info" ), _( "Display the marker's info in a dialog" ), @@ -72,8 +83,8 @@ bool EE_INSPECTION_TOOL::Init() // CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu(); - selToolMenu.AddItem( EE_ACTIONS::showDatasheet, EE_CONDITIONS::SingleSymbol && EE_CONDITIONS::Idle, 400 ); - selToolMenu.AddItem( EE_ACTIONS::showMarkerInfo, singleMarkerCondition && EE_CONDITIONS::Idle, 400 ); + selToolMenu.AddItem( EE_ACTIONS::showDatasheet, EE_CONDITIONS::SingleSymbol && EE_CONDITIONS::Idle, 220 ); + selToolMenu.AddItem( EE_ACTIONS::showMarkerInfo, singleMarkerCondition && EE_CONDITIONS::Idle, 220 ); return true; } @@ -94,18 +105,83 @@ int EE_INSPECTION_TOOL::RunERC( const TOOL_EVENT& aEvent ) } +int EE_INSPECTION_TOOL::RunSimulation( const TOOL_EVENT& aEvent ) +{ +#ifdef KICAD_SPICE + SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) m_frame->Kiway().Player( FRAME_SIMULATOR, true ); + simFrame->Show( true ); + + // On Windows, Raise() does not bring the window on screen, when iconized + if( simFrame->IsIconized() ) + simFrame->Iconize( false ); + + simFrame->Raise(); +#endif /* KICAD_SPICE */ + return 0; +} + + int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent ) { - SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly ); + wxString datasheet; - if( selection.Empty() ) - return 0; + LIB_EDIT_FRAME* libEditFrame = dynamic_cast( m_frame ); + LIB_VIEW_FRAME* libViewFrame = dynamic_cast( m_frame ); - SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front(); - wxString datasheet = component->GetField( DATASHEET )->GetText(); + if( libEditFrame ) + { + LIB_PART* part = libEditFrame->GetCurPart(); - if( !datasheet.IsEmpty() ) - GetAssociatedDocument( m_frame, datasheet ); + if( !part ) + return 0; + + if( part->GetAliasCount() > 1 ) + { + ACTION_MENU popup; + wxString msg; + int id = 0; + + for( LIB_ALIAS* alias : part->GetAliases() ) + { + msg.Printf( wxT( "%s (%s)" ), alias->GetName(), alias->GetDocFileName() ); + popup.Append( id++, msg ); + } + + m_frame->PopupMenu( &popup ); + + if( popup.GetSelected() >= 0 ) + datasheet = part->GetAlias( (unsigned) popup.GetSelected() )->GetDocFileName(); + } + else + datasheet = part->GetAlias( 0 )->GetDocFileName(); + } + else if( libViewFrame ) + { + LIB_ALIAS* entry = libViewFrame->GetSelectedAlias(); + + if( !entry ) + return 0; + + datasheet = entry->GetDocFileName(); + } + else + { + SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::ComponentsOnly ); + + if( selection.Empty() ) + return 0; + + SCH_COMPONENT* component = (SCH_COMPONENT*) selection.Front(); + + datasheet = component->GetField( DATASHEET )->GetText(); + } + + if( !datasheet.IsEmpty() && datasheet != wxT( "~" ) ) + { + SEARCH_STACK* lib_search = m_frame->Prj().SchSearchS(); + + GetAssociatedDocument( m_frame, datasheet, lib_search ); + } return 0; } @@ -152,6 +228,8 @@ 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::RunSimulation, EE_ACTIONS::runSimulation.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 0d1a5d8b5f..3baab0a26b 100644 --- a/eeschema/tools/ee_inspection_tool.h +++ b/eeschema/tools/ee_inspection_tool.h @@ -43,6 +43,7 @@ public: bool Init() override; int RunERC( const TOOL_EVENT& aEvent ); + int RunSimulation( const TOOL_EVENT& aEvent ); int ShowDatasheet( const TOOL_EVENT& aEvent ); int ShowMarkerInfo( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index 05b09746f8..8f7a6c79b0 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -62,6 +62,13 @@ int LIB_CONTROL::SaveAll( const TOOL_EVENT& aEvent ) } +int LIB_CONTROL::Revert( const TOOL_EVENT& aEvent ) +{ + m_frame->OnRevert(); + return 0; +} + + int LIB_CONTROL::ShowLibraryBrowser( const TOOL_EVENT& aEvent ) { wxCommandEvent dummy; @@ -103,6 +110,7 @@ void LIB_CONTROL::setTransitions() Go( &LIB_CONTROL::Save, ACTIONS::save.MakeEvent() ); Go( &LIB_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() ); Go( &LIB_CONTROL::SaveAll, ACTIONS::saveAll.MakeEvent() ); + Go( &LIB_CONTROL::Revert, ACTIONS::revert.MakeEvent() ); Go( &LIB_CONTROL::ShowLibraryBrowser, EE_ACTIONS::showLibraryBrowser.MakeEvent() ); Go( &LIB_CONTROL::ShowElectricalTypes, EE_ACTIONS::showElectricalTypes.MakeEvent() ); diff --git a/eeschema/tools/lib_control.h b/eeschema/tools/lib_control.h index 33b8895cbd..a503a4b926 100644 --- a/eeschema/tools/lib_control.h +++ b/eeschema/tools/lib_control.h @@ -47,6 +47,7 @@ public: int Save( const TOOL_EVENT& aEvent ); int SaveAs( const TOOL_EVENT& aEvent ); int SaveAll( const TOOL_EVENT& aEvent ); + int Revert( const TOOL_EVENT& aEvent ); int ShowLibraryBrowser( const TOOL_EVENT& aEvent ); int ShowElectricalTypes( const TOOL_EVENT& aEvent ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 044de813a9..7049ef715c 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -96,6 +96,11 @@ TOOL_ACTION EE_ACTIONS::editSymbolFields( "eeschema.EditorControl.editSymbolFiel _( "Edit Symbol Fields..." ), _( "Bulk-edit fields of all symbols in schematic" ), spreadsheet_xpm ); +TOOL_ACTION EE_ACTIONS::editSymbolLibraryLinks( "eeschema.EditorControl.editSymbolLibraryLinks", + AS_GLOBAL, 0, + _( "Edit Symbol Library Links..." ), _( "Edit links between schematic and library symbols" ), + edit_cmp_symb_links_xpm ); + TOOL_ACTION EE_ACTIONS::assignFootprints( "eeschema.EditorControl.assignFootprints", AS_GLOBAL, 0, _( "Assign Footprints..." ), _( "Run Cvpcb" ), @@ -1114,6 +1119,14 @@ int SCH_EDITOR_CONTROL::EditSymbolFields( const TOOL_EVENT& aEvent ) } +int SCH_EDITOR_CONTROL::EditSymbolLibraryLinks( const TOOL_EVENT& aEvent ) +{ + InvokeDialogEditComponentsLibId( m_frame ); + m_frame->GetCanvas()->Refresh( true ); + return 0; +} + + int SCH_EDITOR_CONTROL::ShowPcbNew( const TOOL_EVENT& aEvent ) { wxCommandEvent dummy; @@ -1249,6 +1262,7 @@ void SCH_EDITOR_CONTROL::setTransitions() 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::EditSymbolLibraryLinks,EE_ACTIONS::editSymbolLibraryLinks.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() ); diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index f139adcb7d..c849793b68 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -107,6 +107,7 @@ public: int ShowCvpcb( const TOOL_EVENT& aEvent ); int Annotate( const TOOL_EVENT& aEvent ); int EditSymbolFields( const TOOL_EVENT& aEvent ); + int EditSymbolLibraryLinks( const TOOL_EVENT& aEvent ); int ShowPcbNew( const TOOL_EVENT& aEvent ); int UpdatePCB( const TOOL_EVENT& aEvent ); int GenerateBOM( const TOOL_EVENT& aEvent ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 512b40328f..39a1a538f5 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -50,6 +50,7 @@ #include #include #include +#include // Save previous component library viewer state. wxString LIB_VIEW_FRAME::m_libraryName; @@ -69,7 +70,6 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME ) EVT_TOOL( ID_LIBVIEW_SELECT_PART, LIB_VIEW_FRAME::OnSelectSymbol ) EVT_TOOL( ID_LIBVIEW_NEXT, LIB_VIEW_FRAME::onSelectNextSymbol ) EVT_TOOL( ID_LIBVIEW_PREVIOUS, LIB_VIEW_FRAME::onSelectPreviousSymbol ) - EVT_TOOL( ID_LIBVIEW_VIEWDOC, LIB_VIEW_FRAME::onViewSymbolDocument ) EVT_TOOL_RANGE( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, LIB_VIEW_FRAME::onSelectSymbolBodyStyle ) EVT_CHOICE( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onSelectSymbolUnit ) @@ -89,7 +89,6 @@ BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME ) EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton ) EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, LIB_VIEW_FRAME::onUpdateAltBodyStyleButton ) EVT_UPDATE_UI( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onUpdateUnitChoice ) - EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_VIEW_FRAME::onUpdateDocButton ) END_EVENT_TABLE() @@ -234,6 +233,7 @@ void LIB_VIEW_FRAME::setupTools() // Register tools m_toolManager->RegisterTool( new COMMON_TOOLS ); m_toolManager->RegisterTool( new ZOOM_TOOL ); + m_toolManager->RegisterTool( new EE_INSPECTION_TOOL ); // manage show datasheet m_toolManager->RegisterTool( new EE_SELECTION_TOOL ); // manage context menu m_toolManager->RegisterTool( new LIB_CONTROL ); // manage show electrical type option m_toolManager->RegisterTool( new LIB_MOVE_TOOL ); @@ -262,7 +262,7 @@ void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert ) } -LIB_ALIAS* LIB_VIEW_FRAME::getSelectedAlias() const +LIB_ALIAS* LIB_VIEW_FRAME::GetSelectedAlias() const { LIB_ALIAS* alias = NULL; @@ -273,10 +273,10 @@ LIB_ALIAS* LIB_VIEW_FRAME::getSelectedAlias() const } -LIB_PART* LIB_VIEW_FRAME::getSelectedSymbol() const +LIB_PART* LIB_VIEW_FRAME::GetSelectedSymbol() const { LIB_PART* symbol = NULL; - LIB_ALIAS* alias = getSelectedAlias(); + LIB_ALIAS* alias = GetSelectedAlias(); if( alias ) symbol = alias->GetPart(); @@ -287,7 +287,7 @@ LIB_PART* LIB_VIEW_FRAME::getSelectedSymbol() const void LIB_VIEW_FRAME::updatePreviewSymbol() { - LIB_ALIAS* alias = getSelectedAlias(); + LIB_ALIAS* alias = GetSelectedAlias(); KIGFX::SCH_VIEW* view = GetCanvas()->GetView(); if( m_previewItem ) @@ -317,7 +317,7 @@ void LIB_VIEW_FRAME::updatePreviewSymbol() void LIB_VIEW_FRAME::onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent ) { - LIB_PART* symbol = getSelectedSymbol(); + LIB_PART* symbol = GetSelectedSymbol(); aEvent.Enable( symbol && symbol->HasConversion() ); @@ -330,7 +330,7 @@ void LIB_VIEW_FRAME::onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent ) void LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent ) { - LIB_PART* symbol = getSelectedSymbol(); + LIB_PART* symbol = GetSelectedSymbol(); aEvent.Enable( symbol && symbol->HasConversion() ); @@ -417,7 +417,7 @@ void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event ) void LIB_VIEW_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent ) { - LIB_PART* part = getSelectedSymbol(); + LIB_PART* part = GetSelectedSymbol(); int unit_count = 1; @@ -775,7 +775,7 @@ void LIB_VIEW_FRAME::SetFilter( const SCHLIB_FILTER* aFilter ) const BOX2I LIB_VIEW_FRAME::GetDocumentExtents() const { - LIB_ALIAS* alias = getSelectedAlias(); + LIB_ALIAS* alias = GetSelectedAlias(); LIB_PART* part = alias ? alias->GetPart() : nullptr; if( !part ) @@ -806,7 +806,7 @@ void LIB_VIEW_FRAME::OnAddPartToSchematic( wxCommandEvent& aEvent ) return; } - if( getSelectedSymbol() ) + if( GetSelectedSymbol() ) { SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); @@ -816,8 +816,8 @@ void LIB_VIEW_FRAME::OnAddPartToSchematic( wxCommandEvent& aEvent ) return; } - SCH_COMPONENT* component = new SCH_COMPONENT( *getSelectedSymbol(), - getSelectedAlias()->GetLibId(), + SCH_COMPONENT* component = new SCH_COMPONENT( *GetSelectedSymbol(), + GetSelectedAlias()->GetLibId(), g_CurrentSheet, m_unit, m_convert ); // Be sure the link to the corresponding LIB_PART is OK: diff --git a/eeschema/viewlib_frame.h b/eeschema/viewlib_frame.h index 280684ffd4..12fc69a1a0 100644 --- a/eeschema/viewlib_frame.h +++ b/eeschema/viewlib_frame.h @@ -141,8 +141,13 @@ public: int GetUnit() const { return m_unit; } int GetConvert() const { return m_convert; } + LIB_PART* GetSelectedSymbol() const; + LIB_ALIAS* GetSelectedAlias() const; + const BOX2I GetDocumentExtents() const override; + void SyncMenusAndToolbars() override; + private: // Sets up the tool framework void setupTools(); @@ -157,19 +162,14 @@ private: void onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent ); void onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent ); - void onUpdateDocButton( wxUpdateUIEvent& aEvent ); - void OnUpdateElectricalType( wxUpdateUIEvent& aEvent ); void onUpdateUnitChoice( wxUpdateUIEvent& aEvent ); void onSelectNextSymbol( wxCommandEvent& aEvent ); void onSelectPreviousSymbol( wxCommandEvent& aEvent ); - void onViewSymbolDocument( wxCommandEvent& aEvent ); void onSelectSymbolBodyStyle( wxCommandEvent& aEvent ); void onSelectSymbolUnit( wxCommandEvent& aEvent ); void OnAddPartToSchematic( wxCommandEvent& aEvent ); - LIB_ALIAS* getSelectedAlias() const; - LIB_PART* getSelectedSymbol() const; void updatePreviewSymbol(); // Private members: diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index e0871f8902..9e0b49eb5e 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -54,7 +54,7 @@ void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent ) const auto libNicknames = libs->GetLogicalLibs(); adapter->AddLibraries( libNicknames, this ); - LIB_ALIAS *current = getSelectedAlias(); + LIB_ALIAS *current = GetSelectedAlias(); LIB_ID id; int unit = 0; @@ -111,27 +111,6 @@ void LIB_VIEW_FRAME::onSelectPreviousSymbol( wxCommandEvent& aEvent ) } -void LIB_VIEW_FRAME::onUpdateDocButton( wxUpdateUIEvent& aEvent ) -{ - LIB_ALIAS* entry = getSelectedAlias(); - - aEvent.Enable( entry && !entry->GetDocFileName().IsEmpty() ); -} - - -void LIB_VIEW_FRAME::onViewSymbolDocument( wxCommandEvent& aEvent ) -{ - LIB_ALIAS* entry = getSelectedAlias(); - - if( entry && !entry->GetDocFileName().IsEmpty() ) - { - SEARCH_STACK* lib_search = Prj().SchSearchS(); - - GetAssociatedDocument( this, entry->GetDocFileName(), lib_search ); - } -} - - void LIB_VIEW_FRAME::onSelectSymbolBodyStyle( wxCommandEvent& aEvent ) { if( aEvent.GetId() == ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT )