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

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

#include <board.h>
#include <board_design_settings.h>
#include <footprint.h>
#include <pad.h>
#include <pcb_track.h>
#include <pcb_group.h>
#include <zone.h>
#include <collectors.h>
#include <eda_dde.h>
#include <kiface_base.h>
#include <kiway_express.h>
#include <string_utils.h>
#include <netlist_reader/pcb_netlist.h>
#include <netlist_reader/board_netlist_updater.h>
#include <painter.h>
#include <pcb_edit_frame.h>
#include <pcbnew_settings.h>
#include <render_settings.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
#include <tools/pcb_selection_tool.h>
#include <netlist_reader/netlist_reader.h>
#include <wx/log.h>

Go to the source code of this file.

Functions

std::string FormatProbeItem (BOARD_ITEM *aItem)
 
template<typename ItemContainer >
void collectItemsForSyncParts (ItemContainer &aItems, std::set< wxString > &parts)
 

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

◆ collectItemsForSyncParts()

template<typename ItemContainer >
void collectItemsForSyncParts ( ItemContainer &  aItems,
std::set< wxString > &  parts 
)

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

292{
293 for( EDA_ITEM* item : aItems )
294 {
295 switch( item->Type() )
296 {
297 case PCB_GROUP_T:
298 {
299 PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
300
301 collectItemsForSyncParts( group->GetItems(), parts );
302
303 break;
304 }
305 case PCB_FOOTPRINT_T:
306 {
307 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
308 wxString ref = footprint->GetReference();
309
310 parts.emplace( wxT( "F" ) + EscapeString( ref, CTX_IPC ) );
311
312 break;
313 }
314
315 case PCB_PAD_T:
316 {
317 PAD* pad = static_cast<PAD*>( item );
318 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( pad->GetParentFootprint() );
319 wxString ref = footprint->GetReference();
320
321 parts.emplace( wxT( "P" ) + EscapeString( ref, CTX_IPC ) + wxT( "/" )
322 + EscapeString( pad->GetNumber(), CTX_IPC ) );
323
324 break;
325 }
326
327 default: break;
328 }
329 }
330}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
const wxString & GetReference() const
Definition: footprint.h:519
Definition: pad.h:59
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
void collectItemsForSyncParts(ItemContainer &aItems, std::set< wxString > &parts)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
@ CTX_IPC
Definition: string_utils.h:56
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87

References collectItemsForSyncParts(), CTX_IPC, EscapeString(), FOOTPRINT::GetReference(), group, pad, PCB_FOOTPRINT_T, PCB_GROUP_T, and PCB_PAD_T.

Referenced by collectItemsForSyncParts(), and PCB_EDIT_FRAME::SendSelectItemsToSch().

◆ FormatProbeItem()

std::string FormatProbeItem ( BOARD_ITEM aItem)

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

238{
239 FOOTPRINT* footprint;
240
241 if( !aItem )
242 return "$CLEAR: \"HIGHLIGHTED\""; // message to clear highlight state
243
244 switch( aItem->Type() )
245 {
246 case PCB_FOOTPRINT_T:
247 footprint = (FOOTPRINT*) aItem;
248 return StrPrintf( "$PART: \"%s\"", TO_UTF8( footprint->GetReference() ) );
249
250 case PCB_PAD_T:
251 {
252 footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
253 wxString pad = static_cast<PAD*>( aItem )->GetNumber();
254
255 return StrPrintf( "$PART: \"%s\" $PAD: \"%s\"",
256 TO_UTF8( footprint->GetReference() ),
257 TO_UTF8( pad ) );
258 }
259
260 case PCB_FP_TEXT_T:
261 {
262 footprint = static_cast<FOOTPRINT*>( aItem->GetParent() );
263
264 FP_TEXT* text = static_cast<FP_TEXT*>( aItem );
265 const char* text_key;
266
267 /* This can't be a switch since the break need to pull out
268 * from the outer switch! */
269 if( text->GetType() == FP_TEXT::TEXT_is_REFERENCE )
270 text_key = "$REF:";
271 else if( text->GetType() == FP_TEXT::TEXT_is_VALUE )
272 text_key = "$VAL:";
273 else
274 break;
275
276 return StrPrintf( "$PART: \"%s\" %s \"%s\"",
277 TO_UTF8( footprint->GetReference() ),
278 text_key,
279 TO_UTF8( text->GetText() ) );
280 }
281
282 default:
283 break;
284 }
285
286 return "";
287}
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
@ TEXT_is_REFERENCE
Definition: fp_text.h:49
@ TEXT_is_VALUE
Definition: fp_text.h:50
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
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:84
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92

References BOARD_ITEM::GetParent(), FOOTPRINT::GetReference(), pad, PCB_FOOTPRINT_T, PCB_FP_TEXT_T, PCB_PAD_T, StrPrintf(), text, FP_TEXT::TEXT_is_REFERENCE, FP_TEXT::TEXT_is_VALUE, TO_UTF8, and EDA_ITEM::Type().

Referenced by PCB_EDIT_FRAME::SendCrossProbeItem().