KiCad PCB EDA Suite
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-2021 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 
33 class SCH_EDIT_FRAME;
34 
38 class SCH_EDITOR_CONTROL : public wxEvtHandler, public EE_TOOL_BASE<SCH_EDIT_FRAME>
39 {
40 public:
42  EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" ),
43  m_probingPcbToSch( false ),
44  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  int ShowSchematicSetup( const TOOL_EVENT& aEvent );
54  int PageSetup( const TOOL_EVENT& aEvent );
55  int Print( const TOOL_EVENT& aEvent );
56  int Plot( const TOOL_EVENT& aEvent );
57  int Quit( const TOOL_EVENT& aEvent );
58 
66  int RescueSymbols( const TOOL_EVENT& aEvent );
67  int RemapSymbols( const TOOL_EVENT& aEvent );
68 
69  bool RescueLegacyProject( bool aRunningOnDemand );
70  bool RescueSymbolLibTableProject( bool aRunningOnDemand );
71 
72  int FindAndReplace( const TOOL_EVENT& aEvent );
73 
74  int FindNext( const TOOL_EVENT& aEvent );
75  bool HasMatch();
76  int ReplaceAndFindNext( const TOOL_EVENT& aEvent );
77  int ReplaceAll( const TOOL_EVENT& aEvent );
78 
79  int UpdateFind( const TOOL_EVENT& aEvent );
80 
82  int CrossProbeToPcb( const TOOL_EVENT& aEvent );
83 
86  int ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent );
87 
88 #ifdef KICAD_SPICE
89  int SimProbe( const TOOL_EVENT& aEvent );
90  int SimTune( const TOOL_EVENT& aEvent );
91 #endif /* KICAD_SPICE */
92 
94  int HighlightNet( 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 
105  int AssignNetclass( const TOOL_EVENT& aEvent );
106 
107  int Undo( const TOOL_EVENT& aEvent );
108  int Redo( const TOOL_EVENT& aEvent );
109 
111  int Cut( const TOOL_EVENT& aEvent );
112  int Copy( const TOOL_EVENT& aEvent );
113  int Paste( const TOOL_EVENT& aEvent );
114  int Duplicate( const TOOL_EVENT& aEvent );
115 
116  int EditWithSymbolEditor( const TOOL_EVENT& aEvent );
117  int ShowCvpcb( const TOOL_EVENT& aEvent );
118  int Annotate( const TOOL_EVENT& aEvent );
119  int EditSymbolFields( const TOOL_EVENT& aEvent );
120  int EditSymbolLibraryLinks( const TOOL_EVENT& aEvent );
121  int ShowPcbNew( const TOOL_EVENT& aEvent );
122  int UpdatePCB( const TOOL_EVENT& aEvent );
123  int UpdateFromPCB( const TOOL_EVENT& aEvent );
124  int ImportFPAssignments( const TOOL_EVENT& aEvent );
125  int ExportNetlist( const TOOL_EVENT& aEvent );
126  int GenerateBOM( const TOOL_EVENT& aEvent );
127  int DrawSheetOnClipboard( const TOOL_EVENT& aEvent );
128 
129  int ShowBusManager( const TOOL_EVENT& aEvent );
130 
131  int EnterSheet( const TOOL_EVENT& aEvent );
132  int LeaveSheet( const TOOL_EVENT& aEvent );
133  int NavigateHierarchy( const TOOL_EVENT& aEvent );
134 
135  int ToggleHiddenPins( const TOOL_EVENT& aEvent );
136  int ToggleHiddenFields( const TOOL_EVENT& aEvent );
137  int ToggleForceHV( const TOOL_EVENT& aEvent );
138  int TogglePythonConsole( const TOOL_EVENT& aEvent );
139 
140  void AssignFootprints( const std::string& aChangedSetOfReferences );
141 
151  SCH_ITEM* FindSymbolAndItem( const wxString& aReference, bool aSearchHierarchy,
152  SCH_SEARCH_T aSearchType, const wxString& aSearchText );
153 
154 private:
156  bool doCopy( bool aUseLocalClipboard = false );
157 
158  bool rescueProject( RESCUER& aRescuer, bool aRunningOnDemand );
159 
160  bool searchSupplementaryClipboard( const wxString& aSheetFilename, SCH_SCREEN** aScreen );
161 
162  void doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aForce );
163 
164  void updatePastedSymbol( SCH_SYMBOL* aSymbol, SCH_SCREEN* aPasteScreen,
165  const SCH_SHEET_PATH& aPastePath, const KIID_PATH& aClipPath,
166  bool aForceKeepAnnotations );
167 
168  SCH_SHEET_PATH updatePastedSheet( const SCH_SHEET_PATH& aPastePath, const KIID_PATH& aClipPath,
169  SCH_SHEET* aSheet, bool aForceKeepAnnotations,
170  SCH_SHEET_LIST* aPastedSheetsSoFar,
171  SCH_REFERENCE_LIST* aPastedSymbolsSoFar );
172 
173  void setClipboardInstances( const SCH_SCREEN* aPastedScreen );
174 
195  bool processCmpToFootprintLinkFile( const wxString& aFullFilename, bool aForceVisibilityState,
196  bool aVisibilityState );
197 
199  void setTransitions() override;
200 
209  SCH_ITEM* nextMatch( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, SCH_ITEM* aAfter,
210  wxFindReplaceData& aData );
211 
212 private:
213  bool m_probingPcbToSch; // Recursion guard when cross-probing to PcbNew
214  EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
215 
216  // Temporary storage location for Duplicate action
217  std::string m_localClipboard;
218 
219  // A map of sheet filename --> screens for the clipboard contents. We use these to hook up
220  // cut/paste operations for unsaved sheet content.
221  std::map<wxString, SCH_SCREEN*> m_supplementaryClipboard;
222 
223  // A map of KIID_PATH --> symbol instances for the clipboard contents.
224  std::map<KIID_PATH, SYMBOL_INSTANCE_REFERENCE> m_clipboardSymbolInstances;
225 
226  // A map of KIID_PATH --> sheet instances for the clipboard contents.
227  std::map<KIID_PATH, SCH_SHEET_INSTANCE> m_clipboardSheetInstances;
228 };
229 
230 
231 #endif // SCH_EDITOR_CONTROL_H
int TogglePythonConsole(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)
int EditWithSymbolEditor(const TOOL_EVENT &aEvent)
int FindAndReplace(const TOOL_EVENT &aEvent)
int Copy(const TOOL_EVENT &aEvent)
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)
bool RescueLegacyProject(bool aRunningOnDemand)
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
int Redo(const TOOL_EVENT &aEvent)
Clipboard support.
int NavigateHierarchy(const TOOL_EVENT &aEvent)
int EditSymbolFields(const TOOL_EVENT &aEvent)
int ReplaceAndFindNext(const TOOL_EVENT &aEvent)
void updatePastedSymbol(SCH_SYMBOL *aSymbol, SCH_SCREEN *aPasteScreen, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
int New(const TOOL_EVENT &aEvent)
Schematic editor (Eeschema) main window.
int FindNext(const TOOL_EVENT &aEvent)
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
int Annotate(const TOOL_EVENT &aEvent)
int GenerateBOM(const TOOL_EVENT &aEvent)
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
SCH_ITEM * FindSymbolAndItem(const wxString &aReference, bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString &aSearchText)
Find a symbol in the schematic and an item in this symbol.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
int ToggleForceHV(const TOOL_EVENT &aEvent)
int HighlightNet(const TOOL_EVENT &aEvent)
< Highlight net under the cursor.
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
Handle actions specific to the schematic editor.
int EnterSheet(const TOOL_EVENT &aEvent)
SCH_ITEM * nextMatch(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aSheet, SCH_ITEM *aAfter, wxFindReplaceData &aData)
Advance the search and returns the next matching item after aAfter.
int ShowPcbNew(const TOOL_EVENT &aEvent)
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
int Paste(const TOOL_EVENT &aEvent)
int UpdatePCB(const TOOL_EVENT &aEvent)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int LeaveSheet(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
int Print(const TOOL_EVENT &aEvent)
int ReplaceAll(const TOOL_EVENT &aEvent)
int UpdateFind(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
Generic, UI-independent tool event.
Definition: tool_event.h:152
int Plot(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.
bool doCopy(bool aUseLocalClipboard=false)
< copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true
int ImportFPAssignments(const TOOL_EVENT &aEvent)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
void setClipboardInstances(const SCH_SCREEN *aPastedScreen)
int RemapSymbols(const TOOL_EVENT &aEvent)
std::map< KIID_PATH, SCH_SHEET_INSTANCE > m_clipboardSheetInstances
int Duplicate(const TOOL_EVENT &aEvent)
std::map< KIID_PATH, SYMBOL_INSTANCE_REFERENCE > m_clipboardSymbolInstances
int AssignNetclass(const TOOL_EVENT &aEvent)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
int Open(const TOOL_EVENT &aEvent)
int PageSetup(const TOOL_EVENT &aEvent)
std::string m_localClipboard
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 Quit(const TOOL_EVENT &aEvent)
SCH_SEARCH_T
Schematic search type used by the socket link with Pcbnew.
Schematic symbol object.
Definition: sch_symbol.h:78
int ShowBusManager(const TOOL_EVENT &aEvent)
int Cut(const TOOL_EVENT &aEvent)
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
int Undo(const TOOL_EVENT &aEvent)
void AssignFootprints(const std::string &aChangedSetOfReferences)
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:49
int UpdateFromPCB(const TOOL_EVENT &aEvent)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193
int ExportNetlist(const TOOL_EVENT &aEvent)