KiCad PCB EDA Suite
sch_editor_control.cpp File Reference
#include <fctsys.h>
#include <kiway.h>
#include <sch_view.h>
#include <sch_edit_frame.h>
#include <sch_sheet.h>
#include <connection_graph.h>
#include <erc.h>
#include <eeschema_id.h>
#include <netlist_object.h>
#include <tool/tool_manager.h>
#include <tool/picker_tool.h>
#include <tools/ee_actions.h>
#include <tools/sch_editor_control.h>
#include <tools/ee_selection.h>
#include <tools/ee_selection_tool.h>
#include <advanced_config.h>
#include <simulation_cursors.h>
#include <sim/sim_plot_frame.h>
#include <sch_legacy_plugin.h>
#include <class_library.h>
#include <confirm.h>
#include <sch_painter.h>
#include <status_popup.h>
#include <ws_proxy_undo_item.h>
#include <dialogs/dialog_page_settings.h>
#include <dialogs/dialog_fields_editor_global.h>
#include <invoke_sch_dialog.h>

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

527 {
528  SCH_EDIT_FRAME* editFrame = static_cast<SCH_EDIT_FRAME*>( aToolMgr->GetEditFrame() );
529  EE_SELECTION_TOOL* selTool = aToolMgr->GetTool<EE_SELECTION_TOOL>();
530  SCH_EDITOR_CONTROL* editorControl = aToolMgr->GetTool<SCH_EDITOR_CONTROL>();
531  wxString netName;
532  bool retVal = true;
533 
534  if( aPosition != CLEAR )
535  {
536  if( TestDuplicateSheetNames( false ) > 0 )
537  {
538  wxMessageBox( _( "Error: duplicate sub-sheet names found in current sheet." ) );
539  retVal = false;
540  }
541  else
542  {
543  SCH_ITEM* item = (SCH_ITEM*) selTool->GetNode( aPosition );
544 
545  if( item && item->Connection( *g_CurrentSheet ) )
546  netName = item->Connection( *g_CurrentSheet )->Name();
547  }
548  }
549 
550  if( netName.empty() )
551  {
552  editFrame->SetStatusText( wxT( "" ) );
553  editFrame->SendCrossProbeClearHighlight();
554  }
555  else
556  {
557  editFrame->SendCrossProbeNetName( netName );
558  editFrame->SetStatusText( wxString::Format( _( "Highlighted net: %s" ),
559  UnescapeString( netName ) ) );
560  }
561 
562  editFrame->SetSelectedNetName( netName );
564  editorControl->UpdateNetHighlighting( dummy );
565 
566  return retVal;
567 }
EDA_BASE_FRAME * GetEditFrame() const
Definition: tool_manager.h:251
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:177
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:168
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:127
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:123
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 186 of file sch_editor_control.cpp.

187 {
188  EDA_ITEM* found = nullptr;
189 
190  INSPECTOR_FUNC inspector = [&] ( EDA_ITEM* item, void* testData )
191  {
192  if( after )
193  {
194  if( after == item )
195  after = nullptr;
196 
197  return SEARCH_CONTINUE;
198  }
199 
200  if( ( data == &g_markersOnly && item->Type() == SCH_MARKER_T )
201  || item->Matches( *data, nullptr ) )
202  {
203  found = item;
204  return SEARCH_QUIT;
205  }
206 
207  return SEARCH_CONTINUE;
208  };
209 
210  EDA_ITEM::IterateForward( aScreen->GetDrawItems(), inspector, nullptr, EE_COLLECTOR::AllItems );
211 
212  return found;
213 }
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:70
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:404
static const KICAD_T AllItems[]
Definition: ee_collectors.h:41
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:150
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:479
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
SCH_ITEM * GetDrawItems() const
Definition: sch_screen.h:147

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

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