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

Cross probing functions to handle communication to and from Eeschema. More...

#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <kiway_express.h>
#include <pcb_edit_frame.h>
#include <eda_dde.h>
#include <macros.h>
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <class_zone.h>
#include <collectors.h>
#include <pcbnew.h>
#include <netlist_reader/pcb_netlist.h>
#include <tools/pcb_actions.h>
#include <tool/tool_manager.h>
#include <tools/selection_tool.h>
#include <pcb_painter.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 and from Eeschema.

Handle messages between Pcbnew and Eeschema via a socket, the port numbers are KICAD_PCB_PORT_SERVICE_NUMBER (currently 4242) (Eeschema to Pcbnew) KICAD_SCH_PORT_SERVICE_NUMBER (currently 4243) (Pcbnew to Eeschema) Note: these ports must be enabled for firewall protection

Definition in file pcbnew/cross-probing.cpp.

Function Documentation

◆ FormatProbeItem()

std::string FormatProbeItem ( BOARD_ITEM aItem)

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

232 {
233  MODULE* module;
234 
235  if( !aItem )
236  return "$CLEAR: \"HIGHLIGHTED\""; // message to clear highlight state
237 
238  switch( aItem->Type() )
239  {
240  case PCB_MODULE_T:
241  module = (MODULE*) aItem;
242  return StrPrintf( "$PART: \"%s\"", TO_UTF8( module->GetReference() ) );
243 
244  case PCB_PAD_T:
245  {
246  module = (MODULE*) aItem->GetParent();
247  wxString pad = ((D_PAD*)aItem)->GetName();
248 
249  return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"",
250  TO_UTF8( module->GetReference() ),
251  TO_UTF8( pad ) );
252  }
253 
254  case PCB_MODULE_TEXT_T:
255  {
256  module = static_cast<MODULE*>( aItem->GetParent() );
257 
258  TEXTE_MODULE* text_mod = static_cast<TEXTE_MODULE*>( aItem );
259 
260  const char* text_key;
261 
262  /* This can't be a switch since the break need to pull out
263  * from the outer switch! */
264  if( text_mod->GetType() == TEXTE_MODULE::TEXT_is_REFERENCE )
265  text_key = "$REF:";
266  else if( text_mod->GetType() == TEXTE_MODULE::TEXT_is_VALUE )
267  text_key = "$VAL:";
268  else
269  break;
270 
271  return StrPrintf( "$PART: \"%s\" %s \"%s\"",
272  TO_UTF8( module->GetReference() ),
273  text_key,
274  TO_UTF8( text_mod->GetText() ) );
275  }
276 
277  default:
278  break;
279  }
280 
281  return "";
282 }
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
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:436
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:48
class MODULE, a footprint
Definition: typeinfo.h:89
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
BOARD_ITEM_CONTAINER * GetParent() const
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

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

Referenced by PCB_EDIT_FRAME::SendMessageToEESCHEMA().