24#include <wx/tokenzr.h>
34 return aOut->
Print( aNestLevel,
"(pin_net %s %s)",
40 const wxString& aReference,
41 const wxString& aValue,
43 const std::vector<KIID>& aKiids )
75 if( aFootprint ==
nullptr )
84 std::vector<FOOTPRINT::FP_UNIT_INFO> fpUnits;
87 fpUnits.push_back( { u.m_unitName, u.m_pins } );
101 wxLogTrace( wxT(
"NETLIST_STACKED_PINS" ),
102 wxT(
"Looking for pin '%s' in component '%s'" ),
107 wxLogTrace( wxT(
"NETLIST_STACKED_PINS" ),
108 wxT(
" Checking net pin name '%s'" ),
111 if( net.GetPinName() == aPinName )
113 wxLogTrace( wxT(
"NETLIST_STACKED_PINS" ),
114 wxT(
" Found exact match for pin '%s'" ),
121 if( !expandedPins.empty() )
123 wxLogTrace( wxT(
"NETLIST_STACKED_PINS" ),
124 wxT(
" Pin name '%s' expanded to %zu pins" ),
125 net.GetPinName(), expandedPins.size() );
127 for(
const wxString& expandedPin : expandedPins )
129 wxLogTrace( wxT(
"NETLIST_STACKED_PINS" ),
130 wxT(
" Checking expanded pin '%s'" ),
132 if( expandedPin == aPinName )
134 wxLogTrace( wxT(
"NETLIST_STACKED_PINS" ),
135 wxT(
" Found match for pin '%s' in stacked notation '%s'" ),
136 aPinName, net.GetPinName() );
143 wxLogTrace( wxT(
"NETLIST_STACKED_PINS" ),
144 wxT(
" No net found for pin '%s'" ),
154 return it !=
m_variants.end() ? &it->second :
nullptr;
162 return it !=
m_variants.end() ? &it->second :
nullptr;
168 if( aVariant.
m_name.IsEmpty() )
176 updated.
m_name = it->first;
177 it->second = std::move( updated );
201 path +=
'/' + pathStep.AsString();
209 aOut->
Print( nl + 1,
"(fields" );
211 for( std::pair<wxString, wxString> field :
m_fields )
212 aOut->
Print( nl + 2,
"\n(field (name %s) %s)", aOut->
Quotew( field.first ).c_str(),
213 aOut->
Quotew( field.second ).c_str() );
215 aOut->
Print( 0,
")\n" );
219 aOut->
Print( nl + 1,
"(property (name \"dnp\"))\n" );
222 aOut->
Print( nl + 1,
"(property (name \"exclude_from_bom\"))\n" );
225 aOut->
Print( nl + 1,
"(property (name \"exclude_from_pos_files\"))\n" );
229 aOut->
Print( nl + 1,
"(variants" );
231 for(
const auto& [variantName, variant] :
m_variants )
233 aOut->
Print( nl + 2,
"\n(variant (name %s)",
234 aOut->
Quotew( variantName ).c_str() );
236 if( variant.m_hasDnp )
238 aOut->
Print( 0,
" (property (name \"dnp\") (value %s))",
239 aOut->
Quotew( variant.m_dnp ? wxT(
"1" ) : wxT(
"0" ) ).c_str() );
242 if( variant.m_hasExcludedFromBOM )
244 aOut->
Print( 0,
" (property (name \"exclude_from_bom\") (value %s))",
245 aOut->
Quotew( variant.m_excludedFromBOM ? wxT(
"1" ) : wxT(
"0" ) ).c_str() );
248 if( variant.m_hasExcludedFromSim )
250 aOut->
Print( 0,
" (property (name \"exclude_from_sim\") (value %s))",
251 aOut->
Quotew( variant.m_excludedFromSim ? wxT(
"1" ) : wxT(
"0" ) ).c_str() );
254 if( variant.m_hasExcludedFromPosFiles )
256 aOut->
Print( 0,
" (property (name \"exclude_from_pos_files\") (value %s))",
257 aOut->
Quotew( variant.m_excludedFromPosFiles ? wxT(
"1" ) : wxT(
"0" ) ).c_str() );
260 if( !variant.m_fields.empty() )
262 aOut->
Print( 0,
"\n" );
263 aOut->
Print( nl + 3,
"(fields" );
265 for(
const auto& [fieldName, fieldValue] : variant.m_fields )
267 aOut->
Print( nl + 4,
"\n(field (name %s) %s)",
268 aOut->
Quotew( fieldName ).c_str(),
269 aOut->
Quotew( fieldValue ).c_str() );
272 aOut->
Print( 0,
")" );
275 aOut->
Print( 0,
")" );
278 aOut->
Print( 0,
")\n" );
284 aOut->
Print( nl+1,
"(fp_filters" );
289 aOut->
Print( 0,
")\n" );
294 int llen = aOut->
Print( nl+1,
"(nets " );
296 for(
unsigned i = 0; i <
m_nets.size(); ++i )
300 aOut->
Print( 0,
"\n" );
301 llen = aOut->
Print( nl+1,
" " );
304 llen +=
m_nets[i].Format( aOut, 0, aCtl );
307 aOut->
Print( 0,
")\n" );
310 aOut->
Print( nl,
")\n" );
318 aOut->
Print( nl,
"(%s\n", aDocName );
325 aOut->
Print( nl,
")\n" );
344 if(
group.uuid == aUuid )
371 if( aUuidPath.empty() )
374 KIID comp_uuid = aUuidPath.back();
375 KIID_PATH base = aUuidPath;
382 const std::vector<KIID>& kiids = component.
GetKIIDs();
384 if( base != component.
GetPath() )
387 if( std::find( kiids.begin(), kiids.end(), comp_uuid ) != kiids.end() )
402 for(
const KIID& compUuid : component.
GetKIIDs() )
404 if( aUuid == compUuid )
459 for( KIID& member :
group.members )
Used to store the component pin name to net name (and pin function) associations stored in a netlist.
int Format(OUTPUTFORMATTER *aOut, int aNestLevel, int aCtl)
Store all of the related component information found in a netlist.
const COMPONENT_NET & GetNet(unsigned aIndex) const
const KIID_PATH & GetPath() const
std::vector< COMPONENT_NET > m_nets
list of nets shared by the component pins
std::map< wxString, wxString > m_properties
Component-specific properties found in the netlist.
wxArrayString m_footprintFilters
const wxString & GetReference() const
void AddVariant(const COMPONENT_VARIANT &aVariant)
CASE_INSENSITIVE_MAP< COMPONENT_VARIANT > m_variants
void Format(OUTPUTFORMATTER *aOut, int aNestLevel, int aCtl)
const COMPONENT_VARIANT * GetVariant(const wxString &aVariantName) const
KIID_PATH m_path
A fully specified path to the component (but not the component: [ sheetUUID, sheetUUID,...
NETLIST_GROUP * m_group
Group membership for this footprint. Nullptr if none.
bool m_duplicatePadNumbersAreJumpers
Flag that this footprint should automatically treat sets of two or more pads with the same number as ...
nlohmann::ordered_map< wxString, wxString > m_fields
Component-specific user fields found in the netlist.
wxString m_name
The name of the component in m_library used when it was placed on the schematic.
void SetFootprint(FOOTPRINT *aFootprint)
std::vector< KIID > m_kiids
A vector of possible KIIDs corresponding to all units in a symbol.
FOOTPRINT * GetFootprint(bool aRelease=false)
wxString m_library
The name of the component library where m_name was found.
LIB_ID m_fpid
The LIB_ID of the footprint assigned to the component.
static COMPONENT_NET m_emptyNet
const std::vector< KIID > & GetKIIDs() const
COMPONENT(const LIB_ID &aFPID, const wxString &aReference, const wxString &aValue, const KIID_PATH &aPath, const std::vector< KIID > &aKiids)
std::unique_ptr< FOOTPRINT > m_footprint
The FOOTPRINT loaded for #m_FPID.
const LIB_ID & GetFPID() const
void SetGroup(NETLIST_GROUP *aGroup)
std::vector< UNIT_INFO > m_units
A logical library item identifier and consists of various portions much like a URI.
void Format(const char *aDocName, OUTPUTFORMATTER *aOut, int aNestLevel, int aCtl=0)
void AddGroup(NETLIST_GROUP *aGroup)
void AddComponent(COMPONENT *aComponent)
Add aComponent to the NETLIST.
COMPONENT * GetComponentByPath(const KIID_PATH &aPath)
Return a COMPONENT by aPath.
COMPONENT * GetComponentByReference(const wxString &aReference)
Return a COMPONENT by aReference.
COMPONENT * GetComponentByUuid(const KIID &aUuid)
Return a COMPONENT by aUuid.
NETLIST_GROUP * GetGroupByUuid(const KIID &aUuid)
Return a NETLIST_GROUP by aUuid.
void ApplyGroupMembership()
After groups and components are parsed, apply the group memberships to the internal components based ...
bool AnyFootprintsLinked() const
static bool ByFPID(const COMPONENT &ref, const COMPONENT &cmp)
A helper function used to sort the component list used by loadNewModules.
#define CTL_OMIT_FP_UUID
Don't prefix the footprint UUID to the sheet path.
#define CTL_OMIT_FILTERS
Omit the ki_fp_filters attribute in .kicad_xxx files.
static bool empty(const wxTextEntryBase *aCtrl)
bool operator<(const COMPONENT &item1, const COMPONENT &item2)
Compare two COMPONENT objects by reference designator.
static bool ByFPID(const COMPONENT &ref, const COMPONENT &cmp)
A helper function used to sort the component list used by loadNewModules.
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
std::vector< wxString > ExpandStackedPinNotation(const wxString &aPinName, bool *aValid)
Expand stacked pin notation like [1,2,3], [1-4], [A1-A4], or [AA1-AA3,AB4,CD12-CD14] into individual ...