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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21
22#ifndef SCH_EDITOR_CONTROL_H
23#define SCH_EDITOR_CONTROL_H
24
25#include <sch_base_frame.h>
26#include <tools/sch_tool_base.h>
27#include <status_popup.h>
28
29class SCH_EDIT_FRAME;
30class SCH_SCREEN;
31class LIB_SYMBOL;
32
36class SCH_EDITOR_CONTROL : public wxEvtHandler, public SCH_TOOL_BASE<SCH_EDIT_FRAME>
37{
38public:
40 SCH_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" ),
41 m_probingPcbToSch( false ),
42 m_pickerItem( nullptr ),
45 { }
46
48
49 int New( const TOOL_EVENT& aEvent );
50 int Open( const TOOL_EVENT& aEvent );
51 int Save( const TOOL_EVENT& aEvent );
52 int SaveAs( const TOOL_EVENT& aEvent );
53
55 int SaveCurrSheetCopyAs( const TOOL_EVENT& aEvent );
56
57 int Revert( const TOOL_EVENT& aEvent );
58
59 int ShowSchematicSetup( const TOOL_EVENT& aEvent );
60 int PageSetup( const TOOL_EVENT& aEvent );
61 int Print( const TOOL_EVENT& aEvent );
62 int Plot( const TOOL_EVENT& aEvent );
63 int Quit( const TOOL_EVENT& aEvent );
64
72 int RescueSymbols( const TOOL_EVENT& aEvent );
73 int RemapSymbols( const TOOL_EVENT& aEvent );
74
75 bool RescueLegacyProject( bool aRunningOnDemand );
76 bool RescueSymbolLibTableProject( bool aRunningOnDemand );
77
79 int CrossProbeToPcb( const TOOL_EVENT& aEvent );
80
82 int ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent );
83
84 int ExportSymbolsToLibrary( const TOOL_EVENT& aEvent );
85
86 int SimProbe( const TOOL_EVENT& aEvent );
87 int SimTune( const TOOL_EVENT& aEvent );
88
90 int HighlightNet( const TOOL_EVENT& aEvent );
91
93 int HighlightNetChain( const TOOL_EVENT& aEvent );
94 int RemoveFromNetChain( const TOOL_EVENT& aEvent );
95
97 int ClearHighlight( const TOOL_EVENT& aEvent );
98
100 int UpdateNetHighlighting( const TOOL_EVENT& aEvent );
101
103 int HighlightNetCursor( const TOOL_EVENT& aEvent );
104
106 int ReplaceTerminalPin( const TOOL_EVENT& aEvent );
107 int NameNetChain( const TOOL_EVENT& aEvent );
108 int CreateNetChainBetweenPins( const TOOL_EVENT& aEvent );
109
110 int ShowCreateNetChain( const TOOL_EVENT& aEvent );
111
112 int AssignNetclass( const TOOL_EVENT& aEvent );
113 int FindNetInInspector( const TOOL_EVENT& aEvent );
114
115 int Undo( const TOOL_EVENT& aEvent );
116 int Redo( const TOOL_EVENT& aEvent );
117
119 int Cut( const TOOL_EVENT& aEvent );
120 int Copy( const TOOL_EVENT& aEvent );
121 int CopyAsText( const TOOL_EVENT& aEvent );
122 int Paste( const TOOL_EVENT& aEvent );
123 int Duplicate( const TOOL_EVENT& aEvent );
124
138 static const LIB_SYMBOL* ChoosePasteLibSymbol( const SCH_SCREEN* aClipboardScreen,
139 const SCH_SCREEN* aDestScreen,
140 const wxString& aLibSymbolName );
141
142 int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
143 int ShowCvpcb( const TOOL_EVENT& aEvent );
144 int Annotate( const TOOL_EVENT& aEvent );
145 int IncrementAnnotations( const TOOL_EVENT& aEvent );
146 int EditSymbolFields( const TOOL_EVENT& aEvent );
147 int EditSymbolLibraryLinks( const TOOL_EVENT& aEvent );
148 int ShowPcbNew( const TOOL_EVENT& aEvent );
149 int UpdatePCB( const TOOL_EVENT& aEvent );
150 int UpdateFromPCB( const TOOL_EVENT& aEvent );
151 int ImportFPAssignments( const TOOL_EVENT& aEvent );
152 int ImportNonKicadSchematic( const TOOL_EVENT& aEvent );
153 int ExportNetlist( const TOOL_EVENT& aEvent );
154 int GenerateBOM( const TOOL_EVENT& aEvent );
155 int GenerateBOMLegacy( const TOOL_EVENT& aEvent );
156 int DrawSheetOnClipboard( const TOOL_EVENT& aEvent );
157
158 int ShowSearch( const TOOL_EVENT& aEvent );
159 int ShowHierarchy( const TOOL_EVENT& aEvent );
160 int ShowNetNavigator( const TOOL_EVENT& aEvent );
161 int ToggleProperties( const TOOL_EVENT& aEvent );
162 int ToggleLibraryTree( const TOOL_EVENT& aEvent );
163 int ToggleRemoteSymbolPanel( const TOOL_EVENT& aEvent );
164
165 int ToggleHiddenPins( const TOOL_EVENT& aEvent );
166 int ToggleHiddenFields( const TOOL_EVENT& aEvent );
167 int ToggleDirectiveLabels( const TOOL_EVENT& aEvent );
168 int ToggleERCWarnings( const TOOL_EVENT& aEvent );
169 int ToggleERCErrors( const TOOL_EVENT& aEvent );
170 int ToggleERCExclusions( const TOOL_EVENT& aEvent );
171 int MarkSimExclusions( const TOOL_EVENT& aEvent );
172 int ToggleOPVoltages( const TOOL_EVENT& aEvent );
173 int ToggleOPCurrents( const TOOL_EVENT& aEvent );
174 int TogglePinAltIcons( const TOOL_EVENT& aEvent );
175 int ChangeLineMode( const TOOL_EVENT& aEvent );
176 int NextLineMode( const TOOL_EVENT& aEvent );
177 int OnAngleSnapModeChanged( const TOOL_EVENT& aEvent );
178 int ToggleAnnotateAuto( const TOOL_EVENT& aEvent );
179
180 int GridFeedback( const TOOL_EVENT& aEvent );
181
182 void AssignFootprints( const std::string& aChangedSetOfReferences );
183
195 SCH_ITEM* FindSymbolAndItem( const wxString* aPath, const wxString* aReference,
196 bool aSearchHierarchy, SCH_SEARCH_T aSearchType,
197 const wxString& aSearchText );
198
199 void SetHighlightBusMembers( bool aHighlightBusMembers )
200 {
201 m_highlightBusMembers = aHighlightBusMembers;
202 }
203
205
206 int PlaceLinkedDesignBlock( const TOOL_EVENT& aEvent );
207 int SaveToLinkedDesignBlock( const TOOL_EVENT& aEvent );
208
209 int AddVariant( const TOOL_EVENT& aEvent );
210 int RemoveVariant( const TOOL_EVENT& aEvent );
211 int EditVariantDescription( const TOOL_EVENT& aEvent );
212 int RenameVariant( const TOOL_EVENT& aEvent );
213 int CopyVariant( const TOOL_EVENT& aEvent );
214
215private:
217 bool doCopy( bool aUseDuplicateClipboard = false );
218
219 bool rescueProject( RESCUER& aRescuer, bool aRunningOnDemand );
220
221 bool searchSupplementaryClipboard( const wxString& aSheetFilename, SCH_SCREEN** aScreen );
222
223 void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce );
224
225 void updatePastedSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_PATH& aPastePath,
226 const KIID_PATH& aClipPath, bool aForceKeepAnnotations );
227
228 SCH_SHEET_PATH updatePastedSheet( SCH_SHEET* aSheet, const SCH_SHEET_PATH& aPastePath,
229 const KIID_PATH& aClipPath, bool aForceKeepAnnotations,
230 SCH_SHEET_LIST* aPastedSheets,
231 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST>& aPastedSymbols );
232
233 void setPastedSymbolInstances( const SCH_SCREEN* aScreen );
234
244
265 bool processCmpToFootprintLinkFile( const wxString& aFullFilename, bool aForceVisibilityState,
266 bool aVisibilityState );
267
269 void setTransitions() override;
270
271private:
272 bool m_probingPcbToSch; // Recursion guard for PCB to schematic cross-probing
273 EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
274
275 std::string m_duplicateClipboard; // Temporary storage for Duplicate action
277
279
280 // A map of sheet filename --> screens for the clipboard contents. We use these to hook up
281 // cut/paste operations for unsaved sheet content.
282 std::map<wxString, SCH_SCREEN*> m_supplementaryClipboard;
283
284 // A map of KIID_PATH --> symbol instances for the clipboard contents.
285 std::map<KIID_PATH, SCH_SYMBOL_INSTANCE> m_clipboardSymbolInstances;
286
287 std::set<SCH_SYMBOL*> m_pastedSymbols;
288};
289
290
291#endif // SCH_EDITOR_CONTROL_H
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
Define a library symbol object.
Definition lib_symbol.h:114
int PageSetup(const TOOL_EVENT &aEvent)
bool RescueLegacyProject(bool aRunningOnDemand)
int ToggleDirectiveLabels(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
int MarkSimExclusions(const TOOL_EVENT &aEvent)
int Annotate(const TOOL_EVENT &aEvent)
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNet(const TOOL_EVENT &aEvent)
Highlight net chain under the cursor.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
int FindNetInInspector(const TOOL_EVENT &aEvent)
int EditSymbolFields(const TOOL_EVENT &aEvent)
int GenerateBOMLegacy(const TOOL_EVENT &aEvent)
int RemoveFromNetChain(const TOOL_EVENT &aEvent)
Remove any net highlighting.
int HighlightNetCursor(const TOOL_EVENT &aEvent)
Replace one of a net chain's terminal pins.
void AssignFootprints(const std::string &aChangedSetOfReferences)
int CopyAsText(const TOOL_EVENT &aEvent)
int AddVariant(const TOOL_EVENT &aEvent)
int ImportFPAssignments(const TOOL_EVENT &aEvent)
int ChangeLineMode(const TOOL_EVENT &aEvent)
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 CopyVariant(const TOOL_EVENT &aEvent)
int PlaceLinkedDesignBlock(const TOOL_EVENT &aEvent)
int ToggleRemoteSymbolPanel(const TOOL_EVENT &aEvent)
int Quit(const TOOL_EVENT &aEvent)
int RemapSymbols(const TOOL_EVENT &aEvent)
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
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)
int TogglePinAltIcons(const TOOL_EVENT &aEvent)
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
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 SaveToLinkedDesignBlock(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 RemoveVariant(const TOOL_EVENT &aEvent)
int UpdateFromPCB(const TOOL_EVENT &aEvent)
int ToggleAnnotateAuto(const TOOL_EVENT &aEvent)
int EditVariantDescription(const TOOL_EVENT &aEvent)
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
int Duplicate(const TOOL_EVENT &aEvent)
int IncrementAnnotations(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 ReplaceTerminalPin(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)
int ImportNonKicadSchematic(const TOOL_EVENT &aEvent)
int ShowCreateNetChain(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 ShowHierarchy(const TOOL_EVENT &aEvent)
int OnAngleSnapModeChanged(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
static const LIB_SYMBOL * ChoosePasteLibSymbol(const SCH_SCREEN *aClipboardScreen, const SCH_SCREEN *aDestScreen, const wxString &aLibSymbolName)
Choose which cached library symbol a pasted instance should adopt.
int ShowNetNavigator(const TOOL_EVENT &aEvent)
int NameNetChain(const TOOL_EVENT &aEvent)
int SimProbe(const TOOL_EVENT &aEvent)
void updatePastedSymbol(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int HighlightNetChain(const TOOL_EVENT &aEvent)
int ToggleLibraryTree(const TOOL_EVENT &aEvent)
int RenameVariant(const TOOL_EVENT &aEvent)
std::set< SCH_SYMBOL * > m_pastedSymbols
void prunePastedSymbolInstances()
Remove all pasted symbol instances that do not belong to the current project.
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 CreateNetChainBetweenPins(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)
void setPastedSymbolInstances(const SCH_SCREEN *aScreen)
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:162
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:44
Schematic symbol object.
Definition sch_symbol.h:69
SCH_TOOL_BASE(const std::string &aName)
Generic, UI-independent tool event.
Definition tool_event.h:167
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.