KiCad PCB EDA Suite
eeschema/cross-probing.cpp File Reference
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <kiway_express.h>
#include <macros.h>
#include <eda_dde.h>
#include <sch_draw_panel.h>
#include <tool/tool_manager.h>
#include <sch_edit_frame.h>
#include <general.h>
#include <eeschema_id.h>
#include <lib_draw_item.h>
#include <lib_pin.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_view.h>
#include <reporter.h>
#include <netlist_exporters/netlist_exporter_kicad.h>
#include <tools/ee_actions.h>

Go to the source code of this file.

Functions

std::string FormatProbeItem (EDA_ITEM *aItem, SCH_COMPONENT *aComp)
 

Function Documentation

◆ FormatProbeItem()

std::string FormatProbeItem ( EDA_ITEM aItem,
SCH_COMPONENT aComp 
)

Definition at line 146 of file eeschema/cross-probing.cpp.

147 {
148  // This is a keyword followed by a quoted string.
149 
150  // Cross probing to Pcbnew if a pin or a component is found
151  switch( aItem->Type() )
152  {
153  case LIB_PIN_T:
154  wxFAIL_MSG( "What are we doing with LIB_* items here?" );
155  break;
156 
157  case LIB_FIELD_T:
158  wxFAIL_MSG( "What are we doing with LIB_* items here?" );
159  // fall through to SCH_FIELD_T:
160 
161  case SCH_FIELD_T:
162  if( aComp )
163  return StrPrintf( "$PART: \"%s\"", TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
164  break;
165 
166  case SCH_COMPONENT_T:
167  aComp = (SCH_COMPONENT*) aItem;
168  return StrPrintf( "$PART: \"%s\"", TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
169 
170  case SCH_SHEET_T:
171  {
172  SCH_SHEET* sheet = (SCH_SHEET*)aItem;
173  return StrPrintf( "$SHEET: \"%8.8lX\"", (unsigned long) sheet->GetTimeStamp() );
174  }
175 
176  case SCH_PIN_T:
177  {
178  SCH_PIN* pin = (SCH_PIN*) aItem;
179  aComp = pin->GetParentComponent();
180 
181  if( !pin->GetNumber().IsEmpty() )
182  {
183  return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"",
184  TO_UTF8( pin->GetNumber() ),
185  TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
186  }
187  else
188  {
189  return StrPrintf( "$PART: \"%s\"",
190  TO_UTF8( aComp->GetField( REFERENCE )->GetText() ) );
191  }
192  }
193 
194  default:
195  break;
196  }
197 
198  return "";
199 }
int StrPrintf(std::string *aResult, const char *aFormat,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:74
const wxString GetText() const override
Function GetText returns the string associated with the text object.
Definition: sch_field.cpp:105
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
const wxString & GetNumber() const
Definition: sch_pin.h:96
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:47
timestamp_t GetTimeStamp() const
Definition: base_struct.h:210
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:201
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
SCH_COMPONENT * GetParentComponent() const
Definition: sch_pin.cpp:58
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

References SCH_COMPONENT::GetField(), SCH_PIN::GetNumber(), SCH_PIN::GetParentComponent(), SCH_FIELD::GetText(), EDA_ITEM::GetTimeStamp(), LIB_FIELD_T, LIB_PIN_T, REFERENCE, SCH_COMPONENT_T, SCH_FIELD_T, SCH_PIN_T, SCH_SHEET_T, numEval::StrPrintf(), TO_UTF8, and EDA_ITEM::Type().

Referenced by SCH_EDIT_FRAME::SendMessageToPCBNEW().