35#include <wx/wfstream.h>
57 wxFFileOutputStream stream( aOutFileName );
65 return xdoc.Save( stream, 2 );
108 xroot->AddChild( xchains );
126 wxString description;
128 nlohmann::ordered_map<wxString, wxString> fields;
139 wxString ref = aSymbol->
GetRef( &aSheet );
149 wxString ref2 = symbol2->
GetRef( &sheet );
151 if( ref2.CmpNoCase( ref ) != 0 )
161 if( !candidate.IsEmpty() && ( unit < minUnit || value.IsEmpty() ) )
167 if( !candidate.IsEmpty() && ( unit < minUnit || footprint.IsEmpty() ) )
168 footprint = candidate;
174 if( !candidate.IsEmpty() && ( unit < minUnit ||
datasheet.IsEmpty() ) )
181 if( !candidate.IsEmpty() && ( unit < minUnit || description.IsEmpty() ) )
182 description = candidate;
187 if( field.IsMandatory() || field.IsPrivate() )
190 if( unit < minUnit || fields.count( field.GetName() ) == 0 )
193 fields[field.GetName()] = field.GetShownText( &aSheet,
false );
195 fields[field.GetName()] = field.GetText();
199 minUnit = std::min( unit, minUnit );
219 description = descriptionField->
GetShownText( &aSheet,
false );
221 description = descriptionField->
GetText();
225 if( field.IsMandatory() || field.IsPrivate() )
229 fields[field.GetName()] = field.GetShownText( &aSheet,
false );
231 fields[field.GetName()] = field.GetText();
243 aNode->AddChild(
node( wxT(
"value" ), wxT(
"~" ) ) );
245 if( footprint.size() )
251 if( description.size() )
255 aNode->AddChild( xfields =
node( wxT(
"fields" ) ) );
257 for(
const auto& [ fieldName, fieldValue ] : fields )
261 xfields->AddChild( xfield );
268 XNODE* xcomps =
node( wxT(
"components" ) );
290 b->GetRef( &sheet,
false ),
true ) < 0 );
293 std::set<
SCH_SYMBOL*,
decltype( cmp )> ordered_symbols( cmp );
294 std::multiset<
SCH_SYMBOL*,
decltype( cmp )> extra_units( cmp );
299 auto test = ordered_symbols.insert( symbol );
303 if( ( *(
test.first ) )->m_Uuid > symbol->
m_Uuid )
305 extra_units.insert( *(
test.first ) );
306 ordered_symbols.erase(
test.first );
307 ordered_symbols.insert( symbol );
311 extra_units.insert( symbol );
316 for(
EDA_ITEM* item : ordered_symbols )
336 xcomps->AddChild( xcomp =
node( wxT(
"comp" ) ) );
342 xcomp->AddChild( xlibsource =
node( wxT(
"libsource" ) ) );
373 std::vector<SCH_FIELD>& fields = symbol->
GetFields();
377 if( field.IsMandatory() || field.IsPrivate() )
380 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
381 xproperty->
AddAttribute( wxT(
"name" ), field.GetCanonicalName() );
384 xproperty->
AddAttribute( wxT(
"value" ), field.GetShownText( &sheet,
false ) );
386 xproperty->
AddAttribute( wxT(
"value" ), field.GetText() );
389 for(
const SCH_FIELD& sheetField : sheet.Last()->GetFields() )
391 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
392 xproperty->
AddAttribute( wxT(
"name" ), sheetField.GetCanonicalName() );
397 xproperty->
AddAttribute( wxT(
"value" ), sheetField.GetShownText( &sheet,
false ) );
399 xproperty->
AddAttribute( wxT(
"value" ), sheetField.GetText() );
404 if( baseExcludedFromBOM )
406 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
407 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_bom" ) );
412 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
413 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_board" ) );
418 if( baseExcludedFromPosFiles )
420 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
421 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"exclude_from_pos_files" ) );
424 const bool baseDnp = symbol->
ResolveDNP( &sheet ) || sheet.GetDNP();
428 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
434 const std::set<wxString>& variantNames =
m_schematic->GetVariantNames();
436 if( !variantNames.empty() )
439 XNODE* xvariants =
nullptr;
441 for(
const auto& variantName : variantNames )
443 XNODE* xvariant =
nullptr;
445 auto addToVariant = [
this, &xvariant, &variantName](
XNODE* child ) ->
void
452 xvariant =
node( wxT(
"variant" ) );
455 xvariant->AddChild( child );
458 auto addBinaryProp = [
this, &addToVariant]( wxString
const&
name,
bool base,
459 bool effective ) ->
void
461 if( base == effective )
464 XNODE* xvarprop =
node( wxT(
"property" ) );
466 xvarprop->
AddAttribute( wxT(
"value" ), effective ? wxT(
"1" ) : wxT(
"0" ) );
467 addToVariant( xvarprop );
470 bool effectiveDnp = symbol->
ResolveDNP( &sheet, variantName ) || sheet.GetDNP( variantName );
471 addBinaryProp( wxT(
"dnp" ), baseDnp, effectiveDnp );
474 || sheet.GetExcludedFromBOM( variantName );
475 addBinaryProp( wxT(
"exclude_from_bom" ), baseExcludedFromBOM, effectiveExcludedFromBOM );
478 || sheet.GetExcludedFromSim( variantName );
479 addBinaryProp( wxT(
"exclude_from_sim" ), baseExcludedFromSim, effectiveExcludedFromSim );
482 addBinaryProp( wxT(
"exclude_from_pos_files" ), baseExcludedFromPosFiles,
483 effectiveExcludedFromPosFiles );
489 variant = &instance.
m_Variants.at( variantName );
491 if( variant && !variant->
m_Fields.empty() )
493 XNODE* xfields =
nullptr;
495 for(
const auto& [fieldName, fieldValue] : variant->
m_Fields )
497 const wxString baseValue =
498 symbol->
GetFieldText( fieldName, &sheet, wxEmptyString );
500 if( fieldValue == baseValue )
504 xfields =
node( wxT(
"fields" ) );
506 wxString resolvedValue = fieldValue;
509 resolvedValue = symbol->
ResolveText( fieldValue, &sheet );
513 xfields->AddChild( xfield );
516 addToVariant( xfields );
522 xvariants =
node( wxT(
"variants" ) );
524 xvariants->AddChild( xvariant );
529 xcomp->AddChild( xvariants );
532 if(
const std::unique_ptr<LIB_SYMBOL>& part = symbol->
GetLibSymbolRef() )
534 if( part->GetKeyWords().size() )
536 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
537 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"ki_keywords" ) );
538 xproperty->
AddAttribute( wxT(
"value" ), part->GetKeyWords() );
541 if( !part->GetFPFilters().IsEmpty() )
545 for(
const wxString&
filter : part->GetFPFilters() )
548 xcomp->AddChild( xproperty =
node( wxT(
"property" ) ) );
549 xproperty->
AddAttribute( wxT(
"name" ), wxT(
"ki_fp_filters" ) );
550 xproperty->
AddAttribute( wxT(
"value" ), filters.Trim(
false ) );
553 if( part->GetDuplicatePinNumbersAreJumpers() )
554 xcomp->AddChild(
node( wxT(
"duplicate_pin_numbers_are_jumpers" ), wxT(
"1" ) ) );
556 const std::vector<std::set<wxString>>& jumperGroups = part->JumperPinGroups();
558 if( !jumperGroups.empty() )
561 xcomp->AddChild( xproperty =
node( wxT(
"jumper_pin_groups" ) ) );
563 for(
const std::set<wxString>&
group : jumperGroups )
565 xproperty->AddChild( groupNode =
node( wxT(
"group" ) ) );
567 for(
const wxString& pinName :
group )
568 groupNode->AddChild(
node( wxT(
"pin" ), pinName ) );
574 xcomp->AddChild( xsheetpath =
node( wxT(
"sheetpath" ) ) );
576 xsheetpath->
AddAttribute( wxT(
"names" ), sheet.PathHumanReadable() );
577 xsheetpath->
AddAttribute( wxT(
"tstamps" ), sheet.PathAsString() );
580 std::vector<wxString> compClassNames =
583 if( compClassNames.size() > 0 )
585 XNODE* xcompclasslist;
586 xcomp->AddChild( xcompclasslist =
node( wxT(
"component_classes" ) ) );
588 for(
const wxString& compClass : compClassNames )
595 xcomp->AddChild( xunits =
node( wxT(
"tstamps" ) ) );
597 auto range = extra_units.equal_range( symbol );
601 for(
auto it = range.first; it != range.second; ++it )
603 uuid = ( *it )->m_Uuid.AsString();
610 xunits->AddChild(
new XNODE( wxXML_TEXT_NODE, wxEmptyString, uuid ) );
615 xunits->AddChild(
new XNODE( wxXML_TEXT_NODE, wxEmptyString, uuid ) );
619 xcomp->AddChild( xunitInfo =
node( wxT(
"units" ) ) );
634 const std::vector<LIB_SYMBOL::UNIT_PIN_INFO>& defaultUnitInfo = libSym->GetUnitPinInfo();
635 std::map<int, SCH_SYMBOL*> symbolByUnit;
643 int unit = aUnitSymbol->GetUnitSelection( &sheet );
646 symbolByUnit.try_emplace( unit, aUnitSymbol );
649 addUnitSymbol( symbol );
651 auto extraUnitRange = extra_units.equal_range( symbol );
655 for(
auto it = extraUnitRange.first; it != extraUnitRange.second; ++it )
656 addUnitSymbol( *it );
660 for(
size_t unitIdx = 0; unitIdx < defaultUnitInfo.size(); ++unitIdx )
663 auto symbolIt = symbolByUnit.find( unitIdx + 1 );
665 if( symbolIt != symbolByUnit.end() )
667 const std::unique_ptr<LIB_SYMBOL>& unitLibSym = symbolIt->second->GetLibSymbolRef();
671 const std::vector<LIB_SYMBOL::UNIT_PIN_INFO>& unitSpecificInfo =
672 unitLibSym->GetUnitPinInfo();
674 if( unitIdx < unitSpecificInfo.size() )
675 unitInfo = unitSpecificInfo[unitIdx];
680 xunitInfo->AddChild( xunit =
node( wxT(
"unit" ) ) );
684 xunit->AddChild( xpins =
node( wxT(
"pins" ) ) );
689 xpins->AddChild( xpin =
node( wxT(
"pin" ) ) );
725 xcomps->AddChild( xgroup =
node( wxT(
"group" ) ) );
732 xgroup->AddChild( xmembers =
node( wxT(
"members" ) ) );
739 xmembers->AddChild( xmember =
node( wxT(
"member" ) ) );
740 xmember->
AddAttribute( wxT(
"uuid" ), member->m_Uuid.AsString() );
746 xmembers->AddChild( xmember =
node( wxT(
"member" ) ) );
747 xmember->
AddAttribute( wxT(
"uuid" ), member->m_Uuid.AsString() );
752 std::vector<SCH_SHEET_PATH> descendantSheets;
762 xmembers->AddChild( xmember =
node( wxT(
"member" ) ) );
763 xmember->
AddAttribute( wxT(
"uuid" ), descendantItem->m_Uuid.AsString() );
779 XNODE* xvariants =
node( wxT(
"variants" ) );
781 std::set<wxString> variantNames =
m_schematic->GetVariantNames();
783 for(
const wxString& variantName : variantNames )
786 xvariants->AddChild( xvariant =
node( wxT(
"variant" ) ) );
789 wxString description =
m_schematic->GetVariantDescription( variantName );
791 if( !description.IsEmpty() )
792 xvariant->
AddAttribute( wxT(
"description" ), description );
802 std::vector<SCH_SHEET_PATH> symbolSheets;
803 symbolSheets.push_back( aSymbolSheet );
810 const wxString ref = aSymbol->
GetRef( &aSymbolSheet );
818 wxString ref2 = symbol2->
GetRef( &sheet );
821 if( ref2.CmpNoCase( ref ) != 0 )
824 if( otherUnit == primaryUnit )
827 symbolSheets.push_back( sheet );
829 std::unordered_set<wxString> otherClassNames =
831 compClassNames.insert( otherClassNames.begin(), otherClassNames.end() );
841 if( symbolSheetPath.IsContainedWithin( sheetPath ) )
843 compClassNames.insert( sheetCompClasses.begin(), sheetCompClasses.end() );
848 std::vector<wxString> sortedCompClassNames( compClassNames.begin(), compClassNames.end() );
849 std::sort( sortedCompClassNames.begin(), sortedCompClassNames.end(),
850 [](
const wxString& str1,
const wxString& str2 )
852 return str1.Cmp( str2 ) < 0;
855 return sortedCompClassNames;
862 XNODE* xdesign =
node( wxT(
"design" ) );
868 wxFileName sourceFileName;
871 xdesign->AddChild(
node( wxT(
"source" ),
m_schematic->GetFileName() ) );
878 const std::map<wxString, wxString>& properties =
m_schematic->Project().GetTextVars();
880 for(
const std::pair<const wxString, wxString>& prop : properties )
882 xdesign->AddChild( xtextvar =
node( wxT(
"textvar" ), prop.second ) );
889 unsigned sheetIndex = 1;
893 screen = sheet.LastScreen();
895 xdesign->AddChild( xsheet =
node( wxT(
"sheet" ) ) );
898 sheetTxt.Printf( wxT(
"%u" ), sheetIndex++ );
900 xsheet->
AddAttribute( wxT(
"name" ), sheet.PathHumanReadable() );
901 xsheet->
AddAttribute( wxT(
"tstamps" ), sheet.PathAsString() );
906 xsheet->AddChild( xtitleBlock =
node( wxT(
"title_block" ) ) );
914 sourceFileName = wxFileName( screen->
GetFileName() );
915 xtitleBlock->AddChild(
node( wxT(
"source" ), sourceFileName.GetFullName() ) );
917 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
921 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
925 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
929 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
933 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
937 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
941 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
945 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
949 xtitleBlock->AddChild( xcomment =
node( wxT(
"comment" ) ) );
960 XNODE* xlibs =
node( wxT(
"libraries" ) );
965 wxString libNickname = *it;
972 xlibs->AddChild( xlibrary =
node( wxT(
"library" ) ) );
973 xlibrary->
AddAttribute( wxT(
"logical" ), libNickname );
974 xlibrary->AddChild(
node( wxT(
"uri" ), *uri ) );
986 XNODE* xlibparts =
node( wxT(
"libparts" ) );
987 std::vector<SCH_FIELD*> fieldList;
993 wxString libNickname = lcomp->GetLibId().GetLibNickname();;
996 if( !libNickname.IsEmpty() )
1000 xlibparts->AddChild( xlibpart =
node( wxT(
"libpart" ) ) );
1002 xlibpart->
AddAttribute( wxT(
"part" ), lcomp->GetName() );
1005 if( !lcomp->GetDescription().IsEmpty() )
1006 xlibpart->AddChild(
node( wxT(
"description" ), lcomp->GetDescription() ) );
1008 if( !lcomp->GetDatasheetField().GetText().IsEmpty() )
1009 xlibpart->AddChild(
node( wxT(
"docs" ), lcomp->GetDatasheetField().GetText() ) );
1012 if( lcomp->GetFPFilters().GetCount() )
1015 xlibpart->AddChild( xfootprints =
node( wxT(
"footprints" ) ) );
1017 for(
unsigned i = 0; i < lcomp->GetFPFilters().GetCount(); ++i )
1019 if( !lcomp->GetFPFilters()[i].IsEmpty() )
1020 xfootprints->AddChild(
node( wxT(
"fp" ), lcomp->GetFPFilters()[i] ) );
1026 lcomp->GetFields( fieldList );
1029 xlibpart->AddChild( xfields =
node(
"fields" ) );
1031 for(
const SCH_FIELD* field : fieldList )
1034 xfields->AddChild( xfield =
node( wxT(
"field" ), field->GetText() ) );
1035 xfield->
AddAttribute( wxT(
"name" ), field->GetCanonicalName() );
1041 std::vector<SCH_PIN*> pinList = lcomp->GetGraphicalPins( 0, 0 );
1053 for(
int ii = 0; ii < (int)pinList.size()-1; ii++ )
1055 if( pinList[ii]->GetNumber() == pinList[ii+1]->GetNumber() )
1057 pinList.erase(pinList.begin() + ii + 1);
1062 wxLogTrace(
"CVPCB_PINCOUNT",
1063 wxString::Format(
"makeLibParts: lib='%s' part='%s' pinList(size)=%zu",
1064 libNickname, lcomp->GetName(), pinList.size() ) );
1066 if( pinList.size() )
1070 xlibpart->AddChild( pins =
node( wxT(
"pins" ) ) );
1072 for(
unsigned i=0; i<pinList.size(); ++i )
1074 SCH_PIN* basePin = pinList[i];
1076 bool stackedValid =
false;
1080 if( stackedValid && !expandedNums.empty() )
1082 for(
const wxString& num : expandedNums )
1085 pins->AddChild(
pin =
node( wxT(
"pin" ) ) );
1086 pin->AddAttribute( wxT(
"num" ), num );
1090 wxLogTrace(
"CVPCB_PINCOUNT",
1091 wxString::Format(
"makeLibParts: -> pin num='%s' name='%s' (expanded)",
1098 pins->AddChild(
pin =
node( wxT(
"pin" ) ) );
1103 wxLogTrace(
"CVPCB_PINCOUNT",
1104 wxString::Format(
"makeLibParts: -> pin num='%s' name='%s'",
1120 wxString netCodeTxt;
1122 XNODE* xnet =
nullptr;
1144 NET_RECORD(
const wxString& aName ) :
1146 m_HasNoConnect(
false )
1151 bool m_HasNoConnect;
1152 std::vector<NET_NODE> m_Nodes;
1155 std::vector<NET_RECORD*> nets;
1157 std::shared_ptr<NET_SETTINGS> netSettings;
1160 netSettings =
m_schematic->Project().GetProjectFile().NetSettings();
1162 for(
const auto& [ key, subgraphs ] :
m_schematic->ConnectionGraph()->GetNetMap() )
1164 wxString net_name = key.Name;
1165 NET_RECORD* net_record =
nullptr;
1170 if( subgraphs.empty() )
1173 nets.emplace_back(
new NET_RECORD( net_name ) );
1174 net_record = nets.back();
1183 std::shared_ptr<NETCLASS> nc = netSettings->GetEffectiveNetClass( key.Name );
1191 bool nc = subgraph->GetNoConnect() && subgraph->GetNoConnect()->Type() ==
SCH_NO_CONNECT_T;
1195 net_record->m_HasNoConnect =
true;
1197 for(
SCH_ITEM* item : subgraph->GetItems() )
1215 net_record->m_Nodes.emplace_back(
pin, sheet );
1222 std::sort( nets.begin(), nets.end(),
1223 [](
const NET_RECORD* a,
const NET_RECORD*b )
1225 return StrNumCmp( a->m_Name, b->m_Name ) < 0;
1228 for(
int i = 0; i < (int) nets.size(); ++i )
1230 NET_RECORD* net_record = nets[i];
1235 std::sort( net_record->m_Nodes.begin(), net_record->m_Nodes.end(),
1238 wxString refA = a.m_Pin->GetParentSymbol()->GetRef( &a.m_Sheet );
1239 wxString refB = b.m_Pin->GetParentSymbol()->GetRef( &b.m_Sheet );
1242 return a.m_Pin->GetShownNumber() < b.m_Pin->GetShownNumber();
1253 wxString refA = a.m_Pin->GetParentSymbol()->GetRef( &a.m_Sheet );
1254 wxString refB = b.m_Pin->GetParentSymbol()->GetRef( &b.m_Sheet );
1256 return refA == refB && a.m_Pin->GetShownNumber() == b.m_Pin->GetShownNumber();
1261 bool allNetPinsStacked =
true;
1263 if( net_record->m_Nodes.size() > 1 )
1265 SCH_PIN* firstPin = net_record->m_Nodes.begin()->m_Pin;
1267 std::all_of( net_record->m_Nodes.begin() + 1, net_record->m_Nodes.end(),
1270 return firstPin->GetParent() == node.m_Pin->GetParent()
1271 && firstPin->GetPosition() == node.m_Pin->GetPosition()
1272 && firstPin->GetName() == node.m_Pin->GetName();
1276 for(
const NET_NODE& netNode : net_record->m_Nodes )
1278 wxString refText = netNode.m_Pin->GetParentSymbol()->GetRef( &netNode.m_Sheet );
1281 if( refText[0] == wxChar(
'#' ) )
1287 std::vector<wxString> nums =
resolvePadNumbers( netNode.m_Pin, netNode.m_Sheet );
1293 wxString baseName = netNode.m_Pin->GetShownName();
1294 wxString pinType = netNode.m_Pin->GetCanonicalElectricalTypeName();
1298 netCodeTxt.Printf( wxT(
"%d" ), i + 1 );
1300 xnets->AddChild( xnet =
node( wxT(
"net" ) ) );
1302 xnet->
AddAttribute( wxT(
"name" ), net_record->m_Name );
1303 xnet->
AddAttribute( wxT(
"class" ), net_record->m_Class );
1308 for(
const wxString& num : nums )
1310 xnet->AddChild( xnode =
node( wxT(
"node" ) ) );
1314 wxString fullName = baseName.IsEmpty() ? num : baseName + wxT(
"_" ) + num;
1316 if( !baseName.IsEmpty() || nums.size() > 1 )
1319 wxString typeAttr = pinType;
1321 if( net_record->m_HasNoConnect
1322 && ( net_record->m_Nodes.size() == 1 || allNetPinsStacked ) )
1324 typeAttr += wxT(
"+no_connect" );
1332 for( NET_RECORD* record : nets )
1340 const auto& committed =
m_schematic->ConnectionGraph()->GetCommittedNetChains();
1342 if( committed.empty() )
1345 XNODE* xchains =
node( wxT(
"net_chains" ) );
1347 for(
const std::unique_ptr<SCH_NETCHAIN>&
chain : committed )
1353 xchains->AddChild( xchain =
node( wxT(
"net_chain" ) ) );
1356 if( !
chain->GetNetClass().IsEmpty() )
1365 const std::shared_ptr<NET_SETTINGS>& ns = pf.
NetSettings();
1369 wxString className = ns->GetNetChainClass(
chain->GetName() );
1371 if( !className.IsEmpty() )
1372 xchain->
AddAttribute( wxT(
"net_chain_class" ), className );
1380 wxString::Format( wxT(
"#%02X%02X%02X%02X" ),
1381 (
int) std::clamp(
KiROUND( c.
r * 255.0 ), 0, 255 ),
1382 (
int) std::clamp(
KiROUND( c.
g * 255.0 ), 0, 255 ),
1383 (
int) std::clamp(
KiROUND( c.
b * 255.0 ), 0, 255 ),
1384 (
int) std::clamp(
KiROUND( c.
a * 255.0 ), 0, 255 ) ) );
1388 xchain->AddChild( xmembers =
node( wxT(
"members" ) ) );
1394 for(
const wxString& net :
chain->GetNets() )
1400 xmembers->AddChild( xmember =
node( wxT(
"member" ) ) );
1404 if( !
chain->GetTerminalRef( 0 ).IsEmpty() || !
chain->GetTerminalRef( 1 ).IsEmpty() )
1407 xchain->AddChild( xterms =
node( wxT(
"terminal_pins" ) ) );
1409 for(
int i = 0; i < 2; ++i )
1411 if(
chain->GetTerminalRef( i ).IsEmpty() )
1415 xterms->AddChild( xterm =
node( wxT(
"terminal_pin" ) ) );
1427 const wxString& aTextualContent )
1429 XNODE* n =
new XNODE( wxXML_ELEMENT_NODE, aName );
1431 if( aTextualContent.Len() > 0 )
1432 n->AddChild(
new XNODE( wxXML_TEXT_NODE, wxEmptyString, aTextualContent ) );
1449 auto getComponentClassFields = [&](
const std::vector<SCH_FIELD>& fields,
const SCH_SHEET_PATH* sheetPath )
1451 std::unordered_set<wxString> componentClasses;
1455 if( field.GetCanonicalName() == wxT(
"Component Class" ) )
1457 if( field.GetShownText( sheetPath,
false ) != wxEmptyString )
1458 componentClasses.insert( field.GetShownText( sheetPath,
false ) );
1462 return componentClasses;
1470 std::unordered_set<wxString> sheetComponentClasses;
1471 const std::unordered_set<SCH_RULE_AREA*>& sheetRuleAreas = sheetItem->
GetRuleAreaCache();
1477 std::unordered_set<wxString> ruleAreaComponentClasses =
1478 getComponentClassFields( label->GetFields(), &sheet );
1479 sheetComponentClasses.insert( ruleAreaComponentClasses.begin(), ruleAreaComponentClasses.end() );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
wxString GetBuildVersion()
Get the full KiCad version string.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
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.
A color representation with 4 components: red, green, blue, alpha.
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
std::vector< wxString > resolvePadNumbers(const SCH_PIN *aPin, const SCH_SHEET_PATH &aSheetPath) const
Resolve aPin to its effective pad number(s) for every netlist path (issue #2282).
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
The backing store for a PROJECT, in JSON format.
std::shared_ptr< NET_SETTINGS > & NetSettings()
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
bool ResolveExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const
static constexpr char SYNTHETIC_NET_PREFIX[]
Prefix used when synthesising net names for unnamed subgraphs.
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.
Variant information for a schematic symbol.
wxString GetDescription() const override
bool UseLibIdLookup() const
wxString GetFieldText(const wxString &aFieldName, const SCH_SHEET_PATH *aPath=nullptr, const wxString &aVariantName=wxEmptyString) const
wxString GetSchSymbolLibraryName() const
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 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.
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
std::map< wxString, wxString > m_Fields
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)
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
One refdes -> net membership row collected from the NETDEF section.
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)
const SHAPE_LINE_CHAIN chain
wxLogTrace helper definitions.