KiCad PCB EDA Suite
pcbnew/cross-probing.cpp File Reference

Cross probing functions to handle communication to andfrom Eeschema. More...

#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <kiway_express.h>
#include <wxPcbStruct.h>
#include <eda_dde.h>
#include <macros.h>
#include <pcbnew_id.h>
#include <class_board.h>
#include <class_module.h>
#include <collectors.h>
#include <pcbnew.h>
#include <netlist_reader.h>
#include <pcb_netlist.h>
#include <dialogs/dialog_update_pcb.h>
#include <tools/pcb_actions.h>
#include <tool/tool_manager.h>
#include <tools/selection_tool.h>
#include <pcb_draw_panel_gal.h>

Go to the source code of this file.

Functions

std::string FormatProbeItem (BOARD_ITEM *aItem)
 

Detailed Description

Cross probing functions to handle communication to andfrom Eeschema.

Definition in file pcbnew/cross-probing.cpp.

Function Documentation

std::string FormatProbeItem ( BOARD_ITEM aItem)

Definition at line 164 of file pcbnew/cross-probing.cpp.

References BOARD_ITEM::GetParent(), MODULE::GetReference(), EDA_TEXT::GetText(), TEXTE_MODULE::GetType(), PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_PAD_T, StrPrintf(), TEXTE_MODULE::TEXT_is_REFERENCE, TEXTE_MODULE::TEXT_is_VALUE, TO_UTF8, and EDA_ITEM::Type().

Referenced by PCB_EDIT_FRAME::SendMessageToEESCHEMA().

165 {
166  MODULE* module;
167 
168  switch( aItem->Type() )
169  {
170  case PCB_MODULE_T:
171  module = (MODULE*) aItem;
172  return StrPrintf( "$PART: \"%s\"", TO_UTF8( module->GetReference() ) );
173 
174  case PCB_PAD_T:
175  {
176  module = (MODULE*) aItem->GetParent();
177  wxString pad = ((D_PAD*)aItem)->GetPadName();
178 
179  return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"",
180  TO_UTF8( module->GetReference() ),
181  TO_UTF8( pad ) );
182  }
183 
184  case PCB_MODULE_TEXT_T:
185  {
186  module = static_cast<MODULE*>( aItem->GetParent() );
187 
188  TEXTE_MODULE* text_mod = static_cast<TEXTE_MODULE*>( aItem );
189 
190  const char* text_key;
191 
192  /* This can't be a switch since the break need to pull out
193  * from the outer switch! */
194  if( text_mod->GetType() == TEXTE_MODULE::TEXT_is_REFERENCE )
195  text_key = "$REF:";
196  else if( text_mod->GetType() == TEXTE_MODULE::TEXT_is_VALUE )
197  text_key = "$VAL:";
198  else
199  break;
200 
201  return StrPrintf( "$PART: \"%s\" %s \"%s\"",
202  TO_UTF8( module->GetReference() ),
203  text_key,
204  TO_UTF8( text_mod->GetText() ) );
205  }
206 
207  default:
208  break;
209  }
210 
211  return "";
212 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
BOARD_ITEM_CONTAINER * GetParent() const
TEXT_TYPE GetType() const
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
int StrPrintf(std::string *result, const char *format,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:75
#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
class MODULE, a footprint
Definition: typeinfo.h:101
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:411