KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_editor_control.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2019 CERN
5 * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25
26#ifndef SCH_EDITOR_CONTROL_H
27#define SCH_EDITOR_CONTROL_H
28
29#include <sch_base_frame.h>
30#include <tools/ee_tool_base.h>
31#include <status_popup.h>
32
33class SCH_EDIT_FRAME;
34
38class SCH_EDITOR_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<SCH_EDIT_FRAME>
39{
40public:
42 EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" ),
43 m_probingPcbToSch( false ),
44 m_pickerItem( nullptr ),
47 { }
48
50
51 int New( const TOOL_EVENT& aEvent );
52 int Open( const TOOL_EVENT& aEvent );
53 int Save( const TOOL_EVENT& aEvent );
54 int SaveAs( const TOOL_EVENT& aEvent );
55
57 int SaveCurrSheetCopyAs( const TOOL_EVENT& aEvent );
58
59 int Revert( const TOOL_EVENT& aEvent );
60
61 int ShowSchematicSetup( const TOOL_EVENT& aEvent );
62 int PageSetup( const TOOL_EVENT& aEvent );
63 int Print( const TOOL_EVENT& aEvent );
64 int Plot( const TOOL_EVENT& aEvent );
65 int Quit( const TOOL_EVENT& aEvent );
66
74 int RescueSymbols( const TOOL_EVENT& aEvent );
75 int RemapSymbols( const TOOL_EVENT& aEvent );
76
77 bool RescueLegacyProject( bool aRunningOnDemand );
78 bool RescueSymbolLibTableProject( bool aRunningOnDemand );
79
81 int CrossProbeToPcb( const TOOL_EVENT& aEvent );
82
84 int ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent );
85
86 int ExportSymbolsToLibrary( const TOOL_EVENT& aEvent );
87
88 int SimProbe( const TOOL_EVENT& aEvent );
89 int SimTune( const TOOL_EVENT& aEvent );
90
92 int HighlightNet( const TOOL_EVENT& aEvent );
93
95 int ClearHighlight( const TOOL_EVENT& aEvent );
96
98 int UpdateNetHighlighting( const TOOL_EVENT& aEvent );
99
101 int HighlightNetCursor( const TOOL_EVENT& aEvent );
102
103 int AssignNetclass( const TOOL_EVENT& aEvent );
104
105 int Undo( const TOOL_EVENT& aEvent );
106 int Redo( const TOOL_EVENT& aEvent );
107
109 int Cut( const TOOL_EVENT& aEvent );
110 int Copy( const TOOL_EVENT& aEvent );
111 int Paste( const TOOL_EVENT& aEvent );
112 int Duplicate( const TOOL_EVENT& aEvent );
113
114 int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
115 int ShowCvpcb( const TOOL_EVENT& aEvent );
116 int Annotate( const TOOL_EVENT& aEvent );
117 int EditSymbolFields( const TOOL_EVENT& aEvent );
118 int EditSymbolLibraryLinks( const TOOL_EVENT& aEvent );
119 int ShowPcbNew( const TOOL_EVENT& aEvent );
120 int UpdatePCB( const TOOL_EVENT& aEvent );
121 int UpdateFromPCB( const TOOL_EVENT& aEvent );
122 int ImportFPAssignments( const TOOL_EVENT& aEvent );
123 int ExportNetlist( const TOOL_EVENT& aEvent );
124 int GenerateBOM( const TOOL_EVENT& aEvent );
125 int GenerateBOMLegacy( const TOOL_EVENT& aEvent );
126 int DrawSheetOnClipboard( const TOOL_EVENT& aEvent );
127
128 int ShowSearch( const TOOL_EVENT& aEvent );
129 int ShowHierarchy( const TOOL_EVENT& aEvent );
130 int ShowNetNavigator( const TOOL_EVENT& aEvent );
131 int ToggleProperties( const TOOL_EVENT& aEvent );
132
133 int ToggleHiddenPins( const TOOL_EVENT& aEvent );
134 int ToggleHiddenFields( const TOOL_EVENT& aEvent );
135 int ToggleDirectiveLabels( const TOOL_EVENT& aEvent );
136 int ToggleERCWarnings( const TOOL_EVENT& aEvent );
137 int ToggleERCErrors( const TOOL_EVENT& aEvent );
138 int ToggleERCExclusions( const TOOL_EVENT& aEvent );
139 int ToggleOPVoltages( const TOOL_EVENT& aEvent );
140 int ToggleOPCurrents( const TOOL_EVENT& aEvent );
141 int ChangeLineMode( const TOOL_EVENT& aEvent );
142 int NextLineMode( const TOOL_EVENT& aEvent );
143 int ToggleAnnotateAuto( const TOOL_EVENT& aEvent );
144 int ToggleAnnotateRecursive( const TOOL_EVENT& aEvent );
145 int TogglePythonConsole( const TOOL_EVENT& aEvent );
146
147 int GridFeedback( const TOOL_EVENT& aEvent );
148
149 int RepairSchematic( const TOOL_EVENT& aEvent );
150
151 void AssignFootprints( const std::string& aChangedSetOfReferences );
152
164 SCH_ITEM* FindSymbolAndItem( const wxString* aPath, const wxString* aReference,
165 bool aSearchHierarchy, SCH_SEARCH_T aSearchType,
166 const wxString& aSearchText );
167
168 void SetHighlightBusMembers( bool aHighlightBusMembers )
169 {
170 m_highlightBusMembers = aHighlightBusMembers;
171 }
172
174
175private:
177 bool doCopy( bool aUseDuplicateClipboard = false );
178
179 bool rescueProject( RESCUER& aRescuer, bool aRunningOnDemand );
180
181 bool searchSupplementaryClipboard( const wxString& aSheetFilename, SCH_SCREEN** aScreen );
182
183 void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce );
184
185 void updatePastedSymbol( SCH_SYMBOL* aSymbol, SCH_SCREEN* aPasteScreen,
186 const SCH_SHEET_PATH& aPastePath, const KIID_PATH& aClipPath,
187 bool aForceKeepAnnotations );
188
189 SCH_SHEET_PATH updatePastedSheet( const SCH_SHEET_PATH& aPastePath, const KIID_PATH& aClipPath,
190 SCH_SHEET* aSheet, bool aForceKeepAnnotations,
191 SCH_SHEET_LIST* aPastedSheetsSoFar,
192 SCH_REFERENCE_LIST* aPastedSymbolsSoFar );
193
194 void setClipboardInstances( const SCH_SCREEN* aPastedScreen );
195
216 bool processCmpToFootprintLinkFile( const wxString& aFullFilename, bool aForceVisibilityState,
217 bool aVisibilityState );
218
220 void setTransitions() override;
221
222private:
223 bool m_probingPcbToSch; // Recursion guard for PCB to schematic cross-probing
224 EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
225
226 std::string m_duplicateClipboard; // Temporary storage for Duplicate action
228
230
231 // A map of sheet filename --> screens for the clipboard contents. We use these to hook up
232 // cut/paste operations for unsaved sheet content.
233 std::map<wxString, SCH_SCREEN*> m_supplementaryClipboard;
234
235 // A map of KIID_PATH --> symbol instances for the clipboard contents.
236 std::map<KIID_PATH, SCH_SYMBOL_INSTANCE> m_clipboardSymbolInstances;
237
238 // A map of KIID_PATH --> sheet instances for the clipboard contents.
239 std::map<KIID_PATH, SCH_SHEET_INSTANCE> m_clipboardSheetInstances;
240};
241
242
243#endif // SCH_EDITOR_CONTROL_H
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:48
Handle actions specific to the schematic editor.
int PageSetup(const TOOL_EVENT &aEvent)
bool RescueLegacyProject(bool aRunningOnDemand)
int ToggleDirectiveLabels(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
int Annotate(const TOOL_EVENT &aEvent)
int ToggleAnnotateRecursive(const TOOL_EVENT &aEvent)
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNet(const TOOL_EVENT &aEvent)
Remove any net highlighting.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
int EditSymbolFields(const TOOL_EVENT &aEvent)
int GenerateBOMLegacy(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
void AssignFootprints(const std::string &aChangedSetOfReferences)
int ImportFPAssignments(const TOOL_EVENT &aEvent)
int ChangeLineMode(const TOOL_EVENT &aEvent)
void setClipboardInstances(const SCH_SCREEN *aPastedScreen)
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
int ExportSymbolsToLibrary(const TOOL_EVENT &aEvent)
int SaveCurrSheetCopyAs(const TOOL_EVENT &aEvent)
Saves the currently-open schematic sheet to an other name.
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
void SetHighlightBusMembers(bool aHighlightBusMembers)
bool GetHighlightBusMembers() const
int Quit(const TOOL_EVENT &aEvent)
int RemapSymbols(const TOOL_EVENT &aEvent)
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
std::map< KIID_PATH, SCH_SHEET_INSTANCE > m_clipboardSheetInstances
int AssignNetclass(const TOOL_EVENT &aEvent)
std::string m_duplicateClipboard
int ExportNetlist(const TOOL_EVENT &aEvent)
int Open(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
int ToggleOPVoltages(const TOOL_EVENT &aEvent)
int Copy(const TOOL_EVENT &aEvent)
int ToggleERCWarnings(const TOOL_EVENT &aEvent)
int NextLineMode(const TOOL_EVENT &aEvent)
SCH_ITEM * FindSymbolAndItem(const wxString *aPath, const wxString *aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString &aSearchText)
Find a symbol in the schematic and an item in this symbol and select it.
int Redo(const TOOL_EVENT &aEvent)
Clipboard support.
int UpdatePCB(const TOOL_EVENT &aEvent)
int UpdateFromPCB(const TOOL_EVENT &aEvent)
int ToggleAnnotateAuto(const TOOL_EVENT &aEvent)
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
int Duplicate(const TOOL_EVENT &aEvent)
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
int GridFeedback(const TOOL_EVENT &aEvent)
int ShowSearch(const TOOL_EVENT &aEvent)
int EditWithSymbolEditor(const TOOL_EVENT &aEvent)
int SimTune(const TOOL_EVENT &aEvent)
Highlight net under the cursor.
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
int ToggleOPCurrents(const TOOL_EVENT &aEvent)
int ShowPcbNew(const TOOL_EVENT &aEvent)
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
int ToggleERCErrors(const TOOL_EVENT &aEvent)
int TogglePythonConsole(const TOOL_EVENT &aEvent)
int ShowHierarchy(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int ShowNetNavigator(const TOOL_EVENT &aEvent)
int SimProbe(const TOOL_EVENT &aEvent)
void updatePastedSymbol(SCH_SYMBOL *aSymbol, SCH_SCREEN *aPasteScreen, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
int ShowCvpcb(const TOOL_EVENT &aEvent)
SCH_SHEET_PATH updatePastedSheet(const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, SCH_SHEET *aSheet, bool aForceKeepAnnotations, SCH_SHEET_LIST *aPastedSheetsSoFar, SCH_REFERENCE_LIST *aPastedSymbolsSoFar)
int RepairSchematic(const TOOL_EVENT &aEvent)
int Cut(const TOOL_EVENT &aEvent)
int ToggleProperties(const TOOL_EVENT &aEvent)
std::map< KIID_PATH, SCH_SYMBOL_INSTANCE > m_clipboardSymbolInstances
int Save(const TOOL_EVENT &aEvent)
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
Notifies pcbnew about the selected item.
bool doCopy(bool aUseDuplicateClipboard=false)
< copy selection to clipboard or to m_duplicateClipboard
int Undo(const TOOL_EVENT &aEvent)
int ToggleERCExclusions(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
int Print(const TOOL_EVENT &aEvent)
bool processCmpToFootprintLinkFile(const wxString &aFullFilename, bool aForceVisibilityState, bool aVisibilityState)
Read the footprint info from each line in the stuff file by reference designator.
int Revert(const TOOL_EVENT &aEvent)
int GenerateBOM(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:151
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
Schematic symbol object.
Definition: sch_symbol.h:81
Generic, UI-independent tool event.
Definition: tool_event.h:167
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.