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 }
 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 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)
 
int FindAndReplace (const TOOL_EVENT &aEvent)
 
int FindNext (const TOOL_EVENT &aEvent)
 
bool HasMatch ()
 
int ReplaceAndFindNext (const TOOL_EVENT &aEvent)
 
int ReplaceAll (const TOOL_EVENT &aEvent)
 
int UpdateFind (const TOOL_EVENT &aEvent)
 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 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 ShowBusManager (const TOOL_EVENT &aEvent)
 
int EnterSheet (const TOOL_EVENT &aEvent)
 
int LeaveSheet (const TOOL_EVENT &aEvent)
 
int NavigateHierarchy (const TOOL_EVENT &aEvent)
 
int ToggleHiddenPins (const TOOL_EVENT &aEvent)
 
int ToggleHiddenFields (const TOOL_EVENT &aEvent)
 
int ToggleForceHV (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. 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)
 
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 aUseLocalClipboard=false)
 < copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true 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...
 
SCH_ITEMnextMatch (SCH_SCREEN *aScreen, SCH_SHEET_PATH *aSheet, SCH_ITEM *aAfter, wxFindReplaceData &aData)
 Advance the search and returns the next matching item after aAfter. More...
 

Private Attributes

bool m_probingPcbToSch
 
EDA_ITEMm_pickerItem
 
std::string m_localClipboard
 
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
 
std::map< KIID_PATH, SYMBOL_INSTANCE_REFERENCEm_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.

Definition at line 77 of file tool_base.h.

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

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 )
45  { }

◆ ~SCH_EDITOR_CONTROL()

SCH_EDITOR_CONTROL::~SCH_EDITOR_CONTROL ( )
inline

Definition at line 47 of file sch_editor_control.h.

47 { }

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:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
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(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_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(), 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(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ Annotate()

int SCH_EDITOR_CONTROL::Annotate ( const TOOL_EVENT aEvent)

Definition at line 2007 of file sch_editor_control.cpp.

2008 {
2009  wxCommandEvent dummy;
2010  m_frame->OnAnnotate( dummy );
2011  return 0;
2012 }
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
void OnAnnotate(wxCommandEvent &event)

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:
47  SCH_REFERENCE_LIST refs;
49  bool isChanged = false;
50 
51  sheets.GetSymbols( refs, false );
52 
53  DSNLEXER lexer( aChangedSetOfReferences, FROM_UTF8( __func__ ) );
54  PTREE doc;
55 
56  try
57  {
58  Scan( &doc, &lexer );
59 
60  CPTREE& back_anno = doc.get_child( "cvpcb_netlist" );
61  wxString footprint;
62 
63  for( PTREE::const_iterator ref = back_anno.begin(); ref != back_anno.end(); ++ref )
64  {
65  wxASSERT( ref->first == "ref" );
66 
67  wxString reference = (UTF8&) ref->second.front().first;
68 
69  // Ensure the "fpid" node contains a footprint name, and get it if exists
70  if( ref->second.get_child( "fpid" ).size() )
71  {
72  wxString tmp = (UTF8&) ref->second.get_child( "fpid" ).front().first;
73  footprint = tmp;
74  }
75  else
76  footprint.Empty();
77 
78  // Search the symbol in the flat list
79  for( unsigned ii = 0; ii < refs.GetCount(); ++ii )
80  {
81  if( reference == refs[ii].GetRef() )
82  {
83  // We have found a candidate.
84  // Note: it can be not unique (multiple parts per package)
85  // So we *do not* stop the search here
86  SCH_SYMBOL* symbol = refs[ ii ].GetSymbol();
87 
88  // For backwards-compatibility CvPcb currently updates all instances of a
89  // symbol (even though it lists these instances separately).
90  SCH_SHEET_PATH* sheetPath = nullptr; // &refs[ii].GetSheetPath();
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  symbol->SetFootprint( sheetPath, footprint );
100  }
101  }
102  }
103  }
104  }
105  catch( const PTREE_ERROR& ex )
106  {
107  // remap the exception to something the caller is likely to understand.
108  THROW_IO_ERROR( ex.what() );
109  }
110 
111  if( isChanged )
112  {
113  m_frame->SyncView();
114  m_frame->GetCanvas()->Refresh();
115  m_frame->OnModify();
116  }
117 }
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
Definition: utf8.h:70
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:705
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.
void Scan(PTREE *aTree, DSNLEXER *aLexer)
Fill an empty PTREE with information from a KiCad s-expression stream.
Definition: ptree.cpp:86
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:675
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
boost::property_tree::ptree PTREE
Definition: ptree.h:52
const PTREE CPTREE
Definition: ptree.h:53
void SyncView()
Mark all items for refresh.
virtual bool IsVisible() const
Definition: eda_text.h:207
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCHEMATIC & Schematic() const
size_t GetCount() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
boost::property_tree::ptree_error PTREE_ERROR
Definition: ptree.h:54
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
Schematic symbol object.
Definition: sch_symbol.h:78
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...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
Implement a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:78
Field Name Module PCB, i.e. "16DIP300".

References 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(), Scan(), SCH_EDIT_FRAME::Schematic(), SCH_SYMBOL::SetFootprint(), 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 1054 of file sch_editor_control.cpp.

1055 {
1057  KIGFX::VIEW_CONTROLS* controls = getViewControls();
1058  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
1059 
1060  // TODO remove once real-time connectivity is a given
1062  // Ensure the netlist data is up to date:
1064 
1065  // Remove selection in favor of highlighting so the whole net is highlighted
1066  selectionTool->ClearSelection();
1067  highlightNet( m_toolMgr, cursorPos );
1068 
1070 
1071  if( conn )
1072  {
1073  if( !conn->IsBus()
1074  && ( !conn->Driver()
1077  {
1078  m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
1080  return 0;
1081  }
1082  else if( conn->IsBus() && conn->Members().size() == 0 )
1083  {
1084  m_frame->ShowInfoBarError( _( "Bus has no members to assign netclass to." ) );
1086  return 0;
1087  }
1088 
1089  wxArrayString netNames;
1090 
1091  if( conn->IsBus() )
1092  {
1093  for( const std::shared_ptr<SCH_CONNECTION>& member : conn->Members() )
1094  {
1095  if( member->IsBus() )
1096  {
1097  for( const std::shared_ptr<SCH_CONNECTION>& subMember : member->Members() )
1098  netNames.Add( subMember->Name() );
1099  }
1100  else
1101  {
1102  netNames.Add( member->Name() );
1103  }
1104  }
1105  }
1106  else
1107  {
1108  netNames.Add( conn->Name() );
1109  }
1110 
1111  NET_SETTINGS& netSettings = m_frame->Schematic().Prj().GetProjectFile().NetSettings();
1112  wxString netclassName = netSettings.GetNetclassName( netNames.front() );
1113 
1114  wxArrayString headers;
1115  std::vector<wxArrayString> items;
1116 
1117  headers.Add( _( "Netclasses" ) );
1118 
1119  wxArrayString defaultItem;
1120  defaultItem.Add( _( "Default" ) );
1121  items.emplace_back( defaultItem );
1122 
1123  for( const std::pair<const wxString, NETCLASSPTR>& ii : netSettings.m_NetClasses )
1124  {
1125  wxArrayString item;
1126  item.Add( ii.first );
1127  items.emplace_back( item );
1128  }
1129 
1130  EDA_LIST_DIALOG dlg( m_frame, _( "Assign Netclass" ), headers, items, netclassName );
1131  dlg.SetListLabel( _( "Select netclass:" ) );
1132 
1133  if( dlg.ShowModal() == wxID_OK )
1134  {
1135  netclassName = dlg.GetTextSelection();
1136 
1137  for( const wxString& netName : netNames )
1138  {
1139  // Remove from old netclass membership list
1140  if( netSettings.m_NetClassAssignments.count( netName ) )
1141  {
1142  const wxString oldNetclassName = netSettings.m_NetClassAssignments[netName];
1143  NETCLASSPTR oldNetclass = netSettings.m_NetClasses.Find( oldNetclassName );
1144 
1145  if( oldNetclass )
1146  oldNetclass->Remove( netName );
1147  }
1148 
1149  // Add to new netclass membership list
1150  NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName );
1151 
1152  if( newNetclass )
1153  newNetclass->Add( netName );
1154 
1155  netSettings.m_NetClassAssignments[netName] = netclassName;
1156  }
1157  }
1158  }
1159 
1161  return 0;
1162 }
std::map< wxString, wxString > m_NetClassAssignments
Definition: net_settings.h:44
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
const wxString & GetNetclassName(const wxString &aNetName) const
const SCH_CONNECTION * GetHighlightedConnection() const
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
NET_SETTINGS & NetSettings()
Definition: project_file.h:96
A dialog which shows:
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...
NETCLASSES m_NetClasses
Definition: net_settings.h:40
wxString Name(bool aIgnoreSheet=false) const
SCHEMATIC & Schematic() const
SCH_ITEM * Driver() const
An interface for classes handling user events controlling the view behavior such as zooming,...
#define _(s)
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:32
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
bool DisableGridSnapping() const
Definition: tool_event.h:341
static VECTOR2D CLEAR
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
static bool m_allowRealTime
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool IsBus() const
bool m_RealTimeConnectivity
Do real-time connectivity.
PRIORITY GetDriverPriority()

References _, CLEAR, EE_SELECTION_TOOL::ClearSelection(), TOOL_EVENT::DisableGridSnapping(), SCH_CONNECTION::Driver(), NETCLASSES::Find(), ADVANCED_CFG::GetCfg(), CONNECTION_SUBGRAPH::GetDriverPriority(), SCH_EDIT_FRAME::GetHighlightedConnection(), NET_SETTINGS::GetNetclassName(), PROJECT::GetProjectFile(), EDA_LIST_DIALOG::GetTextSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::getViewControls(), highlightNet(), SCH_CONNECTION::IsBus(), CONNECTION_GRAPH::m_allowRealTime, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, NET_SETTINGS::m_NetClassAssignments, NET_SETTINGS::m_NetClasses, ADVANCED_CFG::m_RealTimeConnectivity, TOOL_BASE::m_toolMgr, SCH_CONNECTION::Members(), SCH_CONNECTION::Name(), PROJECT_FILE::NetSettings(), NO_CLEANUP, SCHEMATIC::Prj(), SCH_EDIT_FRAME::RecalculateConnections(), SCH_EDIT_FRAME::Schematic(), EDA_LIST_DIALOG::SetListLabel(), 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ ClearHighlight()

int SCH_EDITOR_CONTROL::ClearHighlight ( const TOOL_EVENT aEvent)

Update net highlighting after an edit.

Definition at line 1046 of file sch_editor_control.cpp.

1047 {
1049 
1050  return 0;
1051 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
static VECTOR2D CLEAR

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

Referenced by setTransitions().

◆ Copy()

int SCH_EDITOR_CONTROL::Copy ( const TOOL_EVENT aEvent)

Definition at line 1490 of file sch_editor_control.cpp.

1491 {
1492  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1493 
1494  if( textEntry )
1495  {
1496  textEntry->Copy();
1497  return 0;
1498  }
1499 
1500  doCopy();
1501 
1502  return 0;
1503 }
bool doCopy(bool aUseLocalClipboard=false)
< copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true

References doCopy().

Referenced by setTransitions().

◆ CrossProbeToPcb()

int SCH_EDITOR_CONTROL::CrossProbeToPcb ( const TOOL_EVENT aEvent)

Equivalent to the above, but initiated by the user.

We also do SCH_SHEETs on this one (they're too slow on big projects for the auto version above).

Definition at line 671 of file sch_editor_control.cpp.

672 {
673  doCrossProbeSchToPcb( aEvent, false );
674  return 0;
675 }
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 1473 of file sch_editor_control.cpp.

1474 {
1475  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1476 
1477  if( textEntry )
1478  {
1479  textEntry->Cut();
1480  return 0;
1481  }
1482 
1483  if( doCopy() )
1485 
1486  return 0;
1487 }
static TOOL_ACTION doDelete
Definition: actions.h:72
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
bool doCopy(bool aUseLocalClipboard=false)
< copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true

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

Referenced by setTransitions().

◆ doCopy()

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

< copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true

Definition at line 1413 of file sch_editor_control.cpp.

1414 {
1416  EE_SELECTION& selection = selTool->RequestSelection();
1417  SCHEMATIC& schematic = m_frame->Schematic();
1418 
1419  if( !selection.GetSize() )
1420  return false;
1421 
1422  selection.SetScreen( m_frame->GetScreen() );
1423  m_supplementaryClipboard.clear();
1424 
1425  for( EDA_ITEM* item : selection )
1426  {
1427  if( item->Type() == SCH_SHEET_T )
1428  {
1429  SCH_SHEET* sheet = (SCH_SHEET*) item;
1430  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1431  }
1432  }
1433 
1434  STRING_FORMATTER formatter;
1435  SCH_SEXPR_PLUGIN plugin;
1436  SCH_SHEET_LIST hierarchy = schematic.GetSheets();
1437  SCH_SHEET_PATH selPath = m_frame->GetCurrentSheet();
1438 
1439  plugin.Format( &selection, &selPath, &hierarchy, &formatter );
1440 
1441  if( aUseLocalClipboard )
1442  {
1443  m_localClipboard = formatter.GetString();
1444  return true;
1445  }
1446 
1447  return m_toolMgr->SaveClipboard( formatter.GetString() );
1448 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void Format(SCH_SHEET *aSheet)
Holds all the data relating to one schematic.
Definition: schematic.h:59
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:102
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard
SCHEMATIC & Schematic() const
const std::string & GetString()
Definition: richio.h:438
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:314
A SCH_PLUGIN derivation for loading schematic files using the new s-expression file format.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
bool SaveClipboard(const std::string &aTextUTF8)
Store information to the system clipboard.
std::string m_localClipboard
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
SCH_SHEET_PATH & GetCurrentSheet() const
Implement an OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:414

References SCH_SEXPR_PLUGIN::Format(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SHEET::GetFileName(), SCH_SHEET::GetScreen(), SCH_EDIT_FRAME::GetScreen(), SCHEMATIC::GetSheets(), STRING_FORMATTER::GetString(), TOOL_MANAGER::GetTool(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_localClipboard, m_supplementaryClipboard, TOOL_BASE::m_toolMgr, EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::SaveClipboard(), 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 685 of file sch_editor_control.cpp.

686 {
687  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
688  if( m_probingPcbToSch )
689  return;
690 
692  SCH_ITEM* item = nullptr;
693  SCH_SYMBOL* symbol = nullptr;
694 
695  if( aForce )
696  {
697  EE_SELECTION& selection = selTool->RequestSelection();
698 
699  if( selection.GetSize() >= 1 )
700  item = (SCH_ITEM*) selection.Front();
701  }
702  else
703  {
704  EE_SELECTION& selection = selTool->GetSelection();
705 
706  if( selection.GetSize() >= 1 )
707  item = (SCH_ITEM*) selection.Front();
708  }
709 
710  if( !item )
711  {
712  if( aForce )
713  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
714 
715  return;
716  }
717 
718 
719  switch( item->Type() )
720  {
721  case SCH_FIELD_T:
722  case LIB_FIELD_T:
723  if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T )
724  {
725  symbol = (SCH_SYMBOL*) item->GetParent();
726  m_frame->SendMessageToPCBNEW( item, symbol );
727  }
728  break;
729 
730  case SCH_SYMBOL_T:
731  symbol = (SCH_SYMBOL*) item;
732  m_frame->SendMessageToPCBNEW( item, symbol );
733  break;
734 
735  case SCH_PIN_T:
736  symbol = (SCH_SYMBOL*) item->GetParent();
737  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), symbol );
738  break;
739 
740  case SCH_SHEET_T:
741  if( aForce )
742  m_frame->SendMessageToPCBNEW( item, nullptr );
743  break;
744 
745  default:
746  break;
747  }
748 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:88
Schematic symbol object.
Definition: sch_symbol.h:78
void SendMessageToPCBNEW(EDA_ITEM *aObjectToSync, SCH_SYMBOL *aPart)
Send a message to Pcbnew via a socket connection.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
EDA_ITEM * Front() const
Definition: selection.h:145

References SELECTION::Front(), EDA_ITEM::GetParent(), EE_SELECTION_TOOL::GetSelection(), SELECTION::GetSize(), TOOL_MANAGER::GetTool(), LIB_FIELD_T, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_probingPcbToSch, TOOL_BASE::m_toolMgr, EE_SELECTION_TOOL::RequestSelection(), SCH_FIELD_T, SCH_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, and SCH_EDIT_FRAME::SendMessageToPCBNEW().

Referenced by CrossProbeToPcb(), and ExplicitCrossProbeToPcb().

◆ DrawSheetOnClipboard()

int SCH_EDITOR_CONTROL::DrawSheetOnClipboard ( const TOOL_EVENT aEvent)

Definition at line 2083 of file sch_editor_control.cpp.

2084 {
2085  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
2087 
2089  return 0;
2090 }
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:477
static bool m_allowRealTime
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.

References SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), ADVANCED_CFG::GetCfg(), LOCAL_CLEANUP, CONNECTION_GRAPH::m_allowRealTime, 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 1464 of file sch_editor_control.cpp.

1465 {
1466  doCopy( true ); // Use the local clipboard
1467  Paste( aEvent );
1468 
1469  return 0;
1470 }
int Paste(const TOOL_EVENT &aEvent)
bool doCopy(bool aUseLocalClipboard=false)
< copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true

References doCopy(), and Paste().

Referenced by setTransitions().

◆ EditSymbolFields()

int SCH_EDITOR_CONTROL::EditSymbolFields ( const TOOL_EVENT aEvent)

Definition at line 2023 of file sch_editor_control.cpp.

2024 {
2026  dlg.ShowQuasiModal();
2027  return 0;
2028 }

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 2031 of file sch_editor_control.cpp.

2032 {
2034  m_frame->HardRedraw();
2035 
2036  return 0;
2037 }
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 1971 of file sch_editor_control.cpp.

1972 {
1974  EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
1975  SCH_SYMBOL* symbol = nullptr;
1976  SYMBOL_EDIT_FRAME* symbolEditor;
1977 
1978  if( selection.GetSize() >= 1 )
1979  symbol = (SCH_SYMBOL*) selection.Front();
1980 
1981  if( !symbol || symbol->GetEditFlags() != 0 )
1982  return 0;
1983 
1985  symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1986 
1987  if( symbolEditor )
1988  {
1989  if( aEvent.IsAction( &EE_ACTIONS::editWithLibEdit ) )
1990  symbolEditor->LoadSymbolFromSchematic( symbol );
1991  else if( aEvent.IsAction( &EE_ACTIONS::editLibSymbolWithLibEdit ) )
1992  {
1993  symbolEditor->LoadSymbol( symbol->GetLibId(), symbol->GetUnit(), symbol->GetConvert() );
1994 
1995  if( !symbolEditor->IsSymbolTreeShown() )
1996  {
1997  wxCommandEvent evt;
1998  symbolEditor->OnToggleSymbolTree( evt );
1999  }
2000  }
2001  }
2002 
2003  return 0;
2004 }
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void LoadSymbolFromSchematic(SCH_SYMBOL *aSymbol)
Load a symbol from the schematic to edit in place.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:393
bool IsSymbolTreeShown() const
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
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
void LoadSymbol(const wxString &aLibrary, const wxString &aSymbol, int Unit)
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:157
void OnToggleSymbolTree(wxCommandEvent &event)
Schematic symbol object.
Definition: sch_symbol.h:78
static TOOL_ACTION showSymbolEditor
Definition: actions.h:160
static const KICAD_T SymbolsOnly[]
Definition: ee_collectors.h:45
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:162
static TOOL_ACTION editLibSymbolWithLibEdit
Definition: ee_actions.h:163
int GetUnit() const
Definition: sch_symbol.h:196
int GetConvert() const
Definition: sch_symbol.h:224
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:148
The symbol library editor main window.

References EE_ACTIONS::editLibSymbolWithLibEdit, EE_ACTIONS::editWithLibEdit, FRAME_SCH_SYMBOL_EDITOR, SCH_SYMBOL::GetConvert(), EDA_ITEM::GetEditFlags(), SCH_SYMBOL::GetLibId(), TOOL_MANAGER::GetTool(), SCH_SYMBOL::GetUnit(), TOOL_EVENT::IsAction(), 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(), ACTIONS::showSymbolEditor, and EE_COLLECTOR::SymbolsOnly.

Referenced by setTransitions().

◆ EnterSheet()

int SCH_EDITOR_CONTROL::EnterSheet ( const TOOL_EVENT aEvent)

Definition at line 2100 of file sch_editor_control.cpp.

2101 {
2103  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
2104 
2105  if( selection.GetSize() == 1 )
2106  {
2107  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
2108 
2111 
2112  // Store the current zoom level into the current screen before switching
2114 
2115  m_frame->GetCurrentSheet().push_back( sheet );
2117  }
2118 
2119  return 0;
2120 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:508
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:313
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:46
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
SCH_SHEET_PATH & GetCurrentSheet() const
double GetScale() const
Definition: view.h:264

References ACTIONS::cancelInteractive, EE_ACTIONS::clearSelection, SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), KIGFX::VIEW::GetScale(), SCH_EDIT_FRAME::GetScreen(), TOOL_MANAGER::GetTool(), SCH_DRAW_PANEL::GetView(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_SCREEN::m_LastZoomLevel, TOOL_BASE::m_toolMgr, SCH_SHEET_PATH::push_back(), EE_SELECTION_TOOL::RequestSelection(), TOOL_MANAGER::RunAction(), and EE_COLLECTOR::SheetsOnly.

Referenced by setTransitions().

◆ ExplicitCrossProbeToPcb()

int SCH_EDITOR_CONTROL::ExplicitCrossProbeToPcb ( const TOOL_EVENT aEvent)

Definition at line 678 of file sch_editor_control.cpp.

679 {
680  doCrossProbeSchToPcb( aEvent, true );
681  return 0;
682 }
void doCrossProbeSchToPcb(const TOOL_EVENT &aEvent, bool aForce)

References doCrossProbeSchToPcb().

Referenced by setTransitions().

◆ ExportNetlist()

int SCH_EDITOR_CONTROL::ExportNetlist ( const TOOL_EVENT aEvent)

Definition at line 2064 of file sch_editor_control.cpp.

2065 {
2066  int result = NET_PLUGIN_CHANGE;
2067 
2068  // If a plugin is removed or added, rebuild and reopen the new dialog
2069  while( result == NET_PLUGIN_CHANGE )
2070  result = InvokeDialogNetList( m_frame );
2071 
2072  return 0;
2073 }
#define NET_PLUGIN_CHANGE
Create and shows NETLIST_DIALOG and returns whatever NETLIST_DIALOG::ShowModal() returns.
int InvokeDialogNetList(SCH_EDIT_FRAME *aCaller)

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

Referenced by setTransitions().

◆ FindAndReplace()

int SCH_EDITOR_CONTROL::FindAndReplace ( const TOOL_EVENT aEvent)

Definition at line 272 of file sch_editor_control.cpp.

273 {
275  return UpdateFind( aEvent );
276 }
static TOOL_ACTION findAndReplace
Definition: actions.h:77
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
int UpdateFind(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
void ShowFindReplaceDialog(bool aReplace)
Run the Find or Find & Replace dialog.

References ACTIONS::findAndReplace, TOOL_EVENT::IsAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_EDIT_FRAME::ShowFindReplaceDialog(), and UpdateFind().

Referenced by FindNext(), ReplaceAll(), ReplaceAndFindNext(), and setTransitions().

◆ FindNext()

int SCH_EDITOR_CONTROL::FindNext ( const TOOL_EVENT aEvent)

Enforce strict ordering. If the page numbers are the same, use UUIDs

Definition at line 428 of file sch_editor_control.cpp.

429 {
430  // A timer during which a subsequent FindNext will result in a wrap-around
431  static wxTimer wrapAroundTimer;
432 
433  wxFindReplaceData& data = m_frame->GetFindReplaceData();
434 
435  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
436  {
437  g_markersOnly.SetFlags( data.GetFlags() );
438 
439  data = g_markersOnly;
440  }
441  else if( data.GetFindString().IsEmpty() )
442  {
443  return FindAndReplace( ACTIONS::find.MakeEvent() );
444  }
445 
446  bool searchAllSheets = !( data.GetFlags() & FR_CURRENT_SHEET_ONLY );
447  EE_SELECTION& selection = m_selectionTool->GetSelection();
448  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
449  SCH_ITEM* item = nullptr;
450 
451  SCH_SHEET_PATH* afterSheet = &m_frame->GetCurrentSheet();
452 
453  if( wrapAroundTimer.IsRunning() )
454  {
455  afterSheet = nullptr;
456  afterItem = nullptr;
457  wrapAroundTimer.Stop();
459  }
460 
462 
463  if( afterSheet || !searchAllSheets )
464  item = nextMatch( m_frame->GetScreen(), &m_frame->GetCurrentSheet(), afterItem, data );
465 
466  if( !item && searchAllSheets )
467  {
468  SCH_SCREENS screens( m_frame->Schematic().Root() );
469  std::vector<SCH_SHEET_PATH*> paths;
470 
471  screens.BuildClientSheetPathList();
472 
473  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
474  {
475  for( SCH_SHEET_PATH& sheet : screen->GetClientSheetPaths() )
476  paths.push_back( &sheet );
477  }
478 
479  std::sort( paths.begin(), paths.end(), [] ( const SCH_SHEET_PATH* lhs,
480  const SCH_SHEET_PATH* rhs ) -> bool
481  {
482  int retval = lhs->ComparePageNum( *rhs );
483 
484  if( retval < 0 )
485  return true;
486  else if( retval > 0 )
487  return false;
488  else
489  return lhs->GetCurrentHash() < rhs->GetCurrentHash();
490  } );
491 
492  for( SCH_SHEET_PATH* sheet : paths )
493  {
494  if( afterSheet )
495  {
496  if( afterSheet->GetPageNumber() == sheet->GetPageNumber() )
497  afterSheet = nullptr;
498 
499  continue;
500  }
501 
502  sheet->UpdateAllScreenReferences();
503 
504  item = nextMatch( sheet->LastScreen(), sheet, nullptr, data );
505 
506  if( item )
507  {
508  m_frame->Schematic().SetCurrentSheet( *sheet );
509 
510  sheet->LastScreen()->TestDanglingEnds();
511 
512  m_frame->SetScreen( sheet->LastScreen() );
514  UpdateFind( ACTIONS::updateFind.MakeEvent() );
515 
516  break;
517  }
518  }
519  }
520 
521  if( item )
522  {
523  m_selectionTool->AddItemToSel( item );
524  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
525  m_frame->GetCanvas()->Refresh();
526  }
527  else
528  {
529  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
530  : _( "Reached end of sheet." );
531 
532  // Show the popup during the time period the user can wrap the search
533  m_frame->ShowFindReplaceStatus( msg + wxS( " " ) +
534  _( "Find again to wrap around to the start." ), 4000 );
535  wrapAroundTimer.StartOnce( 4000 );
536  }
537 
538  return 0;
539 }
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
int FindAndReplace(const TOOL_EVENT &aEvent)
int ComparePageNum(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare sheets by their page number.
void SetScreen(BASE_SCREEN *aScreen) override
static wxFindReplaceData g_markersOnly
static TOOL_ACTION find
Definition: actions.h:76
wxFindReplaceData & GetFindReplaceData()
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
EE_SELECTION & GetSelection()
Return the set of currently selected items.
static TOOL_ACTION updateFind
Definition: actions.h:82
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_ITEM * nextMatch(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aSheet, SCH_ITEM *aAfter, wxFindReplaceData &aData)
Advance the search and returns the next matching item after aAfter.
wxString GetPageNumber() const
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
int UpdateFind(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
void BuildClientSheetPathList()
built the list of sheet paths sharing a screen for each screen in use
#define _(s)
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
static TOOL_ACTION findNextMarker
Definition: actions.h:79
void ClearFindReplaceStatus()
SCH_SHEET & Root() const
Definition: schematic.h:92
int AddItemToSel(const TOOL_EVENT &aEvent)
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
size_t GetCurrentHash() const
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...
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:126
SCH_SHEET_PATH & GetCurrentSheet() const
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593
EDA_ITEM * Front() const
Definition: selection.h:145

References _, EE_SELECTION_TOOL::AddItemToSel(), SCH_SCREENS::BuildClientSheetPathList(), SCH_EDIT_FRAME::ClearFindReplaceStatus(), EE_SELECTION_TOOL::ClearSelection(), SCH_SHEET_PATH::ComparePageNum(), ACTIONS::find, FindAndReplace(), ACTIONS::findNextMarker, EDA_DRAW_FRAME::FocusOnLocation(), FR_CURRENT_SHEET_ONLY, SELECTION::Front(), g_markersOnly, SCH_BASE_FRAME::GetCanvas(), SCH_SHEET_PATH::GetCurrentHash(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_DRAW_FRAME::GetFindReplaceData(), SCH_SHEET_PATH::GetPageNumber(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), TOOL_EVENT::IsAction(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, nextMatch(), EDA_DRAW_PANEL_GAL::Refresh(), SCHEMATIC::Root(), SCH_EDIT_FRAME::Schematic(), SCHEMATIC::SetCurrentSheet(), SCH_EDIT_FRAME::SetScreen(), SCH_EDIT_FRAME::ShowFindReplaceStatus(), SCH_SHEET_PATH::UpdateAllScreenReferences(), ACTIONS::updateFind, UpdateFind(), and SCH_EDIT_FRAME::UpdateHierarchyNavigator().

Referenced by DIALOG_SCH_FIND::OnFind(), ReplaceAndFindNext(), and 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.

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 43 of file eeschema/cross-probing.cpp.

46 {
47  SCH_SHEET_PATH* sheetWithSymbolFound = nullptr;
48  SCH_SYMBOL* symbol = nullptr;
49  wxPoint pos;
50  SCH_PIN* pin = nullptr;
51  SCH_SHEET_LIST sheetList;
52  SCH_ITEM* foundItem = nullptr;
53 
54  if( !aSearchHierarchy )
55  sheetList.push_back( m_frame->GetCurrentSheet() );
56  else
57  sheetList = m_frame->Schematic().GetSheets();
58 
59  for( SCH_SHEET_PATH& sheet : sheetList )
60  {
61  SCH_SCREEN* screen = sheet.LastScreen();
62 
63  for( auto item : screen->Items().OfType( SCH_SYMBOL_T ) )
64  {
65  SCH_SYMBOL* candidate = static_cast<SCH_SYMBOL*>( item );
66 
67  // Search by path if specified, otherwise search by reference
68  bool found = false;
69 
70  if( aPath )
71  {
72  wxString path = sheet.PathAsString() + candidate->m_Uuid.AsString();
73  found = ( *aPath == path );
74  }
75  else
76  {
77  found = ( aReference && aReference->CmpNoCase( candidate->GetRef( &sheet ) ) == 0 );
78  }
79 
80  if( found )
81  {
82  symbol = candidate;
83  sheetWithSymbolFound = &sheet;
84 
85  if( aSearchType == HIGHLIGHT_PIN )
86  {
87  // temporary: will be changed if the pin is found.
88  pos = symbol->GetPosition();
89  pin = symbol->GetPin( aSearchText );
90 
91  // Ensure we have found the right unit in case of multi-units symbol
92  if( pin )
93  {
94  int unit = pin->GetLibPin()->GetUnit();
95 
96  if( unit != 0 && unit != symbol->GetUnit() )
97  {
98  pin = nullptr;
99  continue;
100  }
101 
102  // Get pin position in true schematic coordinate
103  pos = pin->GetPosition();
104  foundItem = pin;
105  break;
106  }
107  }
108  else
109  {
110  pos = symbol->GetPosition();
111  foundItem = symbol;
112  break;
113  }
114  }
115  }
116 
117  if( foundItem )
118  break;
119  }
120 
121  CROSS_PROBING_SETTINGS& crossProbingSettings = m_frame->eeconfig()->m_CrossProbing;
122 
123 
124  if( symbol )
125  {
126  if( *sheetWithSymbolFound != m_frame->GetCurrentSheet() )
127  {
128  m_frame->Schematic().SetCurrentSheet( *sheetWithSymbolFound );
130  }
131 
132  if( crossProbingSettings.center_on_items )
133  {
134  if( crossProbingSettings.zoom_to_fit )
135  {
136  EDA_RECT bbox = symbol->GetBoundingBox();
137  wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
138  VECTOR2D screenSize = getView()->GetViewport().GetSize();
139 
140  // This code tries to come up with a zoom factor that doesn't simply zoom in
141  // to the cross probed symbol, but instead shows a reasonable amount of the
142  // circuit around it to provide context. This reduces or eliminates the need
143  // to manually change the zoom because it's too close.
144 
145  // Using the default text height as a constant to compare against, use the
146  // height of the bounding box of visible items for a footprint to figure out
147  // if this is a big symbol (like a processor) or a small symbol (like a resistor).
148  // This ratio is not useful by itself as a scaling factor. It must be "bent" to
149  // provide good scaling at varying symbol sizes. Bigger symbols need less
150  // scaling than small ones.
151  double currTextHeight = Mils2iu( DEFAULT_TEXT_SIZE );
152 
153  double compRatio = bbSize.y / currTextHeight; // Ratio of symbol to text height
154  double compRatioBent = 1.0;
155 
156  // LUT to scale zoom ratio to provide reasonable schematic context. Must work
157  // with symbols of varying sizes (e.g. 0402 package and 200 pin BGA).
158  // "first" is used as the input and "second" as the output
159  //
160  // "first" = compRatio (symbol height / default text height)
161  // "second" = Amount to scale ratio by
162  std::vector<std::pair<double, double>> lut
163  {
164  {1.25, 16}, // 32
165  {2.5, 12}, //24
166  {5, 8}, // 16
167  {6, 6}, //
168  {10, 4}, //8
169  {20, 2}, //4
170  {40, 1.5}, // 2
171  {100, 1}
172  };
173 
174  std::vector<std::pair<double, double>>::iterator it;
175 
176  // Large symbol default is last LUT entry (1:1).
177  compRatioBent = lut.back().second;
178 
179  // Use LUT to do linear interpolation of "compRatio" within "first", then
180  // use that result to linearly interpolate "second" which gives the scaling
181  // factor needed.
182  if( compRatio >= lut.front().first )
183  {
184  for( it = lut.begin(); it < lut.end() - 1; it++ )
185  {
186  if( it->first <= compRatio && next( it )->first >= compRatio )
187  {
188 
189  double diffx = compRatio - it->first;
190  double diffn = next( it )->first - it->first;
191 
192  compRatioBent = it->second
193  + ( next( it )->second - it->second ) * diffx / diffn;
194  break; // We have our interpolated value
195  }
196  }
197  }
198  else
199  {
200  compRatioBent = lut.front().second; // Small symbol default is first entry
201  }
202 
203  // This is similar to the original KiCad code that scaled the zoom to make sure
204  // symbols were visible on screen. It's simply a ratio of screen size to
205  // symbol size, and its job is to zoom in to make the component fullscreen.
206  // Earlier in the code the symbol BBox is given a 20% margin to add some
207  // breathing room. We compare the height of this enlarged symbol bbox to the
208  // default text height. If a symbol will end up with the sides clipped, we
209  // adjust later to make sure it fits on screen.
210  screenSize.x = std::max( 10.0, screenSize.x );
211  screenSize.y = std::max( 10.0, screenSize.y );
212  double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
213 
214  // Original KiCad code for how much to scale the zoom
215  double kicadRatio = std::max( fabs( bbSize.x / screenSize.x ),
216  fabs( bbSize.y / screenSize.y ) );
217 
218  // If the width of the part we're probing is bigger than what the screen width
219  // will be after the zoom, then punt and use the KiCad zoom algorithm since it
220  // guarantees the part's width will be encompassed within the screen.
221  if( bbSize.x > screenSize.x * ratio * compRatioBent )
222  {
223  // Use standard KiCad zoom for parts too wide to fit on screen/
224  ratio = kicadRatio;
225  compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio
226  wxLogTrace( "CROSS_PROBE_SCALE",
227  wxT( "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f" ),
228  ratio );
229  }
230 
231  // Now that "compRatioBent" holds our final scaling factor we apply it to the
232  // original fullscreen zoom ratio to arrive at the final ratio itself.
233  ratio *= compRatioBent;
234 
235  bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not
236 
237  // Try not to zoom on every cross-probe; it gets very noisy
238  if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
239  getView()->SetScale( getView()->GetScale() / ratio );
240  }
241 
242  m_frame->FocusOnItem( symbol );
243  }
244  }
245 
246  /* Print diag */
247  wxString msg;
248  wxString displayRef;
249 
250  if( aReference )
251  displayRef = *aReference;
252  else if( aPath )
253  displayRef = *aPath;
254 
255  if( symbol )
256  {
257  if( aSearchType == HIGHLIGHT_PIN )
258  {
259  if( foundItem )
260  msg.Printf( _( "%s pin %s found" ), displayRef, aSearchText );
261  else
262  msg.Printf( _( "%s found but pin %s not found" ), displayRef, aSearchText );
263  }
264  else
265  {
266  msg.Printf( _( "%s found" ), displayRef );
267  }
268  }
269  else
270  {
271  msg.Printf( _( "%s not found" ), displayRef );
272  }
273 
274  m_frame->SetStatusText( msg );
275 
276  m_probingPcbToSch = true; // recursion guard
277 
278  {
279  // Clear any existing highlighting
281 
282  if( foundItem )
283  m_toolMgr->RunAction( EE_ACTIONS::addItemToSel, true, foundItem );
284  }
285 
286  m_probingPcbToSch = false;
287 
288  m_frame->GetCanvas()->Refresh();
289 
290  return foundItem;
291 }
CITER next(CITER it)
Definition: ptree.cpp:126
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:512
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
int GetWidth() const
Definition: eda_rect.h:118
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
wxString AsString() const
Definition: kiid.cpp:236
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:464
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:313
EESCHEMA_SETTINGS * eeconfig() const
Cross-probing behavior.
Definition: app_settings.h:30
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCHEMATIC & Schematic() const
#define _(s)
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:33
const KIID m_Uuid
Definition: eda_item.h:474
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:552
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
Schematic symbol object.
Definition: sch_symbol.h:78
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
Definition: sch_symbol.cpp:870
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
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...
Handle the component boundary box.
Definition: eda_rect.h:42
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:126
wxPoint GetPosition() const override
Definition: sch_symbol.h:645
SCH_SHEET_PATH & GetCurrentSheet() const
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
void FocusOnItem(SCH_ITEM *aItem)
const Vec & GetSize() const
Definition: box2.h:172
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:167
int GetUnit() const
Definition: sch_symbol.h:196
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:32
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References _, EE_ACTIONS::addItemToSel, KIID::AsString(), CROSS_PROBING_SETTINGS::center_on_items, EE_ACTIONS::clearSelection, DEFAULT_TEXT_SIZE, 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(), BOX2< Vec >::GetSize(), SCH_SYMBOL::GetUnit(), TOOL_BASE::getView(), KIGFX::VIEW::GetViewport(), EDA_RECT::GetWidth(), HIGHLIGHT_PIN, EDA_RECT::Inflate(), SCH_SCREEN::Items(), APP_SETTINGS_BASE::m_CrossProbing, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_probingPcbToSch, TOOL_BASE::m_toolMgr, EDA_ITEM::m_Uuid, next(), EE_RTREE::OfType(), path, pin, EDA_DRAW_PANEL_GAL::Refresh(), TOOL_MANAGER::RunAction(), SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), SCHEMATIC::SetCurrentSheet(), KIGFX::VIEW::SetScale(), VECTOR2< T >::x, VECTOR2< T >::y, and CROSS_PROBING_SETTINGS::zoom_to_fit.

◆ GenerateBOM()

int SCH_EDITOR_CONTROL::GenerateBOM ( const TOOL_EVENT aEvent)

Definition at line 2076 of file sch_editor_control.cpp.

2077 {
2079  return 0;
2080 }
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:109

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 184 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ 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 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

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

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ 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 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ 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 133 of file tool_base.h.

134  {
135  return m_toolName;
136  }
std::string m_toolName
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

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

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

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

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:283
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

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(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), FindSymbolAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), ROUTER_TOOL::handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_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(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), ToggleHiddenFields(), ToggleHiddenPins(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_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(), UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:285

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), 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(), 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(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), 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(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), PL_POINT_EDITOR::setEditedPoint(), EE_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_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 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

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

◆ HasMatch()

bool SCH_EDITOR_CONTROL::HasMatch ( )

Definition at line 542 of file sch_editor_control.cpp.

543 {
544  wxFindReplaceData& data = m_frame->GetFindReplaceData();
546 
547  return item && item->Matches( data, &m_frame->GetCurrentSheet() );
548 }
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:364
wxFindReplaceData & GetFindReplaceData()
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
SCH_SHEET_PATH & GetCurrentSheet() const
EDA_ITEM * Front() const
Definition: selection.h:145

References SELECTION::Front(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_DRAW_FRAME::GetFindReplaceData(), EE_SELECTION_TOOL::GetSelection(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, and EDA_ITEM::Matches().

Referenced by DIALOG_SCH_FIND::OnUpdateReplaceUI().

◆ HighlightNet()

int SCH_EDITOR_CONTROL::HighlightNet ( const TOOL_EVENT aEvent)

< Highlight net under the cursor.

Remove any net highlighting

Definition at line 1035 of file sch_editor_control.cpp.

1036 {
1037  KIGFX::VIEW_CONTROLS* controls = getViewControls();
1038  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
1039 
1040  highlightNet( m_toolMgr, cursorPos );
1041 
1042  return 0;
1043 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
An interface for classes handling user events controlling the view behavior such as zooming,...
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
bool DisableGridSnapping() const
Definition: tool_event.h:341
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

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 1311 of file sch_editor_control.cpp.

1312 {
1313  // TODO(JE) remove once real-time connectivity is a given
1314  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
1316 
1317  std::string tool = aEvent.GetCommandStr().get();
1318  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1319 
1320  // Deactivate other tools; particularly important if another PICKER is currently running
1321  Activate();
1322 
1323  picker->SetCursor( KICURSOR::BULLSEYE );
1324  picker->SetSnapping( false );
1325 
1326  picker->SetClickHandler(
1327  [this] ( const VECTOR2D& aPos )
1328  {
1329  return highlightNet( m_toolMgr, aPos );
1330  } );
1331 
1332  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1333 
1334  return 0;
1335 }
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION pickerTool
Definition: actions.h:155
static bool highlightNet(TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
void SetCursor(KICURSOR aCursor)
Definition: picker_tool.h:62
void SetClickHandler(CLICK_HANDLER aHandler)
Set a handler for mouse click event.
Definition: picker_tool.h:71
static bool m_allowRealTime
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
void Activate()
Run the tool.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetSnapping(bool aSnap)
Definition: picker_tool.h:64

References TOOL_INTERACTIVE::Activate(), BULLSEYE, ADVANCED_CFG::GetCfg(), TOOL_EVENT::GetCommandStr(), TOOL_MANAGER::GetTool(), highlightNet(), CONNECTION_GRAPH::m_allowRealTime, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, NO_CLEANUP, ACTIONS::pickerTool, SCH_EDIT_FRAME::RecalculateConnections(), 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 203 of file assign_footprints.cpp.

204 {
205  wxString path = wxPathOnly( m_frame->Prj().GetProjectFullName() );
206 
207  wxFileDialog dlg( m_frame, _( "Load Symbol Footprint Link File" ),
208  path, wxEmptyString,
210  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
211 
212  if( dlg.ShowModal() == wxID_CANCEL )
213  return 0;
214 
215  wxString filename = dlg.GetPath();
216 
217  wxArrayString choices;
218  choices.Add( _( "Keep existing footprint field visibility" ) );
219  choices.Add( _( "Show all footprint fields" ) );
220  choices.Add( _( "Hide all footprint fields" ) );
221 
222  wxSingleChoiceDialog choiceDlg( m_frame, _( "Select the footprint field visibility setting." ),
223  _( "Change Visibility" ), choices );
224 
225  if( choiceDlg.ShowModal() == wxID_CANCEL )
226  return 0;
227 
228  bool forceVisibility = (choiceDlg.GetSelection() != 0 );
229  bool visibilityState = (choiceDlg.GetSelection() == 1 );
230 
231  if( !processCmpToFootprintLinkFile( filename, forceVisibility, visibilityState ) )
232  {
233  wxString msg = wxString::Format( _( "Failed to open symbol-footprint link file '%s'." ),
234  filename.GetData() );
235 
236  DisplayError( m_frame, msg );
237  return 0;
238  }
239 
240  m_frame->SyncView();
241  m_frame->GetCanvas()->Refresh();
242  m_frame->OnModify();
243  return 0;
244 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
void SyncView()
Mark all items for refresh.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxString FootprintAssignmentFileWildcard()
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool processCmpToFootprintLinkFile(const wxString &aFullFilename, bool aForceVisibilityState, bool aVisibilityState)
Read the footprint info from each line in the stuff file by reference designator.
#define _(s)
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
Definition: project.cpp:116
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
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...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...

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 bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
bool IsType(FRAME_T aType) const
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.

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
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(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ LeaveSheet()

int SCH_EDITOR_CONTROL::LeaveSheet ( const TOOL_EVENT aEvent)

Definition at line 2123 of file sch_editor_control.cpp.

2124 {
2125  if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
2126  {
2129 
2130  // Store the current zoom level into the current screen before switching
2132 
2135  }
2136 
2137  return 0;
2138 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
double m_LastZoomLevel
last value for the zoom level, useful in Eeschema when changing the current displayed sheet to reuse ...
Definition: sch_screen.h:508
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void DisplayCurrentSheet()
Draw the current sheet on the display.
Definition: hierarch.cpp:313
void pop_back()
Forwarded method from std::vector.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCHEMATIC & Schematic() const
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
SCH_SHEET & Root() const
Definition: schematic.h:92
SCH_SHEET_PATH & GetCurrentSheet() const
double GetScale() const
Definition: view.h:264

References ACTIONS::cancelInteractive, EE_ACTIONS::clearSelection, SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), KIGFX::VIEW::GetScale(), SCH_EDIT_FRAME::GetScreen(), SCH_DRAW_PANEL::GetView(), SCH_SHEET_PATH::Last(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, SCH_SCREEN::m_LastZoomLevel, TOOL_BASE::m_toolMgr, SCH_SHEET_PATH::pop_back(), SCHEMATIC::Root(), TOOL_MANAGER::RunAction(), and SCH_EDIT_FRAME::Schematic().

Referenced by setTransitions().

◆ NavigateHierarchy()

int SCH_EDITOR_CONTROL::NavigateHierarchy ( const TOOL_EVENT aEvent)

Definition at line 279 of file sch_editor_control.cpp.

280 {
282  return 0;
283 }
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.

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

Referenced by setTransitions().

◆ New()

int SCH_EDITOR_CONTROL::New ( const TOOL_EVENT aEvent)

Definition at line 69 of file sch_editor_control.cpp.

70 {
72  return 0;
73 }

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

Referenced by setTransitions().

◆ nextMatch()

SCH_ITEM * SCH_EDITOR_CONTROL::nextMatch ( SCH_SCREEN aScreen,
SCH_SHEET_PATH aSheet,
SCH_ITEM aAfter,
wxFindReplaceData &  aData 
)
private

Advance the search and returns the next matching item after aAfter.

Parameters
aScreenPointer to the screen used for searching
aAfterStarting match to compare
aDataSearch data to compare against or NULL to match the first item found
Returns
pointer to the next search item found or NULL if nothing found

Definition at line 340 of file sch_editor_control.cpp.

342 {
343  bool past_item = true;
344 
345  if( aAfter != nullptr )
346  {
347  past_item = false;
348 
349  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
350  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
351  }
352 
353  std::vector<SCH_ITEM*> sorted_items;
354 
355  for( SCH_ITEM* item : aScreen->Items() )
356  sorted_items.push_back( item );
357 
358  std::sort( sorted_items.begin(), sorted_items.end(),
359  [&]( SCH_ITEM* a, SCH_ITEM* b )
360  {
361  if( a->GetPosition().x == b->GetPosition().x )
362  {
363  // Ensure deterministic sort
364  if( a->GetPosition().y == b->GetPosition().y )
365  return a->m_Uuid < b->m_Uuid;
366 
367  return a->GetPosition().y < b->GetPosition().y;
368  }
369  else
370  return a->GetPosition().x < b->GetPosition().x;
371  }
372  );
373 
374  for( SCH_ITEM* item : sorted_items )
375  {
376  if( item == aAfter )
377  {
378  past_item = true;
379  }
380  else if( past_item )
381  {
382  if( &aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
383  return item;
384 
385  if( item->Matches( aData, aSheet ) )
386  return item;
387 
388  if( item->Type() == SCH_SYMBOL_T )
389  {
390  SCH_SYMBOL* cmp = static_cast<SCH_SYMBOL*>( item );
391 
392  for( SCH_FIELD& field : cmp->GetFields() )
393  {
394  if( field.Matches( aData, aSheet ) )
395  return &field;
396  }
397 
398  for( SCH_PIN* pin : cmp->GetPins() )
399  {
400  if( pin->Matches( aData, aSheet ) )
401  return pin;
402  }
403  }
404 
405  if( item->Type() == SCH_SHEET_T )
406  {
407  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
408 
409  for( SCH_FIELD& field : sheet->GetFields() )
410  {
411  if( field.Matches( aData, aSheet ) )
412  return &field;
413  }
414 
415  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
416  {
417  if( pin->Matches( aData, aSheet ) )
418  return pin;
419  }
420  }
421  }
422  }
423 
424  return nullptr;
425 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
static wxFindReplaceData g_markersOnly
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:741
virtual wxPoint GetPosition() const
Definition: eda_item.h:251
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:90
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
const KIID m_Uuid
Definition: eda_item.h:474
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:183
Schematic symbol object.
Definition: sch_symbol.h:78
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
Definition: sch_symbol.cpp:896
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References g_markersOnly, SCH_SHEET::GetFields(), SCH_SYMBOL::GetFields(), EDA_ITEM::GetParent(), SCH_SHEET::GetPins(), SCH_SYMBOL::GetPins(), EDA_ITEM::GetPosition(), SCH_SCREEN::Items(), EDA_ITEM::m_Uuid, pin, SCH_FIELD_T, SCH_MARKER_T, SCH_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, and EDA_ITEM::Type().

Referenced by FindNext(), and ReplaceAll().

◆ Open()

int SCH_EDITOR_CONTROL::Open ( const TOOL_EVENT aEvent)

Definition at line 76 of file sch_editor_control.cpp.

77 {
79  return 0;
80 }

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 123 of file sch_editor_control.cpp.

124 {
125  PICKED_ITEMS_LIST undoCmd;
126  DS_PROXY_UNDO_ITEM* undoItem = new DS_PROXY_UNDO_ITEM( m_frame );
127  ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS );
128 
129  undoCmd.PushItem( wrapper );
131 
134  dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
135 
136  if( dlg.ShowModal() )
137  {
138  // Update text variables
141  m_frame->GetCanvas()->Refresh();
142 
143  m_frame->OnModify();
144  }
145  else
146  {
148  }
149 
150  return 0;
151 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1482
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define MAX_PAGE_SIZE_EESCHEMA_MILS
Definition: page_info.h:41
Item needs to be redrawn.
Definition: view_item.h:52
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
A holder to handle information on schematic or board items.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
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 RollbackSchematicFromUndo()
Perform an undo of the last edit WITHOUT logging a corresponding redo.
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...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void MarkDirty()
Force redraw of view on the next rendering.
Definition: view.h:633

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 1618 of file sch_editor_control.cpp.

1619 {
1620  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1621 
1622  if( textEntry )
1623  {
1624  textEntry->Paste();
1625  return 0;
1626  }
1627 
1629  std::string content;
1630 
1631  if( aEvent.IsAction( &ACTIONS::duplicate ) )
1632  content = m_localClipboard;
1633  else
1634  content = m_toolMgr->GetClipboardUTF8();
1635 
1636  if( content.empty() )
1637  return 0;
1638 
1639  STRING_LINE_READER reader( content, "Clipboard" );
1640  SCH_SEXPR_PLUGIN plugin;
1641 
1642  SCH_SHEET tempSheet;
1643  SCH_SCREEN* tempScreen = new SCH_SCREEN( &m_frame->Schematic() );
1644 
1645  // Screen object on heap is owned by the sheet.
1646  tempSheet.SetScreen( tempScreen );
1647 
1648  try
1649  {
1650  plugin.LoadContent( reader, &tempSheet );
1651  }
1652  catch( IO_ERROR& )
1653  {
1654  // If it wasn't content, then paste as content
1655  SCH_TEXT* text_item = new SCH_TEXT( wxPoint( 0, 0 ), content );
1656  text_item->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); // Left alignment
1657  tempScreen->Append( text_item );
1658  }
1659 
1660  // Save loaded screen instances to m_clipboardSheetInstances
1661  setClipboardInstances( tempScreen );
1662 
1664 
1665  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1666  {
1667  DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
1668 
1669  if( dlg.ShowModal() == wxID_CANCEL )
1670  return 0;
1671  }
1672 
1673  bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
1674 
1675  // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1676  // else. Pull them back out to start with.
1677  //
1678  EDA_ITEMS loadedItems;
1679  bool sheetsPasted = false;
1680  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1681  SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1682  wxFileName destFn = pasteRoot.Last()->GetFileName();
1683 
1684  if( destFn.IsRelative() )
1685  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1686 
1687  // List of paths in the hierarchy that refer to the destination sheet of the paste
1688  SCH_SHEET_LIST pasteInstances = hierarchy.FindAllSheetsForScreen( pasteRoot.LastScreen() );
1689  pasteInstances.SortByPageNumbers();
1690 
1691  // Build a list of screens from the current design (to avoid loading sheets that already exist)
1692  std::map<wxString, SCH_SCREEN*> loadedScreens;
1693 
1694  for( const SCH_SHEET_PATH& item : hierarchy )
1695  {
1696  if( item.LastScreen() )
1697  loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
1698  }
1699 
1700  // Build symbol list for reannotation of duplicates
1701  SCH_REFERENCE_LIST existingRefs;
1702  hierarchy.GetSymbols( existingRefs );
1703  existingRefs.SortByReferenceOnly();
1704 
1705  // Build UUID map for fetching last-resolved-properties
1706  std::map<KIID, EDA_ITEM*> itemMap;
1707  hierarchy.FillItemMap( itemMap );
1708 
1709  // Keep track of pasted sheets and symbols for the different
1710  // paths to the hierarchy
1711  std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
1712  std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
1713 
1714  for( SCH_ITEM* item : tempScreen->Items() )
1715  {
1716  loadedItems.push_back( item );
1717 
1718  //@todo: we might want to sort the sheets by page number before adding to loadedItems
1719  if( item->Type() == SCH_SHEET_T )
1720  {
1721  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1722  wxFileName srcFn = sheet->GetFileName();
1723 
1724  if( srcFn.IsRelative() )
1725  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1726 
1727  SCH_SHEET_LIST sheetHierarchy( sheet );
1728 
1729  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1730  {
1731  auto msg = wxString::Format( _( "The pasted sheet '%s'\n"
1732  "was dropped because the destination already has "
1733  "the sheet or one of its subsheets as a parent." ),
1734  sheet->GetFileName() );
1735  DisplayError( m_frame, msg );
1736  loadedItems.pop_back();
1737  }
1738  }
1739  }
1740 
1741  // Remove the references from our temporary screen to prevent freeing on the DTOR
1742  tempScreen->Clear( false );
1743 
1744  for( unsigned i = 0; i < loadedItems.size(); ++i )
1745  {
1746  EDA_ITEM* item = loadedItems[i];
1747  KIID_PATH clipPath( wxT("/") ); // clipboard is at root
1748 
1749  if( item->Type() == SCH_SYMBOL_T )
1750  {
1751  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1752 
1753  // The library symbol gets set from the cached library symbols in the current
1754  // schematic not the symbol libraries. The cached library symbol may have
1755  // changed from the original library symbol which would cause the copy to
1756  // be incorrect.
1757  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1758 
1759  wxCHECK2( currentScreen, continue );
1760 
1761  auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1762  auto end = currentScreen->GetLibSymbols().end();
1763 
1764  if( it == end )
1765  {
1766  // If can't find library definition in the design, use the pasted library
1767  it = tempScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1768  end = tempScreen->GetLibSymbols().end();
1769  }
1770 
1771  LIB_SYMBOL* libSymbol = nullptr;
1772 
1773  if( it != end )
1774  {
1775  libSymbol = new LIB_SYMBOL( *it->second );
1776  symbol->SetLibSymbol( libSymbol );
1777  }
1778 
1779  for( SCH_SHEET_PATH& instance : pasteInstances )
1780  updatePastedSymbol( symbol, tempScreen, instance, clipPath, forceKeepAnnotations );
1781 
1782  // Assign a new KIID
1783  const_cast<KIID&>( item->m_Uuid ) = KIID();
1784 
1785  // Make sure pins get a new UUID
1786  for( SCH_PIN* pin : symbol->GetPins() )
1787  const_cast<KIID&>( pin->m_Uuid ) = KIID();
1788 
1789  for( SCH_SHEET_PATH& instance : pasteInstances )
1790  {
1791  // Ignore pseudo-symbols (e.g. power symbols) and symbols from a non-existant
1792  // library.
1793  if( libSymbol && symbol->GetRef( &instance )[0] != wxT( '#' ) )
1794  {
1795  SCH_REFERENCE schReference( symbol, libSymbol, instance );
1796  schReference.SetSheetNumber( instance.GetVirtualPageNumber() );
1797  pastedSymbols[instance].AddItem( schReference );
1798  }
1799  }
1800  }
1801  else if( item->Type() == SCH_SHEET_T )
1802  {
1803  SCH_SHEET* sheet = (SCH_SHEET*) item;
1804  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1805  wxString baseName = nameField.GetText();
1806  wxString candidateName = baseName;
1807  wxString number;
1808 
1809  while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1810  {
1811  number = baseName.Last() + number;
1812  baseName.RemoveLast();
1813  }
1814  // Update hierarchy to include any other sheets we already added, avoiding
1815  // duplicate sheet names
1816  hierarchy = m_frame->Schematic().GetSheets();
1817 
1818  //@todo: it might be better to just iterate through the sheet names
1819  // in this screen instead of the whole hierarchy.
1820  int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1821 
1822  while( hierarchy.NameExists( candidateName ) )
1823  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1824 
1825  nameField.SetText( candidateName );
1826 
1827  wxFileName fn = sheet->GetFileName();
1828  SCH_SCREEN* existingScreen = nullptr;
1829 
1830  sheet->SetParent( pasteRoot.Last() );
1831  sheet->SetScreen( nullptr );
1832 
1833  if( !fn.IsAbsolute() )
1834  {
1835  wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1836  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1837  }
1838 
1839  // Try to find the screen for the pasted sheet by several means
1840  if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1841  &existingScreen ) )
1842  {
1843  if( loadedScreens.count( sheet->GetFileName() ) > 0 )
1844  existingScreen = loadedScreens.at( sheet->GetFileName() );
1845  else
1846  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1847  }
1848 
1849  if( existingScreen )
1850  {
1851  sheet->SetScreen( existingScreen );
1852  }
1853  else
1854  {
1855  if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1856  m_frame->InitSheet( sheet, sheet->GetFileName() );
1857  }
1858 
1859  sheetsPasted = true;
1860 
1861  // Push it to the clipboard path while it still has its old KIID
1862  clipPath.push_back( sheet->m_Uuid );
1863 
1864  // Assign a new KIID to the pasted sheet
1865  const_cast<KIID&>( sheet->m_Uuid ) = KIID();
1866 
1867  // Make sure pins get a new UUID
1868  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1869  const_cast<KIID&>( pin->m_Uuid ) = KIID();
1870 
1871  // Once we have our new KIID we can update all pasted instances. This will either
1872  // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1873  for( SCH_SHEET_PATH& instance : pasteInstances )
1874  {
1875  SCH_SHEET_PATH sheetPath = updatePastedSheet( instance, clipPath, sheet,
1876  forceKeepAnnotations,
1877  &pastedSheets[instance],
1878  &pastedSymbols[instance] );
1879 
1880  sheetPath.GetSymbols( pastedSymbols[instance] );
1881  }
1882  }
1883  else
1884  {
1885  SCH_ITEM* srcItem = dynamic_cast<SCH_ITEM*>( itemMap[ item->m_Uuid ] );
1886  SCH_ITEM* destItem = dynamic_cast<SCH_ITEM*>( item );
1887 
1888  // Everything gets a new KIID
1889  const_cast<KIID&>( item->m_Uuid ) = KIID();
1890 
1891  if( srcItem && destItem )
1892  {
1893  destItem->SetConnectivityDirty( true );
1894  destItem->SetLastResolvedState( srcItem );
1895  }
1896  }
1897 
1898  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1900 
1901  // Reset flags for subsequent move operation
1902  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1903  // Start out hidden so the pasted items aren't "ghosted" in their original location
1904  // before being moved to the current location.
1905  getView()->Hide( item, true );
1906  }
1907 
1908  pasteInstances.SortByPageNumbers();
1909 
1910  if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
1911  {
1912  for( SCH_SHEET_PATH& instance : pasteInstances )
1913  {
1914  pastedSymbols[instance].SortByReferenceOnly();
1915  pastedSymbols[instance].ReannotateDuplicates( existingRefs );
1916  pastedSymbols[instance].UpdateAnnotation();
1917 
1918  // Update existing refs for next iteration
1919  for( size_t i = 0; i < pastedSymbols[instance].GetCount(); i++ )
1920  existingRefs.AddItem( pastedSymbols[instance][i] );
1921  }
1922  }
1923 
1925 
1926  if( sheetsPasted )
1927  {
1928  // Update page numbers: Find next free numeric page number
1929  for( SCH_SHEET_PATH& instance : pasteInstances )
1930  {
1931  pastedSheets[instance].SortByPageNumbers();
1932 
1933  for( SCH_SHEET_PATH& pastedSheet : pastedSheets[instance] )
1934  {
1935  int page = 1;
1936  wxString pageNum = wxString::Format( wxT( "%d" ), page );
1937 
1938  while( hierarchy.PageNumberExists( pageNum ) )
1939  pageNum = wxString::Format( wxT( "%d" ), ++page );
1940 
1941  pastedSheet.SetPageNumber( pageNum );
1942  hierarchy.push_back( pastedSheet );
1943  }
1944  }
1945 
1948  }
1949 
1950  // Now clear the previous selection, select the pasted items, and fire up the "move"
1951  // tool.
1952  //
1954  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1955 
1956  EE_SELECTION& selection = selTool->GetSelection();
1957 
1958  if( !selection.Empty() )
1959  {
1960  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1961 
1962  selection.SetReferencePoint( item->GetPosition() );
1963 
1965  }
1966 
1967  return 0;
1968 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1537
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
const wxString & GetFileName() const
Definition: sch_screen.h:145
virtual void SetLastResolvedState(const SCH_ITEM *aItem)
Definition: sch_item.h:417
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:693
#define IS_NEW
New item, just created.
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:175
void updatePastedSymbol(SCH_SYMBOL *aSymbol, SCH_SCREEN *aPasteScreen, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void InitSheet(SCH_SHEET *aSheet, const wxString &aNewFilename)
Definition: sheet.cpp:97
void AddItem(const SCH_REFERENCE &aItem)
bool searchSupplementaryClipboard(const wxString &aSheetFilename, SCH_SCREEN **aScreen)
virtual wxPoint GetPosition() const
Definition: eda_item.h:251
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:464
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
Define a library symbol object.
Definition: lib_symbol.h:96
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:280
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:122
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:115
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
void Clear(bool aFree=true)
Delete all draw items and clears the project settings.
Definition: sch_screen.cpp:228
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
EE_SELECTION & GetSelection()
Return the set of currently selected items.
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:90
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Definition: kiid.h:44
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:192
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
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
#define IS_MOVING
Item being moved.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:271
std::string GetClipboardUTF8() const
Return the information currently stored in the system clipboard.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCHEMATIC & Schematic() const
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
#define _(s)
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:451
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:506
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:314
void setClipboardInstances(const SCH_SCREEN *aPastedScreen)
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
A SCH_PLUGIN derivation for loading schematic files using the new s-expression file format.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
const KIID m_Uuid
Definition: eda_item.h:474
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:183
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
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
void LoadContent(LINE_READER &aReader, SCH_SHEET *aSheet, int aVersion=SEXPR_SCHEMATIC_FILE_VERSION)
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
std::string m_localClipboard
SCH_SHEET & Root() const
Definition: schematic.h:92
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 AddItemToScreenAndUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItem, bool aUndoAppend)
Add an item to the schematic and adds the changes to the undo/redo container.
Schematic symbol object.
Definition: sch_symbol.h:78
SCH_SCREEN * LastScreen()
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:146
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SortByReferenceOnly()
Sort the list of references by reference.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
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 SortByPageNumbers(bool aUpdateVirtualPageNums=true)
Sort the list of sheets by page number.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION move
Definition: ee_actions.h:114
virtual void SetLabelSpinStyle(LABEL_SPIN_STYLE aSpinStyle)
Set a spin or rotation angle, along with specific horizontal and vertical justification styles with e...
Definition: sch_text.cpp:330
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:240
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:75
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
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.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
static TOOL_ACTION duplicate
Definition: actions.h:71
A helper to define a symbol's reference designator in a schematic.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
Definition: sch_symbol.cpp:896
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:415
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, SCH_REFERENCE_LIST::AddItem(), EE_ACTIONS::addItemsToSel, SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_SCREEN::Append(), SCH_SCREEN::Clear(), EE_ACTIONS::clearSelection, DisplayError(), ACTIONS::duplicate, SELECTION::Empty(), SCH_SHEET_LIST::FindAllSheetsForScreen(), Format(), TOOL_MANAGER::GetClipboardUTF8(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_SHEET::GetFields(), SCH_SCREEN::GetFileName(), SCH_SHEET::GetFileName(), SCH_SCREEN::GetLibSymbols(), SCH_SHEET::GetPins(), SCH_SYMBOL::GetPins(), EDA_ITEM::GetPosition(), PROJECT::GetProjectPath(), SCH_SYMBOL::GetRef(), SCH_SYMBOL::GetSchSymbolLibraryName(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), SCHEMATIC::GetSheets(), SCH_SHEET_PATH::GetSymbols(), EDA_TEXT::GetText(), TOOL_MANAGER::GetTool(), EE_SELECTION::GetTopLeftItem(), TOOL_BASE::getView(), KIGFX::VIEW::Hide(), SCH_EDIT_FRAME::InitSheet(), IS_MOVING, IS_NEW, IS_PASTED, TOOL_EVENT::IsAction(), SCH_SCREEN::Items(), SCH_SHEET_PATH::Last(), SCH_SHEET_PATH::LastScreen(), SCH_SEXPR_PLUGIN::LoadContent(), SCH_EDIT_FRAME::LoadSheetFromFile(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, m_localClipboard, TOOL_BASE::m_toolMgr, EDA_ITEM::m_Uuid, EE_ACTIONS::move, ACTIONS::pasteSpecial, pin, KIWAY_HOLDER::Prj(), REMOVE_ANNOTATIONS, LABEL_SPIN_STYLE::RIGHT, SCHEMATIC::Root(), TOOL_MANAGER::RunAction(), SCH_SHEET_T, SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), SCH_SHEET::SearchHierarchy(), searchSupplementaryClipboard(), setClipboardInstances(), SCH_ITEM::SetConnectivityDirty(), EDA_ITEM::SetFlags(), SCH_TEXT::SetLabelSpinStyle(), SCH_ITEM::SetLastResolvedState(), SCH_SYMBOL::SetLibSymbol(), EDA_ITEM::SetParent(), SELECTION::SetReferencePoint(), SCH_SHEET::SetScreen(), SCH_REFERENCE::SetSheetNumber(), SCH_EDIT_FRAME::SetSheetNumberAndCount(), EDA_TEXT::SetText(), SHEETNAME, SCH_SHEET_LIST::SortByPageNumbers(), SCH_REFERENCE_LIST::SortByReferenceOnly(), 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 244 of file sch_editor_control.cpp.

245 {
246  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
248 
250 
251  dlg.ShowModal();
252 
253  // save project config if the prj config has changed:
254  if( dlg.PrjConfigChanged() )
256 
257  return 0;
258 }
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
static bool m_allowRealTime
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.

References ADVANCED_CFG::GetCfg(), CONNECTION_GRAPH::m_allowRealTime, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, NO_CLEANUP, DIALOG_PLOT_SCHEMATIC::PrjConfigChanged(), SCH_EDIT_FRAME::RecalculateConnections(), and SCH_EDIT_FRAME::SaveProjectSettings().

Referenced by setTransitions().

◆ Print()

int SCH_EDITOR_CONTROL::Print ( const TOOL_EVENT aEvent)

Definition at line 228 of file sch_editor_control.cpp.

229 {
230  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
232 
234 
235  wxFileName fn = m_frame->Prj().AbsolutePath( m_frame->Schematic().RootScreen()->GetFileName() );
236 
237  if( fn.GetName() != NAMELESS_PROJECT )
239 
240  return 0;
241 }
const wxString & GetFileName() const
Definition: sch_screen.h:145
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.
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:269
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCHEMATIC & Schematic() const
static bool m_allowRealTime
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:41
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117

References PROJECT::AbsolutePath(), ADVANCED_CFG::GetCfg(), SCH_SCREEN::GetFileName(), InvokeDialogPrintUsingPrinter(), CONNECTION_GRAPH::m_allowRealTime, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, NAMELESS_PROJECT, NO_CLEANUP, KIWAY_HOLDER::Prj(), SCH_EDIT_FRAME::RecalculateConnections(), 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 120 of file assign_footprints.cpp.

123 {
124  // Build a flat list of symbols in schematic:
125  SCH_REFERENCE_LIST referencesList;
126  SCH_SHEET_LIST sheetList = m_frame->Schematic().GetSheets();
127 
128  sheetList.GetSymbols( referencesList, false );
129 
130  FILE* cmpFile = wxFopen( aFullFilename, wxT( "rt" ) );
131 
132  if( cmpFile == nullptr )
133  return false;
134 
135  // cmpFileReader dtor will close cmpFile
136  FILE_LINE_READER cmpFileReader( cmpFile, aFullFilename );
137 
138  // Now, for each symbol found in file,
139  // replace footprint field value by the new value:
140  wxString reference;
141  wxString footprint;
142  wxString buffer;
143  wxString value;
144 
145  while( cmpFileReader.ReadLine() )
146  {
147  buffer = FROM_UTF8( cmpFileReader.Line() );
148 
149  if( !buffer.StartsWith( wxT( "BeginCmp" ) ) )
150  continue;
151 
152  // Begin symbol description.
153  reference.Empty();
154  footprint.Empty();
155 
156  while( cmpFileReader.ReadLine() )
157  {
158  buffer = FROM_UTF8( cmpFileReader.Line() );
159 
160  if( buffer.StartsWith( wxT( "EndCmp" ) ) )
161  break;
162 
163  // store string value, stored between '=' and ';' delimiters.
164  value = buffer.AfterFirst( '=' );
165  value = value.BeforeLast( ';' );
166  value.Trim(true);
167  value.Trim(false);
168 
169  if( buffer.StartsWith( wxT( "Reference" ) ) )
170  reference = value;
171  else if( buffer.StartsWith( wxT( "IdModule" ) ) )
172  footprint = value;
173  }
174 
175  // A block is read: initialize the footprint field of the corresponding symbol
176  // if the footprint name is not empty
177  if( reference.IsEmpty() )
178  continue;
179 
180  // Search the symbol in the flat list
181  for( unsigned ii = 0; ii < referencesList.GetCount(); ii++ )
182  {
183  if( reference == referencesList[ii].GetRef() )
184  {
185  // We have found a candidate.
186  // Note: it can be not unique (multiple units per part)
187  // So we *do not* stop the search here
188  SCH_SYMBOL* symbol = referencesList[ ii ].GetSymbol();
189  SCH_SHEET_PATH* sheetPath = &referencesList[ii].GetSheetPath();
190 
191  symbol->SetFootprint( sheetPath, footprint );
192 
193  if( aForceVisibilityState )
194  symbol->GetField( FOOTPRINT_FIELD )->SetVisible( aVisibilityState );
195  }
196  }
197  }
198 
199  return true;
200 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
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
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:705
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.
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:675
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
virtual void SetVisible(bool aVisible)
Definition: eda_text.h:206
A LINE_READER that reads from an open file.
Definition: richio.h:172
SCHEMATIC & Schematic() const
size_t GetCount() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
Schematic symbol object.
Definition: sch_symbol.h:78
Field Name Module PCB, i.e. "16DIP300".

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::SetFootprint(), and EDA_TEXT::SetVisible().

Referenced by ImportFPAssignments().

◆ Quit()

int SCH_EDITOR_CONTROL::Quit ( const TOOL_EVENT aEvent)

Definition at line 261 of file sch_editor_control.cpp.

262 {
263  m_frame->Close( false );
264  return 0;
265 }

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 1381 of file sch_editor_control.cpp.

1382 {
1383  if( m_frame->GetRedoCommandCount() == 0 )
1384  return 0;
1385 
1386  // Inform tools that undo command was issued
1388 
1389  /* Get the old list */
1391 
1392  /* Redo the command: */
1394 
1395  /* Put the old list in UndoList */
1396  list->ReversePickersListOrder();
1397  m_frame->PushCommandToUndoList( list );
1398 
1402 
1403  m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1404 
1405  m_frame->SyncView();
1406  m_frame->GetCanvas()->Refresh();
1407  m_frame->OnModify();
1408 
1409  return 0;
1410 }
void ReversePickersListOrder()
Reverse the order of pickers stored in this list.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
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 OnPageSettingsChange() override
Called when modifying the page settings.
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).
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
A holder to handle information on schematic or board items.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Global action (toolbar/main menu event, global shortcut)
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...
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Restore an undo or redo command to put data pointed by aList in the previous state.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...

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 216 of file sch_editor_control.cpp.

217 {
218  DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
219 
220  dlgRemap.ShowQuasiModal();
221 
222  m_frame->GetCanvas()->Refresh( true );
223 
224  return 0;
225 }
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
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...

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 2187 of file sch_editor_control.cpp.

2188 {
2189  int errors = 0;
2190  wxString details;
2191  bool quiet = aEvent.Parameter<bool>();
2192 
2193  // Repair duplicate IDs.
2194  std::map<KIID, EDA_ITEM*> ids;
2195  int duplicates = 0;
2196 
2197  auto processItem =
2198  [&]( EDA_ITEM* aItem )
2199  {
2200  auto it = ids.find( aItem->m_Uuid );
2201 
2202  if( it != ids.end() && it->second != aItem )
2203  {
2204  duplicates++;
2205  const_cast<KIID&>( aItem->m_Uuid ) = KIID();
2206  }
2207 
2208  ids[ aItem->m_Uuid ] = aItem;
2209  };
2210 
2211  // Symbol IDs are the most important, so give them the first crack at "claiming" a
2212  // particular KIID.
2213 
2214  for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
2215  {
2216  SCH_SCREEN* screen = sheet.LastScreen();
2217 
2218  for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_T ) )
2219  {
2220  processItem( item );
2221 
2222  for( SCH_PIN* pin : static_cast<SCH_SYMBOL*>( item )->GetPins( &sheet ) )
2223  processItem( pin );
2224  }
2225  }
2226 
2227  for( const SCH_SHEET_PATH& sheet : m_frame->Schematic().GetSheets() )
2228  {
2229  SCH_SCREEN* screen = sheet.LastScreen();
2230 
2231  for( SCH_ITEM* item : screen->Items() )
2232  {
2233  processItem( item );
2234 
2235  item->RunOnChildren(
2236  [&]( SCH_ITEM* aChild )
2237  {
2238  processItem( item );
2239  } );
2240  }
2241  }
2242 
2243  /*******************************
2244  * Your test here
2245  */
2246 
2247  /*******************************
2248  * Inform the user
2249  */
2250 
2251  if( duplicates )
2252  {
2253  errors += duplicates;
2254  details += wxString::Format( _( "%d duplicate IDs replaced.\n" ), duplicates );
2255  }
2256 
2257  if( errors )
2258  {
2259  m_frame->OnModify();
2260 
2261  wxString msg = wxString::Format( _( "%d potential problems repaired." ), errors );
2262 
2263  if( !quiet )
2264  DisplayInfoMessage( m_frame, msg, details );
2265  }
2266  else if( !quiet )
2267  {
2268  DisplayInfoMessage( m_frame, _( "No errors found." ) );
2269  }
2270 
2271  return 0;
2272 }
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:230
Definition: kiid.h:44
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
SCHEMATIC & Schematic() const
#define _(s)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
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
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:307
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

References _, DisplayInfoMessage(), Format(), SCHEMATIC::GetSheets(), SCH_SCREEN::Items(), 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().

◆ ReplaceAll()

int SCH_EDITOR_CONTROL::ReplaceAll ( const TOOL_EVENT aEvent)

Definition at line 580 of file sch_editor_control.cpp.

581 {
582  wxFindReplaceData& data = m_frame->GetFindReplaceData();
583  bool currentSheetOnly = ( data.GetFlags() & FR_CURRENT_SHEET_ONLY ) > 0;
584  bool modified = false;
585 
586  if( data.GetFindString().IsEmpty() )
587  return FindAndReplace( ACTIONS::find.MakeEvent() );
588 
589  auto doReplace =
590  [&]( SCH_ITEM* aItem, SCH_SHEET_PATH* aSheet, wxFindReplaceData& aData )
591  {
592  m_frame->SaveCopyInUndoList( aSheet->LastScreen(), aItem, UNDO_REDO::CHANGED,
593  modified );
594 
595  if( aItem->Replace( aData, aSheet ) )
596  {
597  m_frame->UpdateItem( aItem, false, true );
598  modified = true;
599  }
600  };
601 
602  if( currentSheetOnly )
603  {
604  SCH_SHEET_PATH* currentSheet = &m_frame->GetCurrentSheet();
605 
606  SCH_ITEM* item = nextMatch( m_frame->GetScreen(), currentSheet, nullptr, data );
607 
608  while( item )
609  {
610  doReplace( item, currentSheet, data );
611  item = nextMatch( m_frame->GetScreen(), currentSheet, item, data );
612  }
613  }
614  else
615  {
616  SCH_SHEET_LIST allSheets = m_frame->Schematic().GetSheets();
617  SCH_SCREENS screens( m_frame->Schematic().Root() );
618 
619  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
620  {
621  SCH_SHEET_LIST sheets = allSheets.FindAllSheetsForScreen( screen );
622 
623  for( unsigned ii = 0; ii < sheets.size(); ++ii )
624  {
625  SCH_ITEM* item = nextMatch( screen, &sheets[ii], nullptr, data );
626 
627  while( item )
628  {
629  if( ii == 0 )
630  {
631  doReplace( item, &sheets[0], data );
632  }
633  else if( item->Type() == SCH_FIELD_T )
634  {
635  SCH_FIELD* field = static_cast<SCH_FIELD*>( item );
636 
637  if( field->GetParent() && field->GetParent()->Type() == SCH_SYMBOL_T )
638  {
639  switch( field->GetId() )
640  {
641  case REFERENCE_FIELD:
642  case VALUE_FIELD:
643  case FOOTPRINT_FIELD:
644  // must be handled for each distinct sheet
645  doReplace( field, &sheets[ii], data );
646  break;
647 
648  default:
649  // handled in first iteration
650  break;
651  }
652  }
653  }
654 
655  item = nextMatch( screen, &sheets[ii], item, data );
656  }
657  }
658  }
659  }
660 
661  if( modified )
662  {
664  m_frame->OnModify();
665  }
666 
667  return 0;
668 }
Field Reference of part, i.e. "IC21".
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
int FindAndReplace(const TOOL_EVENT &aEvent)
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
int GetId() const
Definition: sch_field.h:113
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
static TOOL_ACTION find
Definition: actions.h:76
wxFindReplaceData & GetFindReplaceData()
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_ITEM * nextMatch(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aSheet, SCH_ITEM *aAfter, wxFindReplaceData &aData)
Advance the search and returns the next matching item after aAfter.
Field Value of part, i.e. "3.3K".
SCHEMATIC & Schematic() const
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
static bool Replace(const wxFindReplaceData &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
Definition: eda_item.cpp:170
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
SCH_SHEET & Root() const
Definition: schematic.h:92
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
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.
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
Field Name Module PCB, i.e. "16DIP300".

References CHANGED, ACTIONS::find, SCH_SHEET_LIST::FindAllSheetsForScreen(), FindAndReplace(), FOOTPRINT_FIELD, FR_CURRENT_SHEET_ONLY, SCH_EDIT_FRAME::GetCurrentSheet(), EDA_DRAW_FRAME::GetFindReplaceData(), SCH_FIELD::GetId(), EDA_ITEM::GetParent(), SCH_EDIT_FRAME::GetScreen(), SCHEMATIC::GetSheets(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, nextMatch(), SCH_EDIT_FRAME::OnModify(), REFERENCE_FIELD, EDA_ITEM::Replace(), SCHEMATIC::Root(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_FIELD_T, SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), EDA_ITEM::Type(), SCH_SHEET_PATH::UpdateAllScreenReferences(), SCH_BASE_FRAME::UpdateItem(), and VALUE_FIELD.

Referenced by DIALOG_SCH_FIND::OnReplace(), and setTransitions().

◆ ReplaceAndFindNext()

int SCH_EDITOR_CONTROL::ReplaceAndFindNext ( const TOOL_EVENT aEvent)

Definition at line 551 of file sch_editor_control.cpp.

552 {
553  wxFindReplaceData& data = m_frame->GetFindReplaceData();
556 
557  if( data.GetFindString().IsEmpty() )
558  return FindAndReplace( ACTIONS::find.MakeEvent() );
559 
560  if( item && item->Matches( data, sheet ) )
561  {
562  SCH_ITEM* sch_item = static_cast<SCH_ITEM*>( item );
563 
564  m_frame->SaveCopyInUndoList( sheet->LastScreen(), sch_item, UNDO_REDO::CHANGED, false );
565 
566  if( item->Replace( data, sheet ) )
567  {
568  m_frame->UpdateItem( item, false, true );
570  m_frame->OnModify();
571  }
572 
573  FindNext( ACTIONS::findNext.MakeEvent() );
574  }
575 
576  return 0;
577 }
int FindAndReplace(const TOOL_EVENT &aEvent)
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:364
int FindNext(const TOOL_EVENT &aEvent)
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
static TOOL_ACTION find
Definition: actions.h:76
wxFindReplaceData & GetFindReplaceData()
EE_SELECTION & GetSelection()
Return the set of currently selected items.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false)
Mark an item for refresh.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
static bool Replace(const wxFindReplaceData &aSearchData, wxString &aText)
Perform a text replace on aText using the find and replace criteria in aSearchData on items that supp...
Definition: eda_item.cpp:170
SCH_SCREEN * LastScreen()
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
SCH_SHEET_PATH & GetCurrentSheet() const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
static TOOL_ACTION findNext
Definition: actions.h:78
EDA_ITEM * Front() const
Definition: selection.h:145

References CHANGED, ACTIONS::find, FindAndReplace(), FindNext(), ACTIONS::findNext, SELECTION::Front(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_DRAW_FRAME::GetFindReplaceData(), EE_SELECTION_TOOL::GetSelection(), SCH_SHEET_PATH::LastScreen(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, EDA_ITEM::Matches(), SCH_EDIT_FRAME::OnModify(), EDA_ITEM::Replace(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_SHEET_PATH::UpdateAllScreenReferences(), and SCH_BASE_FRAME::UpdateItem().

Referenced by DIALOG_SCH_FIND::OnReplace(), and setTransitions().

◆ RescueLegacyProject()

bool SCH_EDITOR_CONTROL::RescueLegacyProject ( bool  aRunningOnDemand)

Definition at line 167 of file sch_editor_control.cpp.

168 {
170  m_frame->GetCanvas()->GetBackend() );
171 
172  return rescueProject( rescuer, aRunningOnDemand );
173 }
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCHEMATIC & Schematic() const
SCH_SHEET_PATH & GetCurrentSheet() const
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.

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 186 of file sch_editor_control.cpp.

187 {
188  if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
189  return false;
190 
191  if( aRescuer.GetCandidateCount() )
192  {
193  KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
194 
195  if( viewer )
196  static_cast<SYMBOL_VIEWER_FRAME*>( viewer )->ReCreateLibList();
197 
198  if( aRunningOnDemand )
199  {
200  SCH_SCREENS schematic( m_frame->Schematic().Root() );
201 
202  schematic.UpdateSymbolLinks();
204  }
205 
207  m_frame->SyncView();
208  m_frame->GetCanvas()->Refresh();
209  m_frame->OnModify();
210  }
211 
212  return true;
213 }
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:64
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
Definition: kiway_holder.h:53
void RecalculateConnections(SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:393
static bool RescueProject(wxWindow *aParent, RESCUER &aRescuer, bool aRunningOnDemand)
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
size_t GetCandidateCount()
Return the number of rescue candidates found.
SCHEMATIC & Schematic() const
SCH_SHEET & Root() const
Definition: schematic.h:92
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...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
void UpdateSymbolLinks(REPORTER *aReporter=nullptr)
Initialize the LIB_SYMBOL reference for each SCH_SYMBOL found in the full schematic.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593

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)

Definition at line 176 of file sch_editor_control.cpp.

177 {
180  m_frame->GetCanvas()->GetBackend() );
181 
182  return rescueProject( rescuer, aRunningOnDemand );
183 }
bool rescueProject(RESCUER &aRescuer, bool aRunningOnDemand)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCHEMATIC & Schematic() const
SCH_SHEET_PATH & GetCurrentSheet() const
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.

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().

◆ 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 154 of file sch_editor_control.cpp.

155 {
156  SCH_SCREENS schematic( m_frame->Schematic().Root() );
157 
158  if( schematic.HasNoFullyDefinedLibIds() )
159  RescueLegacyProject( true );
160  else
162 
163  return 0;
164 }
bool RescueLegacyProject(bool aRunningOnDemand)
bool RescueSymbolLibTableProject(bool aRunningOnDemand)
SCHEMATIC & Schematic() const
SCH_SHEET & Root() const
Definition: schematic.h:92
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:593

References 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  }
Model changes (required full reload)
Definition: tool_base.h:80
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36

◆ 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
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 83 of file sch_editor_control.cpp.

84 {
86  return 0;
87 }
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 90 of file sch_editor_control.cpp.

91 {
92  m_frame->SaveProject( true );
93  return 0;
94 }
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().

◆ saveCopyInUndoList()

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

Definition at line 134 of file ee_tool_base.h.

135  {
136  wxASSERT( aItem );
137 
138  KICAD_T itemType = aItem->Type();
139  bool selected = aItem->IsSelected();
140 
141  // IS_SELECTED flag should not be set on undo items which were added for
142  // a drag operation.
143  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
144  aItem->ClearSelected();
145 
146  if( m_isSymbolEditor )
147  {
148  SYMBOL_EDIT_FRAME* editFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
149  wxASSERT( editFrame );
150 
151  editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
152  }
153  else
154  {
155  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
156  wxASSERT( editFrame );
157 
158  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
159  {
160  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
161  static_cast<SCH_ITEM*>( aItem->GetParent() ),
162  UNDO_REDO::CHANGED, aAppend );
163  }
164  else
165  {
166  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
167  static_cast<SCH_ITEM*>( aItem ),
168  aType, aAppend );
169  }
170  }
171 
172  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
173  aItem->SetSelected();
174  }
bool IsSelected() const
Definition: eda_item.h:122
void ClearSelected()
Definition: eda_item.h:131
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:155
Schematic editor (Eeschema) main window.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetSelected()
Definition: eda_item.h:128
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.
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
#define TEMP_SELECTED
flag indicating that the structure has already selected
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
The symbol library editor main window.

◆ SaveCurrSheetCopyAs()

int SCH_EDITOR_CONTROL::SaveCurrSheetCopyAs ( const TOOL_EVENT aEvent)

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

Definition at line 97 of file sch_editor_control.cpp.

98 {
99  SCH_SHEET* curr_sheet = m_frame->GetCurrentSheet().Last();
100  wxFileName curr_fn = curr_sheet->GetFileName();
101  wxFileDialog dlg( m_frame, _( "Schematic Files" ), curr_fn.GetPath(),
102  curr_fn.GetFullName(), KiCadSchematicFileWildcard(),
103  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
104 
105  if( dlg.ShowModal() == wxID_CANCEL )
106  return false;
107 
108  wxFileName newFileName = dlg.GetPath();
109  newFileName.SetExt( KiCadSchematicFileExtension );
110 
111  m_frame->saveSchematicFile( curr_sheet, newFileName.GetFullPath() );
112  return 0;
113 }
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
wxString KiCadSchematicFileWildcard()
bool saveSchematicFile(SCH_SHEET *aSheet, const wxString &aSavePath)
Save aSheet to a schematic file.
#define _(s)
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:314
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
const std::string KiCadSchematicFileExtension
SCH_SHEET_PATH & GetCurrentSheet() const

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 1451 of file sch_editor_control.cpp.

1453 {
1454  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1455  {
1456  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1457  return true;
1458  }
1459 
1460  return false;
1461 }
std::map< wxString, SCH_SCREEN * > m_supplementaryClipboard

References m_supplementaryClipboard.

Referenced by Paste().

◆ setClipboardInstances()

void SCH_EDITOR_CONTROL::setClipboardInstances ( const SCH_SCREEN aPastedScreen)
private

Definition at line 1604 of file sch_editor_control.cpp.

1605 {
1606  m_clipboardSheetInstances.clear();
1607 
1608  for( const SCH_SHEET_INSTANCE& sheet : aPastedScreen->GetSheetInstances() )
1609  m_clipboardSheetInstances[sheet.m_Path] = sheet;
1610 
1612 
1613  for( const SYMBOL_INSTANCE_REFERENCE& symbol : aPastedScreen->GetSymbolInstances() )
1614  m_clipboardSymbolInstances[symbol.m_Path] = symbol;
1615 }
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetSymbolInstances() const
Definition: sch_screen.h:486
const std::vector< SCH_SHEET_INSTANCE > & GetSheetInstances() const
Definition: sch_screen.h:491
A simple container for schematic symbol instance information.
std::map< KIID_PATH, SCH_SHEET_INSTANCE > m_clipboardSheetInstances
std::map< KIID_PATH, SYMBOL_INSTANCE_REFERENCE > m_clipboardSymbolInstances
A simple container for sheet 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
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.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_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 2275 of file sch_editor_control.cpp.

2276 {
2277  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
2278  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
2279  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
2281  //Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveCopyAs.MakeEvent() );
2285  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
2286  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
2287  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
2288 
2291 
2300 
2305 
2306 #ifdef KICAD_SPICE
2307  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
2308  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
2309 #endif /* KICAD_SPICE */
2310 
2316 
2318 
2319  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2320  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2321  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
2322  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
2323  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
2326 
2340 
2342 
2346 
2350 
2352 
2354 }
int TogglePythonConsole(const TOOL_EVENT &aEvent)
int Save(const TOOL_EVENT &aEvent)
int EditWithSymbolEditor(const TOOL_EVENT &aEvent)
int FindAndReplace(const TOOL_EVENT &aEvent)
static TOOL_ACTION rescueSymbols
Definition: ee_actions.h:158
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:200
static TOOL_ACTION findAndReplace
Definition: actions.h:77
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:166
static TOOL_ACTION navigateHierarchy
Definition: ee_actions.h:187
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:151
static TOOL_ACTION pageSettings
Definition: actions.h:56
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:201
int Redo(const TOOL_EVENT &aEvent)
Clipboard support.
int NavigateHierarchy(const TOOL_EVENT &aEvent)
int EditSymbolFields(const TOOL_EVENT &aEvent)
static TOOL_ACTION replaceAll
Definition: actions.h:81
int ReplaceAndFindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION remapSymbols
Definition: ee_actions.h:159
int New(const TOOL_EVENT &aEvent)
int FindNext(const TOOL_EVENT &aEvent)
static TOOL_ACTION updatePcbFromSchematic
Definition: actions.h:163
int ExplicitCrossProbeToPcb(const TOOL_EVENT &aEvent)
static TOOL_ACTION print
Definition: actions.h:57
int Annotate(const TOOL_EVENT &aEvent)
int GenerateBOM(const TOOL_EVENT &aEvent)
static TOOL_ACTION find
Definition: actions.h:76
int EditSymbolLibraryLinks(const TOOL_EVENT &aEvent)
static TOOL_ACTION saveCurrSheetCopyAs
Definition: ee_actions.h:42
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:222
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).
int DrawSheetOnClipboard(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:205
int SaveAs(const TOOL_EVENT &aEvent)
int ToggleForceHV(const TOOL_EVENT &aEvent)
int HighlightNet(const TOOL_EVENT &aEvent)
< Highlight net under the cursor.
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:186
static TOOL_ACTION updateFind
Definition: actions.h:82
static TOOL_ACTION annotate
Definition: ee_actions.h:142
int EnterSheet(const TOOL_EVENT &aEvent)
int ShowPcbNew(const TOOL_EVENT &aEvent)
int Paste(const TOOL_EVENT &aEvent)
static TOOL_ACTION showPcbNew
Definition: ee_actions.h:164
static TOOL_ACTION copy
Definition: actions.h:67
int UpdatePCB(const TOOL_EVENT &aEvent)
int ShowCvpcb(const TOOL_EVENT &aEvent)
static TOOL_ACTION highlightNetTool
Definition: ee_actions.h:223
static TOOL_ACTION showBusManager
Definition: ee_actions.h:153
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:164
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:143
int LeaveSheet(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:217
int Print(const TOOL_EVENT &aEvent)
int ReplaceAll(const TOOL_EVENT &aEvent)
static TOOL_ACTION open
Definition: actions.h:50
static TOOL_ACTION explicitCrossProbe
Definition: ee_actions.h:200
static TOOL_ACTION save
Definition: actions.h:51
static TOOL_ACTION doNew
Definition: actions.h:44
int UpdateFind(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
int Plot(const TOOL_EVENT &aEvent)
static TOOL_ACTION cut
Definition: actions.h:66
static TOOL_ACTION showPythonConsole
Definition: ee_actions.h:211
int ImportFPAssignments(const TOOL_EVENT &aEvent)
static TOOL_ACTION quit
Definition: actions.h:59
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:202
static TOOL_ACTION replaceAndFindNext
Definition: actions.h:80
static TOOL_ACTION plot
Definition: actions.h:58
int ToggleHiddenPins(const TOOL_EVENT &aEvent)
int UpdateNetHighlighting(const TOOL_EVENT &aEvent)
Launch a tool to highlight nets.
int SaveCurrSheetCopyAs(const TOOL_EVENT &aEvent)
Saves the currently-open schematic sheet to an other name.
int RemapSymbols(const TOOL_EVENT &aEvent)
int Duplicate(const TOOL_EVENT &aEvent)
int AssignNetclass(const TOOL_EVENT &aEvent)
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
int Open(const TOOL_EVENT &aEvent)
static TOOL_ACTION findNextMarker
Definition: actions.h:79
static TOOL_ACTION redo
Definition: actions.h:65
int PageSetup(const TOOL_EVENT &aEvent)
int Quit(const TOOL_EVENT &aEvent)
static TOOL_ACTION saveAs
Definition: actions.h:52
static TOOL_ACTION toggleHiddenPins
Definition: ee_actions.h:196
int ShowBusManager(const TOOL_EVENT &aEvent)
int Cut(const TOOL_EVENT &aEvent)
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:165
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:152
int RescueSymbols(const TOOL_EVENT &aEvent)
Perform rescue operations to recover old projects from before certain changes were made.
int ClearHighlight(const TOOL_EVENT &aEvent)
Update net highlighting after an edit.
static TOOL_ACTION drawSheetOnClipboard
Definition: ee_actions.h:208
static TOOL_ACTION repairSchematic
Definition: ee_actions.h:212
int Undo(const TOOL_EVENT &aEvent)
static TOOL_ACTION enterSheet
Definition: ee_actions.h:185
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:221
int RepairSchematic(const TOOL_EVENT &aEvent)
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:162
static TOOL_ACTION simProbe
Definition: ee_actions.h:216
static TOOL_ACTION editLibSymbolWithLibEdit
Definition: ee_actions.h:163
static TOOL_ACTION undo
Definition: actions.h:64
static TOOL_ACTION generateBOM
Definition: ee_actions.h:167
static TOOL_ACTION highlightNet
Definition: ee_actions.h:220
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:154
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:144
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:207
int UpdateFromPCB(const TOOL_EVENT &aEvent)
static TOOL_ACTION findNext
Definition: actions.h:78
static TOOL_ACTION paste
Definition: actions.h:68
static TOOL_ACTION duplicate
Definition: actions.h:71
int ExportNetlist(const TOOL_EVENT &aEvent)
static TOOL_ACTION toggleHiddenFields
Definition: ee_actions.h:197

References Annotate(), EE_ACTIONS::annotate, EE_ACTIONS::assignFootprints, AssignNetclass(), EE_ACTIONS::assignNetclass, EVENTS::ClearedEvent, ClearHighlight(), EE_ACTIONS::clearHighlight, ACTIONS::copy, Copy(), CrossProbeToPcb(), ACTIONS::cut, Cut(), ACTIONS::doNew, DrawSheetOnClipboard(), EE_ACTIONS::drawSheetOnClipboard, ACTIONS::duplicate, Duplicate(), EE_ACTIONS::editLibSymbolWithLibEdit, EditSymbolFields(), EE_ACTIONS::editSymbolFields, EditSymbolLibraryLinks(), EE_ACTIONS::editSymbolLibraryLinks, EE_ACTIONS::editWithLibEdit, EditWithSymbolEditor(), EnterSheet(), EE_ACTIONS::enterSheet, EE_ACTIONS::explicitCrossProbe, ExplicitCrossProbeToPcb(), ExportNetlist(), EE_ACTIONS::exportNetlist, ACTIONS::find, FindAndReplace(), ACTIONS::findAndReplace, FindNext(), ACTIONS::findNext, ACTIONS::findNextMarker, GenerateBOM(), EE_ACTIONS::generateBOM, TOOL_INTERACTIVE::Go(), HighlightNet(), EE_ACTIONS::highlightNet, HighlightNetCursor(), EE_ACTIONS::highlightNetTool, ImportFPAssignments(), EE_ACTIONS::importFPAssignments, LeaveSheet(), EE_ACTIONS::leaveSheet, NavigateHierarchy(), EE_ACTIONS::navigateHierarchy, New(), Open(), ACTIONS::open, ACTIONS::pageSettings, PageSetup(), ACTIONS::paste, Paste(), ACTIONS::pasteSpecial, ACTIONS::plot, Plot(), ACTIONS::print, Print(), ACTIONS::quit, Quit(), ACTIONS::redo, Redo(), RemapSymbols(), EE_ACTIONS::remapSymbols, RepairSchematic(), EE_ACTIONS::repairSchematic, ReplaceAll(), ACTIONS::replaceAll, ReplaceAndFindNext(), ACTIONS::replaceAndFindNext, RescueSymbols(), EE_ACTIONS::rescueSymbols, Save(), ACTIONS::save, ACTIONS::saveAs, SaveAs(), EE_ACTIONS::saveCurrSheetCopyAs, SaveCurrSheetCopyAs(), EE_ACTIONS::schematicSetup, EVENTS::SelectedEvent, EVENTS::SelectedItemsModified, ShowBusManager(), EE_ACTIONS::showBusManager, ShowCvpcb(), ShowPcbNew(), EE_ACTIONS::showPcbNew, EE_ACTIONS::showPythonConsole, ShowSchematicSetup(), EE_ACTIONS::simProbe, EE_ACTIONS::simTune, ToggleForceHV(), EE_ACTIONS::toggleForceHV, ToggleHiddenFields(), EE_ACTIONS::toggleHiddenFields, ToggleHiddenPins(), EE_ACTIONS::toggleHiddenPins, TogglePythonConsole(), ACTIONS::undo, Undo(), EVENTS::UnselectedEvent, ACTIONS::updateFind, UpdateFind(), UpdateFromPCB(), UpdateNetHighlighting(), EE_ACTIONS::updateNetHighlighting, UpdatePCB(), ACTIONS::updatePcbFromSchematic, and ACTIONS::updateSchematicFromPcb.

◆ ShowBusManager()

int SCH_EDITOR_CONTROL::ShowBusManager ( const TOOL_EVENT aEvent)

Definition at line 2093 of file sch_editor_control.cpp.

2094 {
2096  return 0;
2097 }
void InvokeDialogBusManager(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BUS_MANAGER.

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

Referenced by setTransitions().

◆ ShowCvpcb()

int SCH_EDITOR_CONTROL::ShowCvpcb ( const TOOL_EVENT aEvent)

Definition at line 2015 of file sch_editor_control.cpp.

2016 {
2017  wxCommandEvent dummy;
2019  return 0;
2020 }
void OnOpenCvpcb(wxCommandEvent &event)
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72

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

Referenced by setTransitions().

◆ ShowPcbNew()

int SCH_EDITOR_CONTROL::ShowPcbNew ( const TOOL_EVENT aEvent)

Definition at line 2040 of file sch_editor_control.cpp.

2041 {
2042  wxCommandEvent dummy;
2044  return 0;
2045 }
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
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 116 of file sch_editor_control.cpp.

117 {
119  return 0;
120 }
void ShowSchematicSetupDialog(const wxString &aInitialPage=wxEmptyString)

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

Referenced by setTransitions().

◆ ToggleForceHV()

int SCH_EDITOR_CONTROL::ToggleForceHV ( const TOOL_EVENT aEvent)

◆ ToggleHiddenFields()

int SCH_EDITOR_CONTROL::ToggleHiddenFields ( const TOOL_EVENT aEvent)

Definition at line 2156 of file sch_editor_control.cpp.

2157 {
2160 
2161  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
2163 
2165  m_frame->GetCanvas()->Refresh();
2166 
2167  return 0;
2168 }
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1482
EESCHEMA_SETTINGS * eeconfig() const
Item needs to be redrawn.
Definition: view_item.h:52
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:130
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual SCH_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: sch_painter.h:139
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...

References SCH_BASE_FRAME::eeconfig(), SCH_BASE_FRAME::GetCanvas(), KIGFX::SCH_PAINTER::GetSettings(), TOOL_BASE::getView(), EESCHEMA_SETTINGS::m_Appearance, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenText, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::REPAINT, EESCHEMA_SETTINGS::APPEARANCE::show_hidden_fields, and KIGFX::VIEW::UpdateAllItems().

Referenced by setTransitions().

◆ ToggleHiddenPins()

int SCH_EDITOR_CONTROL::ToggleHiddenPins ( const TOOL_EVENT aEvent)

Definition at line 2141 of file sch_editor_control.cpp.

2142 {
2145 
2146  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
2148 
2150  m_frame->GetCanvas()->Refresh();
2151 
2152  return 0;
2153 }
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1482
EESCHEMA_SETTINGS * eeconfig() const
Item needs to be redrawn.
Definition: view_item.h:52
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:130
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual SCH_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: sch_painter.h:139
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...
bool GetShowAllPins() const override
Allow edit frame to show/hide hidden pins.

References SCH_BASE_FRAME::eeconfig(), SCH_BASE_FRAME::GetCanvas(), KIGFX::SCH_PAINTER::GetSettings(), SCH_EDIT_FRAME::GetShowAllPins(), TOOL_BASE::getView(), EESCHEMA_SETTINGS::m_Appearance, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, KIGFX::SCH_RENDER_SETTINGS::m_ShowHiddenPins, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::REPAINT, EESCHEMA_SETTINGS::APPEARANCE::show_hidden_pins, and KIGFX::VIEW::UpdateAllItems().

Referenced by setTransitions().

◆ TogglePythonConsole()

int SCH_EDITOR_CONTROL::TogglePythonConsole ( const TOOL_EVENT aEvent)

Definition at line 2179 of file sch_editor_control.cpp.

2180 {
2181 
2183  return 0;
2184 }
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 1338 of file sch_editor_control.cpp.

1339 {
1340  if( m_frame->GetUndoCommandCount() <= 0 )
1341  return 0;
1342 
1343  // Inform tools that undo command was issued
1345 
1346  // Get the old list
1348  size_t num_undos = m_frame->m_undoList.m_CommandsList.size();
1349 
1350  // The cleanup routines normally run after an operation and so attempt to append their
1351  // undo items onto the operation's list. However, in this case that's going be the list
1352  // under us, which we don't want, so we push a dummy list onto the stack.
1355 
1357 
1361 
1362  // The cleanup routines *should* have appended to our dummy list, but just to be doubly
1363  // sure pop any other new lists off the stack as well
1364  while( m_frame->m_undoList.m_CommandsList.size() > num_undos )
1365  delete m_frame->PopCommandFromUndoList();
1366 
1367  // Now push the old command to the RedoList
1368  List->ReversePickersListOrder();
1369  m_frame->PushCommandToRedoList( List );
1370 
1371  m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1372 
1373  m_frame->SyncView();
1374  m_frame->GetCanvas()->Refresh();
1375  m_frame->OnModify();
1376 
1377  return 0;
1378 }
void ReversePickersListOrder()
Reverse the order of pickers stored in this list.
UNDO_REDO_CONTAINER m_undoList
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
void OnPageSettingsChange() override
Called when modifying the page settings.
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual int GetUndoCommandCount() const
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void SyncView()
Mark all items for refresh.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
A holder to handle information on schematic or board items.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Global action (toolbar/main menu event, global shortcut)
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...
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Restore an undo or redo command to put data pointed by aList in the previous state.
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...

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().

◆ UpdateFind()

int SCH_EDITOR_CONTROL::UpdateFind ( const TOOL_EVENT aEvent)

Notifies pcbnew about the selected item.

Definition at line 286 of file sch_editor_control.cpp.

287 {
288  wxFindReplaceData& data = m_frame->GetFindReplaceData();
289 
290  auto visit =
291  [&]( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheet )
292  {
293  // We may get triggered when the dialog is not opened due to binding
294  // SelectedItemsModified we also get triggered when the find dialog is
295  // closed....so we need to double check the dialog is open.
296  if( m_frame->m_findReplaceDialog != nullptr
297  && !data.GetFindString().IsEmpty()
298  && aItem->Matches( data, aSheet ) )
299  {
300  aItem->SetForceVisible( true );
301  m_selectionTool->BrightenItem( aItem );
302  }
303  else if( aItem->IsBrightened() )
304  {
305  aItem->SetForceVisible( false );
307  }
308  };
309 
310  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
311  || aEvent.IsAction( &ACTIONS::updateFind ) )
312  {
314 
315  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
316  {
317  visit( item, &m_frame->GetCurrentSheet() );
318 
319  item->RunOnChildren(
320  [&]( SCH_ITEM* aChild )
321  {
322  visit( aChild, &m_frame->GetCurrentSheet() );
323  } );
324  }
325  }
326  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
327  {
328  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
329  visit( item, &m_frame->GetCurrentSheet() );
330  }
331 
332  getView()->UpdateItems();
333  m_frame->GetCanvas()->Refresh();
334  m_frame->UpdateTitle();
335 
336  return 0;
337 }
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:364
static TOOL_ACTION findAndReplace
Definition: actions.h:77
void UpdateTitle()
Set the main window title bar text.
bool IsBrightened() const
Definition: eda_item.h:125
static TOOL_ACTION find
Definition: actions.h:76
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:205
wxFindReplaceData & GetFindReplaceData()
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
EE_SELECTION & GetSelection()
Return the set of currently selected items.
static TOOL_ACTION updateFind
Definition: actions.h:82
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void BrightenItem(EDA_ITEM *aItem)
void SetForceVisible(bool aEnable)
Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is se...
Definition: eda_item.h:203
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
DIALOG_SCH_FIND * m_findReplaceDialog
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:179
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1402
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:362
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void UnbrightenItem(EDA_ITEM *aItem)
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:110
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...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
SCH_SHEET_PATH & GetCurrentSheet() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182

References EE_SELECTION_TOOL::BrightenItem(), EE_SELECTION_TOOL::ClearSelection(), ACTIONS::find, ACTIONS::findAndReplace, SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_DRAW_FRAME::GetFindReplaceData(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), TOOL_BASE::getView(), TOOL_EVENT::IsAction(), EDA_ITEM::IsBrightened(), SCH_SCREEN::Items(), SCH_EDIT_FRAME::m_findReplaceDialog, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_selectionTool, TOOL_EVENT::Matches(), EDA_ITEM::Matches(), EDA_DRAW_PANEL_GAL::Refresh(), EVENTS::SelectedItemsModified, EDA_ITEM::SetForceVisible(), EE_SELECTION_TOOL::UnbrightenItem(), ACTIONS::updateFind, KIGFX::VIEW::UpdateItems(), and SCH_EDIT_FRAME::UpdateTitle().

Referenced by FindAndReplace(), FindNext(), DIALOG_SCH_FIND::OnIdle(), DIALOG_SCH_FIND::OnSearchForSelect(), and setTransitions().

◆ UpdateFromPCB()

int SCH_EDITOR_CONTROL::UpdateFromPCB ( const TOOL_EVENT aEvent)

Definition at line 2056 of file sch_editor_control.cpp.

2057 {
2059  dlg.ShowModal();
2060  return 0;
2061 }

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 1165 of file sch_editor_control.cpp.

1166 {
1168  CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
1169  std::vector<EDA_ITEM*> itemsToRedraw;
1170  const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
1171 
1172  if( !screen )
1173  return 0;
1174