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
|
2021-01-26 15:23:37 +00:00
|
|
|
* Copyright (C) 2019-2021 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 ),
|
|
|
|
m_pickerItem( nullptr )
|
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 );
|
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 );
|
|
|
|
|
2019-05-19 21:04:04 +00:00
|
|
|
int FindAndReplace( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
int FindNext( const TOOL_EVENT& aEvent );
|
|
|
|
bool HasMatch();
|
|
|
|
int ReplaceAndFindNext( const TOOL_EVENT& aEvent );
|
|
|
|
int ReplaceAll( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
int UpdateFind( const TOOL_EVENT& aEvent );
|
|
|
|
|
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
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
///< Equivalent to the above, but initiated by the user. We also do SCH_SHEETs on this
|
|
|
|
///< one (they're too slow on big projects for the auto version above).
|
2019-04-30 18:36:11 +00:00
|
|
|
int ExplicitCrossProbeToPcb( const TOOL_EVENT& aEvent );
|
2019-04-29 21:17:26 +00:00
|
|
|
|
2019-04-23 17:12:26 +00:00
|
|
|
#ifdef KICAD_SPICE
|
|
|
|
int SimProbe( const TOOL_EVENT& aEvent );
|
|
|
|
int SimTune( const TOOL_EVENT& aEvent );
|
|
|
|
#endif /* KICAD_SPICE */
|
|
|
|
|
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 );
|
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
|
|
|
|
|
|
|
int ShowBusManager( const TOOL_EVENT& aEvent );
|
2019-04-29 22:24:30 +00:00
|
|
|
|
2019-04-30 14:46:29 +00:00
|
|
|
int EnterSheet( const TOOL_EVENT& aEvent );
|
|
|
|
int LeaveSheet( const TOOL_EVENT& aEvent );
|
2019-05-13 20:42:40 +00:00
|
|
|
int NavigateHierarchy( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
int ToggleHiddenPins( const TOOL_EVENT& aEvent );
|
2020-04-18 15:36:29 +00:00
|
|
|
int ToggleHiddenFields( const TOOL_EVENT& aEvent );
|
2019-05-13 21:49:05 +00:00
|
|
|
int ToggleForceHV( const TOOL_EVENT& aEvent );
|
2019-04-30 14:46:29 +00:00
|
|
|
|
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
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Find a component in the schematic and an item in this component.
|
2019-07-17 20:21:22 +00:00
|
|
|
*
|
|
|
|
* @param aReference The component reference designator to find.
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
SCH_ITEM* FindComponentAndItem( const wxString& aReference,
|
|
|
|
bool aSearchHierarchy,
|
|
|
|
SCH_SEARCH_T aSearchType,
|
|
|
|
const wxString& aSearchText );
|
|
|
|
|
2019-04-14 00:44:05 +00:00
|
|
|
private:
|
2021-01-26 15:23:37 +00:00
|
|
|
///< copy selection to clipboard
|
2019-04-28 16:36:31 +00:00
|
|
|
bool doCopy();
|
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 );
|
|
|
|
|
2020-09-06 10:31:53 +00:00
|
|
|
void updatePastedInstances( const SCH_SHEET_PATH& aPastePath, const KIID_PATH& aClipPath,
|
|
|
|
SCH_SHEET* aSheet, bool aForceKeepAnnotations );
|
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.
|
|
|
|
*/
|
|
|
|
bool processCmpToFootprintLinkFile( const wxString& aFullFilename,
|
|
|
|
bool aForceVisibilityState,
|
|
|
|
bool aVisibilityState );
|
|
|
|
|
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-06-25 23:39:58 +00:00
|
|
|
/**
|
2021-01-26 15:23:37 +00:00
|
|
|
* Advance the search and returns the next matching item after \a aAfter.
|
|
|
|
*
|
2019-06-25 23:39:58 +00:00
|
|
|
* @param aScreen Pointer to the screen used for searching
|
|
|
|
* @param aAfter Starting match to compare
|
|
|
|
* @param aData Search data to compare against or NULL to match the first item found
|
|
|
|
* @return pointer to the next search item found or NULL if nothing found
|
|
|
|
*/
|
2020-09-20 17:52:56 +00:00
|
|
|
SCH_ITEM* nextMatch( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aSheet, SCH_ITEM* aAfter,
|
|
|
|
wxFindReplaceData* aData );
|
2019-06-25 23:39:58 +00:00
|
|
|
|
2019-05-12 11:49:58 +00:00
|
|
|
private:
|
2021-01-26 15:23:37 +00:00
|
|
|
bool m_probingPcbToSch; // Recursion guard when cross-probing to PcbNew
|
2019-06-25 23:39:58 +00:00
|
|
|
EDA_ITEM* m_pickerItem; // Current item for picker highlighting.
|
2019-08-30 20:55:04 +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.
|
|
|
|
std::map<wxString, SCH_SCREEN*> m_supplementaryClipboard;
|
2020-09-06 10:31:53 +00:00
|
|
|
SCH_REFERENCE_LIST m_supplementaryClipboardInstances;
|
|
|
|
KIID_PATH m_supplementaryClipboardPath;
|
2019-04-14 00:44:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SCH_EDITOR_CONTROL_H
|