Moved more operations to ACTIONs.

This commit is contained in:
Jeff Young 2019-06-01 19:36:49 +01:00
parent f49779465e
commit 39b91c90dd
24 changed files with 196 additions and 244 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 );
/**

View File

@ -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 <tomasz.wlostowski@cern.ch>
*
* 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 <kiway.h>
#include <sch_edit_frame.h>
#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();
}

View File

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

View File

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

View File

@ -28,27 +28,38 @@
#include <sch_component.h>
#include <sch_marker.h>
#include <id.h>
#include <kiway.h>
#include <ee_hotkeys.h>
#include <confirm.h>
#include <tool/conditional_menu.h>
#include <tool/selection_conditions.h>
#include <tool/selection.h>
#include <tool/tool_manager.h>
#include <search_stack.h>
#include <sim/sim_plot_frame.h>
#include <sch_view.h>
#include <sch_edit_frame.h>
#include <lib_edit_frame.h>
#include <viewlib_frame.h>
#include <eda_doc.h>
#include <invoke_sch_dialog.h>
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 <project.h>
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<LIB_EDIT_FRAME*>( m_frame );
LIB_VIEW_FRAME* libViewFrame = dynamic_cast<LIB_VIEW_FRAME*>( 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() );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -50,6 +50,7 @@
#include <tool/zoom_tool.h>
#include <tools/lib_control.h>
#include <tools/lib_move_tool.h>
#include <tools/ee_inspection_tool.h>
// 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:

View File

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

View File

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