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

Go to the source code of this file.

Functions

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

Function Documentation

◆ FormatProbeItem()

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

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

155 {
156  // This is a keyword followed by a quoted string.
157 
158  // Cross probing to Pcbnew if a pin or a component is found
159  switch( aItem->Type() )
160  {
161  case SCH_FIELD_T:
162  case LIB_FIELD_T:
163  if( aPart )
164  return StrPrintf( "$PART: \"%s\"", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
165  break;
166 
167  case SCH_COMPONENT_T:
168  aPart = (SCH_COMPONENT*) aItem;
169  return StrPrintf( "$PART: \"%s\"", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
170 
171  case SCH_SHEET_T:
172  {
173  SCH_SHEET* sheet = (SCH_SHEET*)aItem;
174  return StrPrintf( "$SHEET: \"%8.8lX\"", (unsigned long) sheet->GetTimeStamp() );
175  }
176 
177  case LIB_PIN_T:
178  {
179  if( !aPart )
180  break;
181 
182  LIB_PIN* pin = (LIB_PIN*) aItem;
183 
184  if( !pin->GetNumber().IsEmpty() )
185  {
186  return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"", TO_UTF8( pin->GetNumber() ),
187  TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
188  }
189  else
190  {
191  return StrPrintf( "$PART: \"%s\"", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
192  }
193  }
194  break;
195 
196  default:
197  break;
198  }
199 
200  return "";
201 }
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
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
#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
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
timestamp_t GetTimeStamp() const
Definition: base_struct.h:207
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
const wxString & GetNumber() const
Definition: lib_pin.h:194
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:70
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References SCH_COMPONENT::GetField(), LIB_PIN::GetNumber(), EDA_TEXT::GetText(), EDA_ITEM::GetTimeStamp(), LIB_FIELD_T, LIB_PIN_T, REFERENCE, SCH_COMPONENT_T, SCH_FIELD_T, SCH_SHEET_T, numEval::StrPrintf(), TO_UTF8, and EDA_ITEM::Type().

Referenced by SCH_EDIT_FRAME::SendMessageToPCBNEW().