KiCad PCB EDA Suite
eeschema/cross-probing.cpp File Reference
#include <kiface_base.h>
#include <kiway_express.h>
#include <eda_dde.h>
#include <connection_graph.h>
#include <sch_symbol.h>
#include <schematic.h>
#include <reporter.h>
#include <string_utils.h>
#include <netlist_exporters/netlist_exporter_kicad.h>
#include <project/project_file.h>
#include <project/net_settings.h>
#include <tools/ee_actions.h>
#include <tools/sch_editor_control.h>
#include <advanced_config.h>
#include <netclass.h>
#include <wx/log.h>

Go to the source code of this file.

Functions

std::string FormatProbeItem (EDA_ITEM *aItem, SCH_SYMBOL *aSymbol)
 

Function Documentation

◆ FormatProbeItem()

std::string FormatProbeItem ( EDA_ITEM aItem,
SCH_SYMBOL aSymbol 
)

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

365 {
366  // This is a keyword followed by a quoted string.
367 
368  // Cross probing to Pcbnew if a pin or a symbol is found.
369  switch( aItem->Type() )
370  {
371  case SCH_FIELD_T:
372  if( aSymbol )
373  {
374  return StrPrintf( "$PART: \"%s\"",
375  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
376  }
377  break;
378 
379  case SCH_SYMBOL_T:
380  aSymbol = (SCH_SYMBOL*) aItem;
381  return StrPrintf( "$PART: \"%s\"",
382  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
383 
384  case SCH_SHEET_T:
385  {
386  // For cross probing, we need the full path of the sheet, because
387  // in complex hierarchies the sheet uuid of not unique
388  SCH_SHEET* sheet = (SCH_SHEET*)aItem;
389  wxString full_path;
390 
391  SCH_SHEET* parent = sheet;
392  while( (parent = dynamic_cast<SCH_SHEET*>( parent->GetParent() ) ) )
393  {
394  if( parent->GetParent() ) // The root sheet has no parent and path is just "/"
395  {
396  full_path.Prepend( parent->m_Uuid.AsString() );
397  full_path.Prepend( "/" );
398  }
399  }
400 
401  full_path += "/" + sheet->m_Uuid.AsString();
402 
403  return StrPrintf( "$SHEET: \"%s\"", TO_UTF8( full_path ) );
404  }
405 
406  case SCH_PIN_T:
407  {
408  SCH_PIN* pin = (SCH_PIN*) aItem;
409  aSymbol = pin->GetParentSymbol();
410 
411  if( !pin->GetShownNumber().IsEmpty() )
412  {
413  return StrPrintf( "$PIN: \"%s\" $PART: \"%s\"",
414  TO_UTF8( pin->GetShownNumber() ),
415  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
416  }
417  else
418  {
419  return StrPrintf( "$PART: \"%s\"",
420  TO_UTF8( aSymbol->GetField( REFERENCE_FIELD )->GetText() ) );
421  }
422  }
423 
424  default:
425  break;
426  }
427 
428  return "";
429 }
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:675
wxString AsString() const
Definition: kiid.cpp:218
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
Definition: richio.cpp:79
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
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
Schematic symbol object.
Definition: sch_symbol.h:78
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References KIID::AsString(), SCH_SYMBOL::GetField(), EDA_ITEM::GetParent(), EDA_TEXT::GetText(), EDA_ITEM::m_Uuid, pin, REFERENCE_FIELD, SCH_FIELD_T, SCH_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, StrPrintf(), TO_UTF8, and EDA_ITEM::Type().

Referenced by SCH_EDIT_FRAME::SendMessageToPCBNEW().