2019-04-14 00:44:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-08-14 08:28:07 +00:00
|
|
|
* Copyright (C) 2019 CERN
|
2023-01-04 20:39:50 +00:00
|
|
|
* Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-04-14 00:44:05 +00:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SCH_EDITOR_CONTROL_H
|
|
|
|
#define SCH_EDITOR_CONTROL_H
|
|
|
|
|
2019-04-15 14:34:58 +00:00
|
|
|
#include <sch_base_frame.h>
|
2019-05-12 11:49:58 +00:00
|
|
|
#include <tools/ee_tool_base.h>
|
2019-05-19 21:04:04 +00:00
|
|
|
#include <status_popup.h>
|
2019-04-14 00:44:05 +00:00
|
|
|
|
|
|
|
class SCH_EDIT_FRAME;
|
|
|
|
|
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Handle actions specific to the schematic editor.
|
2019-04-14 00:44:05 +00:00
|
|
|
*/
|
2019-05-12 11:49:58 +00:00
|
|
|
class SCH_EDITOR_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<SCH_EDIT_FRAME>
|
2019-04-14 00:44:05 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-05-14 19:21:10 +00:00
|
|
|
SCH_EDITOR_CONTROL() :
|
2019-07-17 20:21:22 +00:00
|
|
|
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" ),
|
2019-08-05 06:47:38 +00:00
|
|
|
m_probingPcbToSch( false ),
|
2022-12-16 19:09:50 +00:00
|
|
|
m_pickerItem( nullptr ),
|
2023-01-11 14:17:36 +00:00
|
|
|
m_duplicateIsHoverSelection( false )
|
2019-05-14 19:21:10 +00:00
|
|
|
{ }
|
|
|
|
|
|
|
|
~SCH_EDITOR_CONTROL() { }
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2019-05-24 23:36:31 +00:00
|
|
|
int New( const TOOL_EVENT& aEvent );
|
|
|
|
int Open( const TOOL_EVENT& aEvent );
|
|
|
|
int Save( const TOOL_EVENT& aEvent );
|
|
|
|
int SaveAs( const TOOL_EVENT& aEvent );
|
2021-09-27 16:22:46 +00:00
|
|
|
|
|
|
|
/// Saves the currently-open schematic sheet to an other name
|
|
|
|
int SaveCurrSheetCopyAs( const TOOL_EVENT& aEvent );
|
2022-04-17 17:14:50 +00:00
|
|
|
|
|
|
|
int Revert( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
int ShowSchematicSetup( const TOOL_EVENT& aEvent );
|
2019-05-24 23:36:31 +00:00
|
|
|
int PageSetup( const TOOL_EVENT& aEvent );
|
|
|
|
int Print( const TOOL_EVENT& aEvent );
|
|
|
|
int Plot( const TOOL_EVENT& aEvent );
|
|
|
|
int Quit( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-05-12 17:12:38 +00:00
|
|
|
/**
|
|
|
|
* 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 );
|
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Notifies pcbnew about the selected item.
|
2019-04-30 18:36:11 +00:00
|
|
|
int CrossProbeToPcb( const TOOL_EVENT& aEvent );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2022-01-16 20:29:03 +00:00
|
|
|
///< Equivalent to the above, but initiated by the user.
|
2019-04-30 18:36:11 +00:00
|
|
|
int ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent );
|
2019-04-29 21:17:26 +00:00
|
|
|
|
2022-09-16 03:06:23 +00:00
|
|
|
int ExportSymbolsToLibrary( const TOOL_EVENT& aEvent );
|
|
|
|
|
2019-04-23 17:12:26 +00:00
|
|
|
int SimProbe( const TOOL_EVENT& aEvent );
|
|
|
|
int SimTune( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Highlight net under the cursor.
|
2019-04-14 00:44:05 +00:00
|
|
|
int HighlightNet( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Remove any net highlighting
|
2019-04-21 23:45:34 +00:00
|
|
|
int ClearHighlight( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Update net highlighting after an edit
|
2019-05-12 17:03:17 +00:00
|
|
|
int UpdateNetHighlighting( const TOOL_EVENT& aEvent );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Launch a tool to highlight nets.
|
2019-04-14 00:44:05 +00:00
|
|
|
int HighlightNetCursor( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-07-07 10:17:30 +00:00
|
|
|
int AssignNetclass( const TOOL_EVENT& aEvent );
|
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
int Undo( const TOOL_EVENT& aEvent );
|
|
|
|
int Redo( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Clipboard support.
|
2019-04-28 16:36:31 +00:00
|
|
|
int Cut( const TOOL_EVENT& aEvent );
|
|
|
|
int Copy( const TOOL_EVENT& aEvent );
|
|
|
|
int Paste( const TOOL_EVENT& aEvent );
|
2021-05-21 16:43:34 +00:00
|
|
|
int Duplicate( const TOOL_EVENT& aEvent );
|
2019-04-23 13:06:37 +00:00
|
|
|
|
2021-02-14 18:29:27 +00:00
|
|
|
int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
|
2019-06-01 15:28:39 +00:00
|
|
|
int ShowCvpcb( const TOOL_EVENT& aEvent );
|
|
|
|
int Annotate( const TOOL_EVENT& aEvent );
|
|
|
|
int EditSymbolFields( const TOOL_EVENT& aEvent );
|
2019-06-01 18:36:49 +00:00
|
|
|
int EditSymbolLibraryLinks( const TOOL_EVENT& aEvent );
|
2019-06-01 15:28:39 +00:00
|
|
|
int ShowPcbNew( const TOOL_EVENT& aEvent );
|
|
|
|
int UpdatePCB( const TOOL_EVENT& aEvent );
|
2020-01-29 16:33:57 +00:00
|
|
|
int UpdateFromPCB( const TOOL_EVENT& aEvent );
|
2019-06-16 16:07:15 +00:00
|
|
|
int ImportFPAssignments( const TOOL_EVENT& aEvent );
|
2019-06-16 13:42:40 +00:00
|
|
|
int ExportNetlist( const TOOL_EVENT& aEvent );
|
2019-06-01 15:28:39 +00:00
|
|
|
int GenerateBOM( const TOOL_EVENT& aEvent );
|
2019-06-16 16:07:15 +00:00
|
|
|
int DrawSheetOnClipboard( const TOOL_EVENT& aEvent );
|
2019-06-01 15:28:39 +00:00
|
|
|
|
2022-06-02 21:56:17 +00:00
|
|
|
int ShowHierarchy( const TOOL_EVENT& aEvent );
|
2019-05-13 20:42:40 +00:00
|
|
|
|
|
|
|
int ToggleHiddenPins( const TOOL_EVENT& aEvent );
|
2020-04-18 15:36:29 +00:00
|
|
|
int ToggleHiddenFields( const TOOL_EVENT& aEvent );
|
2021-11-05 21:16:26 +00:00
|
|
|
int ToggleERCWarnings( const TOOL_EVENT& aEvent );
|
|
|
|
int ToggleERCErrors( const TOOL_EVENT& aEvent );
|
|
|
|
int ToggleERCExclusions( const TOOL_EVENT& aEvent );
|
2023-02-09 17:18:56 +00:00
|
|
|
int ToggleOPVoltages( const TOOL_EVENT& aEvent );
|
|
|
|
int ToggleOPCurrents( const TOOL_EVENT& aEvent );
|
2022-03-22 16:49:38 +00:00
|
|
|
int ChangeLineMode( const TOOL_EVENT& aEvent );
|
|
|
|
int NextLineMode( const TOOL_EVENT& aEvent );
|
2022-04-21 17:06:28 +00:00
|
|
|
int ToggleAnnotateAuto( const TOOL_EVENT& aEvent );
|
2022-04-22 11:55:00 +00:00
|
|
|
int ToggleAnnotateRecursive( const TOOL_EVENT& aEvent );
|
2021-03-18 13:28:04 +00:00
|
|
|
int TogglePythonConsole( const TOOL_EVENT& aEvent );
|
2019-04-30 14:46:29 +00:00
|
|
|
|
2021-11-24 11:04:07 +00:00
|
|
|
int RepairSchematic( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-10-14 19:20:54 +00:00
|
|
|
void AssignFootprints( const std::string& aChangedSetOfReferences );
|
2019-06-16 16:07:15 +00:00
|
|
|
|
2019-07-17 20:21:22 +00:00
|
|
|
/**
|
2022-07-19 15:00:35 +00:00
|
|
|
* Find a symbol in the schematic and an item in this symbol and select it.
|
2019-07-17 20:21:22 +00:00
|
|
|
*
|
2021-12-03 20:35:54 +00:00
|
|
|
* @param aPath The symbol path to find. Pass nullptr to search by aReference.
|
2022-01-16 20:29:03 +00:00
|
|
|
* @param aReference The symbol reference designator to find, or to display in
|
2021-12-03 20:35:54 +00:00
|
|
|
* status bar if aPath is specified
|
2019-07-17 20:21:22 +00:00
|
|
|
* @param aSearchHierarchy If false, search the current sheet only. Otherwise,
|
|
|
|
* the entire hierarchy
|
|
|
|
* @param aSearchType A #SCH_SEARCH_T value used to determine what to search for.
|
|
|
|
* @param aSearchText The text to search for, either in value, reference or elsewhere.
|
|
|
|
*/
|
2021-12-03 20:35:54 +00:00
|
|
|
SCH_ITEM* FindSymbolAndItem( const wxString* aPath, const wxString* aReference,
|
|
|
|
bool aSearchHierarchy, SCH_SEARCH_T aSearchType,
|
|
|
|
const wxString& aSearchText );
|
2019-07-17 20:21:22 +00:00
|
|
|
|
2019-04-14 00:44:05 +00:00
|
|
|
private:
|
2022-12-15 13:47:28 +00:00
|
|
|
///< copy selection to clipboard or to m_duplicateClipboard
|
|
|
|
bool doCopy( bool aUseDuplicateClipboard = false );
|
2019-04-14 00:44:05 +00:00
|
|
|
|
2020-05-12 17:12:38 +00:00
|
|
|
bool rescueProject( RESCUER& aRescuer, bool aRunningOnDemand );
|
|
|
|
|
2019-08-30 20:55:04 +00:00
|
|
|
bool searchSupplementaryClipboard( const wxString& aSheetFilename, SCH_SCREEN** aScreen );
|
|
|
|
|
2019-04-30 18:36:11 +00:00
|
|
|
void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce );
|
|
|
|
|
2021-06-10 14:10:55 +00:00
|
|
|
void updatePastedSymbol( SCH_SYMBOL* aSymbol, SCH_SCREEN* aPasteScreen,
|
2021-05-01 22:56:37 +00:00
|
|
|
const SCH_SHEET_PATH& aPastePath, const KIID_PATH& aClipPath,
|
|
|
|
bool aForceKeepAnnotations );
|
|
|
|
|
|
|
|
SCH_SHEET_PATH updatePastedSheet( const SCH_SHEET_PATH& aPastePath, const KIID_PATH& aClipPath,
|
|
|
|
SCH_SHEET* aSheet, bool aForceKeepAnnotations,
|
2021-05-05 21:41:51 +00:00
|
|
|
SCH_SHEET_LIST* aPastedSheetsSoFar,
|
2021-05-01 22:56:37 +00:00
|
|
|
SCH_REFERENCE_LIST* aPastedSymbolsSoFar );
|
|
|
|
|
|
|
|
void setClipboardInstances( const SCH_SCREEN* aPastedScreen );
|
2019-06-16 16:07:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read the footprint info from each line in the stuff file by reference designator.
|
|
|
|
*
|
|
|
|
* The footprint link file (.cmp) entries created by CvPcb:
|
|
|
|
*
|
|
|
|
* BeginCmp
|
|
|
|
* TimeStamp = /32307DE2/AA450F67;
|
|
|
|
* Reference = C1;
|
|
|
|
* ValeurCmp = 47uF;
|
|
|
|
* IdModule = CP6;
|
|
|
|
* EndCmp
|
|
|
|
*
|
|
|
|
* @param aFullFilename = the full filename to read
|
|
|
|
* @param aForceVisibilityState = Set to true to change the footprint field visibility
|
|
|
|
* state to \a aVisibilityState. False retains the
|
|
|
|
* current footprint field visibility state.
|
|
|
|
* @param aVisibilityState True to show the footprint field or false to hide the footprint
|
|
|
|
* field if \a aForceVisibilityState is true.
|
|
|
|
* @return bool = true if success.
|
|
|
|
*/
|
2021-05-05 21:41:51 +00:00
|
|
|
bool processCmpToFootprintLinkFile( const wxString& aFullFilename, bool aForceVisibilityState,
|
|
|
|
bool aVisibilityState );
|
2019-06-16 16:07:15 +00:00
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Set up handlers for various events.
|
2019-04-14 00:44:05 +00:00
|
|
|
void setTransitions() override;
|
|
|
|
|
2019-05-12 11:49:58 +00:00
|
|
|
private:
|
2023-01-08 14:27:54 +00:00
|
|
|
bool m_probingPcbToSch; // Recursion guard for PCB to schematic cross-probing
|
|
|
|
EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
|
2019-08-30 20:55:04 +00:00
|
|
|
|
2023-01-08 14:27:54 +00:00
|
|
|
std::string m_duplicateClipboard; // Temporary storage for Duplicate action
|
2022-12-15 13:47:28 +00:00
|
|
|
bool m_duplicateIsHoverSelection;
|
2021-05-21 16:43:34 +00:00
|
|
|
|
2020-09-06 10:31:53 +00:00
|
|
|
// A map of sheet filename --> screens for the clipboard contents. We use these to hook up
|
2019-08-30 20:55:04 +00:00
|
|
|
// cut/paste operations for unsaved sheet content.
|
2023-01-08 14:27:54 +00:00
|
|
|
std::map<wxString, SCH_SCREEN*> m_supplementaryClipboard;
|
2021-05-01 22:56:37 +00:00
|
|
|
|
|
|
|
// A map of KIID_PATH --> symbol instances for the clipboard contents.
|
2023-01-04 20:39:50 +00:00
|
|
|
std::map<KIID_PATH, SCH_SYMBOL_INSTANCE> m_clipboardSymbolInstances;
|
2021-05-01 22:56:37 +00:00
|
|
|
|
|
|
|
// A map of KIID_PATH --> sheet instances for the clipboard contents.
|
2023-01-08 14:27:54 +00:00
|
|
|
std::map<KIID_PATH, SCH_SHEET_INSTANCE> m_clipboardSheetInstances;
|
2019-04-14 00:44:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SCH_EDITOR_CONTROL_H
|