79 bool multiHighlight =
false;
89 strncpy( line, cmdline,
sizeof(line) - 1 );
90 line[
sizeof(line) - 1] = 0;
92 idcmd = strtok( line,
" \n\r" );
93 text = strtok(
nullptr,
"\"\n\r" );
95 if( idcmd ==
nullptr )
98 if( strcmp( idcmd,
"$CONFIG" ) == 0 )
103 else if( strcmp( idcmd,
"$CUSTOM_RULES" ) == 0 )
108 else if( strcmp( idcmd,
"$DRC" ) == 0 )
113 else if( strcmp( idcmd,
"$CLEAR" ) == 0 )
130 else if( strcmp( idcmd,
"$NET:" ) == 0 )
143 std::vector<MSG_PANEL_ITEM> items;
150 else if( strcmp( idcmd,
"$NETS:" ) == 0 )
155 wxStringTokenizer netsTok = wxStringTokenizer(
From_UTF8(
text ), wxT(
"," ) );
158 while( netsTok.HasMoreTokens() )
167 std::vector<MSG_PANEL_ITEM> items;
174 multiHighlight =
true;
200 else if( netcode > 0 || multiHighlight )
202 if( !multiHighlight )
204 renderSettings->
SetHighlight( ( netcode >= 0 ), netcode );
218 if( aItem->GetNetCode() == netcode )
219 bbox.
Merge( aItem->GetBoundingBox() );
232 for(
PAD* p : fp->Pads() )
262 return "$CLEAR: \"HIGHLIGHTED\"";
264 switch( aItem->
Type() )
277 return StrPrintf(
"$PART: \"%s\" $PAD: \"%s\"",
286 const char* text_key;
297 return StrPrintf(
"$PART: \"%s\" %s \"%s\"",
311template <
typename ItemContainer>
316 switch( item->Type() )
339 wxString ref =
pad->GetParentFootprint()->GetReference();
356 std::string command =
"$SELECT: ";
360 std::deque<EDA_ITEM*> focusItems = { aFocusItem };
361 std::set<wxString> focusParts;
364 if( focusParts.size() > 0 )
367 command += *focusParts.begin();
380 std::set<wxString> parts;
386 for( wxString part : parts )
413 if( !packet.empty() )
434 if( !packet.empty() )
453 wxArrayString syncArray = wxStringTokenize( syncStr,
"," );
455 std::vector<std::pair<int, BOARD_ITEM*>> orderPairs;
459 if( footprint ==
nullptr )
462 wxString fpSheetPath = footprint->GetPath().AsString().BeforeLast(
'/' );
463 wxString fpUUID = footprint->m_Uuid.AsString();
465 if( fpSheetPath.IsEmpty() )
473 for(
unsigned index = 0; index < syncArray.size(); ++index )
475 wxString syncEntry = syncArray[index];
477 if( syncEntry.empty() )
480 wxString syncData = syncEntry.substr( 1 );
482 switch( syncEntry.GetChar( 0 ).GetValue() )
485 if( fpSheetPath.StartsWith( syncData ) )
487 orderPairs.emplace_back( index, footprint );
491 if( syncData == fpRefEscaped )
493 orderPairs.emplace_back( index, footprint );
498 if( syncData.StartsWith( fpRefEscaped ) )
500 wxString selectPadNumberEscaped =
501 syncData.substr( fpRefEscaped.size() + 1 );
503 wxString selectPadNumber =
UnescapeString( selectPadNumberEscaped );
505 for(
PAD*
pad : footprint->Pads() )
507 if( selectPadNumber ==
pad->GetNumber() )
509 orderPairs.emplace_back( index,
pad );
521 orderPairs.begin(), orderPairs.end(),
522 [](
const std::pair<int, BOARD_ITEM*>& a,
const std::pair<int, BOARD_ITEM*>& b ) ->
bool
524 return a.first < b.first;
527 std::vector<BOARD_ITEM*> items;
528 items.reserve( orderPairs.size() );
530 for(
const std::pair<int, BOARD_ITEM*>& pair : orderPairs )
531 items.push_back( pair.second );
553 COMPONENT* component =
new COMPONENT( footprint->GetFPID(), footprint->GetReference(),
554 footprint->GetValue(), footprint->GetPath(), {} );
556 for(
PAD*
pad : footprint->Pads() )
558 const wxString& netname =
pad->GetShortNetname();
560 if( !netname.IsEmpty() )
562 component->
AddNet(
pad->GetNumber(), netname,
pad->GetPinFunction(),
567 nlohmann::ordered_map<wxString, wxString> fields;
568 for(
PCB_FIELD* field : footprint->Fields() )
569 fields[field->GetCanonicalName()] = field->GetText();
574 std::map<wxString, wxString> properties;
576 if( footprint->GetAttributes() &
FP_DNP )
577 properties.emplace(
"dnp",
"" );
580 properties.emplace(
"exclude_from_bom",
"" );
584 netlist.AddComponent( component );
629 std::string prefix =
"$SELECT: ";
631 if( !payload.compare( 0, prefix.size(), prefix ) )
633 std::string del =
",";
634 std::string paramStr = payload.substr( prefix.size() );
635 size_t modeEnd = paramStr.find( del );
636 bool selectConnections =
false;
640 if( std::stoi( paramStr.substr( 0, modeEnd ) ) == 1 )
641 selectConnections =
true;
643 catch( std::invalid_argument& )
648 std::vector<BOARD_ITEM*> items =
653 if( selectConnections )
674 std::stringstream ss( payload );
677 std::string formatStr;
678 wxCHECK( std::getline( ss, formatStr, delim ), );
680 std::string fnameStr;
681 wxCHECK( std::getline( ss, fnameStr, delim ), );
682 wxASSERT( !fnameStr.empty() );
688 importFormat = std::stoi( formatStr );
690 catch( std::invalid_argument& )
696 std::map<std::string, UTF8> props;
698 std::string key, value;
701 if( !std::getline( ss, key, delim ) )
704 if( !std::getline( ss, value, delim ) )
707 props.emplace( key, value );
711 if( importFormat >= 0 )
712 importFile( fnameStr, importFormat, props.empty() ?
nullptr : &props );
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
static TOOL_ACTION updatePcbFromSchematic
static TOOL_ACTION pluginsReload
static TOOL_ACTION showFootprintLibTable
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...
FOOTPRINT * GetParentFootprint() 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.
const ZONES & Zones() const
void ResetNetHighLight()
Reset all high light data to the init state.
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
bool IsHighLightNetON() const
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr size_type GetHeight() const
Store all of the related footprint information found in a netlist.
void SetFields(nlohmann::ordered_map< wxString, wxString > &aFields)
void SetProperties(std::map< wxString, wxString > &aProps)
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
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual const wxString & GetText() const
Return the string associated with the text 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.
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 runDRC
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 ShowBoardSetupDialog(const wxString &aInitialPage=wxEmptyString)
void KiwayMailIn(KIWAY_EXPRESS &aEvent) override
Receive KIWAY_EXPRESS messages from other players.
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.
bool importFile(const wxString &aFileName, int aFileType, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load the given filename but sets the path to the current project path.
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.
#define CTL_OMIT_FILTERS
Omit the ki_fp_filters attribute in .kicad_xxx files.
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 ...
Class to handle a set of BOARD_ITEMs.
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.
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
wxString UnescapeString(const wxString &aSource)
wxString From_UTF8(const char *cstring)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
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_FIELD_T
class PCB_FIELD, text associated with a footprint property
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint