2019-04-14 01:44:05 +01:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-08-14 09:28:07 +01:00
|
|
|
* Copyright (C) 2019 CERN
|
2023-01-04 15:39:50 -05:00
|
|
|
* Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-04-14 01:44:05 +01: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 15:34:58 +01:00
|
|
|
#include <sch_base_frame.h>
|
2019-05-12 12:49:58 +01:00
|
|
|
#include <tools/ee_tool_base.h>
|
2019-05-19 22:04:04 +01:00
|
|
|
#include <status_popup.h>
|
2019-04-14 01:44:05 +01:00
|
|
|
|
|
|
|
class SCH_EDIT_FRAME;
|
|
|
|
|
|
|
|
/**
|
2021-01-26 10:23:37 -05:00
|
|
|
* Handle actions specific to the schematic editor.
|
2019-04-14 01:44:05 +01:00
|
|
|
*/
|
2019-05-12 12:49:58 +01:00
|
|
|
class SCH_EDITOR_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<SCH_EDIT_FRAME>
|
2019-04-14 01:44:05 +01:00
|
|
|
{
|
|
|
|
public:
|
2019-05-14 20:21:10 +01:00
|
|
|
SCH_EDITOR_CONTROL() :
|
2019-07-17 21:21:22 +01:00
|
|
|
EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" ),
|
2019-08-05 00:47:38 -06:00
|
|
|
m_probingPcbToSch( false ),
|
2022-12-16 19:09:50 +00:00
|
|
|
m_pickerItem( nullptr ),
|
2023-11-17 07:15:43 -05:00
|
|
|
m_duplicateIsHoverSelection( false ),
|
|
|
|
m_highlightBusMembers( false )
|
2019-05-14 20:21:10 +01:00
|
|
|
{ }
|
|
|
|
|
|
|
|
~SCH_EDITOR_CONTROL() { }
|
2019-04-14 01:44:05 +01:00
|
|
|
|
2019-05-25 00:36:31 +01: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 18:22:46 +02:00
|
|
|
|
|
|
|
/// Saves the currently-open schematic sheet to an other name
|
|
|
|
int SaveCurrSheetCopyAs( const TOOL_EVENT& aEvent );
|
2022-04-17 18:14:50 +01:00
|
|
|
|
|
|
|
int Revert( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
int ShowSchematicSetup( const TOOL_EVENT& aEvent );
|
2019-05-25 00:36:31 +01: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 18:12:38 +01: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 10:23:37 -05:00
|
|
|
///< Notifies pcbnew about the selected item.
|
2019-04-30 19:36:11 +01:00
|
|
|
int CrossProbeToPcb( const TOOL_EVENT& aEvent );
|
2019-04-14 01:44:05 +01:00
|
|
|
|
2022-01-16 20:29:03 +00:00
|
|
|
///< Equivalent to the above, but initiated by the user.
|
2019-04-30 19:36:11 +01:00
|
|
|
int ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent );
|
2019-04-29 22:17:26 +01:00
|
|
|
|
2022-09-15 23:06:23 -04:00
|
|
|
int ExportSymbolsToLibrary( const TOOL_EVENT& aEvent );
|
|
|
|
|
2019-04-23 18:12:26 +01:00
|
|
|
int SimProbe( const TOOL_EVENT& aEvent );
|
|
|
|
int SimTune( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
///< Highlight net under the cursor.
|
2019-04-14 01:44:05 +01:00
|
|
|
int HighlightNet( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
///< Remove any net highlighting
|
2019-04-22 00:45:34 +01:00
|
|
|
int ClearHighlight( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
///< Update net highlighting after an edit
|
2019-05-12 18:03:17 +01:00
|
|
|
int UpdateNetHighlighting( const TOOL_EVENT& aEvent );
|
2019-04-14 01:44:05 +01:00
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
///< Launch a tool to highlight nets.
|
2019-04-14 01:44:05 +01:00
|
|
|
int HighlightNetCursor( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-07-07 11:17:30 +01:00
|
|
|
int AssignNetclass( const TOOL_EVENT& aEvent );
|
|
|
|
|
2019-05-14 20:21:10 +01:00
|
|
|
int Undo( const TOOL_EVENT& aEvent );
|
|
|
|
int Redo( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
///< Clipboard support.
|
2019-04-28 17:36:31 +01:00
|
|
|
int Cut( const TOOL_EVENT& aEvent );
|
|
|
|
int Copy( const TOOL_EVENT& aEvent );
|
|
|
|
int Paste( const TOOL_EVENT& aEvent );
|
2021-05-21 17:43:34 +01:00
|
|
|
int Duplicate( const TOOL_EVENT& aEvent );
|
2019-04-23 14:06:37 +01:00
|
|
|
|
2021-02-14 18:29:27 +00:00
|
|
|
int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
|
2019-06-01 16:28:39 +01:00
|
|
|
int ShowCvpcb( const TOOL_EVENT& aEvent );
|
|
|
|
int Annotate( const TOOL_EVENT& aEvent );
|
2024-08-25 20:17:47 -06:00
|
|
|
int IncrementAnnotations( const TOOL_EVENT& aEvent );
|
2019-06-01 16:28:39 +01:00
|
|
|
int EditSymbolFields( const TOOL_EVENT& aEvent );
|
2019-06-01 19:36:49 +01:00
|
|
|
int EditSymbolLibraryLinks( const TOOL_EVENT& aEvent );
|
2019-06-01 16:28:39 +01: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 17:07:15 +01:00
|
|
|
int ImportFPAssignments( const TOOL_EVENT& aEvent );
|
2019-06-16 14:42:40 +01:00
|
|
|
int ExportNetlist( const TOOL_EVENT& aEvent );
|
2019-06-01 16:28:39 +01:00
|
|
|
int GenerateBOM( const TOOL_EVENT& aEvent );
|
2023-09-20 11:12:03 -04:00
|
|
|
int GenerateBOMLegacy( const TOOL_EVENT& aEvent );
|
2019-06-16 17:07:15 +01:00
|
|
|
int DrawSheetOnClipboard( const TOOL_EVENT& aEvent );
|
2019-06-01 16:28:39 +01:00
|
|
|
|
2023-05-14 21:35:39 -04:00
|
|
|
int ShowSearch( const TOOL_EVENT& aEvent );
|
2022-06-02 21:56:17 +00:00
|
|
|
int ShowHierarchy( const TOOL_EVENT& aEvent );
|
2023-05-20 13:47:12 -04:00
|
|
|
int ShowNetNavigator( const TOOL_EVENT& aEvent );
|
2023-06-20 21:57:20 -04:00
|
|
|
int ToggleProperties( const TOOL_EVENT& aEvent );
|
2024-02-21 11:35:09 -05:00
|
|
|
int ToggleLibraryTree( const TOOL_EVENT& aEvent );
|
2019-05-13 21:42:40 +01:00
|
|
|
|
|
|
|
int ToggleHiddenPins( const TOOL_EVENT& aEvent );
|
2020-04-18 16:36:29 +01:00
|
|
|
int ToggleHiddenFields( const TOOL_EVENT& aEvent );
|
2023-04-27 17:59:53 +01:00
|
|
|
int ToggleDirectiveLabels( 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 );
|
2024-06-03 13:59:40 +01:00
|
|
|
int MarkSimExclusions( const TOOL_EVENT& aEvent );
|
2023-02-09 17:18:56 +00:00
|
|
|
int ToggleOPVoltages( const TOOL_EVENT& aEvent );
|
|
|
|
int ToggleOPCurrents( const TOOL_EVENT& aEvent );
|
2024-10-08 22:54:49 -06:00
|
|
|
int TogglePinAltIcons( const TOOL_EVENT& aEvent );
|
2022-03-22 12:49:38 -04:00
|
|
|
int ChangeLineMode( const TOOL_EVENT& aEvent );
|
|
|
|
int NextLineMode( const TOOL_EVENT& aEvent );
|
2022-04-21 13:06:28 -04:00
|
|
|
int ToggleAnnotateAuto( const TOOL_EVENT& aEvent );
|
2022-04-22 07:55:00 -04:00
|
|
|
int ToggleAnnotateRecursive( const TOOL_EVENT& aEvent );
|
2021-03-18 06:28:04 -07:00
|
|
|
int TogglePythonConsole( const TOOL_EVENT& aEvent );
|
2024-01-20 18:35:29 -05:00
|
|
|
int ReloadPlugins( const TOOL_EVENT& aEvent );
|
2019-04-30 15:46:29 +01:00
|
|
|
|
2023-05-30 22:06:49 -04:00
|
|
|
int GridFeedback( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-11-24 11:04:07 +00:00
|
|
|
int RepairSchematic( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-10-14 20:20:54 +01:00
|
|
|
void AssignFootprints( const std::string& aChangedSetOfReferences );
|
2019-06-16 17:07:15 +01:00
|
|
|
|
2019-07-17 21:21:22 +01:00
|
|
|
/**
|
2022-07-19 18:00:35 +03:00
|
|
|
* Find a symbol in the schematic and an item in this symbol and select it.
|
2019-07-17 21:21:22 +01: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 21:21:22 +01: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 21:21:22 +01:00
|
|
|
|
2023-11-17 07:15:43 -05:00
|
|
|
void SetHighlightBusMembers( bool aHighlightBusMembers )
|
|
|
|
{
|
|
|
|
m_highlightBusMembers = aHighlightBusMembers;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetHighlightBusMembers() const { return m_highlightBusMembers; }
|
|
|
|
|
2019-04-14 01:44:05 +01: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 01:44:05 +01:00
|
|
|
|
2020-05-12 18:12:38 +01:00
|
|
|
bool rescueProject( RESCUER& aRescuer, bool aRunningOnDemand );
|
|
|
|
|
2019-08-30 21:55:04 +01:00
|
|
|
bool searchSupplementaryClipboard( const wxString& aSheetFilename, SCH_SCREEN** aScreen );
|
|
|
|
|
2019-04-30 19:36:11 +01:00
|
|
|
void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce );
|
|
|
|
|
2024-01-25 16:34:49 -05:00
|
|
|
void updatePastedSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aPastePath,
|
|
|
|
const KIID_PATH& aClipPath, bool aForceKeepAnnotations );
|
|
|
|
|
|
|
|
SCH_SHEET_PATH updatePastedSheet( SCH_SHEET* aSheet, const SCH_SHEET_PATH& aPastePath,
|
|
|
|
const KIID_PATH& aClipPath, bool aForceKeepAnnotations,
|
|
|
|
SCH_SHEET_LIST* aPastedSheets,
|
|
|
|
std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST>& aPastedSymbols );
|
2021-05-01 23:56:37 +01:00
|
|
|
|
2024-01-15 12:15:30 -05:00
|
|
|
void setPastedSymbolInstances( const SCH_SCREEN* aScreen );
|
2019-06-16 17:07:15 +01:00
|
|
|
|
2023-12-11 08:29:10 -05:00
|
|
|
/**
|
|
|
|
* Remove all pasted symbol instances that do not belong to the current project.
|
|
|
|
*
|
|
|
|
* @warning This should **only** be called when cleaning up after a paste. Otherwise it
|
|
|
|
* could clobber symbol instances for schematics shared across projects. Use
|
|
|
|
* SCH_SCREENS::PruneOrphanedSymbolInstances() to clean up invalid instance for
|
|
|
|
* the current project.
|
|
|
|
*/
|
|
|
|
void prunePastedSymbolInstances();
|
|
|
|
|
2019-06-16 17:07:15 +01: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 22:41:51 +01:00
|
|
|
bool processCmpToFootprintLinkFile( const wxString& aFullFilename, bool aForceVisibilityState,
|
|
|
|
bool aVisibilityState );
|
2019-06-16 17:07:15 +01:00
|
|
|
|
2021-01-26 10:23:37 -05:00
|
|
|
///< Set up handlers for various events.
|
2019-04-14 01:44:05 +01:00
|
|
|
void setTransitions() override;
|
|
|
|
|
2019-05-12 12:49:58 +01: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 21:55:04 +01: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 17:43:34 +01:00
|
|
|
|
2023-11-17 07:15:43 -05:00
|
|
|
bool m_highlightBusMembers;
|
|
|
|
|
2020-09-06 11:31:53 +01:00
|
|
|
// A map of sheet filename --> screens for the clipboard contents. We use these to hook up
|
2019-08-30 21:55:04 +01: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 23:56:37 +01:00
|
|
|
|
|
|
|
// A map of KIID_PATH --> symbol instances for the clipboard contents.
|
2023-01-04 15:39:50 -05:00
|
|
|
std::map<KIID_PATH, SCH_SYMBOL_INSTANCE> m_clipboardSymbolInstances;
|
2021-05-01 23:56:37 +01:00
|
|
|
|
2023-12-11 08:29:10 -05:00
|
|
|
std::set<SCH_SYMBOL*> m_pastedSymbols;
|
2019-04-14 01:44:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SCH_EDITOR_CONTROL_H
|