Move a few more commands to tool framework.

This commit is contained in:
Jeff Young 2020-05-12 18:12:38 +01:00
parent 301ac3461c
commit 724c669434
11 changed files with 135 additions and 143 deletions

View File

@ -1,6 +1,3 @@
/** @file dialog_plot_schematic.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
@ -42,22 +39,11 @@ int DIALOG_PLOT_SCHEMATIC::m_pageSizeSelect = PAGE_SIZE_AUTO;
int DIALOG_PLOT_SCHEMATIC::m_HPGLPaperSizeSelect = PAGE_SIZE_AUTO;
void SCH_EDIT_FRAME::PlotSchematic()
{
DIALOG_PLOT_SCHEMATIC dlg( this );
dlg.ShowModal();
// save project config if the prj config has changed:
if( dlg.PrjConfigChanged() )
SaveProjectSettings();
}
DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent )
: DIALOG_PLOT_SCHEMATIC_BASE( parent ),
m_parent( parent ),
m_plotFormat( PLOT_FORMAT::UNDEFINED ),
m_HPGLPenSize( 1.0 ),
m_defaultLineWidth( parent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true ),
m_penWidth( parent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true )
{

View File

@ -56,10 +56,6 @@ enum id_eeschema_frm
{
ID_IMPORT_NON_KICAD_SCH = ID_END_LIST,
/* Schematic editor main menubar IDs. */
ID_RESCUE_CACHED,
ID_REMAP_SYMBOLS,
/* Library editor horizontal toolbar IDs. */
ID_LIBEDIT_SELECT_PART_NUMBER,

View File

@ -52,6 +52,7 @@
#include <ws_data_model.h>
#include <connection_graph.h>
#include <tool/actions.h>
#include <tools/sch_editor_control.h>>
#include <netlist.h>
@ -426,7 +427,10 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
}
if( !cfg || !cfg->m_RescueNeverShow )
RescueSymbolLibTableProject( false );
{
SCH_EDITOR_CONTROL* editor = m_toolManager->GetTool<SCH_EDITOR_CONTROL>();
editor->RescueSymbolLibTableProject( false );
}
}
// Update all symbol library links for all sheets.

View File

@ -269,13 +269,8 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
toolsMenu->AddSeparator();
toolsMenu->AddItem( ACTIONS::showSymbolEditor, EE_CONDITIONS::ShowAlways );
toolsMenu->AddItem( ID_RESCUE_CACHED, _( "Rescue Symbols..." ),
_( "Find old symbols in project and rename/rescue them" ),
rescue_xpm, EE_CONDITIONS::ShowAlways );
toolsMenu->AddItem( ID_REMAP_SYMBOLS, _( "Remap Symbols..." ),
_( "Remap legacy library symbols to symbol library table" ),
rescue_xpm, remapSymbolsCondition );
toolsMenu->AddItem( EE_ACTIONS::rescueSymbols, EE_CONDITIONS::ShowAlways );
toolsMenu->AddItem( EE_ACTIONS::remapSymbols, remapSymbolsCondition );
toolsMenu->AddSeparator();
toolsMenu->AddItem( EE_ACTIONS::editSymbolFields, EE_CONDITIONS::ShowAlways );

View File

@ -541,53 +541,6 @@ void RESCUER::UndoRescues()
}
bool SCH_EDIT_FRAME::RescueLegacyProject( bool aRunningOnDemand )
{
LEGACY_RESCUER rescuer( Prj(), &GetCurrentSheet(), GetCanvas()->GetBackend() );
return rescueProject( rescuer, aRunningOnDemand );
}
bool SCH_EDIT_FRAME::RescueSymbolLibTableProject( bool aRunningOnDemand )
{
SYMBOL_LIB_TABLE_RESCUER rescuer( Prj(), &GetCurrentSheet(), GetCanvas()->GetBackend() );
return rescueProject( rescuer, aRunningOnDemand );
}
bool SCH_EDIT_FRAME::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
{
if( !RESCUER::RescueProject( this, aRescuer, aRunningOnDemand ) )
return false;
if( aRescuer.GetCandidateCount() )
{
LIB_VIEW_FRAME* viewer = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
if( viewer )
viewer->ReCreateListLib();
if( aRunningOnDemand )
{
SCH_SCREENS schematic;
schematic.UpdateSymbolLinks();
g_ConnectionGraph->Reset();
RecalculateConnections( GLOBAL_CLEANUP );
}
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
SyncView();
GetCanvas()->Refresh();
OnModify();
}
return true;
}
bool RESCUER::RescueProject( wxWindow* aParent, RESCUER& aRescuer, bool aRunningOnDemand )
{
aRescuer.FindCandidates();

View File

@ -201,9 +201,6 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
EVT_MENU( wxID_CLOSE, SCH_EDIT_FRAME::OnExit )
EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject )
EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols )
EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
END_EVENT_TABLE()
@ -889,27 +886,6 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
}
void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
{
SCH_SCREENS schematic;
if( schematic.HasNoFullyDefinedLibIds() )
RescueLegacyProject( true );
else
RescueSymbolLibTableProject( true );
}
void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event )
{
DIALOG_SYMBOL_REMAP dlgRemap( this );
dlgRemap.ShowQuasiModal();
GetCanvas()->Refresh( true );
}
void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
{
if( event.GetId() == wxID_EXIT )
@ -920,17 +896,6 @@ void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
}
void SCH_EDIT_FRAME::Print()
{
InvokeDialogPrintUsingPrinter( this );
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
if( fn.GetName() != NAMELESS_PROJECT )
Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters() );
}
void SCH_EDIT_FRAME::PrintPage( RENDER_SETTINGS* aSettings )
{
wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );

View File

@ -558,11 +558,6 @@ public:
*/
void SetSheetNumberAndCount();
/**
* Show the print dialog.
*/
void Print();
wxPageSetupDialogData& GetPageSetupData() { return m_pageSetupData; }
bool GetPrintMonochrome() { return m_printMonochrome; }
@ -570,9 +565,6 @@ public:
bool GetPrintSheetReference() { return m_printSheetReference; }
void SetPrintSheetReference( bool aShow ) { m_printSheetReference = aShow; }
// Plot functions:
void PlotSchematic();
void NewProject();
void LoadProject();
@ -661,8 +653,6 @@ public:
void OnOpenPcbnew( wxCommandEvent& event );
void OnOpenCvpcb( wxCommandEvent& event );
void OnRescueProject( wxCommandEvent& event );
void OnRemapSymbols( wxCommandEvent& aEvent );
void OnUpdatePCB( wxCommandEvent& event );
void OnAnnotate( wxCommandEvent& event );
@ -943,23 +933,6 @@ public:
*/
bool CreateArchiveLibrary( const wxString& aFileName );
/**
* Perform rescue operations to recover old projects from before certain changes were made.
*
* - Exports cached symbols that conflict with new symbols to a separate library.
* - Exports cached symbols not found in any symbol library.
* - Renames symbols named before libraries were case sensitive.
*
* @param aRunningOnDemand - indicates whether the tool has been called up by the user
* (as opposed to being run automatically). If true, an information dialog is
* displayed if there are no components to rescue. If false, the tool is silent
* if there are no components to rescue, and a "Never Show Again" button is
* displayed.
*/
bool rescueProject( RESCUER& aRescuer, bool aRunningOnDemand );
bool RescueLegacyProject( bool aRunningOnDemand );
bool RescueSymbolLibTableProject( bool aRunningOnDemand );
/**
* Plot or print the current sheet to the clipboard.
*

View File

@ -547,6 +547,18 @@ TOOL_ACTION EE_ACTIONS::schematicSetup( "eeschema.EditorControl.schematicSetup",
_( "Edit schematic setup including annotation styles and electrical rules" ),
options_schematic_xpm );
TOOL_ACTION EE_ACTIONS::rescueSymbols( "eeschema.EditorControl.rescueSymbols",
AS_GLOBAL, 0, "",
_( "Rescue Symbols..." ),
_( "Find old symbols in project and rename/rescue them" ),
rescue_xpm );
TOOL_ACTION EE_ACTIONS::remapSymbols( "eeschema.EditorControl.remapSymbols",
AS_GLOBAL, 0, "",
_( "Remap Symbols..." ),
_( "Remap legacy library symbols to symbol library table" ),
rescue_xpm );
TOOL_ACTION EE_ACTIONS::showBusManager( "eeschema.EditorControl.showBusManager",
AS_GLOBAL, 0, "",
_( "Bus Definitions..." ), _( "Manage bus definitions" ),

View File

@ -153,6 +153,9 @@ public:
static TOOL_ACTION showBusManager;
static TOOL_ACTION schematicSetup;
static TOOL_ACTION rescueSymbols;
static TOOL_ACTION remapSymbols;
// Suite operations
static TOOL_ACTION editWithLibEdit;
static TOOL_ACTION showPcbNew;

View File

@ -28,6 +28,9 @@
#include <dialogs/dialog_fields_editor_global.h>
#include <dialogs/dialog_page_settings.h>
#include <dialogs/dialog_paste_special.h>
#include <dialogs/dialog_plot_schematic.h>
#include <dialogs/dialog_symbol_remap.h>
#include <project_rescue.h>
#include <erc.h>
#include <fctsys.h>
#include <invoke_sch_dialog.h>
@ -43,6 +46,7 @@
#include <advanced_config.h>
#include <sim/sim_plot_frame.h>
#include <simulation_cursors.h>
#include <lib_view_frame.h>
#include <status_popup.h>
#include <tool/picker_tool.h>
#include <tool/tool_manager.h>
@ -51,14 +55,10 @@
#include <tools/ee_selection_tool.h>
#include <tools/sch_editor_control.h>
#include <ws_proxy_undo_item.h>
#include <dialogs/dialog_page_settings.h>
#include <dialogs/dialog_fields_editor_global.h>
#include <invoke_sch_dialog.h>
#include <dialogs/dialog_paste_special.h>
#include <netlist_exporters/netlist_exporter_pspice.h>
#include <math/util.h> // for KiROUND
#include <dialog_update_from_pcb.h>
int SCH_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
{
m_frame->NewProject();
@ -113,16 +113,103 @@ int SCH_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent )
}
int SCH_EDITOR_CONTROL::RescueSymbols( const TOOL_EVENT& aEvent )
{
SCH_SCREENS schematic;
if( schematic.HasNoFullyDefinedLibIds() )
RescueLegacyProject( true );
else
RescueSymbolLibTableProject( true );
return 0;
}
bool SCH_EDITOR_CONTROL::RescueLegacyProject( bool aRunningOnDemand )
{
LEGACY_RESCUER rescuer( m_frame->Prj(), &m_frame->GetCurrentSheet(),
m_frame->GetCanvas()->GetBackend() );
return rescueProject( rescuer, aRunningOnDemand );
}
bool SCH_EDITOR_CONTROL::RescueSymbolLibTableProject( bool aRunningOnDemand )
{
SYMBOL_LIB_TABLE_RESCUER rescuer( m_frame->Prj(), &m_frame->GetCurrentSheet(),
m_frame->GetCanvas()->GetBackend() );
return rescueProject( rescuer, aRunningOnDemand );
}
bool SCH_EDITOR_CONTROL::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand )
{
if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
return false;
if( aRescuer.GetCandidateCount() )
{
KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
if( viewer )
static_cast<LIB_VIEW_FRAME*>( viewer )->ReCreateListLib();
if( aRunningOnDemand )
{
SCH_SCREENS schematic;
schematic.UpdateSymbolLinks();
g_ConnectionGraph->Reset();
m_frame->RecalculateConnections( GLOBAL_CLEANUP );
}
m_frame->GetScreen()->ClearUndoORRedoList( m_frame->GetScreen()->m_UndoList, 1 );
m_frame->SyncView();
m_frame->GetCanvas()->Refresh();
m_frame->OnModify();
}
return true;
}
int SCH_EDITOR_CONTROL::RemapSymbols( const TOOL_EVENT& aEvent )
{
DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
dlgRemap.ShowQuasiModal();
m_frame->GetCanvas()->Refresh( true );
return 0;
}
int SCH_EDITOR_CONTROL::Print( const TOOL_EVENT& aEvent )
{
m_frame->Print();
InvokeDialogPrintUsingPrinter( m_frame );
wxFileName fn = m_frame->Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
if( fn.GetName() != NAMELESS_PROJECT )
m_frame->SaveProjectSettings();
return 0;
}
int SCH_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent )
{
m_frame->PlotSchematic();
DIALOG_PLOT_SCHEMATIC dlg( m_frame );
dlg.ShowModal();
// save project config if the prj config has changed:
if( dlg.PrjConfigChanged() )
m_frame->SaveProjectSettings();
return 0;
}
@ -1504,6 +1591,9 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::RescueSymbols, EE_ACTIONS::rescueSymbols.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::RemapSymbols, EE_ACTIONS::remapSymbols.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::FindAndReplace, ACTIONS::find.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::FindAndReplace, ACTIONS::findAndReplace.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::FindNext, ACTIONS::findNext.MakeEvent() );

View File

@ -58,6 +58,19 @@ public:
int Plot( const TOOL_EVENT& aEvent );
int Quit( const TOOL_EVENT& aEvent );
/**
* Perform rescue operations to recover old projects from before certain changes were made.
*
* - Exports cached symbols that conflict with new symbols to a separate library.
* - Exports cached symbols not found in any symbol library.
* - Renames symbols named before libraries were case sensitive.
*/
int RescueSymbols( const TOOL_EVENT& aEvent );
int RemapSymbols( const TOOL_EVENT& aEvent );
bool RescueLegacyProject( bool aRunningOnDemand );
bool RescueSymbolLibTableProject( bool aRunningOnDemand );
int FindAndReplace( const TOOL_EVENT& aEvent );
int FindNext( const TOOL_EVENT& aEvent );
@ -142,6 +155,8 @@ private:
///> copy selection to clipboard
bool doCopy();
bool rescueProject( RESCUER& aRescuer, bool aRunningOnDemand );
bool searchSupplementaryClipboard( const wxString& aSheetFilename, SCH_SCREEN** aScreen );
void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce );