37#include <wx/wfstream.h>
57 wxFFileOutputStream stream( aOutFileName );
65 return xdoc.Save( stream, 2 );
114 wxString description;
116 nlohmann::ordered_map<wxString, wxString> fields;
127 wxString ref = aSymbol->
GetRef( &aSheet );
137 wxString ref2 = symbol2->
GetRef( &sheet );
139 if( ref2.CmpNoCase( ref ) != 0 )
149 if( !candidate.IsEmpty() && ( unit < minUnit || value.IsEmpty() ) )
155 if( !candidate.IsEmpty() && ( unit < minUnit || footprint.IsEmpty() ) )
156 footprint = candidate;
162 if( !candidate.IsEmpty() && ( unit < minUnit ||
datasheet.IsEmpty() ) )
169 if( !candidate.IsEmpty() && ( unit < minUnit || description.IsEmpty() ) )
170 description = candidate;
175 if( field.IsMandatory() || field.IsPrivate() )
178 if( unit < minUnit || fields.count( field.GetName() ) == 0 )
181 fields[field.GetName()] = field.GetShownText( &aSheet,
false );
183 fields[field.GetName()] = field.GetText();
187 minUnit = std::min( unit, minUnit );
207 description = descriptionField->
GetShownText( &aSheet,
false );
209 description = descriptionField->
GetText();
213 if( field.IsMandatory() || field.IsPrivate() )
217 fields[field.GetName()] = field.GetShownText( &aSheet,
false );
219 fields[field.GetName()] = field.GetText();
231 aNode->AddChild(
node( wxT(
"value" ), wxT(
"~" ) ) );
233 if( footprint.size() )
239 if( description.size() )
243 aNode->AddChild( xfields =
node( wxT(
"fields" ) ) );
245 for(
const auto& [ fieldName, fieldValue ] : fields )
249 xfields->AddChild( xfield );
256 XNODE* xcomps =
node( wxT(
"components" ) );
278 b->GetRef( &sheet,
false ),
true ) < 0 );
281 std::set<
SCH_SYMBOL*,
decltype( cmp )> ordered_symbols( cmp );
282 std::multiset<
SCH_SYMBOL*,
decltype( cmp )> extra_units( cmp );
287 auto test = ordered_symbols.insert( symbol );
291 if( ( *(
test.first ) )->m_Uuid > symbol->
m_Uuid )
293 extra_units.insert( *(
test.first ) );
294 ordered_symbols.erase(
test.first );
295 ordered_symbols.insert( symbol );
299 extra_units.insert( symbol );
304 for(
EDA_ITEM* item : ordered_symbols )
324 xcomps->AddChild( xcomp =
node( wxT(
"comp" ) ) );
330 xcomp->AddChild( xlibsource =
node( wxT(
"libsource" ) ) );
361 std::vector<SCH_FIELD>& fields = symbol->
GetFields();
365 if( field.IsMandatory() || field.IsPrivate() )
368 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
369 xproperty->
AddAttribute( wxT(
"name" ), field.GetCanonicalName() );
372 xproperty->
AddAttribute( wxT(
"value" ), field.GetShownText( &sheet,
false ) );
374 xproperty->
AddAttribute( wxT(
"value" ), field.GetText() );
377 for(
const SCH_FIELD& sheetField : sheet.Last()->GetFields() )
379 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
380 xproperty->
AddAttribute( wxT(
"name" ), sheetField.GetCanonicalName() );
385 xproperty->
AddAttribute( wxT(
"value" ), sheetField.GetShownText( &sheet,
false ) );
387 xproperty->
AddAttribute( wxT(
"value" ), sheetField.GetText() );
392 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
393 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_bom" ) );
398 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
399 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_board" ) );
404 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
405 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_pos_files" ) );
408 if( symbol->
ResolveDNP( &sheet ) || sheet.GetDNP() )
410 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
418 const bool baseDnp = symbol->
GetDNP( &sheet );
422 XNODE* xvariants =
nullptr;
424 for(
const auto& [variantName, variant] : instance.
m_Variants )
426 XNODE* xvariant =
node( wxT(
"variant" ) );
427 bool hasVariantData =
false;
431 if( variant.m_DNP != baseDnp )
433 XNODE* xvarprop =
node( wxT(
"property" ) );
435 xvarprop->
AddAttribute( wxT(
"value" ), variant.m_DNP ? wxT(
"1" ) : wxT(
"0" ) );
436 xvariant->AddChild( xvarprop );
437 hasVariantData =
true;
440 if( variant.m_ExcludedFromBOM != baseExcludedFromBOM )
442 XNODE* xvarprop =
node( wxT(
"property" ) );
443 xvarprop->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_bom" ) );
444 xvarprop->
AddAttribute( wxT(
"value" ), variant.m_ExcludedFromBOM ? wxT(
"1" ) : wxT(
"0" ) );
445 xvariant->AddChild( xvarprop );
446 hasVariantData =
true;
449 if( variant.m_ExcludedFromSim != baseExcludedFromSim )
451 XNODE* xvarprop =
node( wxT(
"property" ) );
452 xvarprop->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_sim" ) );
453 xvarprop->
AddAttribute( wxT(
"value" ), variant.m_ExcludedFromSim ? wxT(
"1" ) : wxT(
"0" ) );
454 xvariant->AddChild( xvarprop );
455 hasVariantData =
true;
458 if( variant.m_ExcludedFromPosFiles != baseExcludedFromPosFiles )
460 XNODE* xvarprop =
node( wxT(
"property" ) );
461 xvarprop->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_pos_files" ) );
462 xvarprop->
AddAttribute( wxT(
"value" ), variant.m_ExcludedFromPosFiles ? wxT(
"1" ) : wxT(
"0" ) );
463 xvariant->AddChild( xvarprop );
464 hasVariantData =
true;
467 if( !variant.m_Fields.empty() )
469 XNODE* xfields =
nullptr;
471 for(
const auto& [fieldName, fieldValue] : variant.m_Fields )
473 const wxString baseValue =
474 symbol->
GetFieldText( fieldName, &sheet, wxEmptyString );
476 if( fieldValue == baseValue )
480 xfields =
node( wxT(
"fields" ) );
482 wxString resolvedValue = fieldValue;
485 resolvedValue = symbol->
ResolveText( fieldValue, &sheet );
489 xfields->AddChild( xfield );
490 hasVariantData =
true;
494 xvariant->AddChild( xfields );
500 xvariants =
node( wxT(
"variants" ) );
502 xvariants->AddChild( xvariant );
511 xcomp->AddChild( xvariants );
514 if(
const std::unique_ptr<LIB_SYMBOL>& part = symbol->
GetLibSymbolRef() )
516 if( part->GetKeyWords().size() )
518 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
519 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"ki_keywords" ) );
520 xproperty->
AddAttribute( wxT(
"value" ), part->GetKeyWords() );
523 if( !part->GetFPFilters().IsEmpty() )
527 for(
const wxString&
filter : part->GetFPFilters() )
530 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
531 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"ki_fp_filters" ) );
532 xproperty->
AddAttribute( wxT(
"value" ), filters.Trim(
false ) );
535 if( part->GetDuplicatePinNumbersAreJumpers() )
536 xcomp->AddChild(
node( wxT(
"duplicate_pin_numbers_are_jumpers" ), wxT(
"1" ) ) );
538 const std::vector<std::set<wxString>>& jumperGroups = part->JumperPinGroups();
540 if( !jumperGroups.empty() )
543 xcomp->AddChild( xproperty =
node( wxT(
"jumper_pin_groups" ) ) );
545 for(
const std::set<wxString>&
group : jumperGroups )
547 xproperty->AddChild( groupNode =
node( wxT(
"group" ) ) );
549 for(
const wxString& pinName :
group )
550 groupNode->AddChild(
node( wxT(
"pin" ), pinName ) );
556 xcomp->AddChild( xsheetpath =
node( wxT(
"sheetpath" ) ) );
558 xsheetpath->
AddAttribute( wxT(
"names" ), sheet.PathHumanReadable() );
559 xsheetpath->
AddAttribute( wxT(
"tstamps" ), sheet.PathAsString() );
562 std::vector<wxString> compClassNames =
565 if( compClassNames.size() > 0 )
567 XNODE* xcompclasslist;
568 xcomp->AddChild( xcompclasslist =
node( wxT(
"component_classes" ) ) );
570 for(
const wxString& compClass : compClassNames )
577 xcomp->AddChild( xunits =
node( wxT(
"tstamps" ) ) );
579 auto range = extra_units.equal_range( symbol );
583 for(
auto it = range.first; it != range.second; ++it )
585 uuid = ( *it )->m_Uuid.AsString();
592 xunits->AddChild(
new XNODE( wxXML_TEXT_NODE, wxEmptyString, uuid ) );
597 xunits->AddChild(
new XNODE( wxXML_TEXT_NODE, wxEmptyString, uuid ) );
601 xcomp->AddChild( xunitInfo =
node( wxT(
"units" ) ) );
616 const std::vector<LIB_SYMBOL::UNIT_PIN_INFO>& defaultUnitInfo = libSym->GetUnitPinInfo();
617 std::map<int, SCH_SYMBOL*> symbolByUnit;
625 int unit = aUnitSymbol->GetUnitSelection( &sheet );
628 symbolByUnit.try_emplace( unit, aUnitSymbol );
631 addUnitSymbol( symbol );
633 auto extraUnitRange = extra_units.equal_range( symbol );
637 for(
auto it = extraUnitRange.first; it != extraUnitRange.second; ++it )
638 addUnitSymbol( *it );
642 for(
size_t unitIdx = 0; unitIdx < defaultUnitInfo.size(); ++unitIdx )
645 auto symbolIt = symbolByUnit.find( unitIdx + 1 );
647 if( symbolIt != symbolByUnit.end() )
649 const std::unique_ptr<LIB_SYMBOL>& unitLibSym = symbolIt->second->GetLibSymbolRef();
653 const std::vector<LIB_SYMBOL::UNIT_PIN_INFO>& unitSpecificInfo =
654 unitLibSym->GetUnitPinInfo();
656 if( unitIdx < unitSpecificInfo.size() )
657 unitInfo = unitSpecificInfo[unitIdx];
662 xunitInfo->AddChild( xunit =
node( wxT(
"unit" ) ) );
666 xunit->AddChild( xpins =
node( wxT(
"pins" ) ) );
671 xpins->AddChild( xpin =
node( wxT(
"pin" ) ) );
707 xcomps->AddChild( xgroup =
node( wxT(
"group" ) ) );
714 xgroup->AddChild( xmembers =
node( wxT(
"members" ) ) );
721 xmembers->AddChild( xmember =
node( wxT(
"member" ) ) );
722 xmember->
AddAttribute( wxT(
"uuid" ), member->m_Uuid.AsString() );
727 std::vector<SCH_SHEET_PATH> descendantSheets;
737 xmembers->AddChild( xmember =
node( wxT(
"member" ) ) );
738 xmember->
AddAttribute( wxT(
"uuid" ), descendantItem->m_Uuid.AsString() );
754 XNODE* xvariants =
node( wxT(
"variants" ) );
756 std::set<wxString> variantNames =
m_schematic->GetVariantNames();
758 for(
const wxString& variantName : variantNames )
761 xvariants->AddChild( xvariant =
node( wxT(
"variant" ) ) );
764 wxString description =
m_schematic->GetVariantDescription( variantName );
766 if( !description.IsEmpty() )
767 xvariant->
AddAttribute( wxT(
"description" ), description );
777 std::vector<SCH_SHEET_PATH> symbolSheets;
778 symbolSheets.push_back( aSymbolSheet );
785 const wxString ref = aSymbol->
GetRef( &aSymbolSheet );
793 wxString ref2 = symbol2->
GetRef( &sheet );
796 if( ref2.CmpNoCase( ref ) != 0 )
799 if( otherUnit == primaryUnit )
802 symbolSheets.push_back( sheet );
804 std::unordered_set<wxString> otherClassNames =
806 compClassNames.insert( otherClassNames.begin(), otherClassNames.end() );
816 if( symbolSheetPath.IsContainedWithin( sheetPath ) )
818 compClassNames.insert( sheetCompClasses.begin(), sheetCompClasses.end() );
823 std::vector<wxString> sortedCompClassNames( compClassNames.begin(), compClassNames.end() );
824 std::sort( sortedCompClassNames.begin(), sortedCompClassNames.end(),
825 [](
const wxString& str1,
const wxString& str2 )
827 return str1.Cmp( str2 ) < 0;
830 return sortedCompClassNames;
837 XNODE* xdesign =
node( wxT(
"design" ) );
843 wxFileName sourceFileName;
846 xdesign->AddChild(
node( wxT(
"source" ),
m_schematic->GetFileName() ) );
853 const std::map<wxString, wxString>& properties =
m_schematic->Project().GetTextVars();
855 for(
const std::pair<const wxString, wxString>& prop : properties )
857 xdesign->AddChild( xtextvar =
node( wxT(
"textvar" ), prop.second ) );
864 unsigned sheetIndex = 1;
868 screen = sheet.LastScreen();
870 xdesign->AddChild( xsheet =
node( wxT(
"sheet" ) ) );
873 sheetTxt.Printf( wxT(
"%u" ), sheetIndex++ );
875 xsheet->
AddAttribute( wxT(
"name" ), sheet.PathHumanReadable() );
876 xsheet->
AddAttribute( wxT(
"tstamps" ), sheet.PathAsString() );
881 xsheet->AddChild( xtitleBlock =
node( wxT(
"title_block" ) ) );
889 sourceFileName = wxFileName( screen->
GetFileName() );
890 xtitleBlock->AddChild(
node( wxT(
"source" ), sourceFileName.GetFullName() ) );
892 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
896 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
900 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
904 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
908 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
912 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
916 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
920 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
924 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
935 XNODE* xlibs =
node( wxT(
"libraries" ) );
940 wxString libNickname = *it;
947 xlibs->AddChild( xlibrary =
node( wxT(
"library" ) ) );
948 xlibrary->
AddAttribute( wxT(
"logical" ), libNickname );
949 xlibrary->AddChild(
node( wxT(
"uri" ), *uri ) );
961 XNODE* xlibparts =
node( wxT(
"libparts" ) );
962 std::vector<SCH_FIELD*> fieldList;
968 wxString libNickname = lcomp->GetLibId().GetLibNickname();;
971 if( !libNickname.IsEmpty() )
975 xlibparts->AddChild( xlibpart =
node( wxT(
"libpart" ) ) );
977 xlibpart->
AddAttribute( wxT(
"part" ), lcomp->GetName() );
980 if( !lcomp->GetDescription().IsEmpty() )
981 xlibpart->AddChild(
node( wxT(
"description" ), lcomp->GetDescription() ) );
983 if( !lcomp->GetDatasheetField().GetText().IsEmpty() )
984 xlibpart->AddChild(
node( wxT(
"docs" ), lcomp->GetDatasheetField().GetText() ) );
987 if( lcomp->GetFPFilters().GetCount() )
990 xlibpart->AddChild( xfootprints =
node( wxT(
"footprints" ) ) );
992 for(
unsigned i = 0; i < lcomp->GetFPFilters().GetCount(); ++i )
994 if( !lcomp->GetFPFilters()[i].IsEmpty() )
995 xfootprints->AddChild(
node( wxT(
"fp" ), lcomp->GetFPFilters()[i] ) );
1001 lcomp->GetFields( fieldList );
1004 xlibpart->AddChild( xfields =
node(
"fields" ) );
1006 for(
const SCH_FIELD* field : fieldList )
1009 xfields->AddChild( xfield =
node( wxT(
"field" ), field->GetText() ) );
1010 xfield->
AddAttribute( wxT(
"name" ), field->GetCanonicalName() );
1016 std::vector<SCH_PIN*> pinList = lcomp->GetGraphicalPins( 0, 0 );
1028 for(
int ii = 0; ii < (int)pinList.size()-1; ii++ )
1030 if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() )
1032 pinList.erase(pinList.begin() + ii + 1);
1037 wxLogTrace(
"CVPCB_PINCOUNT",
1038 wxString::Format(
"makeLibParts: lib='%s' part='%s' pinList(size)=%zu",
1039 libNickname, lcomp->GetName(), pinList.size() ) );
1041 if( pinList.size() )
1045 xlibpart->AddChild( pins =
node( wxT(
"pins" ) ) );
1047 for(
unsigned i=0; i<pinList.size(); ++i )
1049 SCH_PIN* basePin = pinList[i];
1051 bool stackedValid =
false;
1055 if( stackedValid && !expandedNums.empty() )
1057 for(
const wxString& num : expandedNums )
1060 pins->AddChild(
pin =
node( wxT(
"pin" ) ) );
1061 pin->AddAttribute( wxT(
"num" ), num );
1065 wxLogTrace(
"CVPCB_PINCOUNT",
1066 wxString::Format(
"makeLibParts: -> pin num='%s' name='%s' (expanded)",
1073 pins->AddChild(
pin =
node( wxT(
"pin" ) ) );
1078 wxLogTrace(
"CVPCB_PINCOUNT",
1079 wxString::Format(
"makeLibParts: -> pin num='%s' name='%s'",
1095 wxString netCodeTxt;
1097 XNODE* xnet =
nullptr;
1119 NET_RECORD(
const wxString& aName ) :
1121 m_HasNoConnect(
false )
1126 bool m_HasNoConnect;
1127 std::vector<NET_NODE> m_Nodes;
1130 std::vector<NET_RECORD*> nets;
1132 for(
const auto& [ key, subgraphs ] :
m_schematic->ConnectionGraph()->GetNetMap() )
1134 wxString net_name = key.Name;
1135 NET_RECORD* net_record =
nullptr;
1140 if( subgraphs.empty() )
1143 nets.emplace_back(
new NET_RECORD( net_name ) );
1144 net_record = nets.back();
1148 bool nc = subgraph->GetNoConnect() && subgraph->GetNoConnect()->Type() ==
SCH_NO_CONNECT_T;
1151 if( net_record->m_Class.IsEmpty() && subgraph->GetDriver() )
1153 if( subgraph->GetDriver()->GetEffectiveNetClass() )
1155 net_record->m_Class = subgraph->GetDriver()->GetEffectiveNetClass()->GetName();
1161 net_record->m_HasNoConnect =
true;
1163 for(
SCH_ITEM* item : subgraph->GetItems() )
1181 net_record->m_Nodes.emplace_back(
pin, sheet );
1188 std::sort( nets.begin(), nets.end(),
1189 [](
const NET_RECORD* a,
const NET_RECORD*b )
1191 return StrNumCmp( a->m_Name, b->m_Name ) < 0;
1194 for(
int i = 0; i < (int) nets.size(); ++i )
1196 NET_RECORD* net_record = nets[i];
1201 std::sort( net_record->m_Nodes.begin(), net_record->m_Nodes.end(),
1202 [](
const NET_NODE& a,
const NET_NODE& b )
1204 wxString refA = a.m_Pin->GetParentSymbol()->GetRef( &a.m_Sheet );
1205 wxString refB = b.m_Pin->GetParentSymbol()->GetRef( &b.m_Sheet );
1208 return a.m_Pin->GetShownNumber() < b.m_Pin->GetShownNumber();
1217 [](
const NET_NODE& a,
const NET_NODE& b )
1219 wxString refA = a.m_Pin->GetParentSymbol()->GetRef( &a.m_Sheet );
1220 wxString refB = b.m_Pin->GetParentSymbol()->GetRef( &b.m_Sheet );
1222 return refA == refB && a.m_Pin->GetShownNumber() == b.m_Pin->GetShownNumber();
1227 bool allNetPinsStacked =
true;
1229 if( net_record->m_Nodes.size() > 1 )
1231 SCH_PIN* firstPin = net_record->m_Nodes.begin()->m_Pin;
1233 std::all_of( net_record->m_Nodes.begin() + 1, net_record->m_Nodes.end(),
1236 return firstPin->GetParent() == node.m_Pin->GetParent()
1237 && firstPin->GetPosition() == node.m_Pin->GetPosition()
1238 && firstPin->GetName() == node.m_Pin->GetName();
1242 for(
const NET_NODE& netNode : net_record->m_Nodes )
1244 wxString refText = netNode.m_Pin->GetParentSymbol()->GetRef( &netNode.m_Sheet );
1247 if( refText[0] == wxChar(
'#' ) )
1252 netCodeTxt.Printf( wxT(
"%d" ), i + 1 );
1254 xnets->AddChild( xnet =
node( wxT(
"net" ) ) );
1256 xnet->
AddAttribute( wxT(
"name" ), net_record->m_Name );
1257 xnet->
AddAttribute( wxT(
"class" ), net_record->m_Class );
1262 std::vector<wxString> nums = netNode.m_Pin->GetStackedPinNumbers();
1263 wxString baseName = netNode.m_Pin->GetShownName();
1264 wxString pinType = netNode.m_Pin->GetCanonicalElectricalTypeName();
1267 wxString::Format(
"XML: net='%s' ref='%s' base='%s' shownNum='%s' expand=%zu",
1268 net_record->m_Name, refText, baseName,
1269 netNode.m_Pin->GetShownNumber(), nums.size() ) );
1271 for(
const wxString& num : nums )
1273 xnet->AddChild( xnode =
node( wxT(
"node" ) ) );
1277 wxString fullName = baseName.IsEmpty() ? num : baseName + wxT(
"_" ) + num;
1279 if( !baseName.IsEmpty() || nums.size() > 1 )
1282 wxString typeAttr = pinType;
1284 if( net_record->m_HasNoConnect
1285 && ( net_record->m_Nodes.size() == 1 || allNetPinsStacked ) )
1287 typeAttr += wxT(
"+no_connect" );
1289 wxString::Format(
"XML: marking node ref='%s' pin='%s' as no_connect",
1298 for( NET_RECORD* record : nets )
1306 const wxString& aTextualContent )
1308 XNODE* n =
new XNODE( wxXML_ELEMENT_NODE, aName );
1310 if( aTextualContent.Len() > 0 )
1311 n->AddChild(
new XNODE( wxXML_TEXT_NODE, wxEmptyString, aTextualContent ) );
1328 auto getComponentClassFields = [&](
const std::vector<SCH_FIELD>& fields,
const SCH_SHEET_PATH* sheetPath )
1330 std::unordered_set<wxString> componentClasses;
1334 if( field.GetCanonicalName() == wxT(
"Component Class" ) )
1336 if( field.GetShownText( sheetPath,
false ) != wxEmptyString )
1337 componentClasses.insert( field.GetShownText( sheetPath,
false ) );
1341 return componentClasses;
1349 std::unordered_set<wxString> sheetComponentClasses;
1350 const std::unordered_set<SCH_RULE_AREA*>& sheetRuleAreas = sheetItem->
GetRuleAreaCache();
1356 std::unordered_set<wxString> ruleAreaComponentClasses =
1357 getComponentClassFields( label->GetFields(), &sheet );
1358 sheetComponentClasses.insert( ruleAreaComponentClasses.begin(), ruleAreaComponentClasses.end() );
wxString GetBuildVersion()
Get the full KiCad version string.
A subgraph is a set of items that are electrically connected on a single sheet.
A base class for most all the KiCad significant classes used in schematics and boards.
wxString AsString() const
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
const wxString GetUniStringLibNickname() const
Define a library symbol object.
SCHEMATIC * m_schematic
The schematic we're generating a netlist for.
SCH_SYMBOL * findNextSymbol(EDA_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath)
Check if the given symbol should be processed for netlisting.
std::set< LIB_SYMBOL *, LIB_SYMBOL_LESS_THAN > m_libParts
unique library symbols used. LIB_SYMBOL items are sorted by names
UNIQUE_STRINGS m_referencesAlreadyFound
Used for "multiple symbols per package" symbols to avoid processing a lib symbol more than once.
void getSheetComponentClasses()
std::map< SCH_SHEET_PATH, std::unordered_set< wxString > > m_sheetComponentClasses
Map of all sheets to component classes covering the whole sheet.
XNODE * makeDesignHeader()
Fill out a project "design" header into an XML node.
XNODE * makeLibraries()
Fill out an XML node with a list of used libraries and returns it.
bool WriteNetlist(const wxString &aOutFileName, unsigned aNetlistOptions, REPORTER &aReporter) override
Write generic netlist to aOutFileName.
XNODE * node(const wxString &aName, const wxString &aTextualContent=wxEmptyString)
A convenience function that creates a new XNODE with an optional textual child.
XNODE * makeListOfNets(unsigned aCtl)
Fill out an XML node with a list of nets and returns it.
void addSymbolFields(XNODE *aNode, SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSheet, const SCH_SHEET_LIST &aSheetList)
Holder for multi-unit symbol fields.
std::vector< wxString > getComponentClassNamesForAllSymbolUnits(SCH_SYMBOL *aSymbol, const SCH_SHEET_PATH &aSymbolSheet, const SCH_SHEET_LIST &aSheetList)
Finds all component class names attached to any sub-unit of a given symbol.
XNODE * makeSymbols(unsigned aCtl)
XNODE * makeRoot(unsigned aCtl=GNL_ALL)
Build the entire document tree for the generic export.
std::set< wxString > m_libraries
XNODE * makeLibParts()
Fill out an XML node with the unique library parts and returns it.
virtual LIBRARY_MANAGER & GetLibraryManager() const
Container for project specific data.
A pure virtual class used to derive REPORTER objects from.
virtual const wxString & GetText() const override
Return the string associated with the text object.
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0, const wxString &aVariantName=wxEmptyString) const
A set of SCH_ITEMs (i.e., without duplicates).
Base class for any item which can be embedded within the SCHEMATIC container class,...
bool ResolveExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
const std::unordered_set< SCH_RULE_AREA * > & GetRuleAreaCache() const
Get the cache of rule areas enclosing this item.
bool ResolveExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
bool ResolveExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
bool ResolveDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
std::vector< wxString > GetStackedPinNumbers(bool *aValid=nullptr) const
wxString GetCanonicalElectricalTypeName() const
const wxString & GetShownName() const
const wxString & GetShownNumber() const
const wxString & GetFileName() const
TITLE_BLOCK & GetTitleBlock()
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GetSheetsWithinPath(std::vector< SCH_SHEET_PATH > &aSheets, const SCH_SHEET_PATH &aSheetPath) const
Add a SCH_SHEET_PATH object to aSheets for each sheet in the list that are contained within aSheetPat...
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool GetExcludedFromBOM() const
const SCH_SHEET * GetSheet(unsigned aIndex) const
bool GetExcludedFromBoard() const
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
wxString GetDescription() const override
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool UseLibIdLookup() const
wxString GetFieldText(const wxString &aFieldName, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString) const
wxString GetSchSymbolLibraryName() const
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const override
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const
wxString GetShownDescription(int aDepth=0) const override
const LIB_ID & GetLibId() const override
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
int GetUnitCount() const override
Return the number of units per package of the symbol.
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
std::unordered_set< wxString > GetComponentClassNames(const SCH_SHEET_PATH *aPath) const
Return the component classes this symbol belongs in.
virtual bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flag.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
const wxString & GetCompany() const
const wxString & GetRevision() const
const wxString & GetDate() const
const wxString & GetComment(int aIdx) const
const wxString & GetTitle() const
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
void AddAttribute(const wxString &aName, const wxString &aValue) override
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, int aFlags)
const wxChar *const traceStackedPins
Flag to enable debug output for stacked pins handling in symbol/pin code.
void remove_duplicates(_Container &__c)
Deletes all duplicate values from __c.
static bool sortPinsByNumber(SCH_PIN *aPin1, SCH_PIN *aPin2)
PGM_BASE & Pgm()
The global program "get" accessor.
Class to handle a set of SCH_ITEMs.
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
wxString UnescapeString(const wxString &aSource)
wxString GetISO8601CurrentDateTime()
std::vector< wxString > m_pinNumbers
A simple container for schematic symbol instance information.
std::map< wxString, SCH_SYMBOL_VARIANT > m_Variants
A list of symbol variants.
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
wxString GetCanonicalFieldName(FIELD_T aFieldType)
wxLogTrace helper definitions.