KiCad PCB EDA Suite
SCH_EDITOR_CONTROL Class Reference

Handle actions specific to the schematic editor. More...

#include <sch_editor_control.h>

Inheritance diagram for SCH_EDITOR_CONTROL:
EE_TOOL_BASE< SCH_EDIT_FRAME > TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN , MODEL_RELOAD , GAL_SWITCH , REDRAW }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 SCH_EDITOR_CONTROL ()
 
 ~SCH_EDITOR_CONTROL ()
 
int New (const TOOL_EVENT &aEvent)
 
int Open (const TOOL_EVENT &aEvent)
 
int Save (const TOOL_EVENT &aEvent)
 
int SaveAs (const TOOL_EVENT &aEvent)
 
int SaveCurrSheetCopyAs (const TOOL_EVENT &aEvent)
 Saves the currently-open schematic sheet to an other name. More...
 
int Revert (const TOOL_EVENT &aEvent)
 
int ShowSchematicSetup (const TOOL_EVENT &aEvent)
 
int PageSetup (const TOOL_EVENT &aEvent)
 
int Print (const TOOL_EVENT &aEvent)
 
int Plot (const TOOL_EVENT &aEvent)
 
int Quit (const TOOL_EVENT &aEvent)
 
int RescueSymbols (const TOOL_EVENT &aEvent)
 Perform rescue operations to recover old projects from before certain changes were made. More...
 
int RemapSymbols (const TOOL_EVENT &aEvent)
 
bool RescueLegacyProject (bool aRunningOnDemand)
 
bool RescueSymbolLibTableProject (bool aRunningOnDemand)
 Notifies pcbnew about the selected item. More...
 
int CrossProbeToPcb (const TOOL_EVENT &aEvent)
 Equivalent to the above, but initiated by the user. More...
 
int ExplicitCrossProbeToPcb (const TOOL_EVENT &aEvent)
 
int ExportSymbolsToLibrary (const TOOL_EVENT &aEvent)
 
int HighlightNet (const TOOL_EVENT &aEvent)
 < Highlight net under the cursor. More...
 
int ClearHighlight (const TOOL_EVENT &aEvent)
 Update net highlighting after an edit. More...
 
int UpdateNetHighlighting (const TOOL_EVENT &aEvent)
 Launch a tool to highlight nets. More...
 
int HighlightNetCursor (const TOOL_EVENT &aEvent)
 
int AssignNetclass (const TOOL_EVENT &aEvent)
 
int Undo (const TOOL_EVENT &aEvent)
 
int Redo (const TOOL_EVENT &aEvent)
 Clipboard support. More...
 
int Cut (const TOOL_EVENT &aEvent)
 
int Copy (const TOOL_EVENT &aEvent)
 
int Paste (const TOOL_EVENT &aEvent)
 
int Duplicate (const TOOL_EVENT &aEvent)
 
int EditWithSymbolEditor (const TOOL_EVENT &aEvent)
 
int ShowCvpcb (const TOOL_EVENT &aEvent)
 
int Annotate (const TOOL_EVENT &aEvent)
 
int EditSymbolFields (const TOOL_EVENT &aEvent)
 
int EditSymbolLibraryLinks (const TOOL_EVENT &aEvent)
 
int ShowPcbNew (const TOOL_EVENT &aEvent)
 
int UpdatePCB (const TOOL_EVENT &aEvent)
 
int UpdateFromPCB (const TOOL_EVENT &aEvent)
 
int ImportFPAssignments (const TOOL_EVENT &aEvent)
 
int ExportNetlist (const TOOL_EVENT &aEvent)
 
int GenerateBOM (const TOOL_EVENT &aEvent)
 
int DrawSheetOnClipboard (const TOOL_EVENT &aEvent)
 
int ShowHierarchy (const TOOL_EVENT &aEvent)
 
int ToggleHiddenPins (const TOOL_EVENT &aEvent)
 
int ToggleHiddenFields (const TOOL_EVENT &aEvent)
 
int ToggleERCWarnings (const TOOL_EVENT &aEvent)
 
int ToggleERCErrors (const TOOL_EVENT &aEvent)
 
int ToggleERCExclusions (const TOOL_EVENT &aEvent)
 
int ChangeLineMode (const TOOL_EVENT &aEvent)
 
int NextLineMode (const TOOL_EVENT &aEvent)
 
int ToggleAnnotateAuto (const TOOL_EVENT &aEvent)
 
int ToggleAnnotateRecursive (const TOOL_EVENT &aEvent)
 
int TogglePythonConsole (const TOOL_EVENT &aEvent)
 
int RepairSchematic (const TOOL_EVENT &aEvent)
 
void AssignFootprints (const std::string &aChangedSetOfReferences)
 
SCH_ITEMFindSymbolAndItem (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. More...
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Protected Member Functions

void updateItem (EDA_ITEM *aItem, bool aUpdateRTree) const
 Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the SCH_SCREEN's RTree. More...
 
void saveCopyInUndoList (EDA_ITEM *aItem, UNDO_REDO aType, bool aAppend=false, bool aDirtyConnectivity=true)
 
void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

SCH_EDIT_FRAMEm_frame
 
KIGFX::SCH_VIEWm_view
 
EE_SELECTION_TOOLm_selectionTool
 
bool m_isSymbolEditor
 
TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

bool doCopy (bool aUseDuplicateClipboard=false)
 < copy selection to clipboard or to m_duplicateClipboard More...
 
bool rescueProject (RESCUER &aRescuer, bool aRunningOnDemand)
 
bool searchSupplementaryClipboard (const wxString &aSheetFilename, SCH_SCREEN **aScreen)
 
void doCrossProbeSchToPcb (const TOOL_EVENT &aEvent, bool aForce)
 
void updatePastedSymbol (SCH_SYMBOL *aSymbol, SCH_SCREEN *aPasteScreen, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
 
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)
 
void setClipboardInstances (const SCH_SCREEN *aPastedScreen)
 
bool processCmpToFootprintLinkFile (const wxString &aFullFilename, bool aForceVisibilityState, bool aVisibilityState)
 Read the footprint info from each line in the stuff file by reference designator. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
void resetTransitions ()
 Clear the current transition map and restores the default one created by setTransitions(). More...
 
void goInternal (TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
 
EDA_ITEMgetModelInt () const
 
TOOLS_HOLDERgetToolHolderInt () const
 

Private Attributes

bool m_probingPcbToSch
 
EDA_ITEMm_pickerItem
 
std::string m_duplicateClipboard
 
bool m_duplicateIsHoverSelection
 
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
 
std::map< KIID_PATH, SCH_SYMBOL_INSTANCEm_clipboardSymbolInstances
 
std::map< KIID_PATH, SCH_SHEET_INSTANCEm_clipboardSheetInstances
 

Detailed Description

Handle actions specific to the schematic editor.

Definition at line 38 of file sch_editor_control.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determine the reason of reset for a tool.

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

REDRAW 

Full drawing refresh.

Definition at line 77 of file tool_base.h.

78 {
79 RUN,
82 REDRAW
83 };
@ REDRAW
Full drawing refresh.
Definition: tool_base.h:82
@ MODEL_RELOAD
Model changes (required full reload)
Definition: tool_base.h:80
@ GAL_SWITCH
Rendering engine changes.
Definition: tool_base.h:81
@ RUN
Tool is invoked after being inactive.
Definition: tool_base.h:79

Constructor & Destructor Documentation

◆ SCH_EDITOR_CONTROL()

SCH_EDITOR_CONTROL::SCH_EDITOR_CONTROL ( )
inline

Definition at line 41 of file sch_editor_control.h.

41 :
42 EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.EditorControl" ),
43 m_probingPcbToSch( false ),
44 m_pickerItem( nullptr ),
46 { }

◆ ~SCH_EDITOR_CONTROL()

SCH_EDITOR_CONTROL::~SCH_EDITOR_CONTROL ( )
inline

Definition at line 48 of file sch_editor_control.h.

48{ }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 51 of file tool_interactive.cpp.

52{
54}
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), ROUTER_TOOL::RouteSelected(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ Annotate()

int SCH_EDITOR_CONTROL::Annotate ( const TOOL_EVENT aEvent)

Definition at line 1924 of file sch_editor_control.cpp.

1925{
1926 wxCommandEvent dummy;
1928 return 0;
1929}
void OnAnnotate(wxCommandEvent &event)
std::vector< FAB_LAYER_COLOR > dummy

References dummy, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::OnAnnotate().

Referenced by setTransitions().

◆ AssignFootprints()

void SCH_EDITOR_CONTROL::AssignFootprints ( const std::string &  aChangedSetOfReferences)

Definition at line 44 of file assign_footprints.cpp.

45{
46 // Build a flat list of symbols in schematic:
49 bool isChanged = false;
50 bool appendToUndoList = false;
51
52 sheets.GetSymbols( refs, false );
53
54 DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
55 PTREE doc;
56
57 try
58 {
59 Scan( &doc, &lexer );
60
61 CPTREE& back_anno = doc.get_child( "cvpcb_netlist" );
62 wxString footprint;
63
64 for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
65 {
66 wxASSERT( ref->first == "ref" );
67
68 wxString reference = (UTF8&) ref->second.front().first;
69
70 // Ensure the "fpid" node contains a footprint name, and get it if exists
71 if( ref->second.get_child( "fpid" ).size() )
72 {
73 wxString tmp = (UTF8&) ref->second.get_child( "fpid" ).front().first;
74 footprint = tmp;
75 }
76 else
77 footprint.Empty();
78
79 // Search the symbol in the flat list
80 for( unsigned ii = 0; ii < refs.GetCount(); ++ii )
81 {
82 if( reference == refs[ii].GetRef() )
83 {
84 // We have found a candidate.
85 // Note: it can be not unique (multiple parts per package)
86 // So we *do not* stop the search here
87 SCH_SYMBOL* symbol = refs[ ii ].GetSymbol();
88
89 // For backwards-compatibility CvPcb currently updates all instances of a
90 // symbol (even though it lists these instances separately).
91 wxString oldfp = refs[ii].GetFootprint();
92
93 if( oldfp.IsEmpty() && symbol->GetField( FOOTPRINT_FIELD )->IsVisible() )
94 symbol->GetField( FOOTPRINT_FIELD )->SetVisible( false );
95
96 if( oldfp != footprint )
97 {
98 isChanged = true;
99 SCH_SCREEN* screen = refs[ii].GetSheetPath().LastScreen();
100
102 appendToUndoList, false );
103 appendToUndoList = true;
104
105 symbol->SetFootprintFieldText( footprint );
106 }
107 }
108 }
109 }
110 }
111 catch( const PTREE_ERROR& ex )
112 {
113 // remap the exception to something the caller is likely to understand.
114 THROW_IO_ERROR( ex.what() );
115 }
116
117 if( isChanged )
118 {
119 m_frame->SyncView();
121 m_frame->OnModify();
122 }
123}
Implement a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:79
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
virtual bool IsVisible() const
Definition: eda_text.h:136
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:217
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:86
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SyncView()
Mark all items for refresh.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
SCHEMATIC & Schematic() const
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
size_t GetCount() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Add a SCH_REFERENCE object to aReferences for each symbol in the list of sheets.
Schematic symbol object.
Definition: sch_symbol.h:81
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:843
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:837
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:71
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Fill an empty PTREE with information from a KiCad s-expression stream.
Definition: ptree.cpp:86
const PTREE CPTREE
Definition: ptree.h:53
boost::property_tree::ptree_error PTREE_ERROR
Definition: ptree.h:54
boost::property_tree::ptree PTREE
Definition: ptree.h:52
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".

References CHANGED, FOOTPRINT_FIELD, FROM_UTF8(), SCH_BASE_FRAME::GetCanvas(), SCH_REFERENCE_LIST::GetCount(), SCH_SYMBOL::GetField(), SCHEMATIC::GetSheets(), SCH_SHEET_LIST::GetSymbols(), EDA_TEXT::IsVisible(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_EDIT_FRAME::OnModify(), EDA_DRAW_PANEL_GAL::Refresh(), SCH_EDIT_FRAME::SaveCopyInUndoList(), Scan(), SCH_EDIT_FRAME::Schematic(), SCH_SYMBOL::SetFootprintFieldText(), EDA_TEXT::SetVisible(), SCH_BASE_FRAME::SyncView(), and THROW_IO_ERROR.

Referenced by SCH_EDIT_FRAME::KiwayMailIn().

◆ AssignNetclass()

int SCH_EDITOR_CONTROL::AssignNetclass ( const TOOL_EVENT aEvent)

Definition at line 790 of file sch_editor_control.cpp.

791{
793 SCHEMATIC& schematic = m_frame->Schematic();
795
796 const SCH_CONNECTION* conn = nullptr;
797 VECTOR2D connPos;
798
799 for( EDA_ITEM* item : selectionTool->GetSelection() )
800 {
801 conn = static_cast<SCH_ITEM*>( item )->Connection();
802 connPos = item->GetPosition();
803
804 if( conn )
805 break;
806 }
807
808 if( !conn )
809 {
810 m_frame->ShowInfoBarError( _( "No net selected." ) );
811 return 0;
812 }
813
814 // Remove selection in favor of highlighting so the whole net is highlighted
815 selectionTool->ClearSelection();
816 highlightNet( m_toolMgr, connPos );
817
818 wxString netName = conn->Name();
819
820 if( conn->IsBus() )
821 {
822 wxString prefix;
823
824 if( NET_SETTINGS::ParseBusVector( netName, &prefix, nullptr ) )
825 {
826 netName = prefix + wxT( "*" );
827 }
828 else if( NET_SETTINGS::ParseBusGroup( netName, &prefix, nullptr ) )
829 {
830 netName = prefix + wxT( ".*" );
831 }
832 }
833 else if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
835 {
836 m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
838 return 0;
839 }
840
841 DIALOG_ASSIGN_NETCLASS dlg( m_frame, netName, schematic.GetNetClassAssignmentCandidates(),
842 [&]( const std::vector<wxString>& aNetNames )
843 {
844 for( SCH_ITEM* item : screen->Items() )
845 {
846 bool redraw = item->IsBrightened();
847 SCH_CONNECTION* itemConn = item->Connection();
848
849 if( itemConn && alg::contains( aNetNames, itemConn->Name() ) )
850 item->SetBrightened();
851 else
852 item->ClearBrightened();
853
854 redraw |= item->IsBrightened();
855
856 if( item->Type() == SCH_SYMBOL_T )
857 {
858 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
859
860 redraw |= symbol->HasBrightenedPins();
861
862 symbol->ClearBrightenedPins();
863
864 for( SCH_PIN* pin : symbol->GetPins() )
865 {
866 SCH_CONNECTION* pin_conn = pin->Connection();
867
868 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
869 {
870 pin->SetBrightened();
871 redraw = true;
872 }
873 }
874 }
875 else if( item->Type() == SCH_SHEET_T )
876 {
877 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
878 {
879 SCH_CONNECTION* pin_conn = pin->Connection();
880
881 redraw |= pin->IsBrightened();
882
883 if( pin_conn && alg::contains( aNetNames, pin_conn->Name() ) )
884 pin->SetBrightened();
885 else
886 pin->ClearBrightened();
887
888 redraw |= pin->IsBrightened();
889 }
890 }
891
892 if( redraw )
893 getView()->Update( item, KIGFX::VIEW_UPDATE_FLAGS::REPAINT );
894 }
895
897 } );
898
899 if( dlg.ShowModal() )
900 {
902 []( KIGFX::VIEW_ITEM* aItem ) -> int
903 {
904 // Netclass coloured items
905 //
906 if( dynamic_cast<SCH_LINE*>( aItem ) )
907 return KIGFX::REPAINT;
908 else if( dynamic_cast<SCH_JUNCTION*>( aItem ) )
909 return KIGFX::REPAINT;
910 else if( dynamic_cast<SCH_BUS_ENTRY_BASE*>( aItem ) )
911 return KIGFX::REPAINT;
912
913 // Items that might reference an item's netclass name
914 //
915 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
916
917 if( text && text->HasTextVars() )
918 {
919 text->ClearRenderCache();
920 text->ClearBoundingBoxCache();
922 }
923
924 return 0;
925 } );
926 }
927
929 return 0;
930}
PRIORITY GetDriverPriority()
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void ForceRefresh()
Force a redraw.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
EE_SELECTION & GetSelection()
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
Definition: view.cpp:1494
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parse a bus group label into the name and a list of components.
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
Holds all the data relating to one schematic.
Definition: schematic.h:61
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString Name(bool aIgnoreSheet=false) const
bool IsBus() const
SCH_ITEM * Driver() const
SCH_SHEET_PATH & GetCurrentSheet() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
SCH_SCREEN * LastScreen()
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
#define _(s)
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:49
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
static VECTOR2D CLEAR

References _, CLEAR, EE_SELECTION_TOOL::ClearSelection(), SCH_CONNECTION::Driver(), EDA_DRAW_PANEL_GAL::ForceRefresh(), SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), CONNECTION_SUBGRAPH::GetDriverPriority(), EDA_ITEM::GetPosition(), EE_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), highlightNet(), SCH_CONNECTION::IsBus(), SCH_SHEET_PATH::LastScreen(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, SCH_CONNECTION::Name(), NET_SETTINGS::ParseBusGroup(), NET_SETTINGS::ParseBusVector(), SCH_EDIT_FRAME::Schematic(), CONNECTION_SUBGRAPH::SHEET_PIN, and EDA_BASE_FRAME::ShowInfoBarError().

Referenced by setTransitions().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61{
62 m_toolMgr = aManager;
63}

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ ChangeLineMode()

int SCH_EDITOR_CONTROL::ChangeLineMode ( const TOOL_EVENT aEvent)

Definition at line 2075 of file sch_editor_control.cpp.

2076{
2077 m_frame->eeconfig()->m_Drawing.line_mode = aEvent.Parameter<int>();
2079 return 0;
2080}
static TOOL_ACTION refreshPreview
Definition: actions.h:109
EESCHEMA_SETTINGS * eeconfig() const
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142

References SCH_BASE_FRAME::eeconfig(), EESCHEMA_SETTINGS::DRAWING::line_mode, EESCHEMA_SETTINGS::m_Drawing, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), ACTIONS::refreshPreview, and TOOL_MANAGER::RunAction().

Referenced by setTransitions().

◆ ClearHighlight()

int SCH_EDITOR_CONTROL::ClearHighlight ( const TOOL_EVENT aEvent)

Update net highlighting after an edit.

Definition at line 782 of file sch_editor_control.cpp.

783{
785
786 return 0;
787}

References CLEAR, highlightNet(), and TOOL_BASE::m_toolMgr.

Referenced by setTransitions().

◆ Copy()

int SCH_EDITOR_CONTROL::Copy ( const TOOL_EVENT aEvent)

Definition at line 1270 of file sch_editor_control.cpp.

1271{
1272 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1273
1274 if( textEntry )
1275 {
1276 textEntry->Copy();
1277 return 0;
1278 }
1279
1280 doCopy();
1281
1282 return 0;
1283}
bool doCopy(bool aUseDuplicateClipboard=false)
< copy selection to clipboard or to m_duplicateClipboard

References doCopy().

Referenced by setTransitions().

◆ CrossProbeToPcb()

int SCH_EDITOR_CONTROL::CrossProbeToPcb ( const TOOL_EVENT aEvent)

Equivalent to the above, but initiated by the user.

Definition at line 311 of file sch_editor_control.cpp.

312{
313 doCrossProbeSchToPcb( aEvent, false );
314 return 0;
315}
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)

References doCrossProbeSchToPcb().

Referenced by setTransitions().

◆ Cut()

int SCH_EDITOR_CONTROL::Cut ( const TOOL_EVENT aEvent)

Definition at line 1253 of file sch_editor_control.cpp.

1254{
1255 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1256
1257 if( textEntry )
1258 {
1259 textEntry->Cut();
1260 return 0;
1261 }
1262
1263 if( doCopy() )
1265
1266 return 0;
1267}
static TOOL_ACTION doDelete
Definition: actions.h:73

References doCopy(), ACTIONS::doDelete, TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunAction().

Referenced by setTransitions().

◆ doCopy()

bool SCH_EDITOR_CONTROL::doCopy ( bool  aUseDuplicateClipboard = false)
private

< copy selection to clipboard or to m_duplicateClipboard

Definition at line 1181 of file sch_editor_control.cpp.

1182{
1184 EE_SELECTION& selection = selTool->RequestSelection();
1185 SCHEMATIC& schematic = m_frame->Schematic();
1186
1187 if( selection.Empty() )
1188 return false;
1189
1190 if( aUseDuplicateClipboard )
1191 m_duplicateIsHoverSelection = selection.IsHover();
1192
1193 selection.SetScreen( m_frame->GetScreen() );
1195
1196 for( EDA_ITEM* item : selection )
1197 {
1198 if( item->Type() == SCH_SHEET_T )
1199 {
1200 SCH_SHEET* sheet = (SCH_SHEET*) item;
1201 m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1202 }
1203 else if( item->Type() == SCH_FIELD_T && selection.IsHover() )
1204 {
1205 // Most of the time the user is trying to duplicate the parent symbol
1206 // and the field text is in it
1207 selection.Add( item->GetParent() );
1208 }
1209 }
1210
1211 STRING_FORMATTER formatter;
1212 SCH_SEXPR_PLUGIN plugin;
1213 SCH_SHEET_LIST hierarchy = schematic.GetSheets();
1215
1216 plugin.Format( &selection, &selPath, schematic, &formatter, true );
1217
1218 if( selection.IsHover() )
1220
1221 if( aUseDuplicateClipboard )
1222 {
1223 m_duplicateClipboard = formatter.GetString();
1224 return true;
1225 }
1226
1227 return m_toolMgr->SaveClipboard( formatter.GetString() );
1228}
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
EE_SELECTION & RequestSelection(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
Return either an existing selection (filtered), or the selection at the current cursor position if th...
std::string m_duplicateClipboard
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
A SCH_PLUGIN derivation for loading schematic files using the new s-expression file format.
void Format(SCH_SHEET *aSheet)
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
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:302
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:106
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:415
const std::string & GetString()
Definition: richio.h:438
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
@ SCH_FIELD_T
Definition: typeinfo.h:155
@ SCH_SHEET_T
Definition: typeinfo.h:158

References EE_ACTIONS::clearSelection, SCH_SEXPR_PLUGIN::Format(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SHEET::GetFileName(), EDA_ITEM::GetParent(), SCH_SHEET::GetScreen(), SCH_EDIT_FRAME::GetScreen(), SCHEMATIC::GetSheets(), STRING_FORMATTER::GetString(), TOOL_MANAGER::GetTool(), m_duplicateClipboard, m_duplicateIsHoverSelection, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_supplementaryClipboard, TOOL_BASE::m_toolMgr, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), TOOL_MANAGER::SaveClipboard(), SCH_FIELD_T, SCH_SHEET_T, SCH_EDIT_FRAME::Schematic(), and EDA_ITEM::Type().

Referenced by Copy(), Cut(), and Duplicate().

◆ doCrossProbeSchToPcb()

void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb ( const TOOL_EVENT aEvent,
bool  aForce 
)
private

Definition at line 325 of file sch_editor_control.cpp.

326{
327 // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
329 return;
330
332
333 EE_SELECTION& selection = aForce ? selTool->RequestSelection() : selTool->GetSelection();
334
335 m_frame->SendSelectItemsToPcb( selection.GetItemsSortedBySelectionOrder(), aForce );
336}
bool IsSyncingSelection()
void SendSelectItemsToPcb(const std::vector< EDA_ITEM * > &aItems, bool aForce)
Sends items to Pcbnew for selection.

References EE_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), SCH_EDIT_FRAME::IsSyncingSelection(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_probingPcbToSch, TOOL_BASE::m_toolMgr, EE_SELECTION_TOOL::RequestSelection(), and SCH_EDIT_FRAME::SendSelectItemsToPcb().

Referenced by CrossProbeToPcb(), and ExplicitCrossProbeToPcb().

◆ DrawSheetOnClipboard()

int SCH_EDITOR_CONTROL::DrawSheetOnClipboard ( const TOOL_EVENT aEvent)

Definition at line 2000 of file sch_editor_control.cpp.

2001{
2004 return 0;
2005}
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:543
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
@ LOCAL_CLEANUP

References SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), LOCAL_CLEANUP, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::RecalculateConnections().

Referenced by setTransitions().

◆ Duplicate()

int SCH_EDITOR_CONTROL::Duplicate ( const TOOL_EVENT aEvent)

Definition at line 1244 of file sch_editor_control.cpp.

1245{
1246 doCopy( true ); // Use the local clipboard
1247 Paste( aEvent );
1248
1249 return 0;
1250}
int Paste(const TOOL_EVENT &aEvent)

References doCopy(), and Paste().

Referenced by setTransitions().

◆ EditSymbolFields()

int SCH_EDITOR_CONTROL::EditSymbolFields ( const TOOL_EVENT aEvent)

Definition at line 1940 of file sch_editor_control.cpp.

1941{
1943 dlg.ShowQuasiModal();
1944 return 0;
1945}

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and DIALOG_SHIM::ShowQuasiModal().

Referenced by setTransitions().

◆ EditSymbolLibraryLinks()

int SCH_EDITOR_CONTROL::EditSymbolLibraryLinks ( const TOOL_EVENT aEvent)

Definition at line 1948 of file sch_editor_control.cpp.

1949{
1952
1953 return 0;
1954}
void HardRedraw() override
Rebuild the GAL and redraw the screen.
bool InvokeDialogEditSymbolsLibId(SCH_EDIT_FRAME *aCaller)
Run a dialog to modify the LIB_ID of symbols for instance when a symbol has moved from a symbol libra...

References SCH_EDIT_FRAME::HardRedraw(), InvokeDialogEditSymbolsLibId(), and EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame.

Referenced by setTransitions().

◆ EditWithSymbolEditor()

int SCH_EDITOR_CONTROL::EditWithSymbolEditor ( const TOOL_EVENT aEvent)

Definition at line 1873 of file sch_editor_control.cpp.

1874{
1876 EE_SELECTION& selection = selTool->RequestSelection( { SCH_SYMBOL_T } );
1877 SCH_SYMBOL* symbol = nullptr;
1878 SYMBOL_EDIT_FRAME* symbolEditor;
1879
1880 if( selection.GetSize() >= 1 )
1881 symbol = (SCH_SYMBOL*) selection.Front();
1882
1883 if( selection.IsHover() )
1885
1886 if( !symbol || symbol->GetEditFlags() != 0 )
1887 return 0;
1888
1889 if( symbol->IsMissingLibSymbol() )
1890 {
1891 m_frame->ShowInfoBarError( _( "Symbols with broken library symbol links cannot "
1892 "be edited." ) );
1893 return 0;
1894 }
1895
1897 symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1898
1899 if( symbolEditor )
1900 {
1901 if( wxWindow* blocking_win = symbolEditor->Kiway().GetBlockingDialog() )
1902 blocking_win->Close( true );
1903
1904 if( aEvent.IsAction( &EE_ACTIONS::editWithLibEdit ) )
1905 {
1906 symbolEditor->LoadSymbolFromSchematic( symbol );
1907 }
1909 {
1910 symbolEditor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(), symbol->GetConvert() );
1911
1912 if( !symbolEditor->IsSymbolTreeShown() )
1913 {
1914 wxCommandEvent evt;
1915 symbolEditor->OnToggleSymbolTree( evt );
1916 }
1917 }
1918 }
1919
1920 return 0;
1921}
static TOOL_ACTION showSymbolEditor
Definition: actions.h:164
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:145
static TOOL_ACTION editLibSymbolWithLibEdit
Definition: ee_actions.h:171
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:170
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
wxWindow * GetBlockingDialog()
Gets the window pointer to the blocking dialog (to send it signals)
Definition: kiway.cpp:620
int GetUnit() const
Definition: sch_symbol.h:228
int GetConvert() const
Definition: sch_symbol.h:270
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:236
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
The symbol library editor main window.
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
bool IsSymbolTreeShown() const
void OnToggleSymbolTree(wxCommandEvent &event)
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ SCH_SYMBOL_T
Definition: typeinfo.h:156

References _, EE_ACTIONS::clearSelection, EE_ACTIONS::editLibSymbolWithLibEdit, EE_ACTIONS::editWithLibEdit, FRAME_SCH_SYMBOL_EDITOR, KIWAY::GetBlockingDialog(), SCH_SYMBOL::GetConvert(), EDA_ITEM::GetEditFlags(), SCH_SYMBOL::GetLibId(), TOOL_MANAGER::GetTool(), SCH_SYMBOL::GetUnit(), TOOL_EVENT::IsAction(), SCH_SYMBOL::IsMissingLibSymbol(), SYMBOL_EDIT_FRAME::IsSymbolTreeShown(), KIWAY_HOLDER::Kiway(), SYMBOL_EDIT_FRAME::LoadSymbol(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, SYMBOL_EDIT_FRAME::OnToggleSymbolTree(), KIWAY::Player(), EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), SCH_SYMBOL_T, EDA_BASE_FRAME::ShowInfoBarError(), and ACTIONS::showSymbolEditor.

Referenced by setTransitions().

◆ ExplicitCrossProbeToPcb()

int SCH_EDITOR_CONTROL::ExplicitCrossProbeToPcb ( const TOOL_EVENT aEvent)

Definition at line 318 of file sch_editor_control.cpp.

319{
320 doCrossProbeSchToPcb( aEvent, true );
321 return 0;
322}

References doCrossProbeSchToPcb().

Referenced by setTransitions().

◆ ExportNetlist()

int SCH_EDITOR_CONTROL::ExportNetlist ( const TOOL_EVENT aEvent)

Definition at line 1981 of file sch_editor_control.cpp.

1982{
1983 int result = NET_PLUGIN_CHANGE;
1984
1985 // If a plugin is removed or added, rebuild and reopen the new dialog
1986 while( result == NET_PLUGIN_CHANGE )
1987 result = InvokeDialogNetList( m_frame );
1988
1989 return 0;
1990}
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)
#define NET_PLUGIN_CHANGE
Create and shows DIALOG_EXPORT_NETLIST and returns whatever DIALOG_EXPORT_NETLIST::ShowModal() return...

References InvokeDialogNetList(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and NET_PLUGIN_CHANGE.

Referenced by setTransitions().

◆ ExportSymbolsToLibrary()

int SCH_EDITOR_CONTROL::ExportSymbolsToLibrary ( const TOOL_EVENT aEvent)

Definition at line 339 of file sch_editor_control.cpp.

340{
341 bool createNew = aEvent.IsAction( &EE_ACTIONS::exportSymbolsToNewLibrary );
342
343 SCH_REFERENCE_LIST symbols;
344 m_frame->Schematic().GetSheets().GetSymbols( symbols, false );
345
346 std::map<LIB_ID, LIB_SYMBOL*> libSymbols;
347 std::map<LIB_ID, std::vector<SCH_SYMBOL*>> symbolMap;
348
349 for( size_t i = 0; i < symbols.GetCount(); ++i )
350 {
351 SCH_SYMBOL* symbol = symbols[i].GetSymbol();
352 LIB_SYMBOL* libSymbol = symbol->GetLibSymbolRef().get();
353 LIB_ID id = libSymbol->GetLibId();
354
355 if( libSymbols.count( id ) )
356 {
357 wxASSERT_MSG( libSymbols[id]->Compare( *libSymbol, LIB_ITEM::COMPARE_FLAGS::ERC ) == 0,
358 "Two symbols have the same LIB_ID but are different!" );
359 }
360 else
361 {
362 libSymbols[id] = libSymbol;
363 }
364
365 symbolMap[id].emplace_back( symbol );
366 }
367
369
370 wxString targetLib;
371
372 if( createNew )
373 {
374 wxFileName fn;
376
379 ( libTable == &SYMBOL_LIB_TABLE::GetGlobalLibTable() ),
381 {
382 return 0;
383 }
384
385 targetLib = fn.GetName();
386
387 if( libTable->HasLibrary( targetLib, false ) )
388 {
389 DisplayError( m_frame, wxString::Format( _( "Library '%s' already exists." ),
390 targetLib ) );
391 return 0;
392 }
393
394 if( !mgr.CreateLibrary( fn.GetFullPath(), libTable ) )
395 {
396 DisplayError( m_frame, wxString::Format( _( "Could not add library '%s'." ),
397 targetLib ) );
398 return 0;
399 }
400 }
401 else
402 {
403 targetLib = m_frame->SelectLibraryFromList();
404 }
405
406 if( targetLib.IsEmpty() )
407 return 0;
408
409 bool map = IsOK( m_frame, _( "Update symbols in schematic to refer to new library?" ) );
410 bool append = false;
411
412 SYMBOL_LIB_TABLE_ROW* row = mgr.GetLibrary( targetLib );
413 SCH_IO_MGR::SCH_FILE_T type = SCH_IO_MGR::EnumFromStr( row->GetType() );
414 SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( SCH_IO_MGR::FindPlugin( type ) );
415
416 wxFileName dest = row->GetFullURI( true );
417 dest.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS );
418
419 for( const std::pair<const LIB_ID, LIB_SYMBOL*>& it : libSymbols )
420 {
421 LIB_SYMBOL* origSym = it.second;
422 LIB_SYMBOL* newSym = origSym->Flatten().release();
423
424 pi->SaveSymbol( dest.GetFullPath(), newSym );
425
426 if( map )
427 {
428 LIB_ID id = it.first;
429 id.SetLibNickname( targetLib );
430
431
432 for( SCH_SYMBOL* symbol : symbolMap[it.first] )
433 {
434 m_frame->SaveCopyInUndoList( m_frame->GetScreen(), symbol, UNDO_REDO::CHANGED, append, false);
435 symbol->SetLibId( id );
436 append = true;
437 }
438 }
439 }
440
441 if( append )
442 m_frame->OnModify();
443
444 return 0;
445}
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
static TOOL_ACTION exportSymbolsToNewLibrary
Definition: ee_actions.h:178
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
int SetLibNickname(const UTF8 &aNickname)
Override the logical library name portion of the LIB_ID to aNickname.
Definition: lib_id.cpp:98
Define a library symbol object.
Definition: lib_symbol.h:99
LIB_ID GetLibId() const override
Definition: lib_symbol.h:141
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:456
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
static wxString GetDefaultUserSymbolsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:97
SYMBOL_LIB_TABLE * SelectSymLibTable(bool aOptional=false)
Display a dialog asking the user to select a symbol library table.
wxString SelectLibraryFromList()
Display a list of loaded libraries and allows the user to select a library.
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Return the #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy",...
Definition: sch_io_mgr.cpp:101
Helper object to release a SCH_PLUGIN in the context of a potential thrown exception through its dest...
Definition: sch_io_mgr.h:535
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:280
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:192
Class to handle modifications to the symbol libraries.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
const wxString GetType() const override
Return the type of symbol library table represented by this row.
static SYMBOL_LIB_TABLE & GetGlobalLibTable()
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:380
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:300
const std::string KiCadSymbolLibFileExtension
wxString KiCadSymbolLibFileWildcard()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition: wx_filename.h:38

References _, CHANGED, SYMBOL_LIBRARY_MANAGER::CreateLibrary(), DisplayError(), SCH_IO_MGR::EnumFromStr(), EE_ACTIONS::exportSymbolsToNewLibrary, LIB_SYMBOL::Flatten(), FN_NORMALIZE_FLAGS, Format(), SCH_REFERENCE_LIST::GetCount(), PATHS::GetDefaultUserSymbolsPath(), LIB_TABLE_ROW::GetFullURI(), SYMBOL_LIB_TABLE::GetGlobalLibTable(), LIB_SYMBOL::GetLibId(), SYMBOL_LIBRARY_MANAGER::GetLibrary(), SCH_SYMBOL::GetLibSymbolRef(), SCH_EDIT_FRAME::GetScreen(), SCHEMATIC::GetSheets(), SCH_SHEET_LIST::GetSymbols(), SYMBOL_LIB_TABLE_ROW::GetType(), LIB_TABLE::HasLibrary(), TOOL_EVENT::IsAction(), IsOK(), KiCadSymbolLibFileExtension, KiCadSymbolLibFileWildcard(), EDA_DRAW_FRAME::LibraryFileBrowser(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_EDIT_FRAME::OnModify(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_PLUGIN::SaveSymbol(), SCH_EDIT_FRAME::Schematic(), SCH_BASE_FRAME::SelectLibraryFromList(), SCH_BASE_FRAME::SelectSymLibTable(), and LIB_ID::SetLibNickname().

Referenced by setTransitions().

◆ FindSymbolAndItem()

SCH_ITEM * SCH_EDITOR_CONTROL::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.

Parameters
aPathThe symbol path to find. Pass nullptr to search by aReference.
aReferenceThe symbol reference designator to find, or to display in status bar if aPath is specified
aSearchHierarchyIf false, search the current sheet only. Otherwise, the entire hierarchy
aSearchTypeA SCH_SEARCH_T value used to determine what to search for.
aSearchTextThe text to search for, either in value, reference or elsewhere.

Definition at line 45 of file eeschema/cross-probing.cpp.

48{
49 SCH_SHEET_PATH* sheetWithSymbolFound = nullptr;
50 SCH_SYMBOL* symbol = nullptr;
51 VECTOR2I pos;
52 SCH_PIN* pin = nullptr;
53 SCH_SHEET_LIST sheetList;
54 SCH_ITEM* foundItem = nullptr;
55
56 if( !aSearchHierarchy )
57 sheetList.push_back( m_frame->GetCurrentSheet() );
58 else
59 sheetList = m_frame->Schematic().GetSheets();
60
61 for( SCH_SHEET_PATH& sheet : sheetList )
62 {
63 SCH_SCREEN* screen = sheet.LastScreen();
64
65 for( EDA_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
66 {
67 SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );
68
69 // Search by path if specified, otherwise search by reference
70 bool found = false;
71
72 if( aPath )
73 {
74 wxString path = sheet.PathAsString() + candidate->m_Uuid.AsString();
75 found = ( *aPath == path );
76 }
77 else
78 {
79 found = ( aReference && aReference->CmpNoCase( candidate->GetRef( &sheet ) ) == 0 );
80 }
81
82 if( found )
83 {
84 symbol = candidate;
85 sheetWithSymbolFound = &sheet;
86
87 if( aSearchType == HIGHLIGHT_PIN )
88 {
89 // temporary: will be changed if the pin is found.
90 pos = symbol->GetPosition();
91 pin = symbol->GetPin( aSearchText );
92
93 // Ensure we have found the right unit in case of multi-units symbol
94 if( pin )
95 {
96 int unit = pin->GetLibPin()->GetUnit();
97
98 if( unit != 0 && unit != symbol->GetUnit() )
99 {
100 pin = nullptr;
101 continue;
102 }
103
104 // Get pin position in true schematic coordinate
105 pos = pin->GetPosition();
106 foundItem = pin;
107 break;
108 }
109 }
110 else
111 {
112 pos = symbol->GetPosition();
113 foundItem = symbol;
114 break;
115 }
116 }
117 }
118
119 if( foundItem )
120 break;
121 }
122
123 CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
124
125
126 if( symbol )
127 {
128 if( *sheetWithSymbolFound != m_frame->GetCurrentSheet() )
129 {
130 m_frame->Schematic().SetCurrentSheet( *sheetWithSymbolFound );
132 }
133
134 if( crossProbingSettings.center_on_items )
135 {
136 if( crossProbingSettings.zoom_to_fit )
137 {
138 BOX2I bbox = symbol->GetBoundingBox();
139
140 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->ZoomFitCrossProbeBBox( bbox );
141 }
142
143 if( pin )
145 else
146 m_frame->FocusOnItem( symbol );
147 }
148 }
149
150 /* Print diag */
151 wxString msg;
152 wxString displayRef;
153
154 if( aReference )
155 displayRef = *aReference;
156 else if( aPath )
157 displayRef = *aPath;
158
159 if( symbol )
160 {
161 if( aSearchType == HIGHLIGHT_PIN )
162 {
163 if( foundItem )
164 msg.Printf( _( "%s pin %s found" ), displayRef, aSearchText );
165 else
166 msg.Printf( _( "%s found but pin %s not found" ), displayRef, aSearchText );
167 }
168 else
169 {
170 msg.Printf( _( "%s found" ), displayRef );
171 }
172 }
173 else
174 {
175 msg.Printf( _( "%s not found" ), displayRef );
176 }
177
178 m_frame->SetStatusText( msg );
179
181
182 return foundItem;
183}
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:173
const KIID m_Uuid
Definition: eda_item.h:492
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
wxString AsString() const
Definition: kiid.cpp:257
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:125
void DisplayCurrentSheet()
Draw the current sheet on the display.
void FocusOnItem(SCH_ITEM *aItem)
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:109
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:652
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:712
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
@ HIGHLIGHT_PIN
Cross-probing behavior.
Definition: app_settings.h:31
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:34
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:33

References _, KIID::AsString(), CROSS_PROBING_SETTINGS::center_on_items, SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_BASE_FRAME::eeconfig(), SCH_EDIT_FRAME::FocusOnItem(), SCH_SYMBOL::GetBoundingBox(), SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SYMBOL::GetPin(), SCH_SYMBOL::GetPosition(), SCH_SYMBOL::GetRef(), SCHEMATIC::GetSheets(), TOOL_MANAGER::GetTool(), SCH_SYMBOL::GetUnit(), HIGHLIGHT_PIN, SCH_SCREEN::Items(), APP_SETTINGS_BASE::m_CrossProbing, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, EDA_ITEM::m_Uuid, EE_RTREE::OfType(), path, pin, EDA_DRAW_PANEL_GAL::Refresh(), SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), SCHEMATIC::SetCurrentSheet(), and CROSS_PROBING_SETTINGS::zoom_to_fit.

◆ GenerateBOM()

int SCH_EDITOR_CONTROL::GenerateBOM ( const TOOL_EVENT aEvent)

Definition at line 1993 of file sch_editor_control.cpp.

1994{
1996 return 0;
1997}
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:110

References InvokeDialogCreateBOM(), and EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame.

Referenced by setTransitions().

◆ getEditFrame()

template<typename T >
T * TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Return the application window object, casted to requested user type.

Definition at line 185 of file tool_base.h.

186 {
187#if !defined( QA_TEST ) // Dynamic casts give the linker a seizure in the test framework
188 wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
189#endif
190 return static_cast<T*>( getToolHolderInt() );
191 }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), and ZONE_CREATE_HELPER::setUniquePriority().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

122 {
123 return m_toolId;
124 }

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), TOOL_MANAGER::saveViewControls(), and TOOL_MANAGER::ShutdownTool().

◆ GetManager()

TOOL_MANAGER * TOOL_BASE::GetManager ( ) const
inlineinherited

◆ getModel()

template<typename T >
T * TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 197 of file tool_base.h.

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), and ZONE_CREATE_HELPER::createZoneFromExisting().

◆ getModelInt()

EDA_ITEM * TOOL_BASE::getModelInt ( ) const
privateinherited

Definition at line 54 of file tool_base.cpp.

55{
56 return m_toolMgr->GetModel();
57}
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292

References TOOL_MANAGER::GetModel(), and TOOL_BASE::m_toolMgr.

Referenced by TOOL_BASE::getModel().

◆ GetName()

const std::string & TOOL_BASE::GetName ( void  ) const
inlineinherited

Return the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 134 of file tool_base.h.

135 {
136 return m_toolName;
137 }
std::string m_toolName
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), TOOL_MANAGER::RegisterTool(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getToolHolderInt()

TOOLS_HOLDER * TOOL_BASE::getToolHolderInt ( ) const
privateinherited

Definition at line 48 of file tool_base.cpp.

49{
50 return m_toolMgr->GetToolHolder();
51}
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296

References TOOL_MANAGER::GetToolHolder(), and TOOL_BASE::m_toolMgr.

Referenced by TOOL_BASE::getEditFrame().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 109 of file tool_base.h.

110 {
111 return m_type;
112 }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:207

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37{
38 return m_toolMgr->GetView();
39}
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:285

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), SCH_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), EE_SELECTION_TOOL::GuessSelectionCandidates(), ROUTER_TOOL::handleCommonEvents(), EE_SELECTION_TOOL::highlight(), PL_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EE_SELECTION_TOOL::Reset(), EE_TOOL_BASE< T >::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), PNS::TOOL_BASE::Reset(), BOARD_EDITOR_CONTROL::Reset(), DRAWING_TOOL::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), ToggleERCErrors(), ToggleERCExclusions(), ToggleERCWarnings(), ToggleHiddenFields(), ToggleHiddenPins(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), PL_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_FIND_REPLACE_TOOL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< T >::updateItem(), UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_SELECTION_TOOL::view(), PCB_TOOL_BASE::view(), PCB_VIEWER_TOOLS::view(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Return the instance of VIEW_CONTROLS object used in the application.

It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.).

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

43{
44 return m_toolMgr->GetViewControls();
45}
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:287

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), PCB_SELECTION_TOOL::controls(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), COMMON_TOOLS::CursorControl(), EDIT_TOOL::DeleteItems(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), DRAWING_TOOL::Reset(), PCB_POINT_EDITOR::Reset(), COMMON_TOOLS::ResetLocalCoords(), ROUTER_TOOL::RouteSelected(), PCB_SELECTION_TOOL::selectCursor(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCB_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149{
150 TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151
152 goInternal( sptr, aConditions );
153}
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58

References TOOL_INTERACTIVE::goInternal().

Referenced by EDA_3D_CONTROLLER::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), EE_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), setTransitions(), SCH_FIND_REPLACE_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), COMMON_TOOLS::setTransitions(), PICKER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), PL_EDIT_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), PL_POINT_EDITOR::setTransitions(), PL_SELECTION_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), CONVERT_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), DRC_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PAD_TOOL::setTransitions(), PCB_CONTROL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), PROPERTIES_TOOL::setTransitions(), and ZONE_FILLER_TOOL::setTransitions().

◆ goInternal()

void TOOL_INTERACTIVE::goInternal ( TOOL_STATE_FUNC aState,
const TOOL_EVENT_LIST aConditions 
)
privateinherited

Definition at line 70 of file tool_interactive.cpp.

71{
72 m_toolMgr->ScheduleNextState( this, aState, aConditions );
73}
void ScheduleNextState(TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
Define a state transition.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleNextState().

Referenced by TOOL_INTERACTIVE::Go().

◆ HighlightNet()

int SCH_EDITOR_CONTROL::HighlightNet ( const TOOL_EVENT aEvent)

< Highlight net under the cursor.

Remove any net highlighting

Definition at line 771 of file sch_editor_control.cpp.

772{
774 VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
775
776 highlightNet( m_toolMgr, cursorPos );
777
778 return 0;
779}
An interface for classes handling user events controlling the view behavior such as zooming,...
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool DisableGridSnapping() const
Definition: tool_event.h:344

References TOOL_EVENT::DisableGridSnapping(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), highlightNet(), and TOOL_BASE::m_toolMgr.

Referenced by setTransitions().

◆ HighlightNetCursor()

int SCH_EDITOR_CONTROL::HighlightNetCursor ( const TOOL_EVENT aEvent)

Definition at line 1084 of file sch_editor_control.cpp.

1085{
1087
1088 // Deactivate other tools; particularly important if another PICKER is currently running
1089 Activate();
1090
1091 picker->SetCursor( KICURSOR::BULLSEYE );
1092 picker->SetSnapping( false );
1093
1094 picker->SetClickHandler(
1095 [this] ( const VECTOR2D& aPos )
1096 {
1097 return highlightNet( m_toolMgr, aPos );
1098 } );
1099
1101
1102 return 0;
1103}
static TOOL_ACTION pickerTool
Definition: actions.h:158
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
void SetSnapping(bool aSnap)
Definition: picker_tool.h:64
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:62
void Activate()
Run the tool.

References TOOL_INTERACTIVE::Activate(), BULLSEYE, TOOL_MANAGER::GetTool(), highlightNet(), TOOL_BASE::m_toolMgr, ACTIONS::pickerTool, TOOL_MANAGER::RunAction(), PICKER_TOOL_BASE::SetClickHandler(), PICKER_TOOL_BASE::SetCursor(), and PICKER_TOOL_BASE::SetSnapping().

Referenced by setTransitions().

◆ ImportFPAssignments()

int SCH_EDITOR_CONTROL::ImportFPAssignments ( const TOOL_EVENT aEvent)

Definition at line 208 of file assign_footprints.cpp.

209{
210 wxString path = wxPathOnly( m_frame->Prj().GetProjectFullName() );
211
212 wxFileDialog dlg( m_frame, _( "Load Symbol Footprint Link File" ),
213 path, wxEmptyString,
215 wxFD_OPEN | wxFD_FILE_MUST_EXIST );
216
217 if( dlg.ShowModal() == wxID_CANCEL )
218 return 0;
219
220 wxString filename = dlg.GetPath();
221
222 wxArrayString choices;
223 choices.Add( _( "Keep existing footprint field visibility" ) );
224 choices.Add( _( "Show all footprint fields" ) );
225 choices.Add( _( "Hide all footprint fields" ) );
226
227 wxSingleChoiceDialog choiceDlg( m_frame, _( "Select the footprint field visibility setting." ),
228 _( "Change Visibility" ), choices );
229
230 if( choiceDlg.ShowModal() == wxID_CANCEL )
231 return 0;
232
233 bool forceVisibility = (choiceDlg.GetSelection() != 0 );
234 bool visibilityState = (choiceDlg.GetSelection() == 1 );
235
236 if( !processCmpToFootprintLinkFile( filename, forceVisibility, visibilityState ) )
237 {
238 wxString msg = wxString::Format( _( "Failed to open symbol-footprint link file '%s'." ),
239 filename.GetData() );
240
241 DisplayError( m_frame, msg );
242 return 0;
243 }
244
245 m_frame->SyncView();
247 m_frame->OnModify();
248 return 0;
249}
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:120
bool processCmpToFootprintLinkFile(const wxString &aFullFilename, bool aForceVisibilityState, bool aVisibilityState)
Read the footprint info from each line in the stuff file by reference designator.
wxString FootprintAssignmentFileWildcard()

References _, DisplayError(), FootprintAssignmentFileWildcard(), Format(), SCH_BASE_FRAME::GetCanvas(), PROJECT::GetProjectFullName(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_EDIT_FRAME::OnModify(), path, KIWAY_HOLDER::Prj(), processCmpToFootprintLinkFile(), EDA_DRAW_PANEL_GAL::Refresh(), and SCH_BASE_FRAME::SyncView().

Referenced by setTransitions().

◆ Init()

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::Init ( )
inlineoverridevirtualinherited

Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented from TOOL_BASE.

Definition at line 66 of file ee_tool_base.h.

67 {
68 m_frame = getEditFrame<T>();
71
72 // A basic context menu. Many (but not all) tools will choose to override this.
73 auto& ctxMenu = m_menu.GetMenu();
74
75 // cancel current tool goes in main context menu at the top if present
77 ctxMenu.AddSeparator( 1 );
78
79 // Finally, add the standard zoom/grid items
81
82 return true;
83 }
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
bool IsType(FRAME_T aType) const
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:184
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32{
34}
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by EDIT_TOOL::Drag(), ROUTER_TOOL::handleLayerSwitch(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ New()

int SCH_EDITOR_CONTROL::New ( const TOOL_EVENT aEvent)

Definition at line 78 of file sch_editor_control.cpp.

79{
81 return 0;
82}

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::NewProject().

Referenced by setTransitions().

◆ NextLineMode()

◆ Open()

int SCH_EDITOR_CONTROL::Open ( const TOOL_EVENT aEvent)

Definition at line 85 of file sch_editor_control.cpp.

86{
88 return 0;
89}

References SCH_EDIT_FRAME::LoadProject(), and EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame.

Referenced by setTransitions().

◆ PageSetup()

int SCH_EDITOR_CONTROL::PageSetup ( const TOOL_EVENT aEvent)

Definition at line 172 of file sch_editor_control.cpp.

173{
174 PICKED_ITEMS_LIST undoCmd;
176 ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS );
177
178 undoCmd.PushItem( wrapper );
179 m_frame->SaveCopyInUndoList( undoCmd, UNDO_REDO::PAGESETTINGS, false, false );
180
183 dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
184
185 if( dlg.ShowModal() == wxID_OK )
186 {
187 // Update text variables
191
192 m_frame->OnModify();
193 }
194 else
195 {
197 }
198
199 return 0;
200}
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition: base_screen.h:85
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1484
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:641
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
#define MAX_PAGE_SIZE_EESCHEMA_MILS
Definition: page_info.h:41

References SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetScreen(), SCH_DRAW_PANEL::GetView(), BASE_SCREEN::m_DrawingSheetFileName, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, KIGFX::VIEW::MarkDirty(), MAX_PAGE_SIZE_EESCHEMA_MILS, SCH_EDIT_FRAME::OnModify(), PAGESETTINGS, PICKED_ITEMS_LIST::PushItem(), EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::REPAINT, SCH_EDIT_FRAME::RollbackSchematicFromUndo(), SCH_EDIT_FRAME::SaveCopyInUndoList(), DIALOG_PAGES_SETTINGS::SetWksFileName(), and KIGFX::VIEW::UpdateAllItems().

Referenced by setTransitions().

◆ Paste()

int SCH_EDITOR_CONTROL::Paste ( const TOOL_EVENT aEvent)

Definition at line 1391 of file sch_editor_control.cpp.

1392{
1393 wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1394
1395 if( textEntry )
1396 {
1397 textEntry->Paste();
1398 return 0;
1399 }
1400
1402 std::string content;
1403 VECTOR2I eventPos;
1404
1405 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1406 content = m_duplicateClipboard;
1407 else
1408 content = m_toolMgr->GetClipboardUTF8();
1409
1410 if( content.empty() )
1411 return 0;
1412
1413 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1414 eventPos = getViewControls()->GetCursorPosition( false );
1415
1416 STRING_LINE_READER reader( content, "Clipboard" );
1417 SCH_SEXPR_PLUGIN plugin;
1418
1419 SCH_SHEET tempSheet;
1420 SCH_SCREEN* tempScreen = new SCH_SCREEN( &m_frame->Schematic() );
1421
1423 int annotateStartNum = m_frame->Schematic().Settings().m_AnnotateStartNum;
1424
1425 // Screen object on heap is owned by the sheet.
1426 tempSheet.SetScreen( tempScreen );
1427
1428 try
1429 {
1430 plugin.LoadContent( reader, &tempSheet );
1431 }
1432 catch( IO_ERROR& )
1433 {
1434 // If it wasn't content, then paste as text object.
1435 SCH_TEXT* text_item = new SCH_TEXT( wxPoint( 0, 0 ), content );
1436 text_item->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT ); // Left alignment
1437 tempScreen->Append( text_item );
1438 }
1439
1440 // Save loaded screen instances to m_clipboardSheetInstances
1441 setClipboardInstances( tempScreen );
1442
1443 tempScreen->MigrateSimModels();
1444
1445 PASTE_MODE pasteMode = annotate.automatic ? PASTE_MODE::RESPECT_OPTIONS
1447
1448 if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1449 {
1450 DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
1451
1452 if( dlg.ShowModal() == wxID_CANCEL )
1453 return 0;
1454 }
1455
1456 bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
1457
1458 // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1459 // else. Pull them back out to start with.
1460 EDA_ITEMS loadedItems;
1461 bool sheetsPasted = false;
1462 SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1463 SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1464 wxFileName destFn = pasteRoot.Last()->GetFileName();
1465
1466 if( destFn.IsRelative() )
1467 destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1468
1469 // List of paths in the hierarchy that refer to the destination sheet of the paste
1470 SCH_SHEET_LIST pasteInstances = hierarchy.FindAllSheetsForScreen( pasteRoot.LastScreen() );
1471 pasteInstances.SortByPageNumbers();
1472
1473 // Build a list of screens from the current design (to avoid loading sheets that already exist)
1474 std::map<wxString, SCH_SCREEN*> loadedScreens;
1475
1476 for( const SCH_SHEET_PATH& item : hierarchy )
1477 {
1478 if( item.LastScreen() )
1479 loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
1480 }
1481
1482 // Build symbol list for reannotation of duplicates
1483 SCH_REFERENCE_LIST existingRefs;
1484 hierarchy.GetSymbols( existingRefs );
1485 existingRefs.SortByReferenceOnly();
1486
1487 // Build UUID map for fetching last-resolved-properties
1488 std::map<KIID, EDA_ITEM*> itemMap;
1489 hierarchy.FillItemMap( itemMap );
1490
1491 // Keep track of pasted sheets and symbols for the different paths to the hierarchy.
1492 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
1493 std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
1494
1495 for( SCH_ITEM* item : tempScreen->Items() )
1496 {
1497 loadedItems.push_back( item );
1498
1499 //@todo: we might want to sort the sheets by page number before adding to loadedItems
1500 if( item->Type() == SCH_SHEET_T )
1501 {
1502 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1503 wxFileName srcFn = sheet->GetFileName();
1504
1505 if( srcFn.IsRelative() )
1506 srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1507
1508 SCH_SHEET_LIST sheetHierarchy( sheet );
1509
1510 if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1511 {
1512 auto msg = wxString::Format( _( "The pasted sheet '%s'\n"
1513 "was dropped because the destination already has "
1514 "the sheet or one of its subsheets as a parent." ),
1515 sheet->GetFileName() );
1516 DisplayError( m_frame, msg );
1517 loadedItems.pop_back();
1518 }
1519 }
1520 }
1521
1522 // Remove the references from our temporary screen to prevent freeing on the DTOR
1523 tempScreen->Clear( false );
1524
1525 for( unsigned i = 0; i < loadedItems.size(); ++i )
1526 {
1527 EDA_ITEM* item = loadedItems[i];
1528 KIID_PATH clipPath( wxT( "/" ) ); // clipboard is at root
1529
1530 if( item->Type() == SCH_SYMBOL_T )
1531 {
1532 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1533
1534 // The library symbol gets set from the cached library symbols in the current
1535 // schematic not the symbol libraries. The cached library symbol may have
1536 // changed from the original library symbol which would cause the copy to
1537 // be incorrect.
1538 SCH_SCREEN* currentScreen = m_frame->GetScreen();
1539
1540 wxCHECK2( currentScreen, continue );
1541
1542 auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1543 auto end = currentScreen->GetLibSymbols().end();
1544
1545 if( it == end )
1546 {
1547 // If can't find library definition in the design, use the pasted library
1548 it = tempScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1549 end = tempScreen->GetLibSymbols().end();
1550 }
1551
1552 LIB_SYMBOL* libSymbol = nullptr;
1553
1554 if( it != end )
1555 {
1556 libSymbol = new LIB_SYMBOL( *it->second );
1557 symbol->SetLibSymbol( libSymbol );
1558 }
1559
1560 for( SCH_SHEET_PATH& instance : pasteInstances )
1561 updatePastedSymbol( symbol, tempScreen, instance, clipPath, forceKeepAnnotations );
1562
1563 // Assign a new KIID
1564 const_cast<KIID&>( item->m_Uuid ) = KIID();
1565
1566 // Make sure pins get a new UUID
1567 for( SCH_PIN* pin : symbol->GetPins() )
1568 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1569
1570 for( SCH_SHEET_PATH& instance : pasteInstances )
1571 {
1572 // Ignore symbols from a non-existant library.
1573 if( libSymbol )
1574 {
1575 SCH_REFERENCE schReference( symbol, libSymbol, instance );
1576 schReference.SetSheetNumber( instance.GetVirtualPageNumber() );
1577 pastedSymbols[instance].AddItem( schReference );
1578 }
1579 }
1580 }
1581 else if( item->Type() == SCH_SHEET_T )
1582 {
1583 SCH_SHEET* sheet = (SCH_SHEET*) item;
1584 SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1585 wxString baseName = nameField.GetText();
1586 wxString candidateName = baseName;
1587 wxString number;
1588
1589 while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1590 {
1591 number = baseName.Last() + number;
1592 baseName.RemoveLast();
1593 }
1594
1595 // Update hierarchy to include any other sheets we already added, avoiding
1596 // duplicate sheet names
1597 hierarchy = m_frame->Schematic().GetSheets();
1598
1599 //@todo: it might be better to just iterate through the sheet names
1600 // in this screen instead of the whole hierarchy.
1601 int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1602
1603 while( hierarchy.NameExists( candidateName ) )
1604 candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1605
1606 nameField.SetText( candidateName );
1607
1608 wxFileName fn = sheet->GetFileName();
1609 SCH_SCREEN* existingScreen = nullptr;
1610
1611 sheet->SetParent( pasteRoot.Last() );
1612 sheet->SetScreen( nullptr );
1613
1614 if( !fn.IsAbsolute() )
1615 {
1616 wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1617 fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS,
1618 currentSheetFileName.GetPath() );
1619 }
1620
1621 // Try to find the screen for the pasted sheet by several means
1622 if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1623 &existingScreen ) )
1624 {
1625 if( loadedScreens.count( sheet->GetFileName() ) > 0 )
1626 existingScreen = loadedScreens.at( sheet->GetFileName() );
1627 else
1628 searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1629 }
1630
1631 if( existingScreen )
1632 {
1633 sheet->SetScreen( existingScreen );
1634 }
1635 else
1636 {
1637 if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1638 m_frame->InitSheet( sheet, sheet->GetFileName() );
1639 }
1640
1641 sheetsPasted = true;
1642
1643 // Push it to the clipboard path while it still has its old KIID
1644 clipPath.push_back( sheet->m_Uuid );
1645
1646 // Assign a new KIID to the pasted sheet
1647 const_cast<KIID&>( sheet->m_Uuid ) = KIID();
1648
1649 // Make sure pins get a new UUID
1650 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1651 const_cast<KIID&>( pin->m_Uuid ) = KIID();
1652
1653 // Once we have our new KIID we can update all pasted instances. This will either
1654 // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1655 for( SCH_SHEET_PATH& instance : pasteInstances )
1656 {
1657 SCH_SHEET_PATH sheetPath = updatePastedSheet( instance, clipPath, sheet,
1658 ( forceKeepAnnotations && annotate.automatic ),
1659 &pastedSheets[instance],
1660 &pastedSymbols[instance] );
1661
1662 sheetPath.GetSymbols( pastedSymbols[instance] );
1663 }
1664 }
1665 else
1666 {
1667 SCH_ITEM* srcItem = dynamic_cast<SCH_ITEM*>( itemMap[ item->m_Uuid ] );
1668 SCH_ITEM* destItem = dynamic_cast<SCH_ITEM*>( item );
1669
1670 // Everything gets a new KIID
1671 const_cast<KIID&>( item->m_Uuid ) = KIID();
1672
1673 if( srcItem && destItem )
1674 {
1675 destItem->SetConnectivityDirty( true );
1676 destItem->SetLastResolvedState( srcItem );
1677 }
1678 }
1679
1680 // Lines need both ends selected for a move after paste so the whole line moves.
1681 if( item->Type() == SCH_LINE_T )
1682 item->SetFlags( STARTPOINT | ENDPOINT );
1683
1684 item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1686
1687 // Reset flags for subsequent move operation
1688 item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1689
1690 // Start out hidden so the pasted items aren't "ghosted" in their original location
1691 // before being moved to the current location.
1692 getView()->Hide( item, true );
1693 }
1694
1695 pasteInstances.SortByPageNumbers();
1696
1697 if( sheetsPasted )
1698 {
1699 // Update page numbers: Find next free numeric page number
1700 for( SCH_SHEET_PATH& instance : pasteInstances )
1701 {
1702 pastedSheets[instance].SortByPageNumbers();
1703
1704 for( SCH_SHEET_PATH& pastedSheet : pastedSheets[instance] )
1705 {
1706 int page = 1;
1707 wxString pageNum = wxString::Format( "%d", page );
1708
1709 while( hierarchy.PageNumberExists( pageNum ) )
1710 pageNum = wxString::Format( "%d", ++page );
1711
1712 pastedSheet.SetPageNumber( pageNum );
1713 hierarchy.push_back( pastedSheet );
1714 }
1715 }
1716
1719
1720 // Get a version with correct sheet numbers since we've pasted sheets,
1721 // we'll need this when annotating next
1722 hierarchy = m_frame->Schematic().GetSheets();
1723 }
1724
1725 std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> annotatedSymbols;
1726
1727 // Update the list of symbol instances that satisfy the annotation criteria.
1728 for( const SCH_SHEET_PATH& sheetPath : pasteInstances )
1729 {
1730 for( size_t i = 0; i < pastedSymbols[sheetPath].GetCount(); i++ )
1731 {
1732 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS
1733 || pasteMode == PASTE_MODE::RESPECT_OPTIONS
1734 || pastedSymbols[sheetPath][i].AlwaysAnnotate() )
1735 {
1736 annotatedSymbols[sheetPath].AddItem( pastedSymbols[sheetPath][i] );
1737 }
1738 }
1739 }
1740
1741 if( !annotatedSymbols.empty() )
1742 {
1743 for( SCH_SHEET_PATH& instance : pasteInstances )
1744 {
1745 annotatedSymbols[instance].SortByReferenceOnly();
1746
1747 if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
1748 annotatedSymbols[instance].ReannotateDuplicates( existingRefs );
1749 else
1750 annotatedSymbols[instance].ReannotateByOptions( (ANNOTATE_ORDER_T) annotate.sort_order,
1751 (ANNOTATE_ALGO_T) annotate.method,
1752 annotateStartNum, existingRefs,
1753 true,
1754 &hierarchy );
1755
1756 annotatedSymbols[instance].UpdateAnnotation();
1757
1758 // Update existing refs for next iteration
1759 for( size_t i = 0; i < annotatedSymbols[instance].GetCount(); i++ )
1760 existingRefs.AddItem( annotatedSymbols[instance][i] );
1761 }
1762 }
1763
1765
1766 // Now clear the previous selection, select the pasted items, and fire up the "move" tool.
1768 m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1769
1770 EE_SELECTION& selection = selTool->GetSelection();
1771
1772 if( !selection.Empty() )
1773 {
1774 if( aEvent.IsAction( &ACTIONS::duplicate ) )
1775 {
1776 int closest_dist = INT_MAX;
1777
1778 auto processPt =
1779 [&]( const VECTOR2I& pt )
1780 {
1781 int dist = ( eventPos - pt ).EuclideanNorm();
1782
1783 if( dist < closest_dist )
1784 {
1785 selection.SetReferencePoint( pt );
1786 closest_dist = dist;
1787 }
1788 };
1789
1790 // Prefer connection points (which should remain on grid)
1791 for( EDA_ITEM* item : selection.Items() )
1792 {
1793 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item );
1794 LIB_PIN* lib_pin = dynamic_cast<LIB_PIN*>( item );
1795
1796 if( sch_item && sch_item->IsConnectable() )
1797 {
1798 for( const VECTOR2I& pt : sch_item->GetConnectionPoints() )
1799 processPt( pt );
1800 }
1801 else if( lib_pin )
1802 {
1803 processPt( lib_pin->GetPosition() );
1804 }
1805 }
1806
1807 // Only process other points if we didn't find any connection points
1808 if( closest_dist == INT_MAX )
1809 {
1810 for( EDA_ITEM* item : selection.Items() )
1811 {
1812 switch( item->Type() )
1813 {
1814 case SCH_LINE_T:
1815 processPt( static_cast<SCH_LINE*>( item )->GetStartPoint() );
1816 processPt( static_cast<SCH_LINE*>( item )->GetEndPoint() );
1817 break;
1818
1819 case SCH_SHAPE_T:
1820 {
1821 SCH_SHAPE* shape = static_cast<SCH_SHAPE*>( item );
1822
1823 switch( shape->GetShape() )
1824 {
1825 case SHAPE_T::RECT:
1826 for( const VECTOR2I& pt : shape->GetRectCorners() )
1827 processPt( pt );
1828
1829 break;
1830
1831 case SHAPE_T::CIRCLE:
1832 processPt( shape->GetCenter() );
1833 break;
1834
1835 case SHAPE_T::POLY:
1836 for( int ii = 0; ii < shape->GetPolyShape().TotalVertices(); ++ii )
1837 processPt( shape->GetPolyShape().CVertex( ii ) );
1838
1839 break;
1840
1841 default:
1842 processPt( shape->GetStart() );
1843 processPt( shape->GetEnd() );
1844 break;
1845 }
1846
1847 break;
1848 }
1849
1850 default:
1851 processPt( item->GetPosition() );
1852 break;
1853 }
1854 }
1855 }
1856
1858 }
1859 else
1860 {
1861 SCH_ITEM* item = static_cast<SCH_ITEM*>( selection.GetTopLeftItem() );
1862
1863 selection.SetReferencePoint( item->GetPosition() );
1864 }
1865
1867 }
1868
1869 return 0;
1870}
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION duplicate
Definition: actions.h:72
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:247
SHAPE_T GetShape() const
Definition: eda_shape.h:113
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1035
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
PANEL_ANNOTATE m_AnnotatePanel
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
static TOOL_ACTION move
Definition: ee_actions.h:120
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1550
Definition: kiid.h:48
VECTOR2I GetPosition() const override
Definition: lib_pin.h:222
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:178
SCH_SHEET & Root() const
Definition: schematic.h:91
void setClipboardInstances(const SCH_SCREEN *aPastedScreen)
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
void updatePastedSymbol(SCH_SYMBOL *aSymbol, SCH_SCREEN *aPasteScreen, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
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)
bool LoadSheetFromFile(SCH_SHEET *aSheet, SCH_SHEET_PATH *aHierarchy, const wxString &aFileName)
Load a the KiCad schematic file aFileName into the sheet aSheet.
Definition: sheet.cpp:105
void AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:97
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
virtual bool IsConnectable() const
Definition: sch_item.h:349
virtual void SetLastResolvedState(const SCH_ITEM *aItem)
Definition: sch_item.h:417
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:415
virtual std::vector< VECTOR2I > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
Definition: sch_item.h:364
void SortByReferenceOnly()
Sort the list of references by reference.
void AddItem(const SCH_REFERENCE &aItem)
A helper to define a symbol's reference designator in a schematic.
std::map< wxString, LIB_SYMBOL * > & GetLibSymbols()
Fetch a list of unique LIB_SYMBOL object pointers required to properly render each SCH_SYMBOL in this...
Definition: sch_screen.h:478
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:227
const wxString & GetFileName() const
Definition: sch_screen.h:144
void MigrateSimModels()
Migrate any symbols having V6 simulation models to their V7 equivalents.
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:145
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
VECTOR2I GetCenter() const
Definition: sch_shape.h:80
void SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
SCH_SHEET_LIST FindAllSheetsForScreen(const SCH_SCREEN *aScreen) const
Return a SCH_SHEET_LIST with a copy of all the SCH_SHEET_PATH using a particular screen.
void GetSymbols(SCH_REFERENCE_LIST &aReferences, bool aIncludePowerSymbols=true, bool aForceIncludeOrphanSymbols=false) const
Adds SCH_REFERENCE object to aReferences for each symbol in the sheet.
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:93
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:719
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:162
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:175
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:290
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:299
virtual void SetTextSpinStyle(TEXT_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:188
void SetIsHover(bool aIsHover)
Definition: selection.h:78
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:213
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:260
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:241
std::string GetClipboardUTF8() const
Return the information currently stored in the system clipboard.
@ REMOVE_ANNOTATIONS
@ UNIQUE_ANNOTATIONS
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:524
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_NEW
New item, just created.
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_MOVING
Item being moved.
#define STARTPOINT
When a line is selected, these flags indicate which.
ANNOTATE_ORDER_T
Schematic annotation order options.
ANNOTATE_ALGO_T
Schematic annotation type options.
@ SHEETNAME
Definition: sch_sheet.h:45
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129
@ SCH_LINE_T
Definition: typeinfo.h:146
@ SCH_SHAPE_T
Definition: typeinfo.h:147

References _, SCH_REFERENCE_LIST::AddItem(), EE_ACTIONS::addItemsToSel, SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), annotate, SCH_SCREEN::Append(), CIRCLE, SCH_SCREEN::Clear(), EE_ACTIONS::clearSelection, SHAPE_POLY_SET::CVertex(), DisplayError(), ACTIONS::duplicate, SCH_BASE_FRAME::eeconfig(), SELECTION::Empty(), ENDPOINT, EuclideanNorm(), SCH_SHEET_LIST::FillItemMap(), SCH_SHEET_LIST::FindAllSheetsForScreen(), FN_NORMALIZE_FLAGS, Format(), SCH_SHAPE::GetCenter(), TOOL_MANAGER::GetClipboardUTF8(), SCH_ITEM::GetConnectionPoints(), SCH_EDIT_FRAME::GetCurrentSheet(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), EDA_SHAPE::GetEnd(), SCH_SHEET::GetFields(), SCH_SCREEN::GetFileName(), SCH_SHEET::GetFileName(), SCH_SCREEN::GetLibSymbols(), SCH_SHEET::GetPins(), SCH_SYMBOL::GetPins(), EDA_SHAPE::GetPolyShape(), EDA_ITEM::GetPosition(), LIB_PIN::GetPosition(), PROJECT::GetProjectPath(), EDA_SHAPE::GetRectCorners(), SCH_SYMBOL::GetSchSymbolLibraryName(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), EDA_SHAPE::GetShape(), SCHEMATIC::GetSheets(), EDA_SHAPE::GetStart(), SCH_SHEET_PATH::GetSymbols(), SCH_SHEET_LIST::GetSymbols(), EDA_TEXT::GetText(), TOOL_MANAGER::GetTool(), EE_SELECTION::GetTopLeftItem(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), KIGFX::VIEW::Hide(), SCH_EDIT_FRAME::InitSheet(), IS_MOVING, IS_NEW, IS_PASTED, TOOL_EVENT::IsAction(), SCH_ITEM::IsConnectable(), SCH_SCREEN::Items(), SELECTION::Items(), SCH_SHEET_PATH::Last(), SCH_SHEET_PATH::LastScreen(), SCH_SEXPR_PLUGIN::LoadContent(), SCH_EDIT_FRAME::LoadSheetFromFile(), EESCHEMA_SETTINGS::m_AnnotatePanel, SCHEMATIC_SETTINGS::m_AnnotateStartNum, m_duplicateClipboard, m_duplicateIsHoverSelection, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, EDA_ITEM::m_Uuid, SCH_SCREEN::MigrateSimModels(), EE_ACTIONS::move, SCH_SHEET_LIST::NameExists(), SCH_SHEET_LIST::PageNumberExists(), ACTIONS::pasteSpecial, pin, POLY, KIWAY_HOLDER::Prj(), RECT, REMOVE_ANNOTATIONS, RESPECT_OPTIONS, TEXT_SPIN_STYLE::RIGHT, SCHEMATIC::Root(), TOOL_MANAGER::RunAction(), SCH_LINE_T, SCH_SHAPE_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), SCH_SHEET::SearchHierarchy(), searchSupplementaryClipboard(), setClipboardInstances(), SCH_ITEM::SetConnectivityDirty(), EDA_ITEM::SetFlags(), SELECTION::SetIsHover(), SCH_ITEM::SetLastResolvedState(), SCH_SYMBOL::SetLibSymbol(), EDA_ITEM::SetParent(), SELECTION::SetReferencePoint(), SCH_SHEET::SetScreen(), SCH_REFERENCE::SetSheetNumber(), SCH_EDIT_FRAME::SetSheetNumberAndCount(), EDA_TEXT::SetText(), SCH_TEXT::SetTextSpinStyle(), SCHEMATIC::Settings(), SHEETNAME, SCH_SHEET_LIST::SortByPageNumbers(), SCH_REFERENCE_LIST::SortByReferenceOnly(), STARTPOINT, SCH_SHEET_LIST::TestForRecursion(), EDA_ITEM::Type(), UNIQUE_ANNOTATIONS, SCH_SHEET_PATH::UpdateAllScreenReferences(), SCH_EDIT_FRAME::UpdateHierarchyNavigator(), updatePastedSheet(), and updatePastedSymbol().

Referenced by Duplicate(), and setTransitions().

◆ Plot()

int SCH_EDITOR_CONTROL::Plot ( const TOOL_EVENT aEvent)

Definition at line 290 of file sch_editor_control.cpp.

291{
293
294 dlg.ShowModal();
295
296 // save project config if the prj config has changed:
297 if( dlg.PrjConfigChanged() )
299
300 return 0;
301}
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, DIALOG_PLOT_SCHEMATIC::PrjConfigChanged(), and SCH_EDIT_FRAME::SaveProjectSettings().

Referenced by setTransitions().

◆ Print()

int SCH_EDITOR_CONTROL::Print ( const TOOL_EVENT aEvent)

Definition at line 277 of file sch_editor_control.cpp.

278{
280
281 wxFileName fn = m_frame->Prj().AbsolutePath( m_frame->Schematic().RootScreen()->GetFileName() );
282
283 if( fn.GetName() != NAMELESS_PROJECT )
285
286 return 0;
287}
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:305
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:119
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:42

References PROJECT::AbsolutePath(), SCH_SCREEN::GetFileName(), InvokeDialogPrintUsingPrinter(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, NAMELESS_PROJECT, KIWAY_HOLDER::Prj(), SCHEMATIC::RootScreen(), SCH_EDIT_FRAME::SaveProjectSettings(), and SCH_EDIT_FRAME::Schematic().

Referenced by setTransitions().

◆ processCmpToFootprintLinkFile()

bool SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile ( const wxString &  aFullFilename,
bool  aForceVisibilityState,
bool  aVisibilityState 
)
private

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

Parameters
aFullFilename= the full filename to read
aForceVisibilityState= Set to true to change the footprint field visibility state to aVisibilityState. False retains the current footprint field visibility state.
aVisibilityStateTrue to show the footprint field or false to hide the footprint field if aForceVisibilityState is true.
Returns
bool = true if success. Set up handlers for various events.

Definition at line 126 of file assign_footprints.cpp.

129{
130 // Build a flat list of symbols in schematic:
131 SCH_REFERENCE_LIST referencesList;
132 SCH_SHEET_LIST sheetList = m_frame->Schematic().GetSheets();
133
134 sheetList.GetSymbols( referencesList, false );
135
136 FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) );
137
138 if( cmpFile == nullptr )
139 return false;
140
141 // cmpFileReader dtor will close cmpFile
142 FILE_LINE_READER cmpFileReader( cmpFile, aFullFilename );
143
144 // Now, for each symbol found in file,
145 // replace footprint field value by the new value:
146 wxString reference;
147 wxString footprint;
148 wxString buffer;
149 wxString value;
150
151 while( cmpFileReader.ReadLine() )
152 {
153 buffer = FROM_UTF8( cmpFileReader.Line() );
154
155 if( !buffer.StartsWith( wxT( "BeginCmp" ) ) )
156 continue;
157
158 // Begin symbol description.
159 reference.Empty();
160 footprint.Empty();
161
162 while( cmpFileReader.ReadLine() )
163 {
164 buffer = FROM_UTF8( cmpFileReader.Line() );
165
166 if( buffer.StartsWith( wxT( "EndCmp" ) ) )
167 break;
168
169 // store string value, stored between '=' and ';' delimiters.
170 value = buffer.AfterFirst( '=' );
171 value = value.BeforeLast( ';' );
172 value.Trim(true);
173 value.Trim(false);
174
175 if( buffer.StartsWith( wxT( "Reference" ) ) )
176 reference = value;
177 else if( buffer.StartsWith( wxT( "IdModule" ) ) )
178 footprint = value;
179 }
180
181 // A block is read: initialize the footprint field of the corresponding symbol
182 // if the footprint name is not empty
183 if( reference.IsEmpty() )
184 continue;
185
186 // Search the symbol in the flat list
187 for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ )
188 {
189 if( reference == referencesList[ii].GetRef() )
190 {
191 // We have found a candidate.
192 // Note: it can be not unique (multiple units per part)
193 // So we *do not* stop the search here
194 SCH_SYMBOL* symbol = referencesList[ ii ].GetSymbol();
195
196 symbol->SetFootprintFieldText( footprint );
197
198 if( aForceVisibilityState )
199 symbol->GetField( FOOTPRINT_FIELD )->SetVisible( aVisibilityState );
200 }
201 }
202 }
203
204 return true;
205}
A LINE_READER that reads from an open file.
Definition: richio.h:173

References FOOTPRINT_FIELD, FROM_UTF8(), SCH_REFERENCE_LIST::GetCount(), SCH_SYMBOL::GetField(), SCHEMATIC::GetSheets(), SCH_SHEET_LIST::GetSymbols(), LINE_READER::Line(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, FILE_LINE_READER::ReadLine(), SCH_EDIT_FRAME::Schematic(), SCH_SYMBOL::SetFootprintFieldText(), and EDA_TEXT::SetVisible().

Referenced by ImportFPAssignments().

◆ Quit()

int SCH_EDITOR_CONTROL::Quit ( const TOOL_EVENT aEvent)

Definition at line 304 of file sch_editor_control.cpp.

305{
306 m_frame->Close( false );
307 return 0;
308}

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame.

Referenced by setTransitions().

◆ Redo()

int SCH_EDITOR_CONTROL::Redo ( const TOOL_EVENT aEvent)

Clipboard support.

Definition at line 1149 of file sch_editor_control.cpp.

1150{
1151 if( m_frame->GetRedoCommandCount() == 0 )
1152 return 0;
1153
1154 // Inform tools that undo command was issued
1156
1157 /* Get the old list */
1159
1160 /* Redo the command: */
1162
1163 /* Put the old list in UndoList */
1166
1170
1171 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1172
1173 m_frame->SyncView();
1175 m_frame->OnModify();
1176
1177 return 0;
1178}
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
virtual int GetRedoCommandCount() const
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
void ReversePickersListOrder()
Reverse the order of pickers stored in this list.
void OnPageSettingsChange() override
Called when modifying the page settings.
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Restore an undo or redo command to put data pointed by aList in the previous state.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:45
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:101
@ TC_MESSAGE
Definition: tool_event.h:53

References AS_GLOBAL, SCH_BASE_FRAME::GetCanvas(), EDA_BASE_FRAME::GetRedoCommandCount(), TOOL_MANAGER::GetTool(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OnModify(), SCH_EDIT_FRAME::OnPageSettingsChange(), EDA_BASE_FRAME::PopCommandFromRedoList(), TOOL_MANAGER::ProcessEvent(), EDA_BASE_FRAME::PushCommandToUndoList(), SCH_EDIT_FRAME::PutDataInPreviousState(), EDA_DRAW_PANEL_GAL::Refresh(), PICKED_ITEMS_LIST::ReversePickersListOrder(), SCH_EDIT_FRAME::SetSheetNumberAndCount(), SCH_BASE_FRAME::SyncView(), TA_UNDO_REDO_PRE, TC_MESSAGE, and SCH_EDIT_FRAME::TestDanglingEnds().

Referenced by setTransitions().

◆ RemapSymbols()

int SCH_EDITOR_CONTROL::RemapSymbols ( const TOOL_EVENT aEvent)

Definition at line 265 of file sch_editor_control.cpp.

266{
267 DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
268
269 dlgRemap.ShowQuasiModal();
270
271 m_frame->GetCanvas()->Refresh( true );
272
273 return 0;
274}

References SCH_BASE_FRAME::GetCanvas(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EDA_DRAW_PANEL_GAL::Refresh(), and DIALOG_SHIM::ShowQuasiModal().

Referenced by setTransitions().

◆ RepairSchematic()

int SCH_EDITOR_CONTROL::RepairSchematic ( const TOOL_EVENT aEvent)

Definition at line 2116 of file sch_editor_control.cpp.

2117{
2118 int errors = 0;
2119 wxString details;
2120 bool quiet = aEvent.Parameter<bool>();
2121
2122 // Repair duplicate IDs.
2123 std::map<KIID, EDA_ITEM*> ids;
2124 int duplicates = 0;
2125
2126 auto processItem =
2127 [&]( EDA_ITEM* aItem )
2128 {
2129 auto it = ids.find( aItem->m_Uuid );
2130
2131 if( it != ids.end() && it->second != aItem )
2132 {
2133 duplicates++;
2134 const_cast<KIID&>( aItem->m_Uuid ) = KIID();
2135 }
2136
2137 ids[ aItem->m_Uuid ] = aItem;
2138 };
2139
2140 // Symbol IDs are the most important, so give them the first crack at "claiming" a
2141 // particular KIID.
2142
2143 for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
2144 {
2145 SCH_SCREEN* screen = sheet.LastScreen();
2146
2147 for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
2148 {
2149 processItem( item );
2150
2151 for( SCH_PIN* pin : static_cast<SCH_SYMBOL*>( item )->GetPins( &sheet ) )
2152 processItem( pin );
2153 }
2154 }
2155
2156 for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
2157 {
2158 SCH_SCREEN* screen = sheet.LastScreen();
2159
2160 for( SCH_ITEM* item : screen->Items() )
2161 {
2162 processItem( item );
2163
2164 item->RunOnChildren(
2165 [&]( SCH_ITEM* aChild )
2166 {
2167 processItem( item );
2168 } );
2169 }
2170 }
2171
2172 /*******************************
2173 * Your test here
2174 */
2175
2176 /*******************************
2177 * Inform the user
2178 */
2179
2180 if( duplicates )
2181 {
2182 errors += duplicates;
2183 details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
2184 }
2185
2186 if( errors )
2187 {
2188 m_frame->OnModify();
2189
2190 wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
2191
2192 if( !quiet )
2193 DisplayInfoMessage( m_frame, msg, details );
2194 }
2195 else if( !quiet )
2196 {
2197 DisplayInfoMessage( m_frame, _( "No errors found." ) );
2198 }
2199
2200 return 0;
2201}
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:352

References _, DisplayInfoMessage(), Format(), SCHEMATIC::GetSheets(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_RTREE::OfType(), SCH_EDIT_FRAME::OnModify(), TOOL_EVENT::Parameter(), pin, SCH_SYMBOL_T, and SCH_EDIT_FRAME::Schematic().

Referenced by setTransitions().

◆ RescueLegacyProject()

bool SCH_EDITOR_CONTROL::RescueLegacyProject ( bool  aRunningOnDemand)

Definition at line 216 of file sch_editor_control.cpp.

217{
220
221 return rescueProject( rescuer, aRunningOnDemand );
222}
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)

References EDA_DRAW_PANEL_GAL::GetBackend(), SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, KIWAY_HOLDER::Prj(), rescueProject(), and SCH_EDIT_FRAME::Schematic().

Referenced by RescueSymbols().

◆ rescueProject()

bool SCH_EDITOR_CONTROL::rescueProject ( RESCUER aRescuer,
bool  aRunningOnDemand 
)
private

Definition at line 235 of file sch_editor_control.cpp.

236{
237 if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
238 return false;
239
240 if( aRescuer.GetCandidateCount() )
241 {
242 KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
243
244 if( viewer )
245 static_cast<SYMBOL_VIEWER_FRAME*>( viewer )->ReCreateLibList();
246
247 if( aRunningOnDemand )
248 {
249 SCH_SCREENS schematic( m_frame->Schematic().Root() );
250
251 schematic.UpdateSymbolLinks();
253 }
254
256 m_frame->SyncView();
258 m_frame->OnModify();
259 }
260
261 return true;
262}
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:66
static bool RescueProject(wxWindow *aParent, RESCUER &aRescuer, bool aRunningOnDemand)
size_t GetCandidateCount()
Return the number of rescue candidates found.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:638
Symbol library viewer main window.
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ GLOBAL_CLEANUP

References EDA_BASE_FRAME::ClearUndoRedoList(), FRAME_SCH_VIEWER, RESCUER::GetCandidateCount(), SCH_BASE_FRAME::GetCanvas(), GLOBAL_CLEANUP, KIWAY_HOLDER::Kiway(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_EDIT_FRAME::OnModify(), KIWAY::Player(), SCH_EDIT_FRAME::RecalculateConnections(), EDA_DRAW_PANEL_GAL::Refresh(), RESCUER::RescueProject(), SCHEMATIC::Root(), SCH_EDIT_FRAME::Schematic(), SCH_BASE_FRAME::SyncView(), and SCH_SCREENS::UpdateSymbolLinks().

Referenced by RescueLegacyProject(), and RescueSymbolLibTableProject().

◆ RescueSymbolLibTableProject()

bool SCH_EDITOR_CONTROL::RescueSymbolLibTableProject ( bool  aRunningOnDemand)

◆ RescueSymbols()

int SCH_EDITOR_CONTROL::RescueSymbols ( const TOOL_EVENT aEvent)

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.

Definition at line 203 of file sch_editor_control.cpp.

204{
205 SCH_SCREENS schematic( m_frame->Schematic().Root() );
206
207 if( schematic.HasNoFullyDefinedLibIds() )
208 RescueLegacyProject( true );
209 else
211
212 return 0;
213}
bool RescueLegacyProject(bool aRunningOnDemand)
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
Notifies pcbnew about the selected item.

References SCH_SCREENS::HasNoFullyDefinedLibIds(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, RescueLegacyProject(), RescueSymbolLibTableProject(), SCHEMATIC::Root(), and SCH_EDIT_FRAME::Schematic().

Referenced by setTransitions().

◆ Reset()

void EE_TOOL_BASE< SCH_EDIT_FRAME >::Reset ( RESET_REASON  aReason)
inlineoverridevirtualinherited

Bring the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 86 of file ee_tool_base.h.

87 {
88 if( aReason == MODEL_RELOAD )
89 {
90 // Init variables used by every drawing tool
91 m_frame = getEditFrame<T>();
92 m_isSymbolEditor = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame ) != nullptr;
93 }
94
95 m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
96 }

◆ resetTransitions()

void TOOL_INTERACTIVE::resetTransitions ( )
privateinherited

Clear the current transition map and restores the default one created by setTransitions().

Definition at line 63 of file tool_interactive.cpp.

64{
67}
virtual void setTransitions()=0
This method is meant to be overridden in order to specify handlers for events.
void ClearTransitions(TOOL_BASE *aTool)
Clear the state transition map for a tool.

References TOOL_MANAGER::ClearTransitions(), TOOL_BASE::m_toolMgr, and TOOL_INTERACTIVE::setTransitions().

◆ Revert()

int SCH_EDITOR_CONTROL::Revert ( const TOOL_EVENT aEvent)

Definition at line 125 of file sch_editor_control.cpp.

126{
127 SCHEMATIC& schematic = m_frame->Schematic();
128 SCH_SHEET& root = schematic.Root();
129
130 if( m_frame->GetCurrentSheet().Last() != &root )
131 {
134
135 // Store the current zoom level into the current screen before switching
137
138 SCH_SHEET_PATH rootSheetPath;
139 rootSheetPath.push_back( &root );
140 m_frame->SetCurrentSheet( rootSheetPath );
142
143 wxSafeYield();
144 }
145
146 wxString msg;
147 msg.Printf( _( "Revert '%s' (and all sub-sheets) to last version saved?" ),
148 schematic.GetFileName() );
149
150 if( !IsOK( m_frame, msg ) )
151 return false;
152
153 SCH_SCREENS screenList( schematic.Root() );
154
155 for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
156 screen->SetContentModified( false ); // do not prompt the user for changes
157
159 m_frame->OpenProjectFiles( std::vector<wxString>( 1, schematic.GetFileName() ) );
160
161 return 0;
162}
void ReleaseFile()
Release the current file marked in use.
double GetScale() const
Definition: view.h:269
wxString GetFileName() const override
Helper to retrieve the filename from the root sheet screen.
Definition: schematic.cpp:172
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Open a project or set of files given by aFileList.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:562
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.

References _, ACTIONS::cancelInteractive, EE_ACTIONS::clearSelection, SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), SCHEMATIC::GetFileName(), SCH_SCREENS::GetFirst(), SCH_SCREENS::GetNext(), KIGFX::VIEW::GetScale(), SCH_EDIT_FRAME::GetScreen(), SCH_DRAW_PANEL::GetView(), IsOK(), SCH_SHEET_PATH::Last(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_SCREEN::m_LastZoomLevel, TOOL_BASE::m_toolMgr, SCH_EDIT_FRAME::OpenProjectFiles(), SCH_SHEET_PATH::push_back(), EDA_DRAW_FRAME::ReleaseFile(), SCHEMATIC::Root(), TOOL_MANAGER::RunAction(), SCH_EDIT_FRAME::Schematic(), and SCH_EDIT_FRAME::SetCurrentSheet().

Referenced by setTransitions().

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88{
89 m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90}
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

◆ Save()

int SCH_EDITOR_CONTROL::Save ( const TOOL_EVENT aEvent)

Definition at line 92 of file sch_editor_control.cpp.

93{
95 return 0;
96}
bool SaveProject(bool aSaveAs=false)
Save the currently-open schematic (including its hierarchy) and associated project.

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::SaveProject().

Referenced by setTransitions().

◆ SaveAs()

int SCH_EDITOR_CONTROL::SaveAs ( const TOOL_EVENT aEvent)

Definition at line 99 of file sch_editor_control.cpp.

100{
101 m_frame->SaveProject( true );
102 return 0;
103}

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::SaveProject().

Referenced by setTransitions().

◆ saveCopyInUndoList()

void EE_TOOL_BASE< SCH_EDIT_FRAME >::saveCopyInUndoList ( EDA_ITEM aItem,
UNDO_REDO  aType,
bool  aAppend = false,
bool  aDirtyConnectivity = true 
)
inlineprotectedinherited

Definition at line 134 of file ee_tool_base.h.

136 {
137 wxASSERT( aItem );
138
139 KICAD_T itemType = aItem->Type();
140 bool selected = aItem->IsSelected();
141
142 // IS_SELECTED flag should not be set on undo items which were added for
143 // a drag operation.
144 if( selected && aItem->HasFlag( SELECTED_BY_DRAG ) )
145 aItem->ClearSelected();
146
147 if( m_isSymbolEditor )
148 {
149 SYMBOL_EDIT_FRAME* editFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
150 wxCHECK_RET( editFrame, wxT( "editFrame is null" ) );
151
152 editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
153 }
154 else
155 {
156 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
157 wxASSERT( editFrame );
158
159 if( editFrame )
160 {
161 if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
162 {
163 editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
164 static_cast<SCH_ITEM*>( aItem->GetParent() ),
165 UNDO_REDO::CHANGED, aAppend,
166 aDirtyConnectivity );
167 }
168 else
169 {
170 editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
171 static_cast<SCH_ITEM*>( aItem ), aType,
172 aAppend, aDirtyConnectivity );
173 }
174 }
175 }
176
177 if( selected && aItem->HasFlag( SELECTED_BY_DRAG ) )
178 aItem->SetSelected();
179 }
void ClearSelected()
Definition: eda_item.h:118
bool IsSelected() const
Definition: eda_item.h:106
void SetSelected()
Definition: eda_item.h:115
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:143
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
Schematic editor (Eeschema) main window.
void SaveCopyInUndoList(EDA_ITEM *aItem, UNDO_REDO aUndoType=UNDO_REDO::LIBEDIT, bool aAppend=false)
Create a copy of the current symbol, and save it in the undo list.
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157
@ SCH_PIN_T
Definition: typeinfo.h:159

◆ SaveCurrSheetCopyAs()

int SCH_EDITOR_CONTROL::SaveCurrSheetCopyAs ( const TOOL_EVENT aEvent)

Saves the currently-open schematic sheet to an other name.

Definition at line 106 of file sch_editor_control.cpp.

107{
108 SCH_SHEET* curr_sheet = m_frame->GetCurrentSheet().Last();
109 wxFileName curr_fn = curr_sheet->GetFileName();
110 wxFileDialog dlg( m_frame, _( "Schematic Files" ), curr_fn.GetPath(),
111 curr_fn.GetFullName(), KiCadSchematicFileWildcard(),
112 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
113
114 if( dlg.ShowModal() == wxID_CANCEL )
115 return false;
116
117 wxFileName newFileName = dlg.GetPath();
118 newFileName.SetExt( KiCadSchematicFileExtension );
119
120 m_frame->saveSchematicFile( curr_sheet, newFileName.GetFullPath() );
121 return 0;
122}
bool saveSchematicFile(SCH_SHEET *aSheet, const wxString &aSavePath)
Save aSheet to a schematic file.
const std::string KiCadSchematicFileExtension
wxString KiCadSchematicFileWildcard()

References _, SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SHEET::GetFileName(), KiCadSchematicFileExtension, KiCadSchematicFileWildcard(), SCH_SHEET_PATH::Last(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::saveSchematicFile().

Referenced by setTransitions().

◆ searchSupplementaryClipboard()

bool SCH_EDITOR_CONTROL::searchSupplementaryClipboard ( const wxString &  aSheetFilename,
SCH_SCREEN **  aScreen 
)
private

Definition at line 1231 of file sch_editor_control.cpp.

1233{
1234 if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1235 {
1236 *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1237 return true;
1238 }
1239
1240 return false;
1241}

References m_supplementaryClipboard.

Referenced by Paste().

◆ setClipboardInstances()

void SCH_EDITOR_CONTROL::setClipboardInstances ( const SCH_SCREEN aPastedScreen)
private

Definition at line 1377 of file sch_editor_control.cpp.

1378{
1380
1381 for( const SCH_SHEET_INSTANCE& sheet : aPastedScreen->GetSheetInstances() )
1382 m_clipboardSheetInstances[sheet.m_Path] = sheet;
1383
1385
1386 for( const SCH_SYMBOL_INSTANCE& symbol : aPastedScreen->GetSymbolInstances() )
1387 m_clipboardSymbolInstances[symbol.m_Path] = symbol;
1388}
std::map< KIID_PATH, SCH_SHEET_INSTANCE > m_clipboardSheetInstances
std::map< KIID_PATH, SCH_SYMBOL_INSTANCE > m_clipboardSymbolInstances
const std::vector< SCH_SYMBOL_INSTANCE > & GetSymbolInstances() const
Definition: sch_screen.h:513
const std::vector< SCH_SHEET_INSTANCE > & GetSheetInstances() const
Definition: sch_screen.h:518
A simple container for sheet instance information.
A simple container for schematic symbol instance information.

References SCH_SCREEN::GetSheetInstances(), SCH_SCREEN::GetSymbolInstances(), m_clipboardSheetInstances, and m_clipboardSymbolInstances.

Referenced by Paste().

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Assign a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 76 of file tool_interactive.cpp.

77{
78 if( aMenu )
79 aMenu->SetTool( this );
80 else
81 aTrigger = CMENU_OFF;
82
83 m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
84}
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Set behavior of the tool's context popup menu.
@ CMENU_OFF
Definition: tool_event.h:149

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and ACTION_MENU::SetTool().

Referenced by SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void SCH_EDITOR_CONTROL::setTransitions ( )
overrideprivatevirtual

This method is meant to be overridden in order to specify handlers for events.

It is called every time tool is reset or finished.

Implements TOOL_INTERACTIVE.

Definition at line 2204 of file sch_editor_control.cpp.

2205{
2206 Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
2207 Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
2208 Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
2215 Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
2216 Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
2217
2220
2226
2227#ifdef KICAD_SPICE
2228 Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
2229 Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
2230#endif /* KICAD_SPICE */
2231
2237
2239
2240 Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2241 Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2242 Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
2243 Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
2247
2261
2263
2274
2276
2278
2281}
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:167
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION revert
Definition: actions.h:55
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION plot
Definition: actions.h:58
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION pageSettings
Definition: actions.h:56
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION quit
Definition: actions.h:59
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION redo
Definition: actions.h:66
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:168
static TOOL_ACTION print
Definition: actions.h:57
static TOOL_ACTION doNew
Definition: actions.h:47
static TOOL_ACTION cut
Definition: actions.h:67
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:173
static TOOL_ACTION repairSchematic
Definition: ee_actions.h:232
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:167
static TOOL_ACTION toggleAnnotateAuto
Definition: ee_actions.h:241
static TOOL_ACTION lineMode90
Definition: ee_actions.h:236
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:213
static TOOL_ACTION highlightNet
Definition: ee_actions.h:249
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:250
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:161
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:231
static TOOL_ACTION toggleERCWarnings
Definition: ee_actions.h:215
static TOOL_ACTION simTune
Definition: ee_actions.h:246
static TOOL_ACTION toggleERCExclusions
Definition: ee_actions.h:217
static TOOL_ACTION lineModeNext
Definition: ee_actions.h:238
static TOOL_ACTION lineModeFree
Definition: ee_actions.h:235
static TOOL_ACTION toggleERCErrors
Definition: ee_actions.h:216
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:252
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:251
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:174
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:160
static TOOL_ACTION selectOnPCB
Definition: ee_actions.h:220
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:166
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:214
static TOOL_ACTION simProbe
Definition: ee_actions.h:245
static TOOL_ACTION exportSymbolsToLibrary
Definition: ee_actions.h:177
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:228
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:152
static TOOL_ACTION annotate
Definition: ee_actions.h:151
static TOOL_ACTION showHierarchy
Definition: ee_actions.h:205
static TOOL_ACTION lineMode45
Definition: ee_actions.h:237
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:153
static TOOL_ACTION saveCurrSheetCopyAs
Definition: ee_actions.h:42
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:172
static TOOL_ACTION generateBOM
Definition: ee_actions.h:175
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:162
static const TOOL_EVENT ClearedEvent
Definition: actions.h:208
static const TOOL_EVENT SelectedEvent
Definition: actions.h:206
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:213
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:205
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
int PageSetup(const TOOL_EVENT &aEvent)
int SaveAs(const TOOL_EVENT &aEvent)
int Annotate(const TOOL_EVENT &aEvent)
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNet(const TOOL_EVENT &aEvent)
< Highlight net under the cursor.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
int EditSymbolFields(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
int ImportFPAssignments(const TOOL_EVENT &aEvent)
int ChangeLineMode(const TOOL_EVENT &aEvent)
int ExportSymbolsToLibrary(const TOOL_EVENT &aEvent)
int SaveCurrSheetCopyAs(const TOOL_EVENT &aEvent)
Saves the currently-open schematic sheet to an other name.
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
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.
int AssignNetclass(const TOOL_EVENT &aEvent)
int ExportNetlist(const TOOL_EVENT &aEvent)
int Open(const TOOL_EVENT &aEvent)
int Copy(const TOOL_EVENT &aEvent)
int ToggleERCWarnings(const TOOL_EVENT &aEvent)
int NextLineMode(const TOOL_EVENT &aEvent)
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)
int EditWithSymbolEditor(const TOOL_EVENT &aEvent)
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
int ExplicitCrossProbeToPcb(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)
int ShowCvpcb(const TOOL_EVENT &aEvent)
int RepairSchematic(const TOOL_EVENT &aEvent)
int Cut(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
int Undo(const TOOL_EVENT &aEvent)
int ToggleERCExclusions(const TOOL_EVENT &aEvent)
int Plot(const TOOL_EVENT &aEvent)
int Print(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int GenerateBOM(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).

References EE_ACTIONS::annotate, Annotate(), EE_ACTIONS::assignFootprints, EE_ACTIONS::assignNetclass, AssignNetclass(), ChangeLineMode(), EVENTS::ClearedEvent, EE_ACTIONS::clearHighlight, ClearHighlight(), Copy(), ACTIONS::copy, CrossProbeToPcb(), Cut(), ACTIONS::cut, ACTIONS::doNew, EE_ACTIONS::drawSheetOnClipboard, DrawSheetOnClipboard(), Duplicate(), ACTIONS::duplicate, EE_ACTIONS::editLibSymbolWithLibEdit, EE_ACTIONS::editSymbolFields, EditSymbolFields(), EE_ACTIONS::editSymbolLibraryLinks, EditSymbolLibraryLinks(), EE_ACTIONS::editWithLibEdit, EditWithSymbolEditor(), ExplicitCrossProbeToPcb(), EE_ACTIONS::exportNetlist, ExportNetlist(), EE_ACTIONS::exportSymbolsToLibrary, ExportSymbolsToLibrary(), EE_ACTIONS::exportSymbolsToNewLibrary, EE_ACTIONS::generateBOM, GenerateBOM(), TOOL_INTERACTIVE::Go(), EE_ACTIONS::highlightNet, HighlightNet(), HighlightNetCursor(), EE_ACTIONS::highlightNetTool, EE_ACTIONS::importFPAssignments, ImportFPAssignments(), EE_ACTIONS::lineMode45, EE_ACTIONS::lineMode90, EE_ACTIONS::lineModeFree, EE_ACTIONS::lineModeNext, New(), NextLineMode(), Open(), ACTIONS::open, ACTIONS::pageSettings, PageSetup(), Paste(), ACTIONS::paste, ACTIONS::pasteSpecial, Plot(), ACTIONS::plot, EVENTS::PointSelectedEvent, Print(), ACTIONS::print, Quit(), ACTIONS::quit, Redo(), ACTIONS::redo, EE_ACTIONS::remapSymbols, RemapSymbols(), EE_ACTIONS::repairSchematic, RepairSchematic(), EE_ACTIONS::rescueSymbols, RescueSymbols(), Revert(), ACTIONS::revert, Save(), ACTIONS::save, SaveAs(), ACTIONS::saveAs, EE_ACTIONS::saveCurrSheetCopyAs, SaveCurrSheetCopyAs(), EE_ACTIONS::schematicSetup, EVENTS::SelectedEvent, EVENTS::SelectedItemsModified, EE_ACTIONS::selectOnPCB, ShowCvpcb(), EE_ACTIONS::showHierarchy, ShowHierarchy(), EE_ACTIONS::showPcbNew, ShowPcbNew(), EE_ACTIONS::showPythonConsole, ShowSchematicSetup(), EE_ACTIONS::simProbe, EE_ACTIONS::simTune, EE_ACTIONS::toggleAnnotateAuto, ToggleAnnotateAuto(), EE_ACTIONS::toggleERCErrors, ToggleERCErrors(), EE_ACTIONS::toggleERCExclusions, ToggleERCExclusions(), EE_ACTIONS::toggleERCWarnings, ToggleERCWarnings(), EE_ACTIONS::toggleHiddenFields, ToggleHiddenFields(), EE_ACTIONS::toggleHiddenPins, ToggleHiddenPins(), TogglePythonConsole(), Undo(), ACTIONS::undo, EVENTS::UnselectedEvent, UpdateFromPCB(), EE_ACTIONS::updateNetHighlighting, UpdateNetHighlighting(), UpdatePCB(), ACTIONS::updatePcbFromSchematic, and ACTIONS::updateSchematicFromPcb.

◆ ShowCvpcb()

int SCH_EDITOR_CONTROL::ShowCvpcb ( const TOOL_EVENT aEvent)

Definition at line 1932 of file sch_editor_control.cpp.

1933{
1934 wxCommandEvent dummy;
1936 return 0;
1937}
void OnOpenCvpcb(wxCommandEvent &event)

References dummy, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::OnOpenCvpcb().

Referenced by setTransitions().

◆ ShowHierarchy()

int SCH_EDITOR_CONTROL::ShowHierarchy ( const TOOL_EVENT aEvent)

Definition at line 2008 of file sch_editor_control.cpp.

2009{
2010 getEditFrame<SCH_EDIT_FRAME>()->ToggleSchematicHierarchy();
2011 return 0;
2012}

Referenced by setTransitions().

◆ ShowPcbNew()

int SCH_EDITOR_CONTROL::ShowPcbNew ( const TOOL_EVENT aEvent)

Definition at line 1957 of file sch_editor_control.cpp.

1958{
1959 wxCommandEvent dummy;
1961 return 0;
1962}
void OnOpenPcbnew(wxCommandEvent &event)

References dummy, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::OnOpenPcbnew().

Referenced by setTransitions().

◆ ShowSchematicSetup()

int SCH_EDITOR_CONTROL::ShowSchematicSetup ( const TOOL_EVENT aEvent)

Definition at line 165 of file sch_editor_control.cpp.

166{
168 return 0;
169}
void ShowSchematicSetupDialog(const wxString &aInitialPage=wxEmptyString)

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::ShowSchematicSetupDialog().

Referenced by setTransitions().

◆ ToggleAnnotateAuto()

◆ ToggleAnnotateRecursive()

int SCH_EDITOR_CONTROL::ToggleAnnotateRecursive ( const TOOL_EVENT aEvent)

◆ ToggleERCErrors()

int SCH_EDITOR_CONTROL::ToggleERCErrors ( const TOOL_EVENT aEvent)

◆ ToggleERCExclusions()

◆ ToggleERCWarnings()

◆ ToggleHiddenFields()

◆ ToggleHiddenPins()

◆ TogglePythonConsole()

int SCH_EDITOR_CONTROL::TogglePythonConsole ( const TOOL_EVENT aEvent)

Definition at line 2108 of file sch_editor_control.cpp.

2109{
2110
2112 return 0;
2113}
void ScriptingConsoleEnableDisable()
Toggles the scripting console visibility.

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and EDA_DRAW_FRAME::ScriptingConsoleEnableDisable().

Referenced by setTransitions().

◆ Undo()

int SCH_EDITOR_CONTROL::Undo ( const TOOL_EVENT aEvent)

Definition at line 1106 of file sch_editor_control.cpp.

1107{
1108 if( m_frame->GetUndoCommandCount() <= 0 )
1109 return 0;
1110
1111 // Inform tools that undo command was issued
1113
1114 // Get the old list
1116 size_t num_undos = m_frame->m_undoList.m_CommandsList.size();
1117
1118 // The cleanup routines normally run after an operation and so attempt to append their
1119 // undo items onto the operation's list. However, in this case that's going be the list
1120 // under us, which we don't want, so we push a dummy list onto the stack.
1123
1125
1129
1130 // The cleanup routines *should* have appended to our dummy list, but just to be doubly
1131 // sure pop any other new lists off the stack as well
1132 while( m_frame->m_undoList.m_CommandsList.size() > num_undos )
1134
1135 // Now push the old command to the RedoList
1138
1139 m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1140
1141 m_frame->SyncView();
1143 m_frame->OnModify();
1144
1145 return 0;
1146}
UNDO_REDO_CONTAINER m_undoList
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual int GetUndoCommandCount() const
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList

References AS_GLOBAL, dummy, SCH_BASE_FRAME::GetCanvas(), TOOL_MANAGER::GetTool(), EDA_BASE_FRAME::GetUndoCommandCount(), UNDO_REDO_CONTAINER::m_CommandsList, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, EDA_BASE_FRAME::m_undoList, SCH_EDIT_FRAME::OnModify(), SCH_EDIT_FRAME::OnPageSettingsChange(), EDA_BASE_FRAME::PopCommandFromUndoList(), TOOL_MANAGER::ProcessEvent(), EDA_BASE_FRAME::PushCommandToRedoList(), EDA_BASE_FRAME::PushCommandToUndoList(), SCH_EDIT_FRAME::PutDataInPreviousState(), EDA_DRAW_PANEL_GAL::Refresh(), PICKED_ITEMS_LIST::ReversePickersListOrder(), SCH_EDIT_FRAME::SetSheetNumberAndCount(), SCH_BASE_FRAME::SyncView(), TA_UNDO_REDO_PRE, TC_MESSAGE, and SCH_EDIT_FRAME::TestDanglingEnds().

Referenced by setTransitions().

◆ UpdateFromPCB()

int SCH_EDITOR_CONTROL::UpdateFromPCB ( const TOOL_EVENT aEvent)

Definition at line 1973 of file sch_editor_control.cpp.

1974{
1976 dlg.ShowModal();
1977 return 0;
1978}

References EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame.

Referenced by setTransitions().

◆ updateItem()

void EE_TOOL_BASE< SCH_EDIT_FRAME >::updateItem ( EDA_ITEM aItem,
bool  aUpdateRTree 
) const
inlineprotectedinherited

Similar to getView()->Update(), but handles items that are redrawn by their parents and updating the SCH_SCREEN's RTree.

Similar to m_frame->SaveCopyInUndoList(), but handles items that are owned by their parents.

Definition at line 103 of file ee_tool_base.h.

◆ UpdateNetHighlighting()

int SCH_EDITOR_CONTROL::UpdateNetHighlighting ( const TOOL_EVENT aEvent)

Launch a tool to highlight nets.

Definition at line 933 of file sch_editor_control.cpp.

934{
936 CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
937 std::vector<EDA_ITEM*> itemsToRedraw;
938 const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
939
940 if( !screen )
941 return 0;
942
943 bool selectedIsBus = selectedConn ? selectedConn->IsBus() : false;
944 wxString selectedName = selectedConn ? selectedConn->Name() : wxString( wxS( "" ) );
945
946 bool selectedIsNoNet = false;
947 CONNECTION_SUBGRAPH* selectedSubgraph = nullptr;
948
949 if( selectedConn && selectedConn->Driver() == nullptr )
950 {
951 selectedIsNoNet = true;
952 selectedSubgraph = connectionGraph->GetSubgraphForItem( selectedConn->Parent() );
953 }
954
955 for( SCH_ITEM* item : screen->Items() )
956 {
957 bool redraw = item->IsBrightened();
958 bool highlight = false;
959
960 if( selectedConn )
961 {
962 SCH_CONNECTION* itemConn = nullptr;
963 SCH_SYMBOL* symbol = nullptr;
964
965 if( item->Type() == SCH_SYMBOL_T )
966 symbol = static_cast<SCH_SYMBOL*>( item );
967
968 if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
969 itemConn = symbol->Connection();
970 else
971 itemConn = item->Connection();
972
973 if( selectedIsNoNet && selectedSubgraph )
974 {
975 for( SCH_ITEM* subgraphItem : selectedSubgraph->m_items )
976 {
977 if( item == subgraphItem )
978 {
979 highlight = true;
980 break;
981 }
982 }
983 }
984 else if( selectedIsBus && itemConn && itemConn->IsNet() )
985 {
986 for( const std::shared_ptr<SCH_CONNECTION>& member : selectedConn->Members() )
987 {
988 if( member->Name() == itemConn->Name() )
989 {
990 highlight = true;
991 break;
992 }
993 else if( member->IsBus() )
994 {
995 for( const std::shared_ptr<SCH_CONNECTION>& bus_member : member->Members() )
996 {
997 if( bus_member->Name() == itemConn->Name() )
998 {
999 highlight = true;
1000 break;
1001 }
1002 }
1003 }
1004 }
1005 }
1006 else if( selectedConn && itemConn && selectedName == itemConn->Name() )
1007 {
1008 highlight = true;
1009 }
1010 }
1011
1012 if( highlight )
1013 item->SetBrightened();
1014 else
1015 item->ClearBrightened();
1016
1017 redraw |= item->IsBrightened();
1018
1019 if( item->Type() == SCH_SYMBOL_T )
1020 {
1021 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1022
1023 redraw |= symbol->HasBrightenedPins();
1024
1025 symbol->ClearBrightenedPins();
1026
1027 for( SCH_PIN* pin : symbol->GetPins() )
1028 {
1029 SCH_CONNECTION* pin_conn = pin->Connection();
1030
1031 if( pin_conn && pin_conn->Name() == selectedName )
1032 {
1033 pin->SetBrightened();
1034 redraw = true;
1035 }
1036 }
1037
1038 if( symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
1039 {
1040 std::vector<SCH_FIELD>& fields = symbol->GetFields();
1041
1042 for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1043 {
1044 if( item->IsBrightened() && fields[id].IsVisible() )
1045 fields[id].SetBrightened();
1046 else
1047 fields[id].ClearBrightened();
1048 }
1049 }
1050 }
1051 else if( item->Type() == SCH_SHEET_T )
1052 {
1053 for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1054 {
1055 SCH_CONNECTION* pin_conn = pin->Connection();
1056 bool redrawPin = pin->IsBrightened();
1057
1058 if( pin_conn && pin_conn->Name() == selectedName )
1059 pin->SetBrightened();
1060 else
1061 pin->ClearBrightened();
1062
1063 redrawPin ^= pin->IsBrightened();
1064 redraw |= redrawPin;
1065 }
1066 }
1067
1068 if( redraw )
1069 itemsToRedraw.push_back( item );
1070 }
1071
1072 // Be sure highlight change will be redrawn
1073 KIGFX::VIEW* view = getView();
1074
1075 for( EDA_ITEM* redrawItem : itemsToRedraw )
1077
1079
1080 return 0;
1081}
Calculates the connectivity of a schematic and generates netlists.
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
A subgraph is a set of items that are electrically connected on a single sheet.
std::vector< SCH_ITEM * > m_items
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1591
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:130
bool IsNet() const
SCH_ITEM * Parent() const
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
const SCH_CONNECTION * GetHighlightedConnection() const
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:146
bool HasBrightenedPins()
void ClearBrightenedPins()
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:879
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".

References EDA_ITEM::ClearBrightened(), SCH_SYMBOL::ClearBrightenedPins(), SCH_ITEM::Connection(), SCHEMATIC::ConnectionGraph(), SCH_CONNECTION::Driver(), SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SYMBOL::GetFields(), SCH_EDIT_FRAME::GetHighlightedConnection(), SCH_SYMBOL::GetLibSymbolRef(), SCH_SHEET::GetPins(), SCH_SYMBOL::GetPins(), CONNECTION_GRAPH::GetSubgraphForItem(), TOOL_BASE::getView(), SCH_SYMBOL::HasBrightenedPins(), EDA_ITEM::IsBrightened(), SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsNet(), SCH_SCREEN::Items(), SCH_SHEET_PATH::LastScreen(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, CONNECTION_SUBGRAPH::m_items, SCH_CONNECTION::Members(), SCH_CONNECTION::Name(), SCH_CONNECTION::Parent(), pin, REFERENCE_FIELD, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::REPAINT, SCH_SHEET_T, SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), EDA_ITEM::SetBrightened(), EDA_ITEM::Type(), KIGFX::VIEW::Update(), and VALUE_FIELD.

Referenced by SCH_EDIT_FRAME::DisplayCurrentSheet(), and setTransitions().

◆ updatePastedSheet()

SCH_SHEET_PATH SCH_EDITOR_CONTROL::updatePastedSheet ( const SCH_SHEET_PATH aPastePath,
const KIID_PATH aClipPath,
SCH_SHEET aSheet,
bool  aForceKeepAnnotations,
SCH_SHEET_LIST aPastedSheetsSoFar,
SCH_REFERENCE_LIST aPastedSymbolsSoFar 
)
private

Definition at line 1331 of file sch_editor_control.cpp.

1336{
1337 wxCHECK( aSheet && aPastedSheetsSoFar && aPastedSymbolsSoFar, aPastePath );
1338
1339 SCH_SHEET_PATH sheetPath = aPastePath;
1340 sheetPath.push_back( aSheet );
1341
1342 aPastedSheetsSoFar->push_back( sheetPath );
1343
1344 if( aSheet->GetScreen() == nullptr )
1345 return sheetPath; // We can only really set the page number but not load any items
1346
1347 for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1348 {
1349 if( item->Type() == SCH_SYMBOL_T )
1350 {
1351 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1352
1353 updatePastedSymbol( symbol, aSheet->GetScreen(), sheetPath, aClipPath,
1354 aForceKeepAnnotations );
1355 }
1356 else if( item->Type() == SCH_SHEET_T )
1357 {
1358 SCH_SHEET* subsheet = static_cast<SCH_SHEET*>( item );
1359
1360 KIID_PATH newClipPath = aClipPath;
1361 newClipPath.push_back( subsheet->m_Uuid );
1362
1363 updatePastedSheet( sheetPath, newClipPath, subsheet, aForceKeepAnnotations,
1364 aPastedSheetsSoFar, aPastedSymbolsSoFar );
1365
1366 SCH_SHEET_PATH subSheetPath = sheetPath;
1367
1368 subSheetPath.push_back( subsheet );
1369 subSheetPath.GetSymbols( *aPastedSymbolsSoFar );
1370 }
1371 }
1372
1373 return sheetPath;
1374}

References SCH_SHEET::GetScreen(), SCH_SHEET_PATH::GetSymbols(), SCH_SCREEN::Items(), EDA_ITEM::m_Uuid, SCH_SHEET_PATH::push_back(), SCH_SHEET_T, SCH_SYMBOL_T, EDA_ITEM::Type(), updatePastedSheet(), and updatePastedSymbol().

Referenced by Paste(), and updatePastedSheet().

◆ updatePastedSymbol()

void SCH_EDITOR_CONTROL::updatePastedSymbol ( SCH_SYMBOL aSymbol,
SCH_SCREEN aPasteScreen,
const SCH_SHEET_PATH aPastePath,
const KIID_PATH aClipPath,
bool  aForceKeepAnnotations 
)
private

Definition at line 1286 of file sch_editor_control.cpp.

1290{
1291 wxCHECK( aSymbol && aPasteScreen, /* void */ );
1292
1293 KIID_PATH clipItemPath = aClipPath;
1294
1295 wxString reference, value, footprint;
1296 int unit;
1297
1298 if( m_clipboardSymbolInstances.count( clipItemPath ) > 0 )
1299 {
1300 SCH_SYMBOL_INSTANCE instance = m_clipboardSymbolInstances.at( clipItemPath );
1301
1302 unit = instance.m_Unit;
1303 reference = instance.m_Reference;
1304 }
1305 else
1306 {
1307 // Some legacy versions saved value fields escaped. While we still do in the symbol
1308 // editor, we don't anymore in the schematic, so be sure to unescape them.
1309 SCH_FIELD* valueField = aSymbol->GetField( VALUE_FIELD );
1310 valueField->SetText( UnescapeString( valueField->GetText() ) );
1311
1312 // Pasted from notepad or an older instance of eeschema. Use the values in the fields
1313 // instead.
1314 reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
1315 value = aSymbol->GetField( VALUE_FIELD )->GetText();
1316 footprint = aSymbol->GetField( FOOTPRINT_FIELD )->GetText();
1317 unit = aSymbol->GetUnit();
1318 }
1319
1320 if( aForceKeepAnnotations && !reference.IsEmpty() )
1321 aSymbol->SetRef( &aPastePath, reference );
1322 else
1323 aSymbol->ClearAnnotation( &aPastePath, false );
1324
1325 // We might clear annotations but always leave the original unit number from the paste.
1326 aSymbol->SetUnitSelection( &aPastePath, unit );
1327 aSymbol->SetUnit( unit );
1328}
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:694
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:384
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:787
wxString UnescapeString(const wxString &aSource)

References SCH_SYMBOL::ClearAnnotation(), FOOTPRINT_FIELD, SCH_SYMBOL::GetField(), EDA_TEXT::GetText(), SCH_SYMBOL::GetUnit(), m_clipboardSymbolInstances, SCH_SYMBOL_INSTANCE::m_Reference, SCH_SYMBOL_INSTANCE::m_Unit, REFERENCE_FIELD, SCH_SYMBOL::SetRef(), EDA_TEXT::SetText(), SCH_SYMBOL::SetUnit(), SCH_SYMBOL::SetUnitSelection(), UnescapeString(), and VALUE_FIELD.

Referenced by Paste(), and updatePastedSheet().

◆ UpdatePCB()

int SCH_EDITOR_CONTROL::UpdatePCB ( const TOOL_EVENT aEvent)

Definition at line 1965 of file sch_editor_control.cpp.

1966{
1967 wxCommandEvent dummy;
1969 return 0;
1970}
void OnUpdatePCB(wxCommandEvent &event)

References dummy, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, and SCH_EDIT_FRAME::OnUpdatePCB().

Referenced by setTransitions().

◆ Wait()

TOOL_EVENT * TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

58{
59 return m_toolMgr->ScheduleWait( this, aEventList );
60}
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pause execution of a given tool until one or more events matching aConditions arrives.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleWait().

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDA_3D_CONTROLLER::Main(), CVPCB_CONTROL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_clipboardSheetInstances

std::map<KIID_PATH, SCH_SHEET_INSTANCE> SCH_EDITOR_CONTROL::m_clipboardSheetInstances
private

Definition at line 222 of file sch_editor_control.h.

Referenced by setClipboardInstances().

◆ m_clipboardSymbolInstances

std::map<KIID_PATH, SCH_SYMBOL_INSTANCE> SCH_EDITOR_CONTROL::m_clipboardSymbolInstances
private

Definition at line 219 of file sch_editor_control.h.

Referenced by setClipboardInstances(), and updatePastedSymbol().

◆ m_duplicateClipboard

std::string SCH_EDITOR_CONTROL::m_duplicateClipboard
private

Definition at line 211 of file sch_editor_control.h.

Referenced by doCopy(), and Paste().

◆ m_duplicateIsHoverSelection

bool SCH_EDITOR_CONTROL::m_duplicateIsHoverSelection
private

Definition at line 212 of file sch_editor_control.h.

Referenced by doCopy(), and Paste().

◆ m_frame

SCH_EDIT_FRAME * EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame
protectedinherited

Definition at line 182 of file ee_tool_base.h.

◆ m_isSymbolEditor

bool EE_TOOL_BASE< SCH_EDIT_FRAME >::m_isSymbolEditor
protectedinherited

Definition at line 185 of file ee_tool_base.h.

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

The functions below are not yet implemented - their interface may change.

Definition at line 125 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), EDA_3D_CONTROLLER::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< T >::Init(), SCH_DRAWING_TOOLS::Init(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), PICKER_TOOL::Init(), ZOOM_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_SELECTION_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), ROUTER_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), DRAWING_TOOL::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PAD_TOOL::Init(), PCB_SELECTION_TOOL::Init(), PCB_TOOL_BASE::Init(), PCB_VIEWER_TOOLS::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDA_3D_CONTROLLER::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ m_pickerItem

EDA_ITEM* SCH_EDITOR_CONTROL::m_pickerItem
private

Definition at line 209 of file sch_editor_control.h.

◆ m_probingPcbToSch

bool SCH_EDITOR_CONTROL::m_probingPcbToSch
private

Definition at line 208 of file sch_editor_control.h.

Referenced by doCrossProbeSchToPcb().

◆ m_selectionTool

EE_SELECTION_TOOL* EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool
protectedinherited

Definition at line 184 of file ee_tool_base.h.

◆ m_supplementaryClipboard

std::map<wxString, SCH_SCREEN*> SCH_EDITOR_CONTROL::m_supplementaryClipboard
private

Definition at line 216 of file sch_editor_control.h.

Referenced by doCopy(), and searchSupplementaryClipboard().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 210 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and TOOL_BASE::IsToolActive().

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), SELECTION_TOOL::AddItemsToSel(), SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), AssignNetclass(), BOARD_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), ChangeLineMode(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), ClearHighlight(), BOARD_INSPECTION_TOOL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MICROWAVE_TOOL::createInductorBetween(), EE_INSPECTION_TOOL::CrossProbe(), DRC_TOOL::CrossProbe(), COMMON_TOOLS::CursorControl(), Cut(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), doCopy(), BOARD_EDITOR_CONTROL::doCrossProbePcbToSch(), doCrossProbeSchToPcb(), SCH_EDIT_TOOL::DoDelete(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideRatsnestNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PCB_SELECTION_TOOL::doSyncSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::Drag(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), EditWithSymbolEditor(), PCB_SELECTION_TOOL::EnterGroup(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::ExitGroup(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::FindItem(), FindSymbolAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCB_SELECTION_TOOL::grabUnconnected(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), EE_TOOL_BASE< T >::Init(), SCH_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_POINT_EDITOR::Init(), ROUTER_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), BOARD_INSPECTION_TOOL::Init(), BOARD_REANNOTATE_TOOL::Init(), CONVERT_TOOL::Init(), DRAWING_TOOL::Init(), EDIT_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), PCB_POINT_EDITOR::Init(), PCB_SELECTION_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), POSITION_RELATIVE_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EDA_3D_CONTROLLER::Main(), CVPCB_CONTROL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), NextLineMode(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), GERBVIEW_CONTROL::Print(), PCB_CONTROL::Print(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::rebuildConnectivity(), ZONE_FILLER_TOOL::rebuildConnectivity(), EE_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::RecombinePad(), Redo(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), PCB_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), PAD_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), Revert(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), ROUTER_TOOL::RouteSelected(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), GERBVIEW_SELECTION_TOOL::selectPoint(), PL_SELECTION_TOOL::SelectPoint(), PCB_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_SELECTION_TOOL::selectSameSheet(), PCB_SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDIT_TOOL::Swap(), EE_SELECTION_TOOL::SyncSelection(), COMMON_TOOLS::ToggleCursor(), COMMON_TOOLS::ToggleCursorStyle(), EDA_3D_CONTROLLER::ToggleVisibility(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), SCH_MOVE_TOOL::trimDanglingLines(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), Undo(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), GROUP_TOOL::Ungroup(), PCB_SELECTION_TOOL::unrouteSelected(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), BOARD_INSPECTION_TOOL::UpdateLocalRatsnest(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), EE_POINT_EDITOR::updateParentItem(), PNS::TOOL_BASE::updateStartItem(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), and BOARD_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 214 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

◆ m_view

KIGFX::SCH_VIEW* EE_TOOL_BASE< SCH_EDIT_FRAME >::m_view
protectedinherited

Definition at line 183 of file ee_tool_base.h.


The documentation for this class was generated from the following files: