KiCad PCB EDA Suite
sch_editor_control.cpp File Reference

Go to the source code of this file.

Functions

EDA_ITEMnextMatch (SCH_SCREEN *aScreen, EDA_ITEM *after, wxFindReplaceData *data)
 
static bool highlightNet (TOOL_MANAGER *aToolMgr, const VECTOR2D &aPosition)
 

Variables

static wxFindReplaceData g_markersOnly
 
static VECTOR2D CLEAR
 

Function Documentation

◆ highlightNet()

static bool highlightNet ( TOOL_MANAGER aToolMgr,
const VECTOR2D aPosition 
)
static

Definition at line 641 of file sch_editor_control.cpp.

642 {
643  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
644  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
645  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
646  wxString netName;
647  bool retVal = true;
648 
649  if( aPosition != CLEAR )
650  {
651  if( TestDuplicateSheetNames( false ) > 0 )
652  {
653  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
654  retVal = false;
655  }
656  else
657  {
658  SCH_ITEM* item = (SCH_ITEM*) selTool->GetNode( aPosition );
659 
660  if( item && item->Connection( *g_CurrentSheet ) )
661  netName = item->Connection( *g_CurrentSheet )->Name();
662  }
663  }
664 
665  if( netName.empty() )
666  {
667  editFrame->SetStatusText( wxT( "" ) );
668  editFrame->SendCrossProbeClearHighlight();
669  }
670  else
671  {
672  editFrame->SendCrossProbeNetName( netName );
673  editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
674  UnescapeString( netName ) ) );
675  }
676 
677  editFrame->SetSelectedNetName( netName );
679  editorControl->UpdateNetHighlighting( dummy );
680 
681  return retVal;
682 }
EDA_BASE_FRAME * GetEditFrame() const
Definition: tool_manager.h:268
void SendCrossProbeNetName(const wxString &aNetName)
Sends a net name to pcbnew for highlighting.
void SendCrossProbeClearHighlight()
Tells PcbNew to clear the existing highlighted net, if one exists.
Schematic editor (Eeschema) main window.
Class SCH_EDITOR_CONTROL.
int TestDuplicateSheetNames(bool aCreateMarker)
Function TestDuplicateSheetNames( ) inside a given sheet, one cannot have sheets with duplicate names...
Definition: erc.cpp:174
wxString Name(bool aIgnoreSheet=false) const
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
Class TOOL_EVENT.
Definition: tool_event.h:171
static VECTOR2D CLEAR
#define _(s)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet.
Definition: sch_item.cpp:128
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
void SetSelectedNetName(const wxString &aNetName)
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114

References _, CLEAR, SCH_ITEM::Connection(), dummy(), Format(), g_CurrentSheet, TOOL_MANAGER::GetEditFrame(), TOOL_MANAGER::GetTool(), SCH_CONNECTION::Name(), SCH_EDIT_FRAME::SendCrossProbeClearHighlight(), SCH_EDIT_FRAME::SendCrossProbeNetName(), SCH_EDIT_FRAME::SetSelectedNetName(), TestDuplicateSheetNames(), and UnescapeString().

Referenced by SCH_EDITOR_CONTROL::ClearHighlight(), SCH_EDITOR_CONTROL::HighlightNet(), and SCH_EDITOR_CONTROL::HighlightNetCursor().

◆ nextMatch()

EDA_ITEM* nextMatch ( SCH_SCREEN aScreen,
EDA_ITEM after,
wxFindReplaceData *  data 
)

Definition at line 175 of file sch_editor_control.cpp.

176 {
177  EDA_ITEM* found = nullptr;
178 
179  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
180  {
181  if( after )
182  {
183  if( after == item )
184  after = nullptr;
185 
186  return SEARCH_CONTINUE;
187  }
188 
189  if( ( data == &g_markersOnly && item->Type() == SCH_MARKER_T )
190  || item->Matches( *data, nullptr ) )
191  {
192  found = item;
193  return SEARCH_QUIT;
194  }
195 
196  return SEARCH_CONTINUE;
197  };
198 
199  EDA_ITEM::IterateForward( aScreen->GetDrawItems(), inspector, nullptr, EE_COLLECTOR::AllItems );
200 
201  return found;
202 }
std::function< SEARCH_RESULT(EDA_ITEM *aItem, void *aTestData) > INSPECTOR_FUNC
Typedef INSPECTOR is used to inspect and possibly collect the (search) results of iterating over a li...
Definition: base_struct.h:83
static wxFindReplaceData g_markersOnly
static SEARCH_RESULT IterateForward(EDA_ITEM *listStart, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function IterateForward walks through the object tree calling the inspector() on each object type req...
Definition: base_struct.h:418
static const KICAD_T AllItems[]
Definition: ee_collectors.h:42
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:512
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:152

References EE_COLLECTOR::AllItems, g_markersOnly, SCH_SCREEN::GetDrawItems(), EDA_ITEM::IterateForward(), EDA_ITEM::Matches(), SCH_MARKER_T, SEARCH_CONTINUE, SEARCH_QUIT, and EDA_ITEM::Type().

Referenced by SCH_EDITOR_CONTROL::FindNext(), and SCH_EDITOR_CONTROL::ReplaceAll().

Variable Documentation

◆ CLEAR

◆ g_markersOnly

wxFindReplaceData g_markersOnly
static

Definition at line 125 of file sch_editor_control.cpp.

Referenced by SCH_EDITOR_CONTROL::FindNext(), and nextMatch().