75 bool multiHighlight =
false;
85 strncpy( line, cmdline,
sizeof(line) - 1 );
86 line[
sizeof(line) - 1] = 0;
88 idcmd = strtok( line,
" \n\r" );
89 text = strtok(
nullptr,
"\"\n\r" );
91 if( idcmd ==
nullptr )
94 if( strcmp( idcmd,
"$NET:" ) == 0 )
107 std::vector<MSG_PANEL_ITEM> items;
113 if( strcmp( idcmd,
"$NETS:" ) == 0 )
118 wxStringTokenizer netsTok = wxStringTokenizer(
FROM_UTF8(
text ), wxT(
"," ) );
121 while( netsTok.HasMoreTokens() )
130 std::vector<MSG_PANEL_ITEM> items;
137 multiHighlight =
true;
149 else if( strcmp( idcmd,
"$CLEAR" ) == 0 )
178 else if( netcode > 0 || multiHighlight )
180 if( !multiHighlight )
182 renderSettings->
SetHighlight( ( netcode >= 0 ), netcode );
196 if( aItem->GetNetCode() == netcode )
197 bbox.
Merge( aItem->GetBoundingBox() );
210 for(
PAD* p : fp->Pads() )
242 return "$CLEAR: \"HIGHLIGHTED\"";
244 switch( aItem->
Type() )
253 wxString
pad =
static_cast<PAD*
>( aItem )->GetNumber();
255 return StrPrintf(
"$PART: \"%s\" $PAD: \"%s\"",
265 const char* text_key;
276 return StrPrintf(
"$PART: \"%s\" %s \"%s\"",
290template <
typename ItemContainer>
295 switch( item->Type() )
336 std::string command =
"$SELECT: ";
340 std::deque<EDA_ITEM*> focusItems = { aFocusItem };
341 std::set<wxString> focusParts;
344 if( focusParts.size() > 0 )
347 command += *focusParts.begin();
360 std::set<wxString> parts;
366 for( wxString part : parts )
393 if( !packet.empty() )
414 if( !packet.empty() )
433 wxArrayString syncArray = wxStringTokenize( syncStr,
"," );
435 std::vector<std::pair<int, BOARD_ITEM*>> orderPairs;
439 if( footprint ==
nullptr )
442 wxString fpSheetPath = footprint->GetPath().AsString().BeforeLast(
'/' );
443 wxString fpUUID = footprint->m_Uuid.AsString();
445 if( fpSheetPath.IsEmpty() )
453 for(
unsigned index = 0; index < syncArray.size(); ++index )
455 wxString syncEntry = syncArray[index];
457 if( syncEntry.empty() )
460 wxString syncData = syncEntry.substr( 1 );
462 switch( syncEntry.GetChar( 0 ).GetValue() )
465 if( fpSheetPath.StartsWith( syncData ) )
467 orderPairs.emplace_back( index, footprint );
471 if( syncData == fpRefEscaped )
473 orderPairs.emplace_back( index, footprint );
478 if( syncData.StartsWith( fpRefEscaped ) )
480 wxString selectPadNumberEscaped =
481 syncData.substr( fpRefEscaped.size() + 1 );
483 wxString selectPadNumber =
UnescapeString( selectPadNumberEscaped );
485 for(
PAD*
pad : footprint->Pads() )
487 if( selectPadNumber ==
pad->GetNumber() )
489 orderPairs.emplace_back( index,
pad );
501 orderPairs.begin(), orderPairs.end(),
502 [](
const std::pair<int, BOARD_ITEM*>& a,
const std::pair<int, BOARD_ITEM*>& b ) ->
bool
504 return a.first < b.first;
507 std::vector<BOARD_ITEM*> items;
508 items.reserve( orderPairs.size() );
510 for(
const std::pair<int, BOARD_ITEM*>& pair : orderPairs )
511 items.push_back( pair.second );
533 COMPONENT* component =
new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
534 footprint->GetValue(), footprint->GetPath(), {} );
536 for(
PAD*
pad : footprint->Pads() )
538 const wxString& netname =
pad->GetShortNetname();
540 if( !netname.IsEmpty() )
542 component->
AddNet(
pad->GetNumber(), netname,
pad->GetPinFunction(),
547 netlist.AddComponent( component );
592 std::string prefix =
"$SELECT: ";
594 if( !payload.compare( 0, prefix.size(), prefix ) )
596 std::string del =
",";
597 std::string paramStr = payload.substr( prefix.size() );
598 int modeEnd = paramStr.find( del );
599 bool selectConnections =
false;
603 if( std::stoi( paramStr.substr( 0, modeEnd ) ) == 1 )
604 selectConnections =
true;
606 catch( std::invalid_argument& )
611 std::vector<BOARD_ITEM*> items =
616 if( selectConnections )
619 static_cast<void*
>( &items ) );
624 static_cast<void*
>( &items ) );
643 size_t split = payload.find(
'\n' );
644 wxCHECK(
split != std::string::npos, );
649 importFormat = std::stoi( payload.substr( 0,
split ) );
651 catch( std::invalid_argument& )
657 std::string
path = payload.substr(
split + 1 );
658 wxASSERT( !
path.empty() );
660 if( importFormat >= 0 )
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION updatePcbFromSchematic
CROSS_PROBING_SETTINGS m_CrossProbing
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
BOARD_ITEM_CONTAINER * GetParent() const
Update the BOARD with a new netlist.
bool UpdateNetlist(NETLIST &aNetlist)
Update the board's components according to the new netlist.
void SetDeleteUnusedFootprints(bool aEnabled)
void SetReplaceFootprints(bool aEnabled)
void SetLookupByTimestamp(bool aEnabled)
Information pertinent to a Pcbnew printed circuit board.
const std::set< int > & GetHighLightNetCodes() const
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
void ResetNetHighLight()
Reset all high light data to the init state.
FOOTPRINTS & Footprints()
bool IsHighLightNetON() const
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
coord_type GetHeight() const
coord_type GetWidth() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Store all of the related footprint information found in a netlist.
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsHighlightEnabled() const
Return current highlight setting.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Carry a payload from one KIWAY_PLAYER to another within a PROJECT.
std::string & GetPayload()
Return the payload, which can be any text but it typically self identifying s-expression.
MAIL_T Command()
Returns the MAIL_T associated with this mail.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Handle the data for a net.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Return the information about the NETINFO_ITEM in aList to display in the message panel.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
static TOOL_ACTION highlightItem
static TOOL_ACTION pluginsReload
Scripting Actions.
static TOOL_ACTION syncSelection
Sets selection to specified items, zooms to fit, if enabled.
static TOOL_ACTION syncSelectionWithNets
Sets selection to specified items with connected nets, zooms to fit, if enabled.
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Update3DView(bool aMarkDirty, bool aRefresh, const wxString *aTitle=nullptr)
Update the 3D view, if the viewer is opened by this frame.
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
bool importFile(const wxString &aFileName, int aFileType)
Load the given filename but sets the path to the current project path.
void OnNetlistChanged(BOARD_NETLIST_UPDATER &aUpdater, bool *aRunDragCommand)
Called after netlist is updated.
void ExecuteRemoteCommand(const char *cmdline) override
Execute a remote command send by Eeschema via a socket, port KICAD_PCB_PORT_SERVICE_NUMBER (currently...
void SendCrossProbeItem(BOARD_ITEM *aSyncItem)
Send a message to the schematic editor so that it may move its cursor to an item with the same refere...
bool FetchNetlistFromSchematic(NETLIST &aNetlist, const wxString &aAnnotateMessage)
void SendSelectItemsToSch(const std::deque< EDA_ITEM * > &aItems, EDA_ITEM *aFocusItem, bool aForce)
Send a message to the schematic editor to try to find schematic counterparts of specified PCB items a...
std::vector< BOARD_ITEM * > FindItemsFromSyncSelection(std::string syncStr)
Used to find items by selection synchronization spec string.
void SendCrossProbeNetName(const wxString &aNetName)
Send a net name to Eeschema for highlighting.
A set of BOARD_ITEMs (i.e., without duplicates).
Handle a list of polygons defining a copper zone.
bool SendCommand(int aService, const std::string &aMessage)
Used by a client to sent (by a socket connection) a data to a server.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
void collectItemsForSyncParts(ItemContainer &aItems, std::set< wxString > &parts)
std::string FormatProbeItem(BOARD_ITEM *aItem)
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.
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
static std::vector< std::string > split(const std::string &aStr, const std::string &aDelim)
Split the input string into a vector of output strings.
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
bool center_on_items
Automatically pan to cross-probed items.
bool auto_highlight
Automatically turn on highlight mode in the target frame.
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint