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 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)
 
void AssignFootprints (const std::string &aChangedSetOfReferences)
 
SCH_ITEMFindSymbolAndItem (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 1883 of file sch_editor_control.cpp.

1884 {
1885  wxCommandEvent dummy;
1886  m_frame->OnAnnotate( dummy );
1887  return 0;
1888 }
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:675
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:645
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:185
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:186
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 956 of file sch_editor_control.cpp.

957 {
960  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
961 
962  // TODO remove once real-time connectivity is a given
964  // Ensure the netlist data is up to date:
966 
967  // Remove selection in favor of highlighting so the whole net is highlighted
968  selectionTool->ClearSelection();
969  highlightNet( m_toolMgr, cursorPos );
970 
972 
973  if( conn )
974  {
975  if( !conn->IsBus()
976  && ( !conn->Driver()
979  {
980  m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
982  return 0;
983  }
984  else if( conn->IsBus() && conn->Members().size() == 0 )
985  {
986  m_frame->ShowInfoBarError( _( "Bus has no members to assign netclass to." ) );
988  return 0;
989  }
990 
991  wxArrayString netNames;
992 
993  if( conn->IsBus() )
994  {
995  for( const std::shared_ptr<SCH_CONNECTION>& member : conn->Members() )
996  {
997  if( member->IsBus() )
998  {
999  for( const std::shared_ptr<SCH_CONNECTION>& subMember : member->Members() )
1000  netNames.Add( subMember->Name() );
1001  }
1002  else
1003  {
1004  netNames.Add( member->Name() );
1005  }
1006  }
1007  }
1008  else
1009  {
1010  netNames.Add( conn->Name() );
1011  }
1012 
1013  NET_SETTINGS& netSettings = m_frame->Schematic().Prj().GetProjectFile().NetSettings();
1014  wxString netclassName = netSettings.GetNetclassName( netNames.front() );
1015 
1016  wxArrayString headers;
1017  std::vector<wxArrayString> items;
1018 
1019  headers.Add( _( "Netclasses" ) );
1020 
1021  wxArrayString defaultItem;
1022  defaultItem.Add( _( "Default" ) );
1023  items.emplace_back( defaultItem );
1024 
1025  for( const std::pair<const wxString, NETCLASSPTR>& ii : netSettings.m_NetClasses )
1026  {
1027  wxArrayString item;
1028  item.Add( ii.first );
1029  items.emplace_back( item );
1030  }
1031 
1032  EDA_LIST_DIALOG dlg( m_frame, _( "Assign Netclass" ), headers, items, netclassName );
1033  dlg.SetListLabel( _( "Select netclass:" ) );
1034 
1035  if( dlg.ShowModal() == wxID_OK )
1036  {
1037  netclassName = dlg.GetTextSelection();
1038 
1039  for( const wxString& netName : netNames )
1040  {
1041  // Remove from old netclass membership list
1042  if( netSettings.m_NetClassAssignments.count( netName ) )
1043  {
1044  const wxString oldNetclassName = netSettings.m_NetClassAssignments[netName];
1045  NETCLASSPTR oldNetclass = netSettings.m_NetClasses.Find( oldNetclassName );
1046 
1047  if( oldNetclass )
1048  oldNetclass->Remove( netName );
1049  }
1050 
1051  // Add to new netclass membership list
1052  NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName );
1053 
1054  if( newNetclass )
1055  newNetclass->Add( netName );
1056 
1057  netSettings.m_NetClassAssignments[netName] = netclassName;
1058  }
1059  }
1060  }
1061 
1063  return 0;
1064 }
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:94
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 948 of file sch_editor_control.cpp.

949 {
951 
952  return 0;
953 }
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 1386 of file sch_editor_control.cpp.

1387 {
1388  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1389 
1390  if( textEntry )
1391  {
1392  textEntry->Copy();
1393  return 0;
1394  }
1395 
1396  doCopy();
1397 
1398  return 0;
1399 }
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 579 of file sch_editor_control.cpp.

580 {
581  doCrossProbeSchToPcb( aEvent, false );
582  return 0;
583 }
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 1369 of file sch_editor_control.cpp.

1370 {
1371  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1372 
1373  if( textEntry )
1374  {
1375  textEntry->Cut();
1376  return 0;
1377  }
1378 
1379  if( doCopy() )
1381 
1382  return 0;
1383 }
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 1309 of file sch_editor_control.cpp.

1310 {
1312  EE_SELECTION& selection = selTool->RequestSelection();
1313  SCHEMATIC& schematic = m_frame->Schematic();
1314 
1315  if( !selection.GetSize() )
1316  return false;
1317 
1318  selection.SetScreen( m_frame->GetScreen() );
1319  m_supplementaryClipboard.clear();
1320 
1321  for( EDA_ITEM* item : selection )
1322  {
1323  if( item->Type() == SCH_SHEET_T )
1324  {
1325  SCH_SHEET* sheet = (SCH_SHEET*) item;
1326  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1327  }
1328  }
1329 
1330  STRING_FORMATTER formatter;
1331  SCH_SEXPR_PLUGIN plugin;
1332  SCH_SHEET_LIST hierarchy = schematic.GetSheets();
1333  SCH_SHEET_PATH selPath = m_frame->GetCurrentSheet();
1334 
1335  plugin.Format( &selection, &selPath, &hierarchy, &formatter );
1336 
1337  if( aUseLocalClipboard )
1338  {
1339  m_localClipboard = formatter.GetString();
1340  return true;
1341  }
1342 
1343  return m_toolMgr->SaveClipboard( formatter.GetString() );
1344 }
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:103
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:315
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:100
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 593 of file sch_editor_control.cpp.

594 {
595  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
596  if( m_probingPcbToSch )
597  return;
598 
600  SCH_ITEM* item = nullptr;
601  SCH_SYMBOL* symbol = nullptr;
602 
603  if( aForce )
604  {
605  EE_SELECTION& selection = selTool->RequestSelection();
606 
607  if( selection.GetSize() >= 1 )
608  item = (SCH_ITEM*) selection.Front();
609  }
610  else
611  {
612  EE_SELECTION& selection = selTool->GetSelection();
613 
614  if( selection.GetSize() >= 1 )
615  item = (SCH_ITEM*) selection.Front();
616  }
617 
618  if( !item )
619  {
620  if( aForce )
621  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
622 
623  return;
624  }
625 
626 
627  switch( item->Type() )
628  {
629  case SCH_FIELD_T:
630  case LIB_FIELD_T:
631  if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T )
632  {
633  symbol = (SCH_SYMBOL*) item->GetParent();
634  m_frame->SendMessageToPCBNEW( item, symbol );
635  }
636  break;
637 
638  case SCH_SYMBOL_T:
639  symbol = (SCH_SYMBOL*) item;
640  m_frame->SendMessageToPCBNEW( item, symbol );
641  break;
642 
643  case SCH_PIN_T:
644  symbol = (SCH_SYMBOL*) item->GetParent();
645  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), symbol );
646  break;
647 
648  case SCH_SHEET_T:
649  if( aForce )
650  m_frame->SendMessageToPCBNEW( item, nullptr );
651  break;
652 
653  default:
654  break;
655  }
656 }
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:115
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:87
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:193
EDA_ITEM * Front() const
Definition: selection.h:144

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

1960 {
1962  return 0;
1963 }
void DrawCurrentSheetToClipboard()
Use the wxWidgets print code to draw an image of the current sheet onto the clipboard.
Definition: sheet.cpp:474

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

Referenced by setTransitions().

◆ Duplicate()

int SCH_EDITOR_CONTROL::Duplicate ( const TOOL_EVENT aEvent)

Definition at line 1360 of file sch_editor_control.cpp.

1361 {
1362  doCopy( true ); // Use the local clipboard
1363  Paste( aEvent );
1364 
1365  return 0;
1366 }
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 1899 of file sch_editor_control.cpp.

1900 {
1902  dlg.ShowQuasiModal();
1903  return 0;
1904 }

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

1908 {
1910  m_frame->HardRedraw();
1911 
1912  return 0;
1913 }
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 1860 of file sch_editor_control.cpp.

1861 {
1863  EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
1864  SCH_SYMBOL* symbol = nullptr;
1865  SYMBOL_EDIT_FRAME* symbolEditor;
1866 
1867  if( selection.GetSize() >= 1 )
1868  symbol = (SCH_SYMBOL*) selection.Front();
1869 
1870  if( !symbol || symbol->GetEditFlags() != 0 )
1871  return 0;
1872 
1874  symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1875 
1876  if( symbolEditor )
1877  symbolEditor->LoadSymbolFromSchematic( symbol );
1878 
1879  return 0;
1880 }
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:382
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_FLAGS GetEditFlags() const
Definition: eda_item.h:158
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
The symbol library editor main window.

References FRAME_SCH_SYMBOL_EDITOR, EDA_ITEM::GetEditFlags(), TOOL_MANAGER::GetTool(), KIWAY_HOLDER::Kiway(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, 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 1973 of file sch_editor_control.cpp.

1974 {
1976  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1977 
1978  if( selection.GetSize() == 1 )
1979  {
1980  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1981 
1984 
1985  // Store the current zoom level into the current screen before switching
1987 
1988  m_frame->GetCurrentSheet().push_back( sheet );
1991  }
1992 
1993  return 0;
1994 }
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:481
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:285
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.
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
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(), EE_COLLECTOR::SheetsOnly, and SCH_EDIT_FRAME::UpdateHierarchyNavigator().

Referenced by setTransitions().

◆ ExplicitCrossProbeToPcb()

int SCH_EDITOR_CONTROL::ExplicitCrossProbeToPcb ( const TOOL_EVENT aEvent)

Definition at line 586 of file sch_editor_control.cpp.

587 {
588  doCrossProbeSchToPcb( aEvent, true );
589  return 0;
590 }
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 1940 of file sch_editor_control.cpp.

1941 {
1942  int result = NET_PLUGIN_CHANGE;
1943 
1944  // If a plugin is removed or added, rebuild and reopen the new dialog
1945  while( result == NET_PLUGIN_CHANGE )
1946  result = InvokeDialogNetList( m_frame );
1947 
1948  return 0;
1949 }
#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 232 of file sch_editor_control.cpp.

233 {
235  return UpdateFind( aEvent );
236 }
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 name and number are the same, we use UUIDs

Definition at line 390 of file sch_editor_control.cpp.

391 {
392  // A timer during which a subsequent FindNext will result in a wrap-around
393  static wxTimer wrapAroundTimer;
394 
395  wxFindReplaceData& data = m_frame->GetFindReplaceData();
396 
397  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
398  {
399  g_markersOnly.SetFlags( data.GetFlags() );
400 
401  data = g_markersOnly;
402  }
403  else if( data.GetFindString().IsEmpty() )
404  {
405  return FindAndReplace( ACTIONS::find.MakeEvent() );
406  }
407 
408  bool searchAllSheets = !( data.GetFlags() & FR_CURRENT_SHEET_ONLY );
409  EE_SELECTION& selection = m_selectionTool->GetSelection();
410  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
411  SCH_ITEM* item = nullptr;
412 
413  SCH_SHEET_PATH* afterSheet = &m_frame->GetCurrentSheet();
414 
415  if( wrapAroundTimer.IsRunning() )
416  {
417  afterSheet = nullptr;
418  afterItem = nullptr;
419  wrapAroundTimer.Stop();
421  }
422 
424 
425  if( afterSheet || !searchAllSheets )
426  item = nextMatch( m_frame->GetScreen(), &m_frame->GetCurrentSheet(), afterItem, data );
427 
428  if( !item && searchAllSheets )
429  {
430  SCH_SCREENS screens( m_frame->Schematic().Root() );
431  std::vector<SCH_SHEET_PATH*> paths;
432 
433  screens.BuildClientSheetPathList();
434 
435  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
436  {
437 
438  for( SCH_SHEET_PATH& sheet : screen->GetClientSheetPaths() )
439  {
440  paths.push_back( &sheet );
441  }
442  }
443 
444  std::sort( paths.begin(), paths.end(), [] ( const SCH_SHEET_PATH* lhs,
445  const SCH_SHEET_PATH* rhs ) -> bool
446  {
447  int retval = lhs->ComparePageNumAndName( *rhs );
448 
449  if( retval < 0 )
450  return true;
451  else if( retval > 0 )
452  return false;
453  else
454  return lhs->GetCurrentHash() < rhs->GetCurrentHash();
455  } );
456 
457  for( SCH_SHEET_PATH* sheet : paths )
458  {
459  if( afterSheet )
460  {
461  if( afterSheet->GetPageNumber() == sheet->GetPageNumber() )
462  afterSheet = nullptr;
463 
464  continue;
465  }
466 
467  SCH_SCREEN* screen = sheet->LastScreen();
468 
469  item = nextMatch( screen, sheet, nullptr, data );
470 
471  if( item )
472  {
473  m_frame->Schematic().SetCurrentSheet( *sheet );
475 
476  screen->TestDanglingEnds();
477 
478  m_frame->SetScreen( screen );
480  UpdateFind( ACTIONS::updateFind.MakeEvent() );
481 
482  break;
483  }
484  }
485  }
486 
487  if( item )
488  {
489  m_selectionTool->AddItemToSel( item );
490  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
491  m_frame->GetCanvas()->Refresh();
492  }
493  else
494  {
495  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
496  : _( "Reached end of sheet." );
497 
498  // Show the popup during the time period the user can wrap the search
499  m_frame->ShowFindReplaceStatus( msg + wxS( " " ) +
500  _( "Find again to wrap around to the start." ), 4000 );
501  wrapAroundTimer.StartOnce( 4000 );
502  }
503 
504  return 0;
505 }
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
int FindAndReplace(const TOOL_EVENT &aEvent)
void SetScreen(BASE_SCREEN *aScreen) override
static wxFindReplaceData g_markersOnly
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
Definition: sch_screen.cpp:978
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
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.
int ComparePageNumAndName(const SCH_SHEET_PATH &aSheetPathToTest) const
Compare sheets by their page number and then by their name.
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:177
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:193
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:557
EDA_ITEM * Front() const
Definition: selection.h:144

References _, EE_SELECTION_TOOL::AddItemToSel(), SCH_SCREENS::BuildClientSheetPathList(), SCH_EDIT_FRAME::ClearFindReplaceStatus(), EE_SELECTION_TOOL::ClearSelection(), SCH_SHEET_PATH::ComparePageNumAndName(), 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_SCREEN::TestDanglingEnds(), SCH_SHEET_PATH::UpdateAllScreenReferences(), UpdateFind(), ACTIONS::updateFind, and SCH_EDIT_FRAME::UpdateHierarchyNavigator().

Referenced by DIALOG_SCH_FIND::OnFind(), ReplaceAndFindNext(), and setTransitions().

◆ FindSymbolAndItem()

SCH_ITEM * SCH_EDITOR_CONTROL::FindSymbolAndItem ( const wxString &  aReference,
bool  aSearchHierarchy,
SCH_SEARCH_T  aSearchType,
const wxString &  aSearchText 
)

Find a symbol in the schematic and an item in this symbol.

Parameters
aReferenceThe symbol reference designator to find.
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.

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

1953 {
1955  return 0;
1956 }
int InvokeDialogCreateBOM(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BOM and return whatever DIALOG_BOM::ShowModal() returns.
Definition: dialog_bom.cpp:108

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(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_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(), 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::updateParentItem(), 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(), EE_POINT_EDITOR::setEditedPoint(), PL_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(), ROUTER_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(), SCRIPTING_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), COMMON_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(), PAD_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), DRC_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ HasMatch()

bool SCH_EDITOR_CONTROL::HasMatch ( )

Definition at line 508 of file sch_editor_control.cpp.

509 {
510  wxFindReplaceData& data = m_frame->GetFindReplaceData();
512 
513  return item && item->Matches( data, &m_frame->GetCurrentSheet() );
514 }
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:365
wxFindReplaceData & GetFindReplaceData()
EE_SELECTION & GetSelection()
Return the set of currently selected items.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:177
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
SCH_SHEET_PATH & GetCurrentSheet() const
EDA_ITEM * Front() const
Definition: selection.h:144

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

938 {
940  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
941 
942  highlightNet( m_toolMgr, cursorPos );
943 
944  return 0;
945 }
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 1213 of file sch_editor_control.cpp.

1214 {
1215  // TODO(JE) remove once real-time connectivity is a given
1216  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
1218 
1219  std::string tool = aEvent.GetCommandStr().get();
1220  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1221 
1222  // Deactivate other tools; particularly important if another PICKER is currently running
1223  Activate();
1224 
1225  picker->SetCursor( KICURSOR::BULLSEYE );
1226  picker->SetSnapping( false );
1227 
1228  picker->SetClickHandler(
1229  [this] ( const VECTOR2D& aPos )
1230  {
1231  return highlightNet( m_toolMgr, aPos );
1232  } );
1233 
1234  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1235 
1236  return 0;
1237 }
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:271
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 ( void  )
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:177
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 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 1997 of file sch_editor_control.cpp.

1998 {
1999  if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
2000  {
2003 
2004  // Store the current zoom level into the current screen before switching
2006 
2010  }
2011 
2012  return 0;
2013 }
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:481
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:285
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
void UpdateHierarchyNavigator(bool aForceUpdate=false)
Run the Hierarchy Navigator dialog.
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
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(), SCH_EDIT_FRAME::Schematic(), and SCH_EDIT_FRAME::UpdateHierarchyNavigator().

Referenced by setTransitions().

◆ NavigateHierarchy()

int SCH_EDITOR_CONTROL::NavigateHierarchy ( const TOOL_EVENT aEvent)

Definition at line 239 of file sch_editor_control.cpp.

240 {
242  return 0;
243 }
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 66 of file sch_editor_control.cpp.

67 {
69  return 0;
70 }

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

302 {
303  bool past_item = true;
304 
305  if( aAfter != nullptr )
306  {
307  past_item = false;
308 
309  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
310  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
311  }
312 
313  std::vector<SCH_ITEM*> sorted_items;
314 
315  for( SCH_ITEM* item : aScreen->Items() )
316  {
317  sorted_items.push_back( item );
318  }
319 
320  std::sort( sorted_items.begin(), sorted_items.end(),
321  [&]( SCH_ITEM* a, SCH_ITEM* b )
322  {
323  if( a->GetPosition().x == b->GetPosition().x )
324  {
325  // Ensure deterministic sort
326  if( a->GetPosition().y == b->GetPosition().y )
327  return a->m_Uuid < b->m_Uuid;
328 
329  return a->GetPosition().y < b->GetPosition().y;
330  }
331  else
332  return a->GetPosition().x < b->GetPosition().x;
333  }
334  );
335 
336  for( SCH_ITEM* item : sorted_items )
337  {
338  if( item == aAfter )
339  {
340  past_item = true;
341  }
342  else if( past_item )
343  {
344  if( &aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
345  return item;
346 
347  if( item->Matches( aData, aSheet ) )
348  return item;
349 
350  if( item->Type() == SCH_SYMBOL_T )
351  {
352  SCH_SYMBOL* cmp = static_cast<SCH_SYMBOL*>( item );
353 
354  for( SCH_FIELD& field : cmp->GetFields() )
355  {
356  if( field.Matches( aData, aSheet ) )
357  return &field;
358  }
359 
360  for( SCH_PIN* pin : cmp->GetPins() )
361  {
362  if( pin->Matches( aData, aSheet ) )
363  return pin;
364  }
365  }
366 
367  if( item->Type() == SCH_SHEET_T )
368  {
369  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
370 
371  for( SCH_FIELD& field : sheet->GetFields() )
372  {
373  if( field.Matches( aData, aSheet ) )
374  return &field;
375  }
376 
377  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
378  {
379  if( pin->Matches( aData, aSheet ) )
380  return pin;
381  }
382  }
383  }
384  }
385 
386  return nullptr;
387 }
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:711
virtual wxPoint GetPosition() const
Definition: eda_item.h:252
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:88
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
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:475
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
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:193
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:866
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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

74 {
76  return 0;
77 }

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

102 {
103  PICKED_ITEMS_LIST undoCmd;
104  DS_PROXY_UNDO_ITEM* undoItem = new DS_PROXY_UNDO_ITEM( m_frame );
105  ITEM_PICKER wrapper( m_frame->GetScreen(), undoItem, UNDO_REDO::PAGESETTINGS );
106 
107  undoCmd.PushItem( wrapper );
109 
111  dlg.SetWksFileName( BASE_SCREEN::m_DrawingSheetFileName );
112 
113  if( dlg.ShowModal() != wxID_OK )
115 
116  return 0;
117 }
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.
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.
#define MAX_PAGE_SIZE_MILS
Definition: page_info.h:41

References SCH_EDIT_FRAME::GetScreen(), BASE_SCREEN::m_DrawingSheetFileName, EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, MAX_PAGE_SIZE_MILS, PAGESETTINGS, PICKED_ITEMS_LIST::PushItem(), SCH_EDIT_FRAME::RollbackSchematicFromUndo(), SCH_EDIT_FRAME::SaveCopyInUndoList(), and DIALOG_PAGES_SETTINGS::SetWksFileName().

Referenced by setTransitions().

◆ Paste()

int SCH_EDITOR_CONTROL::Paste ( const TOOL_EVENT aEvent)

Definition at line 1517 of file sch_editor_control.cpp.

1518 {
1519  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1520 
1521  if( textEntry )
1522  {
1523  textEntry->Paste();
1524  return 0;
1525  }
1526 
1528  std::string text;
1529 
1530  if( aEvent.IsAction( &ACTIONS::duplicate ) )
1532  else
1534 
1535  if( text.empty() )
1536  return 0;
1537 
1538  STRING_LINE_READER reader( text, "Clipboard" );
1539  SCH_SEXPR_PLUGIN plugin;
1540 
1541  SCH_SHEET paste_sheet;
1542  SCH_SCREEN* paste_screen = new SCH_SCREEN( &m_frame->Schematic() );
1543 
1544  // Screen object on heap is owned by the sheet.
1545  paste_sheet.SetScreen( paste_screen );
1546 
1547  try
1548  {
1549  plugin.LoadContent( reader, &paste_sheet );
1550  }
1551  catch( IO_ERROR& )
1552  {
1553  // If it wasn't content, then paste as text
1554  SCH_TEXT* text_item = new SCH_TEXT( wxPoint( 0, 0 ), text );
1555  text_item->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); // Left alignment
1556  paste_screen->Append( text_item );
1557  }
1558 
1559  // Save loaded screen instances to m_clipboardSheetInstances
1560  setClipboardInstances( paste_screen );
1561 
1563 
1564  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1565  {
1566  DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
1567 
1568  if( dlg.ShowModal() == wxID_CANCEL )
1569  return 0;
1570  }
1571 
1572  bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
1573 
1574  // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1575  // else. Pull them back out to start with.
1576  //
1577  EDA_ITEMS loadedItems;
1578  bool sheetsPasted = false;
1579  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1580  SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1581  wxFileName destFn = pasteRoot.Last()->GetFileName();
1582 
1583  if( destFn.IsRelative() )
1584  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1585 
1586  // List of paths in the hierarchy that refer to the destination sheet of the paste
1587  SCH_SHEET_LIST pasteInstances = hierarchy.FindAllSheetsForScreen( pasteRoot.LastScreen() );
1588  pasteInstances.SortByPageNumbers();
1589 
1590  // Build a list of screens from the current design (to avoid loading sheets that already exist)
1591  std::map<wxString, SCH_SCREEN*> loadedScreens;
1592 
1593  for( const SCH_SHEET_PATH& item : hierarchy )
1594  {
1595  if( item.LastScreen() )
1596  loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
1597  }
1598 
1599  // Build symbol list for reannotation of duplicates
1600  SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets();
1601  SCH_REFERENCE_LIST existingRefs;
1602  sheets.GetSymbols( existingRefs );
1603  existingRefs.SortByReferenceOnly();
1604 
1605  // Keep track of pasted sheets and symbols for the different
1606  // paths to the hierarchy
1607  std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
1608  std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
1609 
1610  for( SCH_ITEM* item : paste_screen->Items() )
1611  {
1612  loadedItems.push_back( item );
1613 
1614  //@todo: we might want to sort the sheets by page number before adding to loadedItems
1615  if( item->Type() == SCH_SHEET_T )
1616  {
1617  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1618  wxFileName srcFn = sheet->GetFileName();
1619 
1620  if( srcFn.IsRelative() )
1621  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1622 
1623  SCH_SHEET_LIST sheetHierarchy( sheet );
1624 
1625  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1626  {
1627  auto msg = wxString::Format( _( "The pasted sheet '%s'\n"
1628  "was dropped because the destination already has "
1629  "the sheet or one of its subsheets as a parent." ),
1630  sheet->GetFileName() );
1631  DisplayError( m_frame, msg );
1632  loadedItems.pop_back();
1633  }
1634  }
1635  }
1636 
1637  // Remove the references from our temporary screen to prevent freeing on the DTOR
1638  paste_screen->Clear( false );
1639 
1640  for( unsigned i = 0; i < loadedItems.size(); ++i )
1641  {
1642  EDA_ITEM* item = loadedItems[i];
1643  KIID_PATH clipPath( wxT("/") ); // clipboard is at root
1644 
1645  if( item->Type() == SCH_SYMBOL_T )
1646  {
1647  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1648 
1649  // The library symbol gets set from the cached library symbols in the current
1650  // schematic not the symbol libraries. The cached library symbol may have
1651  // changed from the original library symbol which would cause the copy to
1652  // be incorrect.
1653  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1654 
1655  wxCHECK2( currentScreen, continue );
1656 
1657  auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1658  auto end = currentScreen->GetLibSymbols().end();
1659 
1660  if( it == end )
1661  {
1662  // If can't find library definition in the design, use the pasted library
1663  it = paste_screen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1664  end = paste_screen->GetLibSymbols().end();
1665  }
1666 
1667  LIB_SYMBOL* libSymbol = nullptr;
1668 
1669  if( it != end )
1670  {
1671  libSymbol = new LIB_SYMBOL( *it->second );
1672  symbol->SetLibSymbol( libSymbol );
1673  }
1674 
1675  for( SCH_SHEET_PATH& instance : pasteInstances )
1676  {
1677  updatePastedSymbol( symbol, paste_screen, instance, clipPath,
1678  forceKeepAnnotations );
1679  }
1680 
1681  // Assign a new KIID
1682  const_cast<KIID&>( item->m_Uuid ) = KIID();
1683 
1684  // Make sure pins get a new UUID
1685  for( SCH_PIN* pin : symbol->GetPins() )
1686  const_cast<KIID&>( pin->m_Uuid ) = KIID();
1687 
1688  for( SCH_SHEET_PATH& instance : pasteInstances )
1689  {
1690  // Ignore pseudo-symbols (e.g. power symbols) and symbols from a non-existant
1691  // library.
1692  if( libSymbol && symbol->GetRef( &instance )[0] != wxT( '#' ) )
1693  {
1694  SCH_REFERENCE schReference( symbol, libSymbol, instance );
1695  schReference.SetSheetNumber( instance.GetVirtualPageNumber() );
1696  pastedSymbols[instance].AddItem( schReference );
1697  }
1698  }
1699  }
1700  else if( item->Type() == SCH_SHEET_T )
1701  {
1702  SCH_SHEET* sheet = (SCH_SHEET*) item;
1703  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1704  wxString baseName = nameField.GetText();
1705  wxString candidateName = baseName;
1706  wxString number;
1707 
1708  while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1709  {
1710  number = baseName.Last() + number;
1711  baseName.RemoveLast();
1712  }
1713  // Update hierarchy to include any other sheets we already added, avoiding
1714  // duplicate sheet names
1715  hierarchy = m_frame->Schematic().GetSheets();
1716 
1717  //@todo: it might be better to just iterate through the sheet names
1718  // in this screen instead of the whole hierarchy.
1719  int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1720 
1721  while( hierarchy.NameExists( candidateName ) )
1722  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1723 
1724  nameField.SetText( candidateName );
1725 
1726  wxFileName fn = sheet->GetFileName();
1727  SCH_SCREEN* existingScreen = nullptr;
1728 
1729  sheet->SetParent( pasteRoot.Last() );
1730  sheet->SetScreen( nullptr );
1731 
1732  if( !fn.IsAbsolute() )
1733  {
1734  wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1735  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1736  }
1737 
1738  // Try to find the screen for the pasted sheet by several means
1739  if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1740  &existingScreen ) )
1741  {
1742  if( loadedScreens.count( sheet->GetFileName() ) > 0 )
1743  existingScreen = loadedScreens.at( sheet->GetFileName() );
1744  else
1745  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1746  }
1747 
1748  if( existingScreen )
1749  {
1750  sheet->SetScreen( existingScreen );
1751  }
1752  else
1753  {
1754  if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1755  m_frame->InitSheet( sheet, sheet->GetFileName() );
1756  }
1757 
1758  sheetsPasted = true;
1759 
1760  // Push it to the clipboard path while it still has its old KIID
1761  clipPath.push_back( sheet->m_Uuid );
1762 
1763  // Assign a new KIID to the pasted sheet
1764  const_cast<KIID&>( sheet->m_Uuid ) = KIID();
1765 
1766  // Make sure pins get a new UUID
1767  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1768  const_cast<KIID&>( pin->m_Uuid ) = KIID();
1769 
1770  // Once we have our new KIID we can update all pasted instances. This will either
1771  // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1772  for( SCH_SHEET_PATH& instance : pasteInstances )
1773  {
1774  SCH_SHEET_PATH sheetPath = updatePastedSheet( instance, clipPath, sheet,
1775  forceKeepAnnotations,
1776  &pastedSheets[instance],
1777  &pastedSymbols[instance] );
1778 
1779  sheetPath.GetSymbols( pastedSymbols[instance] );
1780  }
1781  }
1782  else
1783  {
1784  // Everything gets a new KIID
1785  const_cast<KIID&>( item->m_Uuid ) = KIID();
1786  }
1787 
1788  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1790 
1791  // Reset flags for subsequent move operation
1792  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1793  // Start out hidden so the pasted items aren't "ghosted" in their original location
1794  // before being moved to the current location.
1795  getView()->Hide( item, true );
1796  }
1797 
1798  pasteInstances.SortByPageNumbers();
1799 
1800  if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
1801  {
1802  for( SCH_SHEET_PATH& instance : pasteInstances )
1803  {
1804  pastedSymbols[instance].SortByReferenceOnly();
1805  pastedSymbols[instance].ReannotateDuplicates( existingRefs );
1806  pastedSymbols[instance].UpdateAnnotation();
1807 
1808  // Update existing refs for next iteration
1809  for( size_t i = 0; i < pastedSymbols[instance].GetCount(); i++ )
1810  existingRefs.AddItem( pastedSymbols[instance][i] );
1811  }
1812  }
1813 
1815 
1816  if( sheetsPasted )
1817  {
1818  // Update page numbers: Find next free numeric page number
1819  for( SCH_SHEET_PATH& instance : pasteInstances )
1820  {
1821  pastedSheets[instance].SortByPageNumbers();
1822 
1823  for( SCH_SHEET_PATH& pastedSheet : pastedSheets[instance] )
1824  {
1825  int page = 1;
1826  wxString pageNum = wxString::Format( "%d", page );
1827 
1828  while( hierarchy.PageNumberExists( pageNum ) )
1829  pageNum = wxString::Format( "%d", ++page );
1830 
1831  pastedSheet.SetPageNumber( pageNum );
1832  hierarchy.push_back( pastedSheet );
1833  }
1834  }
1835 
1838  }
1839 
1840  // Now clear the previous selection, select the pasted items, and fire up the "move"
1841  // tool.
1842  //
1844  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1845 
1846  EE_SELECTION& selection = selTool->GetSelection();
1847 
1848  if( !selection.Empty() )
1849  {
1850  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1851 
1852  selection.SetReferencePoint( item->GetPosition() );
1854  }
1855 
1856  return 0;
1857 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:271
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1485
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
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:635
#define IS_NEW
New item, just created.
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.
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:60
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:156
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:153
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:252
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:441
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:257
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:116
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:226
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:88
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:186
#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:114
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:248
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:424
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:507
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
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:315
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:97
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:475
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
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:144
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:100
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION move
Definition: ee_actions.h:110
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:319
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:193
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:133
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:866
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

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(), SCH_SHEET_LIST::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(), EDA_ITEM::SetFlags(), SCH_TEXT::SetLabelSpinStyle(), 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(), text, 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 207 of file sch_editor_control.cpp.

208 {
210 
211  dlg.ShowModal();
212 
213  // save project config if the prj config has changed:
214  if( dlg.PrjConfigChanged() )
216 
217  return 0;
218 }
void SaveProjectSettings() override
Save changes to the project settings to the project (.pro) file.

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

Referenced by setTransitions().

◆ Print()

int SCH_EDITOR_CONTROL::Print ( const TOOL_EVENT aEvent)

Definition at line 194 of file sch_editor_control.cpp.

195 {
197 
198  wxFileName fn = m_frame->Prj().AbsolutePath( m_frame->Schematic().RootScreen()->GetFileName() );
199 
200  if( fn.GetName() != NAMELESS_PROJECT )
202 
203  return 0;
204 }
const wxString & GetFileName() const
Definition: sch_screen.h:145
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
#define NAMELESS_PROJECT
default name for nameless projects
Definition: project.h:41
SCH_SCREEN * RootScreen() const
Helper to retrieve the screen of the root sheet.
Definition: schematic.cpp:117

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

Referenced by setTransitions().

◆ processCmpToFootprintLinkFile()

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

Read the footprint info from each line in the stuff file by reference designator.

The footprint link file (.cmp) entries created by CvPcb:

BeginCmp TimeStamp = /32307DE2/AA450F67; Reference = C1; ValeurCmp = 47uF; IdModule = CP6; EndCmp

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

Definition at line 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:675
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:645
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:185
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 221 of file sch_editor_control.cpp.

222 {
223  m_frame->Close( false );
224  return 0;
225 }

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

1278 {
1279  if( m_frame->GetRedoCommandCount() == 0 )
1280  return 0;
1281 
1282  // Inform tools that undo command was issued
1284 
1285  /* Get the old list */
1287 
1288  /* Redo the command: */
1290 
1291  /* Put the old list in UndoList */
1292  list->ReversePickersListOrder();
1293  m_frame->PushCommandToUndoList( list );
1294 
1298 
1299  m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1300 
1301  m_frame->SyncView();
1302  m_frame->GetCanvas()->Refresh();
1303  m_frame->OnModify();
1304 
1305  return 0;
1306 }
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 182 of file sch_editor_control.cpp.

183 {
184  DIALOG_SYMBOL_REMAP dlgRemap( m_frame );
185 
186  dlgRemap.ShowQuasiModal();
187 
188  m_frame->GetCanvas()->Refresh( true );
189 
190  return 0;
191 }
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().

◆ ReplaceAll()

int SCH_EDITOR_CONTROL::ReplaceAll ( const TOOL_EVENT aEvent)

Definition at line 542 of file sch_editor_control.cpp.

543 {
544  wxFindReplaceData& data = m_frame->GetFindReplaceData();
545  bool modified = false;
546 
547  if( data.GetFindString().IsEmpty() )
548  return FindAndReplace( ACTIONS::find.MakeEvent() );
549 
550  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
551  SCH_SCREENS screens( m_frame->Schematic().Root() );
552 
553  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
554  {
555  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
556 
557  for( EDA_ITEM* item = nextMatch( screen, sheet, nullptr, data ); item; )
558  {
559  if( item->Replace( data, sheet ) )
560  {
561  m_frame->UpdateItem( item );
562  modified = true;
563  }
564 
565  item = nextMatch( screen, sheet, dynamic_cast<SCH_ITEM*>( item ), data );
566  }
567  }
568 
569  if( modified )
570  {
572  m_frame->OnModify();
573  }
574 
575  return 0;
576 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
int FindAndReplace(const TOOL_EVENT &aEvent)
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
SCH_SHEET_PATH * FindSheetForScreen(const SCH_SCREEN *aScreen)
Return a pointer to the first SCH_SHEET_PATH object (not necessarily the only one) using a particular...
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
static TOOL_ACTION find
Definition: actions.h:76
wxFindReplaceData & GetFindReplaceData()
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.
SCHEMATIC & Schematic() 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
SCH_SHEET & Root() const
Definition: schematic.h:92
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
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...
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:557

References ACTIONS::find, FindAndReplace(), SCH_SHEET_LIST::FindSheetForScreen(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_DRAW_FRAME::GetFindReplaceData(), SCHEMATIC::GetSheets(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, nextMatch(), SCH_EDIT_FRAME::OnModify(), SCHEMATIC::Root(), SCH_EDIT_FRAME::Schematic(), SCH_SHEET_PATH::UpdateAllScreenReferences(), and SCH_BASE_FRAME::UpdateItem().

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

◆ ReplaceAndFindNext()

int SCH_EDITOR_CONTROL::ReplaceAndFindNext ( const TOOL_EVENT aEvent)

Definition at line 517 of file sch_editor_control.cpp.

518 {
519  wxFindReplaceData& data = m_frame->GetFindReplaceData();
522 
523  if( data.GetFindString().IsEmpty() )
524  return FindAndReplace( ACTIONS::find.MakeEvent() );
525 
526  if( item && item->Matches( data, sheet ) )
527  {
528  if( item->Replace( data, sheet ) )
529  {
530  m_frame->UpdateItem( item );
532  m_frame->OnModify();
533  }
534 
535  FindNext( ACTIONS::findNext.MakeEvent() );
536  }
537 
538  return 0;
539 }
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:365
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
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.
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:177
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:145
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
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...
static TOOL_ACTION findNext
Definition: actions.h:78
EDA_ITEM * Front() const
Definition: selection.h:144

References ACTIONS::find, FindAndReplace(), FindNext(), ACTIONS::findNext, 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, EDA_ITEM::Matches(), SCH_EDIT_FRAME::OnModify(), EDA_ITEM::Replace(), 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 133 of file sch_editor_control.cpp.

134 {
136  m_frame->GetCanvas()->GetBackend() );
137 
138  return rescueProject( rescuer, aRunningOnDemand );
139 }
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 152 of file sch_editor_control.cpp.

153 {
154  if( !RESCUER::RescueProject( m_frame, aRescuer, aRunningOnDemand ) )
155  return false;
156 
157  if( aRescuer.GetCandidateCount() )
158  {
159  KIWAY_PLAYER* viewer = m_frame->Kiway().Player( FRAME_SCH_VIEWER, false );
160 
161  if( viewer )
162  static_cast<SYMBOL_VIEWER_FRAME*>( viewer )->ReCreateLibList();
163 
164  if( aRunningOnDemand )
165  {
166  SCH_SCREENS schematic( m_frame->Schematic().Root() );
167 
168  schematic.UpdateSymbolLinks();
170  }
171 
173  m_frame->SyncView();
174  m_frame->GetCanvas()->Refresh();
175  m_frame->OnModify();
176  }
177 
178  return true;
179 }
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:382
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:557

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

143 {
146  m_frame->GetCanvas()->GetBackend() );
147 
148  return rescueProject( rescuer, aRunningOnDemand );
149 }
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 120 of file sch_editor_control.cpp.

121 {
122  SCH_SCREENS schematic( m_frame->Schematic().Root() );
123 
124  if( schematic.HasNoFullyDefinedLibIds() )
125  RescueLegacyProject( true );
126  else
128 
129  return 0;
130 }
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:557

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

81 {
83  return 0;
84 }
bool SaveProject(bool aSaveAs=false)
Saves 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 87 of file sch_editor_control.cpp.

88 {
89  m_frame->SaveProject( true );
90  return 0;
91 }
bool SaveProject(bool aSaveAs=false)
Saves 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  KICAD_T itemType = aItem->Type();
137  bool selected = aItem->IsSelected();
138 
139  // IS_SELECTED flag should not be set on undo items which were added for
140  // a drag operation.
141  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
142  aItem->ClearSelected();
143 
144  if( m_isSymbolEditor )
145  {
146  SYMBOL_EDIT_FRAME* editFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
147  wxASSERT( editFrame );
148 
149  editFrame->SaveCopyInUndoList( static_cast<LIB_ITEM*>( aItem ), aType, aAppend );
150  }
151  else
152  {
153  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
154  wxASSERT( editFrame );
155 
156  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
157  {
158  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
159  static_cast<SCH_ITEM*>( aItem->GetParent() ),
160  UNDO_REDO::CHANGED, aAppend );
161  }
162  else
163  {
164  editFrame->SaveCopyInUndoList( editFrame->GetScreen(),
165  static_cast<SCH_ITEM*>( aItem ),
166  aType, aAppend );
167  }
168  }
169 
170  if( selected && aItem->HasFlag( TEMP_SELECTED ) )
171  aItem->SetSelected();
172  }
bool IsSelected() const
Definition: eda_item.h:123
void ClearSelected()
Definition: eda_item.h:132
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:156
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:129
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:115
#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:113
The symbol library editor main window.

◆ searchSupplementaryClipboard()

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

Definition at line 1347 of file sch_editor_control.cpp.

1349 {
1350  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1351  {
1352  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1353  return true;
1354  }
1355 
1356  return false;
1357 }
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 1503 of file sch_editor_control.cpp.

1504 {
1505  m_clipboardSheetInstances.clear();
1506 
1507  for( const SCH_SHEET_INSTANCE& sheet : aPastedScreen->GetSheetInstances() )
1508  m_clipboardSheetInstances[sheet.m_Path] = sheet;
1509 
1511 
1512  for( const SYMBOL_INSTANCE_REFERENCE& symbol : aPastedScreen->GetSymbolInstances() )
1513  m_clipboardSymbolInstances[symbol.m_Path] = symbol;
1514 }
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetSymbolInstances() const
Definition: sch_screen.h:459
const std::vector< SCH_SHEET_INSTANCE > & GetSheetInstances() const
Definition: sch_screen.h:464
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 2062 of file sch_editor_control.cpp.

2063 {
2064  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
2065  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
2066  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
2071  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
2072  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
2073  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
2074 
2077 
2086 
2091 
2092 #ifdef KICAD_SPICE
2093  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
2094  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
2095 #endif /* KICAD_SPICE */
2096 
2102 
2104 
2105  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2106  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2107  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
2108  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
2109  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
2112 
2125 
2127 
2131 
2135 
2137 }
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:154
int Copy(const TOOL_EVENT &aEvent)
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
static TOOL_ACTION findAndReplace
Definition: actions.h:77
static TOOL_ACTION exportNetlist
Definition: ee_actions.h:161
static TOOL_ACTION navigateHierarchy
Definition: ee_actions.h:182
int ShowSchematicSetup(const TOOL_EVENT &aEvent)
int HighlightNetCursor(const TOOL_EVENT &aEvent)
static TOOL_ACTION assignFootprints
Definition: ee_actions.h:147
static TOOL_ACTION pageSettings
Definition: actions.h:56
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:200
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:155
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)
int CrossProbeToPcb(const TOOL_EVENT &aEvent)
Equivalent to the above, but initiated by the user.
static TOOL_ACTION updateNetHighlighting
Definition: ee_actions.h:216
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:204
int SaveAs(const TOOL_EVENT &aEvent)
static TOOL_ACTION saveCopyAs
Definition: actions.h:53
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:181
static TOOL_ACTION updateFind
Definition: actions.h:82
static TOOL_ACTION annotate
Definition: ee_actions.h:138
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:159
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:217
static TOOL_ACTION showBusManager
Definition: ee_actions.h:149
static TOOL_ACTION updateSchematicFromPcb
Definition: actions.h:164
static TOOL_ACTION editSymbolFields
Definition: ee_actions.h:139
int LeaveSheet(const TOOL_EVENT &aEvent)
int ToggleHiddenFields(const TOOL_EVENT &aEvent)
static TOOL_ACTION simTune
Definition: ee_actions.h:211
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:195
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:206
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:201
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 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:191
int ShowBusManager(const TOOL_EVENT &aEvent)
int Cut(const TOOL_EVENT &aEvent)
static TOOL_ACTION importFPAssignments
Definition: ee_actions.h:160
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:148
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:203
int Undo(const TOOL_EVENT &aEvent)
static TOOL_ACTION enterSheet
Definition: ee_actions.h:180
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:215
static TOOL_ACTION editWithLibEdit
Definition: ee_actions.h:158
static TOOL_ACTION simProbe
Definition: ee_actions.h:210
static TOOL_ACTION undo
Definition: actions.h:64
static TOOL_ACTION generateBOM
Definition: ee_actions.h:162
static TOOL_ACTION highlightNet
Definition: ee_actions.h:214
static TOOL_ACTION schematicSetup
Definition: ee_actions.h:150
static TOOL_ACTION editSymbolLibraryLinks
Definition: ee_actions.h:140
static TOOL_ACTION toggleForceHV
Definition: ee_actions.h:202
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:192

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(), 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, Plot(), ACTIONS::plot, Print(), ACTIONS::print, Quit(), ACTIONS::quit, ACTIONS::redo, Redo(), RemapSymbols(), EE_ACTIONS::remapSymbols, ReplaceAll(), ACTIONS::replaceAll, ReplaceAndFindNext(), ACTIONS::replaceAndFindNext, RescueSymbols(), EE_ACTIONS::rescueSymbols, Save(), ACTIONS::save, ACTIONS::saveAs, SaveAs(), ACTIONS::saveCopyAs, 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, UpdateFind(), ACTIONS::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 1966 of file sch_editor_control.cpp.

1967 {
1969  return 0;
1970 }
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 1891 of file sch_editor_control.cpp.

1892 {
1893  wxCommandEvent dummy;
1895  return 0;
1896 }
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 1916 of file sch_editor_control.cpp.

1917 {
1918  wxCommandEvent dummy;
1920  return 0;
1921 }
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 94 of file sch_editor_control.cpp.

95 {
97  return 0;
98 }
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 2031 of file sch_editor_control.cpp.

2032 {
2035 
2036  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
2038 
2040  m_frame->GetCanvas()->Refresh();
2041 
2042  return 0;
2043 }
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1430
EESCHEMA_SETTINGS * eeconfig() const
Item needs to be redrawn.
Definition: view_item.h:57
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:134
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:143
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 2016 of file sch_editor_control.cpp.

2017 {
2020 
2021  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
2023 
2025  m_frame->GetCanvas()->Refresh();
2026 
2027  return 0;
2028 }
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1430
EESCHEMA_SETTINGS * eeconfig() const
Item needs to be redrawn.
Definition: view_item.h:57
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:134
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:143
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 2054 of file sch_editor_control.cpp.

2055 {
2056 
2058  return 0;
2059 }
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 1240 of file sch_editor_control.cpp.

1241 {
1242  if( m_frame->GetUndoCommandCount() <= 0 )
1243  return 0;
1244 
1245  // Inform tools that undo command was issued
1247 
1248  /* Get the old list */
1250  size_t num_undos = m_frame->m_undoList.m_CommandsList.size();
1251 
1252  /* Undo the command */
1254 
1258 
1259  // If we modified anything during cleanup we don't want it going on the undolist
1260  while( m_frame->m_undoList.m_CommandsList.size() > num_undos )
1261  delete m_frame->PopCommandFromUndoList();
1262 
1263  // Now push the old command to the RedoList
1264  List->ReversePickersListOrder();
1265  m_frame->PushCommandToRedoList( List );
1266 
1267  m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1268 
1269  m_frame->SyncView();
1270  m_frame->GetCanvas()->Refresh();
1271  m_frame->OnModify();
1272 
1273  return 0;
1274 }
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
void OnPageSettingsChange() override
Called when modifying the page settings.
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, 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(), 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 246 of file sch_editor_control.cpp.

247 {
248  wxFindReplaceData& data = m_frame->GetFindReplaceData();
249 
250  auto visit =
251  [&]( EDA_ITEM* aItem, SCH_SHEET_PATH* aSheet )
252  {
253  // We may get triggered when the dialog is not opened due to binding
254  // SelectedItemsModified we also get triggered when the find dialog is
255  // closed....so we need to double check the dialog is open.
256  if( m_frame->m_findReplaceDialog != nullptr
257  && !data.GetFindString().IsEmpty()
258  && aItem->Matches( data, aSheet ) )
259  {
260  aItem->SetForceVisible( true );
261  m_selectionTool->BrightenItem( aItem );
262  }
263  else if( aItem->IsBrightened() )
264  {
265  aItem->SetForceVisible( false );
267  }
268  };
269 
270  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
271  || aEvent.IsAction( &ACTIONS::updateFind ) )
272  {
274 
275  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
276  {
277  visit( item, &m_frame->GetCurrentSheet() );
278 
279  item->RunOnChildren(
280  [&]( SCH_ITEM* aChild )
281  {
282  visit( aChild, &m_frame->GetCurrentSheet() );
283  } );
284  }
285  }
286  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
287  {
288  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
289  visit( item, &m_frame->GetCurrentSheet() );
290  }
291 
292  getView()->UpdateItems();
293  m_frame->GetCanvas()->Refresh();
294  m_frame->UpdateTitle();
295 
296  return 0;
297 }
virtual bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:365
static TOOL_ACTION findAndReplace
Definition: actions.h:77
void UpdateTitle()
Set the main window title bar text.
bool IsBrightened() const
Definition: eda_item.h:126
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:204
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:204
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:177
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1412
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:100
SCH_SHEET_PATH & GetCurrentSheet() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193

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

1933 {
1935  dlg.ShowModal();
1936  return 0;
1937 }

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

1068 {
1070  CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
1071  std::vector<EDA_ITEM*> itemsToRedraw;
1072  const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
1073 
1074  if( !screen )
1075  return 0;
1076 
1077  bool selectedIsBus = selectedConn ? selectedConn->IsBus() : false;
1078  wxString selectedName = selectedConn ? selectedConn->Name() : "";
1079 
1080  bool selectedIsNoNet = false;
1081  CONNECTION_SUBGRAPH* selectedSubgraph = nullptr;
1082 
1083  if( selectedConn && selectedConn->Driver() == nullptr )
1084  {
1085  selectedIsNoNet = true;
1086  selectedSubgraph = connectionGraph->GetSubgraphForItem( selectedConn->Parent() );
1087  }
1088 
1089  for( SCH_ITEM* item : screen->Items() )
1090  {
1091  SCH_CONNECTION* itemConn = nullptr;
1092  SCH_SYMBOL* symbol = nullptr;
1093  bool redraw = item->IsBrightened();
1094  bool highlight = false;
1095 
1096  if( item->Type() == SCH_SYMBOL_T )
1097  symbol = static_cast<SCH_SYMBOL*>( item );
1098 
1099  if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
1100  itemConn = symbol->Connection();
1101  else
1102  itemConn = item->Connection();
1103 
1104  if( selectedIsNoNet && selectedSubgraph )
1105  {
1106  for( SCH_ITEM* subgraphItem : selectedSubgraph->m_items )
1107  {
1108  if( item == subgraphItem )
1109  {
1110  highlight = true;
1111  break;
1112  }
1113  }
1114  }
1115  else if( selectedIsBus && itemConn && itemConn->IsNet() )
1116  {
1117  for( const std::shared_ptr<SCH_CONNECTION>& member : selectedConn->Members() )
1118  {
1119  if( member->Name() == itemConn->Name() )
1120  {
1121  highlight = true;
1122  break;
1123  }
1124  else if( member->IsBus() )
1125  {
1126  for( const std::shared_ptr<SCH_CONNECTION>& child_member : member->Members() )
1127  {
1128  if( child_member->Name() == itemConn->Name() )
1129  {
1130  highlight = true;
1131  break;
1132  }
1133  }
1134  }
1135  }
1136  }
1137  else if( selectedConn && itemConn && selectedName == itemConn->Name() )
1138  {
1139  highlight = true;
1140  }
1141 
1142  if( highlight )
1143  item->SetBrightened();
1144  else
1145  item->ClearBrightened();
1146 
1147  redraw |= item->IsBrightened();
1148 
1149  // symbol is only non-null if the item is a SCH_SYMBOL_T
1150  if( symbol )
1151  {
1152  redraw |= symbol->HasBrightenedPins();
1153 
1154  symbol->ClearBrightenedPins();
1155 
1156  for( SCH_PIN* pin : symbol->GetPins() )
1157  {
1158  SCH_CONNECTION* pin_conn = pin->Connection();
1159 
1160  if( pin_conn && pin_conn->Name() == selectedName )
1161  {
1162  pin->SetBrightened();
1163  redraw = true;
1164  }
1165  }
1166 
1167  if( symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
1168  {
1169  std::vector<SCH_FIELD>& fields = symbol->GetFields();
1170 
1171  for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1172  {
1173  if( item->IsBrightened() && fields[id].IsVisible() )
1174  fields[id].SetBrightened();
1175  else
1176  fields[id].ClearBrightened();
1177  }
1178  }
1179  }
1180  else if( item->Type() == SCH_SHEET_T )
1181  {
1182  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1183  {
1184  SCH_CONNECTION* pin_conn = pin->Connection();
1185  bool redrawPin = pin->IsBrightened();
1186 
1187  if( pin_conn && pin_conn->Name() == selectedName )
1188  pin->SetBrightened();
1189  else
1190  pin->ClearBrightened();
1191 
1192  redrawPin ^= pin->IsBrightened();
1193  redraw |= redrawPin;
1194  }
1195  }
1196 
1197  if( redraw )
1198  itemsToRedraw.push_back( item );
1199  }
1200 
1201  // Be sure highlight change will be redrawn
1202  KIGFX::VIEW* view = getView();
1203 
1204  for( EDA_ITEM* redrawItem : itemsToRedraw )
1206 
1207  m_frame->GetCanvas()->Refresh();
1208 
1209  return 0;
1210 }
Field Reference of part, i.e. "IC21".
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:131
Calculates the connectivity of a schematic and generates netlists.
const SCH_CONNECTION * GetHighlightedConnection() const
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:711
bool IsBrightened() const
Definition: eda_item.h:126
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
A subgraph is a set of items that are electrically connected on a single sheet.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:164
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
Item needs to be redrawn.
Definition: view_item.h:57
wxString Name(bool aIgnoreSheet=false) const
Field Value of part, i.e. "3.3K".
std::vector< SCH_ITEM * > m_items
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
SCHEMATIC & Schematic() const
SCH_ITEM * Driver() const
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
bool HasBrightenedPins()
void ClearBrightenedPins()
bool IsNet() const
Schematic symbol object.
Definition: sch_symbol.h:78
SCH_SCREEN * LastScreen()
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
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:100
SCH_ITEM * Parent() const
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
SCH_SHEET_PATH & GetCurrentSheet() const
CONNECTION_SUBGRAPH * GetSubgraphForItem(SCH_ITEM *aItem)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
bool IsBus() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193
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:866
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1518

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

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

◆ updatePastedSheet()

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

Definition at line 1449 of file sch_editor_control.cpp.

1454 {
1455  SCH_SHEET_PATH sheetPath = aPastePath;
1456  sheetPath.push_back( aSheet );
1457 
1458  aSheet->AddInstance( sheetPath.Path() );
1459 
1460  wxString pageNum;
1461 
1462  if( m_clipboardSheetInstances.count( aClipPath ) > 0 )
1463  pageNum = m_clipboardSheetInstances.at( aClipPath ).m_PageNumber;
1464  else
1465  pageNum = wxString::Format( "%d", static_cast<int>( aPastedSheetsSoFar->size() ) );