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

1797 {
1798  wxCommandEvent dummy;
1799  m_frame->OnAnnotate( dummy );
1800  return 0;
1801 }
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:70
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:665
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
bool IsVisible() const
Definition: eda_text.h:193
void SetVisible(bool aVisible)
Definition: eda_text.h:192
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:635
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
boost::property_tree::ptree PTREE
Definition: ptree.h:52
const PTREE CPTREE
Definition: ptree.h:53
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.
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
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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
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 907 of file sch_editor_control.cpp.

908 {
911  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
912 
913  // TODO remove once real-time connectivity is a given
915  // Ensure the netlist data is up to date:
917 
918  // Remove selection in favor of highlighting so the whole net is highlighted
919  selectionTool->ClearSelection();
920  highlightNet( m_toolMgr, cursorPos );
921 
923 
924  if( conn )
925  {
926  if( !conn->Driver() || CONNECTION_SUBGRAPH::GetDriverPriority( conn->Driver() )
928  {
929  m_frame->ShowInfoBarError( _( "Net must be labeled to assign a netclass." ) );
931  return 0;
932  }
933 
934  wxString netName = conn->Name();
936  wxString netclassName = netSettings.GetNetclassName( netName );
937 
938  wxArrayString headers;
939  std::vector<wxArrayString> items;
940 
941  headers.Add( _( "Netclasses" ) );
942 
943  wxArrayString defaultItem;
944  defaultItem.Add( _( "Default" ) );
945  items.emplace_back( defaultItem );
946 
947  for( const auto& ii : netSettings.m_NetClasses )
948  {
949  wxArrayString item;
950  item.Add( ii.first );
951  items.emplace_back( item );
952  }
953 
954  EDA_LIST_DIALOG dlg( m_frame, _( "Assign Netclass" ), headers, items, netclassName );
955  dlg.SetListLabel( _( "Select netclass:" ) );
956 
957  if( dlg.ShowModal() == wxID_OK )
958  {
959  netclassName = dlg.GetTextSelection();
960 
961  // Remove from old netclass membership list
962  if( netSettings.m_NetClassAssignments.count( netName ) )
963  {
964  const wxString oldNetclassName = netSettings.m_NetClassAssignments[ netName ];
965  NETCLASSPTR oldNetclass = netSettings.m_NetClasses.Find( oldNetclassName );
966 
967  if( oldNetclass )
968  oldNetclass->Remove( netName );
969  }
970 
971  // Add to new netclass membership list
972  NETCLASSPTR newNetclass = netSettings.m_NetClasses.Find( netclassName );
973 
974  if( newNetclass )
975  newNetclass->Add( netName );
976 
977  netSettings.m_NetClassAssignments[ netName ] = netclassName;
978  netSettings.ResolveNetClassAssignments();
979  }
980  }
981 
983  return 0;
984 }
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:
NETCLASSES m_NetClasses
Definition: net_settings.h:40
wxString Name(bool aIgnoreSheet=false) const
void ResolveNetClassAssignments(bool aRebuildFromScratch=false)
Explode the list of netclass assignments to include atomic members of composite labels (buses).
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:336
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.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
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 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(), 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::Name(), PROJECT_FILE::NetSettings(), NO_CLEANUP, SCHEMATIC::Prj(), SCH_EDIT_FRAME::RecalculateConnections(), NET_SETTINGS::ResolveNetClassAssignments(), 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 899 of file sch_editor_control.cpp.

900 {
902 
903  return 0;
904 }
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 1301 of file sch_editor_control.cpp.

1302 {
1303  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1304 
1305  if( textEntry )
1306  {
1307  textEntry->Copy();
1308  return 0;
1309  }
1310 
1311  doCopy();
1312 
1313  return 0;
1314 }
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 529 of file sch_editor_control.cpp.

530 {
531  doCrossProbeSchToPcb( aEvent, false );
532  return 0;
533 }
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 1284 of file sch_editor_control.cpp.

1285 {
1286  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1287 
1288  if( textEntry )
1289  {
1290  textEntry->Cut();
1291  return 0;
1292  }
1293 
1294  if( doCopy() )
1296 
1297  return 0;
1298 }
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 1224 of file sch_editor_control.cpp.

1225 {
1227  EE_SELECTION& selection = selTool->RequestSelection();
1228  SCHEMATIC& schematic = m_frame->Schematic();
1229 
1230  if( !selection.GetSize() )
1231  return false;
1232 
1233  selection.SetScreen( m_frame->GetScreen() );
1234  m_supplementaryClipboard.clear();
1235 
1236  for( EDA_ITEM* item : selection )
1237  {
1238  if( item->Type() == SCH_SHEET_T )
1239  {
1240  SCH_SHEET* sheet = (SCH_SHEET*) item;
1241  m_supplementaryClipboard[ sheet->GetFileName() ] = sheet->GetScreen();
1242  }
1243  }
1244 
1245  STRING_FORMATTER formatter;
1246  SCH_SEXPR_PLUGIN plugin;
1247  SCH_SHEET_LIST hierarchy = schematic.GetSheets();
1248  SCH_SHEET_PATH selPath = m_frame->GetCurrentSheet();
1249 
1250  plugin.Format( &selection, &selPath, &hierarchy, &formatter );
1251 
1252  if( aUseLocalClipboard )
1253  {
1254  m_localClipboard = formatter.GetString();
1255  return true;
1256  }
1257 
1258  return m_toolMgr->SaveClipboard( formatter.GetString() );
1259 }
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:435
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:411

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

544 {
545  // Don't get in an infinite loop SCH -> PCB -> SCH -> PCB -> SCH -> ...
546  if( m_probingPcbToSch )
547  return;
548 
550  SCH_ITEM* item = nullptr;
551  SCH_SYMBOL* symbol = nullptr;
552 
553  if( aForce )
554  {
555  EE_SELECTION& selection = selTool->RequestSelection();
556 
557  if( selection.GetSize() >= 1 )
558  item = (SCH_ITEM*) selection.Front();
559  }
560  else
561  {
562  EE_SELECTION& selection = selTool->GetSelection();
563 
564  if( selection.GetSize() >= 1 )
565  item = (SCH_ITEM*) selection.Front();
566  }
567 
568  if( !item )
569  {
570  if( aForce )
571  m_frame->SendMessageToPCBNEW( nullptr, nullptr );
572 
573  return;
574  }
575 
576 
577  switch( item->Type() )
578  {
579  case SCH_FIELD_T:
580  case LIB_FIELD_T:
581  if( item->GetParent() && item->GetParent()->Type() == SCH_SYMBOL_T )
582  {
583  symbol = (SCH_SYMBOL*) item->GetParent();
584  m_frame->SendMessageToPCBNEW( item, symbol );
585  }
586  break;
587 
588  case SCH_SYMBOL_T:
589  symbol = (SCH_SYMBOL*) item;
590  m_frame->SendMessageToPCBNEW( item, symbol );
591  break;
592 
593  case SCH_PIN_T:
594  symbol = (SCH_SYMBOL*) item->GetParent();
595  m_frame->SendMessageToPCBNEW( static_cast<SCH_PIN*>( item ), symbol );
596  break;
597 
598  case SCH_SHEET_T:
599  if( aForce )
600  m_frame->SendMessageToPCBNEW( item, nullptr );
601  break;
602 
603  default:
604  break;
605  }
606 }
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:197
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 1872 of file sch_editor_control.cpp.

1873 {
1875  return 0;
1876 }
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 1275 of file sch_editor_control.cpp.

1276 {
1277  doCopy( true ); // Use the local clipboard
1278  Paste( aEvent );
1279 
1280  return 0;
1281 }
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 1812 of file sch_editor_control.cpp.

1813 {
1815  dlg.ShowQuasiModal();
1816  return 0;
1817 }

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

1821 {
1823  m_frame->HardRedraw();
1824 
1825  return 0;
1826 }
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 1773 of file sch_editor_control.cpp.

1774 {
1776  EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SymbolsOnly );
1777  SCH_SYMBOL* symbol = nullptr;
1778  SYMBOL_EDIT_FRAME* symbolEditor;
1779 
1780  if( selection.GetSize() >= 1 )
1781  symbol = (SCH_SYMBOL*) selection.Front();
1782 
1783  if( !symbol || symbol->GetEditFlags() != 0 )
1784  return 0;
1785 
1787  symbolEditor = (SYMBOL_EDIT_FRAME*) m_frame->Kiway().Player( FRAME_SCH_SYMBOL_EDITOR, false );
1788 
1789  if( symbolEditor )
1790  symbolEditor->LoadSymbolFromSchematic( symbol );
1791 
1792  return 0;
1793 }
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:373
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:48
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 1886 of file sch_editor_control.cpp.

1887 {
1889  const EE_SELECTION& selection = selTool->RequestSelection( EE_COLLECTOR::SheetsOnly );
1890 
1891  if( selection.GetSize() == 1 )
1892  {
1893  SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
1894 
1897 
1898  // Store the current zoom level into the current screen before switching
1900 
1901  m_frame->GetCurrentSheet().push_back( sheet );
1904  }
1905 
1906  return 0;
1907 }
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:475
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:49
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:263

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

537 {
538  doCrossProbeSchToPcb( aEvent, true );
539  return 0;
540 }
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 1853 of file sch_editor_control.cpp.

1854 {
1855  int result = NET_PLUGIN_CHANGE;
1856 
1857  // If a plugin is removed or added, rebuild and reopen the new dialog
1858  while( result == NET_PLUGIN_CHANGE )
1859  result = InvokeDialogNetList( m_frame );
1860 
1861  return 0;
1862 }
#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)

Definition at line 363 of file sch_editor_control.cpp.

364 {
365  // A timer during which a subsequent FindNext will result in a wrap-around
366  static wxTimer wrapAroundTimer;
367 
368  wxFindReplaceData* data = m_frame->GetFindReplaceData();
369 
370  if( aEvent.IsAction( &ACTIONS::findNextMarker ) )
371  {
372  if( data )
373  g_markersOnly.SetFlags( data->GetFlags() );
374 
375  data = &g_markersOnly;
376  }
377  else if( !data )
378  {
379  return FindAndReplace( ACTIONS::find.MakeEvent() );
380  }
381 
382  bool searchAllSheets = !( data->GetFlags() & FR_CURRENT_SHEET_ONLY );
383  EE_SELECTION& selection = m_selectionTool->GetSelection();
384  SCH_SCREEN* afterScreen = m_frame->GetScreen();
385  SCH_ITEM* afterItem = dynamic_cast<SCH_ITEM*>( selection.Front() );
386  SCH_ITEM* item = nullptr;
387 
388  if( wrapAroundTimer.IsRunning() )
389  {
390  afterScreen = nullptr;
391  afterItem = nullptr;
392  wrapAroundTimer.Stop();
394  }
395 
397 
398  if( afterScreen || !searchAllSheets )
399  item = nextMatch( m_frame->GetScreen(), &m_frame->GetCurrentSheet(), afterItem, data );
400 
401  if( !item && searchAllSheets )
402  {
403  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
404  SCH_SCREENS screens( m_frame->Schematic().Root() );
405 
406  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
407  {
408  if( afterScreen )
409  {
410  if( afterScreen == screen )
411  afterScreen = nullptr;
412 
413  continue;
414  }
415 
416  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
417 
418  item = nextMatch( screen, sheet, nullptr, data );
419 
420  if( item )
421  {
422  wxCHECK_MSG( sheet, 0, "Sheet not found for " + screen->GetFileName() );
423 
424  m_frame->Schematic().SetCurrentSheet( *sheet );
426 
427  screen->TestDanglingEnds();
428 
429  m_frame->SetScreen( screen );
430  UpdateFind( ACTIONS::updateFind.MakeEvent() );
431 
432  break;
433  }
434  }
435  }
436 
437  if( item )
438  {
439  m_selectionTool->AddItemToSel( item );
440  m_frame->FocusOnLocation( item->GetBoundingBox().GetCenter() );
441  m_frame->GetCanvas()->Refresh();
442  }
443  else
444  {
445  wxString msg = searchAllSheets ? _( "Reached end of schematic." )
446  : _( "Reached end of sheet." );
447 
448  // Show the popup during the time period the user can wrap the search
449  m_frame->ShowFindReplaceStatus( msg + wxS( " " ) +
450  _( "Find again to wrap around to the start." ), 4000 );
451  wrapAroundTimer.StartOnce( 4000 );
452  }
453 
454  return 0;
455 }
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void ShowFindReplaceStatus(const wxString &aMsg, int aStatusTime)
int FindAndReplace(const TOOL_EVENT &aEvent)
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
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 SetScreen(BASE_SCREEN *aScreen) override
static wxFindReplaceData g_markersOnly
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
static TOOL_ACTION find
Definition: actions.h:76
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_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.
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.
int UpdateFind(const TOOL_EVENT &aEvent)
Notifies pcbnew about the selected item.
SCHEMATIC & Schematic() const
#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...
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
static TOOL_ACTION findNextMarker
Definition: actions.h:79
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
Definition: schematic.h:87
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.
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:124
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:197
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition: sch_screen.h:551
EDA_ITEM * Front() const
Definition: selection.h:144

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

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:514
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:431
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
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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:554
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:830
EE_RTREE & Items()
Definition: sch_screen.h:102
Handle the component boundary box.
Definition: eda_rect.h:42
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:124
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:179
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:197
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 1865 of file sch_editor_control.cpp.

1866 {
1868  return 0;
1869 }
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 siezure 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(), 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(), 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(), 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(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_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 128 of file tool_interactive.h.

130 {
131  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
132 
133  goInternal( sptr, aConditions );
134 }
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(), SCRIPTING_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), COMMON_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PCB_VIEWER_TOOLS::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(), PCB_CONTROL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), DRC_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), BOARD_INSPECTION_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 458 of file sch_editor_control.cpp.

459 {
460  wxFindReplaceData* data = m_frame->GetFindReplaceData();
462 
463  return data && item && item->Matches( *data, &m_frame->GetCurrentSheet() );
464 }
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()
Get the find criteria (as set by the dialog).
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(), SCH_EDIT_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 888 of file sch_editor_control.cpp.

889 {
891  VECTOR2D cursorPos = controls->GetCursorPosition( !aEvent.DisableGridSnapping() );
892 
893  highlightNet( m_toolMgr, cursorPos );
894 
895  return 0;
896 }
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:336
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 1133 of file sch_editor_control.cpp.

1134 {
1135  // TODO(JE) remove once real-time connectivity is a given
1136  if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
1138 
1139  std::string tool = aEvent.GetCommandStr().get();
1140  PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
1141 
1142  // Deactivate other tools; particularly important if another PICKER is currently running
1143  Activate();
1144 
1145  picker->SetCursor( KICURSOR::BULLSEYE );
1146  picker->SetSnapping( false );
1147 
1148  picker->SetClickHandler(
1149  [this] ( const VECTOR2D& aPos )
1150  {
1151  return highlightNet( m_toolMgr, aPos );
1152  } );
1153 
1154  m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
1155 
1156  return 0;
1157 }
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:455
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:252
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:117
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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
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 1910 of file sch_editor_control.cpp.

1911 {
1912  if( m_frame->GetCurrentSheet().Last() != &m_frame->Schematic().Root() )
1913  {
1916 
1917  // Store the current zoom level into the current screen before switching
1919 
1923  }
1924 
1925  return 0;
1926 }
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:475
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:263

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

297 {
298  bool past_item = true;
299 
300  if( aAfter != nullptr )
301  {
302  past_item = false;
303 
304  if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
305  aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
306  }
307 
308 
309  for( SCH_ITEM* item : aScreen->Items() )
310  {
311  if( item == aAfter )
312  {
313  past_item = true;
314  }
315  else if( past_item )
316  {
317  if( aData == &g_markersOnly && item->Type() == SCH_MARKER_T )
318  return item;
319 
320  if( item->Matches( *aData, aSheet ) )
321  return item;
322 
323  if( item->Type() == SCH_SYMBOL_T )
324  {
325  SCH_SYMBOL* cmp = static_cast<SCH_SYMBOL*>( item );
326 
327  for( SCH_FIELD& field : cmp->GetFields() )
328  {
329  if( field.Matches( *aData, aSheet ) )
330  return &field;
331  }
332 
333  for( SCH_PIN* pin : cmp->GetPins() )
334  {
335  if( pin->Matches( *aData, aSheet ) )
336  return pin;
337  }
338  }
339 
340  if( item->Type() == SCH_SHEET_T )
341  {
342  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
343 
344  for( SCH_FIELD& field : sheet->GetFields() )
345  {
346  if( field.Matches( *aData, aSheet ) )
347  return &field;
348  }
349 
350  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
351  {
352  if( pin->Matches( *aData, aSheet ) )
353  return pin;
354  }
355  }
356  }
357  }
358 
359  return nullptr;
360 }
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:701
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
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
Schematic symbol object.
Definition: sch_symbol.h:78
EE_RTREE & Items()
Definition: sch_screen.h:102
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
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:856
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(), SCH_SCREEN::Items(), 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 1432 of file sch_editor_control.cpp.

1433 {
1434  wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( wxWindow::FindFocus() );
1435 
1436  if( textEntry )
1437  {
1438  textEntry->Paste();
1439  return 0;
1440  }
1441 
1443  std::string text;
1444 
1445  if( aEvent.IsAction( &ACTIONS::duplicate ) )
1447  else
1449 
1450  if( text.empty() )
1451  return 0;
1452 
1453  STRING_LINE_READER reader( text, "Clipboard" );
1454  SCH_SEXPR_PLUGIN plugin;
1455 
1456  SCH_SHEET paste_sheet;
1457  SCH_SCREEN* paste_screen = new SCH_SCREEN( &m_frame->Schematic() );
1458 
1459  // Screen object on heap is owned by the sheet.
1460  paste_sheet.SetScreen( paste_screen );
1461 
1462  try
1463  {
1464  plugin.LoadContent( reader, &paste_sheet );
1465  }
1466  catch( IO_ERROR& )
1467  {
1468  // If it wasn't content, then paste as text
1469  paste_screen->Append( new SCH_TEXT( wxPoint( 0, 0 ), text ) );
1470  }
1471 
1472  // Save loaded screen instances to m_clipboardSheetInstances
1473  setClipboardInstances( paste_screen );
1474 
1476 
1477  if( aEvent.IsAction( &ACTIONS::pasteSpecial ) )
1478  {
1479  DIALOG_PASTE_SPECIAL dlg( m_frame, &pasteMode );
1480 
1481  if( dlg.ShowModal() == wxID_CANCEL )
1482  return 0;
1483  }
1484 
1485  bool forceKeepAnnotations = pasteMode != PASTE_MODE::REMOVE_ANNOTATIONS;
1486 
1487  // SCH_SEXP_PLUGIN added the items to the paste screen, but not to the view or anything
1488  // else. Pull them back out to start with.
1489  //
1490  EDA_ITEMS loadedItems;
1491  bool sheetsPasted = false;
1492  SCH_SHEET_LIST hierarchy = m_frame->Schematic().GetSheets();
1493  SCH_SHEET_PATH& pasteRoot = m_frame->GetCurrentSheet();
1494  wxFileName destFn = pasteRoot.Last()->GetFileName();
1495 
1496  if( destFn.IsRelative() )
1497  destFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1498 
1499  // List of paths in the hierarchy that refer to the destination sheet of the paste
1500  SCH_SHEET_LIST pasteInstances = hierarchy.FindAllSheetsForScreen( pasteRoot.LastScreen() );
1501  pasteInstances.SortByPageNumbers();
1502 
1503  // Build a list of screens from the current design (to avoid loading sheets that already exist)
1504  std::map<wxString, SCH_SCREEN*> loadedScreens;
1505 
1506  for( const SCH_SHEET_PATH& item : hierarchy )
1507  {
1508  if( item.LastScreen() )
1509  loadedScreens[item.Last()->GetFileName()] = item.LastScreen();
1510  }
1511 
1512  // Build symbol list for reannotation of duplicates
1513  SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets();
1514  SCH_REFERENCE_LIST existingRefs;
1515  sheets.GetSymbols( existingRefs );
1516  existingRefs.SortByReferenceOnly();
1517 
1518  // Keep track of pasted sheets and symbols for the different
1519  // paths to the hierarchy
1520  std::map<SCH_SHEET_PATH, SCH_REFERENCE_LIST> pastedSymbols;
1521  std::map<SCH_SHEET_PATH, SCH_SHEET_LIST> pastedSheets;
1522 
1523  for( SCH_ITEM* item : paste_screen->Items() )
1524  {
1525  loadedItems.push_back( item );
1526 
1527  //@todo: we might want to sort the sheets by page number before adding to loadedItems
1528  if( item->Type() == SCH_SHEET_T )
1529  {
1530  SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1531  wxFileName srcFn = sheet->GetFileName();
1532 
1533  if( srcFn.IsRelative() )
1534  srcFn.MakeAbsolute( m_frame->Prj().GetProjectPath() );
1535 
1536  SCH_SHEET_LIST sheetHierarchy( sheet );
1537 
1538  if( hierarchy.TestForRecursion( sheetHierarchy, destFn.GetFullPath( wxPATH_UNIX ) ) )
1539  {
1540  auto msg = wxString::Format( _( "The pasted sheet \"%s\"\n"
1541  "was dropped because the destination already has "
1542  "the sheet or one of its subsheets as a parent." ),
1543  sheet->GetFileName() );
1544  DisplayError( m_frame, msg );
1545  loadedItems.pop_back();
1546  }
1547  }
1548  }
1549 
1550  // Remove the references from our temporary screen to prevent freeing on the DTOR
1551  paste_screen->Clear( false );
1552 
1553  for( unsigned i = 0; i < loadedItems.size(); ++i )
1554  {
1555  EDA_ITEM* item = loadedItems[i];
1556  KIID_PATH clipPath( wxT("/") ); // clipboard is at root
1557 
1558  if( item->Type() == SCH_SYMBOL_T )
1559  {
1560  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1561 
1562  // The library symbol gets set from the cached library symbols in the current
1563  // schematic not the symbol libraries. The cached library symbol may have
1564  // changed from the original library symbol which would cause the copy to
1565  // be incorrect.
1566  SCH_SCREEN* currentScreen = m_frame->GetScreen();
1567 
1568  wxCHECK2( currentScreen, continue );
1569 
1570  auto it = currentScreen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1571  auto end = currentScreen->GetLibSymbols().end();
1572 
1573  if( it == end )
1574  {
1575  // If can't find library definition in the design, use the pasted library
1576  it = paste_screen->GetLibSymbols().find( symbol->GetSchSymbolLibraryName() );
1577  end = paste_screen->GetLibSymbols().end();
1578  }
1579 
1580  LIB_SYMBOL* libSymbol = nullptr;
1581 
1582  if( it != end )
1583  {
1584  libSymbol = new LIB_SYMBOL( *it->second );
1585  symbol->SetLibSymbol( libSymbol );
1586  }
1587 
1588  for( SCH_SHEET_PATH& instance : pasteInstances )
1589  {
1590  updatePastedSymbol( symbol, paste_screen, instance, clipPath,
1591  forceKeepAnnotations );
1592  }
1593 
1594  // Assign a new KIID
1595  const_cast<KIID&>( item->m_Uuid ) = KIID();
1596 
1597  // Make sure pins get a new UUID
1598  for( SCH_PIN* pin : symbol->GetPins() )
1599  const_cast<KIID&>( pin->m_Uuid ) = KIID();
1600 
1601  for( SCH_SHEET_PATH& instance : pasteInstances )
1602  {
1603  // Ignore pseudo-symbols (e.g. power symbols) and symbols from a non-existant
1604  // library.
1605  if( libSymbol && symbol->GetRef( &instance )[0] != wxT( '#' ) )
1606  {
1607  SCH_REFERENCE schReference( symbol, libSymbol, instance );
1608  schReference.SetSheetNumber( instance.GetVirtualPageNumber() );
1609  pastedSymbols[instance].AddItem( schReference );
1610  }
1611  }
1612  }
1613  else if( item->Type() == SCH_SHEET_T )
1614  {
1615  SCH_SHEET* sheet = (SCH_SHEET*) item;
1616  SCH_FIELD& nameField = sheet->GetFields()[SHEETNAME];
1617  wxString baseName = nameField.GetText();
1618  wxString candidateName = baseName;
1619  wxString number;
1620 
1621  while( !baseName.IsEmpty() && wxIsdigit( baseName.Last() ) )
1622  {
1623  number = baseName.Last() + number;
1624  baseName.RemoveLast();
1625  }
1626  // Update hierarchy to include any other sheets we already added, avoiding
1627  // duplicate sheet names
1628  hierarchy = m_frame->Schematic().GetSheets();
1629 
1630  //@todo: it might be better to just iterate through the sheet names
1631  // in this screen instead of the whole hierarchy.
1632  int uniquifier = std::max( 0, wxAtoi( number ) ) + 1;
1633 
1634  while( hierarchy.NameExists( candidateName ) )
1635  candidateName = wxString::Format( wxT( "%s%d" ), baseName, uniquifier++ );
1636 
1637  nameField.SetText( candidateName );
1638 
1639  wxFileName fn = sheet->GetFileName();
1640  SCH_SCREEN* existingScreen = nullptr;
1641 
1642  sheet->SetParent( pasteRoot.Last() );
1643  sheet->SetScreen( nullptr );
1644 
1645  if( !fn.IsAbsolute() )
1646  {
1647  wxFileName currentSheetFileName = pasteRoot.LastScreen()->GetFileName();
1648  fn.Normalize( wxPATH_NORM_ALL, currentSheetFileName.GetPath() );
1649  }
1650 
1651  // Try to find the screen for the pasted sheet by several means
1652  if( !m_frame->Schematic().Root().SearchHierarchy( fn.GetFullPath( wxPATH_UNIX ),
1653  &existingScreen ) )
1654  {
1655  if( loadedScreens.count( sheet->GetFileName() ) > 0 )
1656  existingScreen = loadedScreens.at( sheet->GetFileName() );
1657  else
1658  searchSupplementaryClipboard( sheet->GetFileName(), &existingScreen );
1659  }
1660 
1661  if( existingScreen )
1662  {
1663  sheet->SetScreen( existingScreen );
1664  }
1665  else
1666  {
1667  if( !m_frame->LoadSheetFromFile( sheet, &pasteRoot, fn.GetFullPath() ) )
1668  m_frame->InitSheet( sheet, sheet->GetFileName() );
1669  }
1670 
1671  sheetsPasted = true;
1672 
1673  // Push it to the clipboard path while it still has its old KIID
1674  clipPath.push_back( sheet->m_Uuid );
1675 
1676  // Assign a new KIID to the pasted sheet
1677  const_cast<KIID&>( sheet->m_Uuid ) = KIID();
1678 
1679  // Make sure pins get a new UUID
1680  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1681  const_cast<KIID&>( pin->m_Uuid ) = KIID();
1682 
1683  // Once we have our new KIID we can update all pasted instances. This will either
1684  // reset the annotations or copy "kept" annotations from the supplementary clipboard.
1685  for( SCH_SHEET_PATH& instance : pasteInstances )
1686  {
1687  SCH_SHEET_PATH sheetPath = updatePastedSheet( instance, clipPath, sheet,
1688  forceKeepAnnotations,
1689  &pastedSheets[instance],
1690  &pastedSymbols[instance] );
1691 
1692  sheetPath.GetSymbols( pastedSymbols[instance] );
1693  }
1694  }
1695  else
1696  {
1697  // Everything gets a new KIID
1698  const_cast<KIID&>( item->m_Uuid ) = KIID();
1699  }
1700 
1701  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1703 
1704  // Reset flags for subsequent move operation
1705  item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );
1706  // Start out hidden so the pasted items aren't "ghosted" in their original location
1707  // before being moved to the current location.
1708  getView()->Hide( item, true );
1709  }
1710 
1711  pasteInstances.SortByPageNumbers();
1712 
1713  if( pasteMode == PASTE_MODE::UNIQUE_ANNOTATIONS )
1714  {
1715  for( SCH_SHEET_PATH& instance : pasteInstances )
1716  {
1717  pastedSymbols[instance].SortByReferenceOnly();
1718  pastedSymbols[instance].ReannotateDuplicates( existingRefs );
1719  pastedSymbols[instance].UpdateAnnotation();
1720 
1721  // Update existing refs for next iteration
1722  for( size_t i = 0; i < pastedSymbols[instance].GetCount(); i++ )
1723  existingRefs.AddItem( pastedSymbols[instance][i] );
1724  }
1725  }
1726 
1728 
1729  if( sheetsPasted )
1730  {
1731  // Update page numbers: Find next free numeric page number
1732  for( SCH_SHEET_PATH& instance : pasteInstances )
1733  {
1734  pastedSheets[instance].SortByPageNumbers();
1735 
1736  for( SCH_SHEET_PATH& pastedSheet : pastedSheets[instance] )
1737  {
1738  int page = 1;
1739  wxString pageNum = wxString::Format( "%d", page );
1740 
1741  while( hierarchy.PageNumberExists( pageNum ) )
1742  pageNum = wxString::Format( "%d", ++page );
1743 
1744  pastedSheet.SetPageNumber( pageNum );
1745  hierarchy.push_back( pastedSheet );
1746  }
1747  }
1748 
1751  }
1752 
1753  // Now clear the previous selection, select the pasted items, and fire up the "move"
1754  // tool.
1755  //
1757  m_toolMgr->RunAction( EE_ACTIONS::addItemsToSel, true, &loadedItems );
1758 
1759  EE_SELECTION& selection = selTool->GetSelection();
1760 
1761  if( !selection.Empty() )
1762  {
1763  SCH_ITEM* item = (SCH_ITEM*) selection.GetTopLeftItem();
1764 
1765  selection.SetReferencePoint( item->GetPosition() );
1767  }
1768 
1769  return 0;
1770 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:252
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1471
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:137
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:630
#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:157
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:431
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:247
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:123
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:215
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:238
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:418
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()
Definition: sch_screen.h:102
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
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:237
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:197
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:856
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, SCHEMATIC::Root(), TOOL_MANAGER::RunAction(), SCH_SHEET_T, SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), SCH_SHEET::SearchHierarchy(), searchSupplementaryClipboard(), setClipboardInstances(), EDA_ITEM::SetFlags(), 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:137
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:271
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 == NULL )
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:665
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 SetVisible(bool aVisible)
Definition: eda_text.h:192
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:635
Container to create a flattened list of symbols because in a complex hierarchy, a symbol can be used ...
A LINE_READER that reads from an open file.
Definition: richio.h:172
#define NULL
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, NULL, 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 1192 of file sch_editor_control.cpp.

1193 {
1194  if( m_frame->GetRedoCommandCount() == 0 )
1195  return 0;
1196 
1197  // Inform tools that undo command was issued
1199 
1200  /* Get the old list */
1202 
1203  /* Redo the command: */
1205 
1206  /* Put the old list in UndoList */
1207  list->ReversePickersListOrder();
1208  m_frame->PushCommandToUndoList( list );
1209 
1213 
1214  m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1215 
1216  m_frame->SyncView();
1217  m_frame->GetCanvas()->Refresh();
1218  m_frame->OnModify();
1219 
1220  return 0;
1221 }
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Global action (toolbar/main menu event, global shortcut)
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=NULL) 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 492 of file sch_editor_control.cpp.

493 {
494  wxFindReplaceData* data = m_frame->GetFindReplaceData();
495  bool modified = false;
496 
497  if( !data )
498  return FindAndReplace( ACTIONS::find.MakeEvent() );
499 
500  SCH_SHEET_LIST schematic = m_frame->Schematic().GetSheets();
501  SCH_SCREENS screens( m_frame->Schematic().Root() );
502 
503  for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
504  {
505  SCH_SHEET_PATH* sheet = schematic.FindSheetForScreen( screen );
506 
507  for( EDA_ITEM* item = nextMatch( screen, sheet, nullptr, data ); item; )
508  {
509  if( item->Replace( *data, sheet ) )
510  {
511  m_frame->UpdateItem( item );
512  modified = true;
513  }
514 
515  item = nextMatch( screen, sheet, dynamic_cast<SCH_ITEM*>( item ), data );
516  }
517  }
518 
519  if( modified )
520  {
522  m_frame->OnModify();
523  }
524 
525  return 0;
526 }
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.
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
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
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:551

References ACTIONS::find, FindAndReplace(), SCH_SHEET_LIST::FindSheetForScreen(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_EDIT_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 467 of file sch_editor_control.cpp.

468 {
469  wxFindReplaceData* data = m_frame->GetFindReplaceData();
472 
473  if( !data )
474  return FindAndReplace( ACTIONS::find.MakeEvent() );
475 
476  if( item && item->Matches( *data, sheet ) )
477  {
478  if( item->Replace( *data, sheet ) )
479  {
480  m_frame->UpdateItem( item );
482  m_frame->OnModify();
483  }
484 
485  FindNext( ACTIONS::findNext.MakeEvent() );
486  }
487 
488  return 0;
489 }
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.
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
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
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(), SCH_EDIT_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:373
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
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
SCH_SHEET & Root() const
Definition: schematic.h:92
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:551

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:551

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 }

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->Save_File( true );
90  return 0;
91 }
void Save_File(bool doSaveAs=false)

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

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

1264 {
1265  if( m_supplementaryClipboard.count( aSheetFilename ) > 0 )
1266  {
1267  *aScreen = m_supplementaryClipboard[ aSheetFilename ];
1268  return true;
1269  }
1270 
1271  return false;
1272 }
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 1418 of file sch_editor_control.cpp.

1419 {
1420  m_clipboardSheetInstances.clear();
1421 
1422  for( const SCH_SHEET_INSTANCE& sheet : aPastedScreen->GetSheetInstances() )
1423  m_clipboardSheetInstances[sheet.m_Path] = sheet;
1424 
1426 
1427  for( const SYMBOL_INSTANCE_REFERENCE& symbol : aPastedScreen->GetSymbolInstances() )
1428  m_clipboardSymbolInstances[symbol.m_Path] = symbol;
1429 }
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetSymbolInstances() const
Definition: sch_screen.h:453
const std::vector< SCH_SHEET_INSTANCE > & GetSheetInstances() const
Definition: sch_screen.h:458
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 1975 of file sch_editor_control.cpp.

1976 {
1977  Go( &SCH_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
1978  Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
1979  Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
1983  Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
1984  Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
1985  Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
1986 
1989 
1998 
2003 
2004 #ifdef KICAD_SPICE
2005  Go( &SCH_EDITOR_CONTROL::SimProbe, EE_ACTIONS::simProbe.MakeEvent() );
2006  Go( &SCH_EDITOR_CONTROL::SimTune, EE_ACTIONS::simTune.MakeEvent() );
2007 #endif /* KICAD_SPICE */
2008 
2015 
2017 
2018  Go( &SCH_EDITOR_CONTROL::Undo, ACTIONS::undo.MakeEvent() );
2019  Go( &SCH_EDITOR_CONTROL::Redo, ACTIONS::redo.MakeEvent() );
2020  Go( &SCH_EDITOR_CONTROL::Cut, ACTIONS::cut.MakeEvent() );
2021  Go( &SCH_EDITOR_CONTROL::Copy, ACTIONS::copy.MakeEvent() );
2022  Go( &SCH_EDITOR_CONTROL::Paste, ACTIONS::paste.MakeEvent() );
2025 
2038 
2040 
2044 
2048 
2050 }
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 cancelInteractive
Definition: actions.h:62
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)
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, ACTIONS::cancelInteractive, 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(), 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 1879 of file sch_editor_control.cpp.

1880 {
1882  return 0;
1883 }
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 1804 of file sch_editor_control.cpp.

1805 {
1806  wxCommandEvent dummy;
1808  return 0;
1809 }
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:70

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

1830 {
1831  wxCommandEvent dummy;
1833  return 0;
1834 }
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:70
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 1944 of file sch_editor_control.cpp.

1945 {
1948 
1949  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1951 
1953  m_frame->GetCanvas()->Refresh();
1954 
1955  return 0;
1956 }
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1416
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:133
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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:142

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

1930 {
1933 
1934  KIGFX::SCH_PAINTER* painter = static_cast<KIGFX::SCH_PAINTER*>( getView()->GetPainter() );
1936 
1938  m_frame->GetCanvas()->Refresh();
1939 
1940  return 0;
1941 }
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
Definition: view.cpp:1416
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:133
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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:142
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 1967 of file sch_editor_control.cpp.

1968 {
1969 
1971  return 0;
1972 }
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 1160 of file sch_editor_control.cpp.

1161 {
1162  if( m_frame->GetUndoCommandCount() <= 0 )
1163  return 0;
1164 
1165  // Inform tools that undo command was issued
1167 
1168  /* Get the old list */
1170 
1171  /* Undo the command */
1173 
1174  /* Put the old list in RedoList */
1175  List->ReversePickersListOrder();
1176  m_frame->PushCommandToRedoList( List );
1177 
1181 
1182  m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
1183 
1184  m_frame->SyncView();
1185  m_frame->GetCanvas()->Refresh();
1186  m_frame->OnModify();
1187 
1188  return 0;
1189 }
void ReversePickersListOrder()
Reverse the order of pickers stored in this list.
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
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
Global action (toolbar/main menu event, global shortcut)
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(), EE_TOOL_BASE< SCH_EDIT_FRAME >::m_frame, TOOL_BASE::m_toolMgr, 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  if( data && aItem->Matches( *data, aSheet ) )
254  {
255  aItem->SetForceVisible( true );
256  m_selectionTool->BrightenItem( aItem );
257  }
258  else if( aItem->IsBrightened() )
259  {
260  aItem->SetForceVisible( false );
262  }
263  };
264 
265  if( aEvent.IsAction( &ACTIONS::find ) || aEvent.IsAction( &ACTIONS::findAndReplace )
266  || aEvent.IsAction( &ACTIONS::updateFind ) )
267  {
269 
270  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
271  {
272  visit( item, &m_frame->GetCurrentSheet() );
273 
274  item->RunOnChildren(
275  [&]( SCH_ITEM* aChild )
276  {
277  visit( aChild, &m_frame->GetCurrentSheet() );
278  } );
279  }
280  }
281  else if( aEvent.Matches( EVENTS::SelectedItemsModified ) )
282  {
283  for( EDA_ITEM* item : m_selectionTool->GetSelection() )
284  visit( item, &m_frame->GetCurrentSheet() );
285  }
286 
287  getView()->UpdateItems();
288  m_frame->GetCanvas()->Refresh();
289  m_frame->UpdateTitle();
290 
291  return 0;
292 }
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
wxFindReplaceData * GetFindReplaceData()
Get the find criteria (as set by the dialog).
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
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.
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:1398
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:357
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
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
int ClearSelection(const TOOL_EVENT &aEvent)
Select all visible items in sheet.
EE_RTREE & Items()
Definition: sch_screen.h:102
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:197

References EE_SELECTION_TOOL::BrightenItem(), EE_SELECTION_TOOL::ClearSelection(), ACTIONS::find, ACTIONS::findAndReplace, SCH_BASE_FRAME::GetCanvas(), SCH_EDIT_FRAME::GetCurrentSheet(), SCH_EDIT_FRAME::GetFindReplaceData(), SCH_EDIT_FRAME::GetScreen(), EE_SELECTION_TOOL::GetSelection(), TOOL_BASE::getView(), TOOL_EVENT::IsAction(), EDA_ITEM::IsBrightened(), SCH_SCREEN::Items(), 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 1845 of file sch_editor_control.cpp.

1846 {
1848  dlg.ShowModal();
1849  return 0;
1850 }

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

988 {
990  CONNECTION_GRAPH* connectionGraph = m_frame->Schematic().ConnectionGraph();
991  std::vector<EDA_ITEM*> itemsToRedraw;
992  const SCH_CONNECTION* selectedConn = m_frame->GetHighlightedConnection();
993 
994  if( !screen )
995  return 0;
996 
997  bool selectedIsBus = selectedConn ? selectedConn->IsBus() : false;
998  wxString selectedName = selectedConn ? selectedConn->Name() : "";
999 
1000  bool selectedIsNoNet = false;
1001  CONNECTION_SUBGRAPH* selectedSubgraph = nullptr;
1002 
1003  if( selectedConn && selectedConn->Driver() == nullptr )
1004  {
1005  selectedIsNoNet = true;
1006  selectedSubgraph = connectionGraph->GetSubgraphForItem( selectedConn->Parent() );
1007  }
1008 
1009  for( SCH_ITEM* item : screen->Items() )
1010  {
1011  SCH_CONNECTION* itemConn = nullptr;
1012  SCH_SYMBOL* symbol = nullptr;
1013  bool redraw = item->IsBrightened();
1014  bool highlight = false;
1015 
1016  if( item->Type() == SCH_SYMBOL_T )
1017  symbol = static_cast<SCH_SYMBOL*>( item );
1018 
1019  if( symbol && symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
1020  itemConn = symbol->Connection();
1021  else
1022  itemConn = item->Connection();
1023 
1024  if( selectedIsNoNet && selectedSubgraph )
1025  {
1026  for( SCH_ITEM* subgraphItem : selectedSubgraph->m_items )
1027  {
1028  if( item == subgraphItem )
1029  {
1030  highlight = true;
1031  break;
1032  }
1033  }
1034  }
1035  else if( selectedIsBus && itemConn && itemConn->IsNet() )
1036  {
1037  for( const std::shared_ptr<SCH_CONNECTION>& member : selectedConn->Members() )
1038  {
1039  if( member->Name() == itemConn->Name() )
1040  {
1041  highlight = true;
1042  break;
1043  }
1044  else if( member->IsBus() )
1045  {
1046  for( const std::shared_ptr<SCH_CONNECTION>& child_member : member->Members() )
1047  {
1048  if( child_member->Name() == itemConn->Name() )
1049  {
1050  highlight = true;
1051  break;
1052  }
1053  }
1054  }
1055  }
1056  }
1057  else if( selectedConn && itemConn && selectedName == itemConn->Name() )
1058  {
1059  highlight = true;
1060  }
1061 
1062  if( highlight )
1063  item->SetBrightened();
1064  else
1065  item->ClearBrightened();
1066 
1067  redraw |= item->IsBrightened();
1068 
1069  // symbol is only non-null if the item is a SCH_SYMBOL_T
1070  if( symbol )
1071  {
1072  redraw |= symbol->HasBrightenedPins();
1073 
1074  symbol->ClearBrightenedPins();
1075 
1076  for( SCH_PIN* pin : symbol->GetPins() )
1077  {
1078  SCH_CONNECTION* pin_conn = pin->Connection();
1079 
1080  if( pin_conn && pin_conn->Name() == selectedName )
1081  {
1082  pin->SetBrightened();
1083  redraw = true;
1084  }
1085  }
1086 
1087  if( symbol->GetLibSymbolRef() && symbol->GetLibSymbolRef()->IsPower() )
1088  {
1089  std::vector<SCH_FIELD>& fields = symbol->GetFields();
1090 
1091  for( int id : { REFERENCE_FIELD, VALUE_FIELD } )
1092  {
1093  if( item->IsBrightened() && fields[id].IsVisible() )
1094  fields[id].SetBrightened();
1095  else
1096  fields[id].ClearBrightened();
1097  }
1098  }
1099  }
1100  else if( item->Type() == SCH_SHEET_T )
1101  {
1102  for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
1103  {
1104  SCH_CONNECTION* pin_conn = pin->Connection();
1105  bool redrawPin = pin->IsBrightened();
1106 
1107  if( pin_conn && pin_conn->Name() == selectedName )
1108  pin->SetBrightened();
1109  else
1110  pin->ClearBrightened();
1111 
1112  redrawPin ^= pin->IsBrightened();
1113  redraw |= redrawPin;
1114  }
1115  }
1116 
1117  if( redraw )
1118  itemsToRedraw.push_back( item );
1119  }
1120 
1121  // Be sure highlight change will be redrawn
1122  KIGFX::VIEW* view = getView();
1123 
1124  for( EDA_ITEM* redrawItem : itemsToRedraw )
1126 
1127  m_frame->GetCanvas()->Refresh();
1128 
1129  return 0;
1130 }
Field Reference of part, i.e. "IC21".
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:129
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:701
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
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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()
Definition: sch_screen.h:102
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:67
bool IsBus() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
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:856
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:1504

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

1369 {
1370  SCH_SHEET_PATH sheetPath = aPastePath;
1371  sheetPath.push_back( aSheet );
1372 
1373  aSheet->AddInstance( sheetPath.Path() );
1374 
1375  wxString pageNum;
1376 
1377  if( m_clipboardSheetInstances.count( aClipPath ) > 0 )
1378  pageNum = m_clipboardSheetInstances.at( aClipPath ).m_PageNumber;
1379  else
1380  pageNum = wxString::Format( "%d", static_cast<int>( aPastedSheetsSoFar->size() ) );
1381 
1382  aSheet->SetPageNumber( sheetPath, pageNum );
1383  aPastedSheetsSoFar->push_back( sheetPath );
1384 
1385  if( aSheet->GetScreen() == nullptr )
1386  return sheetPath; // We can only really set the page number but not load any items
1387 
1388  for( SCH_ITEM* item : aSheet->GetScreen()->Items() )
1389  {
1390  if( item->Type() == SCH_SYMBOL_T )
1391  {
1392  SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
1393 
1394  updatePastedSymbol( symbol, aSheet->GetScreen(), sheetPath, aClipPath,
1395  aForceKeepAnnotations );
1396  }
1397  else if( item->Type() == SCH_SHEET_T )
1398  {
1399  SCH_SHEET* subsheet = static_cast<SCH_SHEET*>( item );
1400 
1401  KIID_PATH newClipPath = aClipPath;
1402  newClipPath.push_back( subsheet->m_Uuid );
1403 
1404  updatePastedSheet( sheetPath, newClipPath, subsheet, aForceKeepAnnotations,
1405  aPastedSheetsSoFar, aPastedSymbolsSoFar );
1406 
1407  SCH_SHEET_PATH subSheetPath = sheetPath;
1408  subSheetPath.push_back( subsheet );
1409 
1410  subSheetPath.GetSymbols( *aPastedSymbolsSoFar );
1411  }
1412  }
1413 
1414  return sheetPath;
1415 }
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void updatePastedSymbol(SCH_SYMBOL *aSymbol, SCH_SCREEN *aPasteScreen, const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, bool aForceKeepAnnotations)
SCH_SCREEN * GetScreen() const
Definition: sch_sheet.h:103
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1136
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::map< KIID_PATH, SCH_SHEET_INSTANCE > m_clipboardSheetInstances
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
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
SCH_SHEET_PATH updatePastedSheet(const SCH_SHEET_PATH &aPastePath, const KIID_PATH &aClipPath, SCH_SHEET *aSheet, bool aForceKeepAnnotations, SCH_SHEET_LIST *aPastedSheetsSoFar, SCH_REFERENCE_LIST *aPastedSymbolsSoFar)
Schematic symbol object.
Definition: sch_symbol.h:78
EE_RTREE & Items()
Definition: sch_screen.h:102
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.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
bool AddInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1094

References SCH_SHEET::AddInstance(), Format(), SCH_SHEET::GetScreen(), SCH_SHEET_PATH::GetSymbols(), SCH_SCREEN::Items(), m_clipboardSheetInstances, EDA_ITEM::m_Uuid, SCH_SHEET_PATH::Path(), SCH_SHEET_PATH::push_back(), SCH_SHEET_T, SCH_SYMBOL_T, SCH_SHEET::SetPageNumber(), EDA_ITEM::Type(), and updatePastedSymbol().

Referenced by Paste().

◆ updatePastedSymbol()

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

Definition at line 1317 of file sch_editor_control.cpp.

1321 {
1322  KIID_PATH clipItemPath = aClipPath;
1323  clipItemPath.push_back( aSymbol->m_Uuid );
1324 
1325  wxString reference, value, footprint;
1326  int unit;
1327 
1328  if( m_clipboardSymbolInstances.count( clipItemPath ) > 0 )
1329  {
1330  SYMBOL_INSTANCE_REFERENCE instance = m_clipboardSymbolInstances.at( clipItemPath );
1331 
1332  unit = instance.m_Unit;
1333  reference = instance.m_Reference;
1334  value = instance.m_Value;
1335  footprint = instance.m_Footprint;
1336  }
1337  else
1338  {
1339  // Pasted from notepad or an older instance of eeschema.
1340  // Use the values in the fields instead
1341  reference = aSymbol->GetField( REFERENCE_FIELD )->GetText();
1342  value = aSymbol->GetField( VALUE_FIELD )->GetText();
1343