38#include <wx/tokenzr.h>
49 wxString ret( aNetName );
51 ret.Replace(
"!",
"~" );
59 wxString token = aText;
65 bool sectionOpen =
false;
67 for( wxString::size_type i = 0; i < aText.size(); i++ )
70 if( aText[ i ] ==
'\\' )
72 if( i + 1 != aText.size() )
73 text.Append( aText[ i + 1 ] );
87 if( aText[ i ] ==
'!' )
96 static wxString escapeChars( wxT(
" )]}'\"" ) );
98 if( i + 1 != aText.size() && escapeChars.Find( aText[i + 1] ) == wxNOT_FOUND )
105 text.Append( aText[ i ] );
111 if( aText[i] ==
',' && sectionOpen )
117 text.Append( aText[ i ] );
126 if( aText->StartsWith(
'>' ) && aText->AfterFirst(
' ' ).IsEmpty() )
128 wxString token = aText->Upper();
130 if ( token == wxT(
">NAME" ) ) *aText = wxT(
"${REFERENCE}" );
131 else if( token == wxT(
">VALUE" ) ) *aText = wxT(
"${VALUE}" );
132 else if( token == wxT(
">PART" ) ) *aText = wxT(
"${REFERENCE}" );
133 else if( token == wxT(
">GATE" ) ) *aText = wxT(
"${UNIT}" );
134 else if( token == wxT(
">MODULE" ) ) *aText = wxT(
"${FOOTPRINT_NAME}" );
135 else if( token == wxT(
">SHEETNR" ) ) *aText = wxT(
"${#}" );
136 else if( token == wxT(
">SHEETS" ) ) *aText = wxT(
"${##}" );
137 else if( token == wxT(
">SHEET" ) ) *aText = wxT(
"${#}/${##}" );
138 else if( token == wxT(
">SHEETNR_TOTAL" ) ) *aText = wxT(
"${#}" );
139 else if( token == wxT(
">SHEETS_TOTAL" ) ) *aText = wxT(
"${##}" );
140 else if( token == wxT(
">SHEET_TOTAL" ) ) *aText = wxT(
"${#}/${##}" );
141 else if( token == wxT(
">SHEET_HEADLINE" ) ) *aText = wxT(
"${SHEETNAME}" );
142 else if( token == wxT(
">ASSEMBLY_VARIANT" ) ) *aText = wxT(
"${ASSEMBLY_VARIANT}" );
143 else if( token == wxT(
">DRAWING_NAME" ) ) *aText = wxT(
"${PROJECTNAME}" );
144 else if( token == wxT(
">LAST_DATE_TIME" ) ) *aText = wxT(
"${CURRENT_DATE}" );
145 else if( token == wxT(
">PLOT_DATE_TIME" ) ) *aText = wxT(
"${CURRENT_DATE}" );
146 else *aText = wxString::Format( wxS(
"${%s}" ), aText->Mid( 1 ).Trim() );
157 aDescr.Replace( wxS(
"\n" ), wxS(
" " ) );
158 aDescr.Replace( wxS(
"\r" ), wxEmptyString );
160 wxRegEx( wxS(
"<a\\s+(?:[^>]*?\\s+)?href=\"([^\"]*)\"[^>]*>" ) )
161 .ReplaceAll( &aDescr, wxS(
"\\1 " ) );
163 aDescr.Replace( wxS(
"<p>" ), wxS(
"\n\n" ) );
164 aDescr.Replace( wxS(
"</p>" ), wxS(
"\n\n" ) );
166 aDescr.Replace( wxS(
"<br>" ), wxS(
"\n" ) );
167 aDescr.Replace( wxS(
"<ul>" ), wxS(
"\n" ) );
168 aDescr.Replace( wxS(
"</ul>" ), wxS(
"\n\n" ) );
169 aDescr.Replace( wxS(
"<li></li>" ), wxS(
"\n" ) );
170 aDescr.Replace( wxS(
"<li>" ), wxS(
"\n \u2022 " ) );
174 wxRegEx( wxS(
"\n +" ) ).ReplaceAll( &aDescr, wxS(
"\n" ) );
175 wxRegEx( wxS(
" +\n" ) ).ReplaceAll( &aDescr, wxS(
"\n" ) );
177 wxRegEx( wxS(
"\n{3,}" ) ).ReplaceAll( &aDescr, wxS(
"\n\n" ) );
178 wxRegEx( wxS(
"^\n+" ) ).ReplaceAll( &aDescr, wxEmptyString );
179 wxRegEx( wxS(
"\n+$" ) ).ReplaceAll( &aDescr, wxEmptyString );
191 std::function<size_t(
const wxXmlNode* )> countNodes =
192 [&](
const wxXmlNode* node )
198 if(
const wxXmlNode* child = node->GetChildren() )
199 count += countNodes( child );
203 node = node->GetNext();
209 cnt = countNodes( aNode );
213 wxLogTrace(
traceEagleIo, wxS(
"XML node '%s' count = %zu took %0.4f ms." ),
214 aNode->GetName(), cnt, timer.
msecs() );
221 m_isAvailable = !aData.IsEmpty();
232 static std::array<int, 9> DIVIDERS = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };
234 int integer, pre_fraction, post_fraction;
235 long long unsigned fraction;
239 bool negative = ( aValue[0] ==
'-' );
243 int ret = sscanf( aValue.c_str(),
"%d.%n%llu%n", &integer, &pre_fraction, &fraction,
255 int digits = post_fraction - pre_fraction;
259 if( digits >=
static_cast<int>( DIVIDERS.size() ) )
261 long long unsigned denom = pow( 10, digits - DIVIDERS.size() + 1 );
262 digits = DIVIDERS.size() - 1;
266 int frac_value =
ConvertToNm( fraction, aUnit ) / DIVIDERS[digits];
281 case EU_NM: ret = aValue;
break;
282 case EU_MM: ret = (
long long) aValue * 1000000;
break;
283 case EU_INCH: ret = (
long long) aValue * 25400000;
break;
284 case EU_MIL: ret = (
long long) aValue * 25400;
break;
287 if( ( ret > 0 ) != ( aValue > 0 ) )
288 wxLogError(
_(
"Invalid size %lld: too large" ), aValue );
302 wxStringTokenizer tokens( aUrn,
":" );
304 host = tokens.GetNextToken();
305 path = tokens.GetNextToken();
309 wxString tmp = tokens.GetNextToken();
311 assetId = tmp.BeforeFirst(
'/' );
324 static std::set<wxString> validAssetTypes =
333 if( validAssetTypes.count(
assetType ) == 0 )
362 return std::string( aValue.ToUTF8() );
371 if( aValue.ToCDouble( &value ) )
375 aValue.ToStdString() +
"'." );
382 if( aValue.IsEmpty() )
383 throw XML_PARSER_ERROR(
"Conversion to int failed. Original value is empty." );
385 return wxAtoi( aValue );
392 if( aValue !=
"yes" && aValue !=
"no" )
394 aValue.ToStdString() +
395 "', is neither 'yes' nor 'no'." );
397 return aValue ==
"yes";
408 value.
spin = aRot.find(
'S' ) != aRot.npos;
409 value.
mirror = aRot.find(
'M' ) != aRot.npos;
411 size_t rPos = aRot.find(
'R' );
413 if( rPos == wxString::npos )
420 size_t offset = rPos + 1;
429 wxString degreesStr = aRot.Mid( offset );
432 if( !degreesStr.ToCDouble( &value.
degrees ) )
467 if( aNode->GetAttribute( aAttribute, &value ) )
468 return Convert<T>( value );
470 throw XML_PARSER_ERROR(
"The required attribute " + aAttribute +
" is missing at "
471 "line " + wxString::Format(
"%d", aNode->GetLineNumber() ) +
498 aCurrentNode = aCurrentNode->GetChildren();
500 while( aCurrentNode )
505 nodesMap[aCurrentNode->GetName()] = aCurrentNode;
508 aCurrentNode = aCurrentNode->GetNext();
519 double dx = aEnd.
x - aStart.
x, dy = aEnd.
y - aStart.
y;
520 VECTOR2I mid = ( aStart + aEnd ) / 2;
522 double dlen = sqrt( dx*dx + dy*dy );
524 if( !std::isnormal( dlen ) || !std::isnormal( aAngle ) )
528 THROW_IO_ERROR( wxString::Format(
_(
"Invalid Arc with radius %0.2f and angle %0.2f" ),
533 double dist = dlen / ( 2 * tan(
DEG2RAD( aAngle ) / 2 ) );
536 mid.
x + dist * ( dy / dlen ),
537 mid.
y - dist * ( dx / dlen )
548 if( aAlignment ==
"center" )
550 else if( aAlignment ==
"center-right" )
552 else if( aAlignment ==
"top-left" )
554 else if( aAlignment ==
"top-center" )
556 else if( aAlignment ==
"top-right" )
558 else if( aAlignment ==
"bottom-left" )
560 else if( aAlignment ==
"bottom-center" )
562 else if( aAlignment ==
"bottom-right" )
564 else if( aAlignment ==
"center-left" )
608 x1 = parseRequiredAttribute<ECOORD>( aWire,
"x1" );
609 y1 = parseRequiredAttribute<ECOORD>( aWire,
"y1" );
610 x2 = parseRequiredAttribute<ECOORD>( aWire,
"x2" );
611 y2 = parseRequiredAttribute<ECOORD>( aWire,
"y2" );
612 width = parseRequiredAttribute<ECOORD>( aWire,
"width" );
613 layer = parseRequiredAttribute<int>( aWire,
"layer" );
614 curve = parseOptionalAttribute<double>( aWire,
"curve" );
616 opt_wxString s = parseOptionalAttribute<wxString>( aWire,
"style" );
618 if( s ==
"continuous" )
620 else if( s ==
"longdash" )
622 else if( s ==
"shortdash" )
624 else if( s ==
"dashdot" )
627 s = parseOptionalAttribute<wxString>( aWire,
"cap" );
631 else if( s ==
"flat" )
645 for( wxXmlNode* child = aSegment->GetChildren(); child; child = child->GetNext() )
647 if( child->GetName() ==
"pinref" )
648 pinRefs.emplace_back( std::make_unique<EPINREF>( child, aIo ) );
649 else if( child->GetName() ==
"portref" )
650 portRefs.emplace_back( std::make_unique<EPORTREF>( child, aIo ) );
651 else if( child->GetName() ==
"wire" )
652 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
653 else if( child->GetName() ==
"junction" )
654 junctions.emplace_back( std::make_unique<EJUNCTION>( child, aIo ) );
655 else if( child->GetName() ==
"label" )
656 labels.emplace_back( std::make_unique<ELABEL>( child, aIo ) );
657 else if( child->GetName() ==
"probe" )
658 probes.emplace_back( std::make_unique<EPROBE>( child, aIo ) );
674 name = parseRequiredAttribute<wxString>( aBus,
"name" );
676 for( wxXmlNode* child = aBus->GetChildren(); child; child = child->GetNext() )
678 if( child->GetName() ==
"segment" )
679 segments.emplace_back( std::make_unique<ESEGMENT>( child, aIo ) );
697 x = parseRequiredAttribute<ECOORD>( aJunction,
"x" );
698 y = parseRequiredAttribute<ECOORD>( aJunction,
"y" );
724 x = parseRequiredAttribute<ECOORD>( aLabel,
"x" );
725 y = parseRequiredAttribute<ECOORD>( aLabel,
"y" );
726 size = parseRequiredAttribute<ECOORD>( aLabel,
"size" );
727 layer = parseRequiredAttribute<int>( aLabel,
"layer" );
728 font = parseOptionalAttribute<wxString>( aLabel,
"font" );
729 ratio = parseOptionalAttribute<int>( aLabel,
"ratio" );
730 rot = parseOptionalAttribute<EROT>( aLabel,
"rot" );
731 xref = parseOptionalAttribute<wxString>( aLabel,
"xref" );
732 align = parseOptionalAttribute<wxString>( aLabel,
"align" );
748 netname = parseRequiredAttribute<wxString>( aNet,
"name" );
749 netcode = parseRequiredAttribute<int>( aNet,
"class" );
751 for( wxXmlNode* segment = aNet->GetChildren(); segment; segment = segment->GetNext() )
752 segments.emplace_back( std::make_unique<ESEGMENT>( segment ) );
774 x = parseRequiredAttribute<ECOORD>( aVia,
"x" );
775 y = parseRequiredAttribute<ECOORD>( aVia,
"y" );
777 wxString ext = parseRequiredAttribute<wxString>( aVia,
"extent" );
780 drill = parseRequiredAttribute<ECOORD>( aVia,
"drill" );
781 diam = parseOptionalAttribute<ECOORD>( aVia,
"diameter" );
782 shape = parseOptionalAttribute<wxString>( aVia,
"shape" );
802 x = parseRequiredAttribute<ECOORD>( aCircle,
"x" );
803 y = parseRequiredAttribute<ECOORD>( aCircle,
"y" );
804 radius = parseRequiredAttribute<ECOORD>( aCircle,
"radius" );
805 width = parseRequiredAttribute<ECOORD>( aCircle,
"width" );
806 layer = parseRequiredAttribute<int>( aCircle,
"layer" );
827 x1 = parseRequiredAttribute<ECOORD>( aRect,
"x1" );
828 y1 = parseRequiredAttribute<ECOORD>( aRect,
"y1" );
829 x2 = parseRequiredAttribute<ECOORD>( aRect,
"x2" );
830 y2 = parseRequiredAttribute<ECOORD>( aRect,
"y2" );
831 layer = parseRequiredAttribute<int>( aRect,
"layer" );
832 rot = parseOptionalAttribute<EROT>( aRect,
"rot" );
848 text = aDescription->GetNodeContent();
849 language = parseOptionalAttribute<wxString>( aDescription,
"language" );
875 name = parseRequiredAttribute<wxString>( aTree,
"name" );
876 value = parseOptionalAttribute<wxString>( aTree,
"value" );
878 x = parseOptionalAttribute<ECOORD>( aTree,
"x" );
879 y = parseOptionalAttribute<ECOORD>( aTree,
"y" );
880 size = parseOptionalAttribute<ECOORD>( aTree,
"size" );
882 layer = parseOptionalAttribute<int>( aTree,
"layer" );
883 ratio = parseOptionalAttribute<double>( aTree,
"ratio" );
884 rot = parseOptionalAttribute<EROT>( aTree,
"rot" );
886 opt_wxString stemp = parseOptionalAttribute<wxString>( aTree,
"display" );
891 else if( stemp ==
"name" )
893 else if( stemp ==
"both" )
898 stemp = parseOptionalAttribute<wxString>( aTree,
"align" );
917 part = parseRequiredAttribute<wxString>( aPinRef,
"part" );
918 gate = parseRequiredAttribute<wxString>( aPinRef,
"gate" );
919 pin = parseRequiredAttribute<wxString>( aPinRef,
"pin" );
935 moduleinst = parseRequiredAttribute<wxString>( aPortRef,
"moduleinst" );
936 port = parseRequiredAttribute<wxString>( aPortRef,
"port" );
961 x = parseRequiredAttribute<ECOORD>( aProbe,
"x" );
962 y = parseRequiredAttribute<ECOORD>( aProbe,
"y" );
963 size = parseRequiredAttribute<double>( aProbe,
"size" );
964 layer = parseRequiredAttribute<int>( aProbe,
"layer" );
965 font = parseOptionalAttribute<wxString>( aProbe,
"font" );
966 ratio = parseOptionalAttribute<int>( aProbe,
"ratio" );
967 rot = parseOptionalAttribute<EROT>( aProbe,
"rot" );
968 xref = parseOptionalAttribute<bool>( aProbe,
"xref" );
992 x1 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x1" ) );
993 y1 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y1" ) );
994 x2 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x2" ) );
995 y2 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y2" ) );
996 x3 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x3" ) );
997 y3 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y3" ) );
998 textsize = parseOptionalAttribute<ECOORD>( aDimension, wxT(
"textsize" ) );
999 layer = parseRequiredAttribute<int>( aDimension, wxT(
"layer" ) );
1000 dimensionType = parseOptionalAttribute<wxString>( aDimension, wxT(
"dtype" ) );
1023 text = aText->GetNodeContent();
1024 x = parseRequiredAttribute<ECOORD>( aText,
"x" );
1025 y = parseRequiredAttribute<ECOORD>( aText,
"y" );
1026 size = parseRequiredAttribute<ECOORD>( aText,
"size" );
1027 layer = parseRequiredAttribute<int>( aText,
"layer" );
1029 font = parseOptionalAttribute<wxString>( aText,
"font" );
1030 ratio = parseOptionalAttribute<double>( aText,
"ratio" );
1031 rot = parseOptionalAttribute<EROT>( aText,
"rot" );
1033 opt_wxString stemp = parseOptionalAttribute<wxString>( aText,
"align" );
1047 const wxString& fontName =
font.
CGet();
1049 if( fontName ==
"vector" )
1053 else if( fontName ==
"fixed" )
1095 x1 = parseRequiredAttribute<ECOORD>( aFrameNode,
"x1" );
1096 y1 = parseRequiredAttribute<ECOORD>( aFrameNode,
"y1" );
1097 x2 = parseRequiredAttribute<ECOORD>( aFrameNode,
"x2" );
1098 y2 = parseRequiredAttribute<ECOORD>( aFrameNode,
"y2" );
1099 columns = parseRequiredAttribute<int>( aFrameNode,
"columns" );
1100 rows = parseRequiredAttribute<int>( aFrameNode,
"rows" );
1101 layer = parseRequiredAttribute<int>( aFrameNode,
"layer" );
1102 border_left = parseOptionalAttribute<bool>( aFrameNode,
"border-left" );
1103 border_top = parseOptionalAttribute<bool>( aFrameNode,
"border-top" );
1104 border_right = parseOptionalAttribute<bool>( aFrameNode,
"border-right" );
1105 border_bottom = parseOptionalAttribute<bool>( aFrameNode,
"border-bottom" );
1115 name = parseRequiredAttribute<wxString>( aPad,
"name" );
1116 x = parseRequiredAttribute<ECOORD>( aPad,
"x" );
1117 y = parseRequiredAttribute<ECOORD>( aPad,
"y" );
1118 rot = parseOptionalAttribute<EROT>( aPad,
"rot" );
1119 stop = parseOptionalAttribute<bool>( aPad,
"stop" );
1120 thermals = parseOptionalAttribute<bool>( aPad,
"thermals" );
1144 drill = parseOptionalAttribute<ECOORD>( aPad,
"drill" );
1147 diameter = parseOptionalAttribute<ECOORD>( aPad,
"diameter" );
1149 opt_wxString s = parseOptionalAttribute<wxString>( aPad,
"shape" );
1154 else if( s ==
"round" )
1156 else if( s ==
"octagon" )
1158 else if( s ==
"long" )
1160 else if( s ==
"offset" )
1163 first = parseOptionalAttribute<bool>( aPad,
"first" );
1189 dx = parseRequiredAttribute<ECOORD>( aSMD,
"dx" );
1190 dy = parseRequiredAttribute<ECOORD>( aSMD,
"dy" );
1191 layer = parseRequiredAttribute<int>( aSMD,
"layer" );
1193 roundness = parseOptionalAttribute<int>( aSMD,
"roundness" );
1194 cream = parseOptionalAttribute<bool>( aSMD,
"cream" );
1219 name = parseRequiredAttribute<wxString>( aPin,
"name" );
1220 x = parseRequiredAttribute<ECOORD>( aPin,
"x" );
1221 y = parseRequiredAttribute<ECOORD>( aPin,
"y" );
1223 visible = parseOptionalAttribute<wxString>( aPin,
"visible" );
1224 length = parseOptionalAttribute<wxString>( aPin,
"length" );
1225 direction = parseOptionalAttribute<wxString>( aPin,
"direction" );
1226 function = parseOptionalAttribute<wxString>( aPin,
"function" );
1227 swaplevel = parseOptionalAttribute<int>( aPin,
"swaplevel" );
1228 rot = parseOptionalAttribute<EROT>( aPin,
"rot" );
1246 x = parseRequiredAttribute<ECOORD>( aVertex,
"x" );
1247 y = parseRequiredAttribute<ECOORD>( aVertex,
"y" );
1248 curve = parseOptionalAttribute<double>( aVertex,
"curve" );
1278 width = parseRequiredAttribute<ECOORD>( aPolygon,
"width" );
1279 layer = parseRequiredAttribute<int>( aPolygon,
"layer" );
1281 spacing = parseOptionalAttribute<ECOORD>( aPolygon,
"spacing" );
1282 isolate = parseOptionalAttribute<ECOORD>( aPolygon,
"isolate" );
1283 opt_wxString s = parseOptionalAttribute<wxString>( aPolygon,
"pour" );
1291 else if( s ==
"cutout" )
1294 orphans = parseOptionalAttribute<bool>( aPolygon,
"orphans" );
1295 thermals = parseOptionalAttribute<bool>( aPolygon,
"thermals" );
1296 rank = parseOptionalAttribute<int>( aPolygon,
"rank" );
1298 for( wxXmlNode* child = aPolygon->GetChildren(); child; child = child->GetNext() )
1300 if( child->GetName() ==
"vertex" )
1301 vertices.emplace_back( std::make_unique<EVERTEX>( child, aIo ) );
1319 width = parseRequiredAttribute<double>( aSpline,
"width" );
1321 for( wxXmlNode* child = aSpline->GetChildren(); child; child = child->GetNext() )
1323 if( child->GetName() ==
"vertex" )
1324 vertices.emplace_back( std::make_unique<EVERTEX>( child, aIo ) );
1344 name = parseRequiredAttribute<wxString>( aVariant,
"name" );
1345 populate = parseOptionalAttribute<bool>( aVariant,
"populate" );
1346 value = parseOptionalAttribute<wxString>( aVariant,
"value" );
1347 technology = parseOptionalAttribute<wxString>( aVariant,
"technology" );
1362 name = parseRequiredAttribute<wxString>( aModel,
"name" );
1363 model = aModel->GetNodeContent();
1380 gate = parseRequiredAttribute<wxString>( aPinMap,
"gate" );
1381 pin = parseRequiredAttribute<wxString>( aPinMap,
"pin" );
1382 pinorder = parseRequiredAttribute<wxString>( aPinMap,
"pinorder" );
1399 isusermap = parseOptionalAttribute<bool>( aPinMapping,
"isusermap" );
1400 iddevicewide = parseOptionalAttribute<bool>( aPinMapping,
"iddevicewide" );
1401 spiceprefix = parseOptionalAttribute<wxString>( aPinMapping,
"spiceprefix" );
1403 for( wxXmlNode* child = aPinMapping->GetChildren(); child; child = child->GetNext() )
1405 if( child->GetName() ==
"pinmap" )
1406 pinmaps.emplace_back( std::make_unique<EPINMAP>( child, aIo ) );
1419 pinmapping = std::make_unique<EPINMAPPING>( aSpice );
1421 if( aSpice->GetName() ==
"model" )
1422 model = std::make_unique<EMODEL>( aSpice );
1441 x = parseRequiredAttribute<ECOORD>( aHole,
"x" );
1442 y = parseRequiredAttribute<ECOORD>( aHole,
"y" );
1443 drill = parseRequiredAttribute<ECOORD>( aHole,
"drill" );
1475 name = parseRequiredAttribute<wxString>( aElement,
"name" );
1476 library = parseRequiredAttribute<wxString>( aElement,
"library" );
1477 value = parseRequiredAttribute<wxString>( aElement,
"value" );
1478 std::string p = parseRequiredAttribute<std::string>( aElement,
"package" );
1480 package = wxString::FromUTF8( p.c_str() );
1482 x = parseRequiredAttribute<ECOORD>( aElement,
"x" );
1483 y = parseRequiredAttribute<ECOORD>( aElement,
"y" );
1486 library_urn = parseOptionalAttribute<EURN>( aElement,
"library_urn" );
1487 locked = parseOptionalAttribute<bool>( aElement,
"locked" );
1488 smashed = parseOptionalAttribute<bool>( aElement,
"smashed" );
1489 rot = parseOptionalAttribute<EROT>( aElement,
"rot" );
1491 for( wxXmlNode* child = aElement->GetChildren(); child; child = child->GetNext() )
1493 if( child->GetName() ==
"attribute" )
1495 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1496 attributes[ attr->name ] = std::move( attr );
1498 else if( child->GetName() ==
"variant" )
1500 std::unique_ptr<EVARIANT> variant = std::make_unique<EVARIANT>( child, aIo );
1501 variants[ variant->name ] = std::move( variant );
1505 AdvanceProgressPhase();
1524 number = parseRequiredAttribute<int>( aLayer,
"number" );
1525 name = parseRequiredAttribute<wxString>( aLayer,
"name" );
1526 color = parseRequiredAttribute<int>( aLayer,
"color" );
1527 fill = parseRequiredAttribute<int>( aLayer,
"fill" );
1528 visible = parseOptionalAttribute<bool>( aLayer,
"visible" );
1529 active = parseOptionalAttribute<bool>( aLayer,
"active" );
1549 name = parseRequiredAttribute<wxString>( aPart,
"name" );
1550 library = parseRequiredAttribute<wxString>( aPart,
"library" );
1551 libraryUrn = parseOptionalAttribute<EURN>( aPart,
"library_urn" );
1552 deviceset = parseRequiredAttribute<wxString>( aPart,
"deviceset" );
1553 device = parseRequiredAttribute<wxString>( aPart,
"device" );
1554 package3d_urn = parseOptionalAttribute<wxString>( aPart,
"package3d_urn" );
1558 technology = parseOptionalAttribute<wxString>( aPart,
"technology" );
1559 value = parseOptionalAttribute<wxString>( aPart,
"value" );
1561 for( wxXmlNode* child = aPart->GetChildren(); child; child = child->GetNext() )
1563 if( child->GetName() ==
"attribute" )
1565 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1566 attributes[ attr->name ] = std::move( attr );
1568 else if( child->GetName() ==
"variant" )
1570 std::unique_ptr<EVARIANT> variant = std::make_unique<EVARIANT>( child, aIo );
1571 variants[ variant->name ] = std::move( variant );
1573 else if( child->GetName() ==
"spice" )
1575 spice = std::make_unique<ESPICE>( child, aIo );
1597 part = parseRequiredAttribute<wxString>( aInstance,
"part" );
1598 gate = parseRequiredAttribute<wxString>( aInstance,
"gate" );
1600 x = parseRequiredAttribute<ECOORD>( aInstance,
"x" );
1601 y = parseRequiredAttribute<ECOORD>( aInstance,
"y" );
1604 smashed = parseOptionalAttribute<bool>( aInstance,
"smashed" );
1605 rot = parseOptionalAttribute<EROT>( aInstance,
"rot" );
1607 for( wxXmlNode* child = aInstance->GetChildren(); child; child = child->GetNext() )
1609 if( child->GetName() ==
"attribute" )
1611 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1612 attributes[ attr->name ] = std::move( attr );
1635 name = parseRequiredAttribute<wxString>( aGate,
"name" );
1636 symbol = parseRequiredAttribute<wxString>( aGate,
"symbol" );
1638 x = parseRequiredAttribute<ECOORD>( aGate,
"x" );
1639 y = parseRequiredAttribute<ECOORD>( aGate,
"y" );
1641 opt_wxString stemp = parseOptionalAttribute<wxString>( aGate,
"addlevel" );
1644 if( stemp ==
"must" )
1646 else if( stemp ==
"can" )
1648 else if( stemp ==
"next" )
1650 else if( stemp ==
"request" )
1652 else if( stemp ==
"always" )
1657 swaplevel = parseOptionalAttribute<int>( aGate,
"swaplevel" );
1675 gate = parseRequiredAttribute<wxString>( aConnect,
"gate" );
1676 pin = parseRequiredAttribute<wxString>( aConnect,
"pin" );
1677 pad = parseRequiredAttribute<wxString>( aConnect,
"pad" );
1678 contactroute = parseOptionalAttribute<wxString>( aConnect,
"contactroute" );
1693 name = parseRequiredAttribute<wxString>( aTechnology,
"name" );
1695 for( wxXmlNode* child = aTechnology->GetChildren(); child; child = child->GetNext() )
1697 if( child->GetName() ==
"attribute" )
1698 attributes.emplace_back( std::make_unique<EATTR>( child, aIo ) );
1714 package3d_urn = parseRequiredAttribute<wxString>( aPackage3dInst,
"package3d_urn" );
1729 name = parseRequiredAttribute<wxString>( aDevice,
"name" );
1730 opt_wxString pack = parseOptionalAttribute<wxString>( aDevice,
"package" );
1734 std::string p( pack->c_str() );
1736 package.
Set( wxString::FromUTF8( p.c_str() ) );
1739 for( wxXmlNode* child = aDevice->GetChildren(); child; child = child->GetNext() )
1741 if( child->GetName() ==
"connects" )
1743 for( wxXmlNode* connect = child->GetChildren(); connect; connect = connect->GetNext() )
1745 if( connect->GetName() ==
"connect" )
1746 connects.emplace_back( std::make_unique<ECONNECT>( connect, aIo ) );
1751 else if( child->GetName() ==
"packages3dinstances" )
1753 for( wxXmlNode* package3dinst = child->GetChildren(); package3dinst;
1754 package3dinst = package3dinst->GetNext() )
1756 if( package3dinst->GetName() ==
"package3dinstance" )
1757 package3dinstances.emplace_back( std::make_unique<EPACKAGE3DINST>( package3dinst, aIo ) );
1762 else if( child->GetName() ==
"technologies" )
1764 for( wxXmlNode* technology = child->GetChildren(); technology;
1765 technology = technology->GetNext() )
1767 if( technology->GetName() ==
"technology" )
1768 technologies.emplace_back( std::make_unique<ETECHNOLOGY>( technology, aIo ) );
1796 name = parseRequiredAttribute<wxString>( aDeviceSet,
"name" );
1797 urn = parseOptionalAttribute<EURN>( aDeviceSet,
"urn" );
1798 locally_modified = parseOptionalAttribute<bool>( aDeviceSet,
"locally_modified" );
1799 prefix = parseOptionalAttribute<wxString>( aDeviceSet,
"prefix" );
1800 uservalue = parseOptionalAttribute<bool>( aDeviceSet,
"uservalue" );
1801 library_version = parseOptionalAttribute<int>( aDeviceSet,
"library_version" );
1803 parseOptionalAttribute<bool>( aDeviceSet,
"library_locally_modified" );
1805 for( wxXmlNode* child = aDeviceSet->GetChildren(); child; child = child->GetNext() )
1807 if( child->GetName() ==
"description" )
1809 description = std::make_optional<EDESCRIPTION>( child, aIo );
1811 else if( child->GetName() ==
"gates" )
1813 for( wxXmlNode* gate = child->GetChildren(); gate; gate = gate->GetNext() )
1815 std::unique_ptr<EGATE> tmp = std::make_unique<EGATE>( gate, aIo );
1816 gates[tmp->name] = std::move( tmp );
1821 else if( child->GetName() ==
"devices" )
1823 for( wxXmlNode* device = child->GetChildren(); device; device = device->GetNext() )
1824 devices.emplace_back( std::make_unique<EDEVICE>( device, aIo ) );
1828 else if( child->GetName() ==
"spice" )
1830 spice = std::make_optional<ESPICE>( child, aIo );
1850 number = parseRequiredAttribute<wxString>( aClass,
"number" );
1851 name = parseRequiredAttribute<wxString>( aClass,
"name" );
1852 width = parseOptionalAttribute<ECOORD>( aClass,
"width" );
1853 drill = parseOptionalAttribute<ECOORD>( aClass,
"drill" );
1855 for( wxXmlNode* child = aClass->GetChildren(); child; child = child->GetNext() )
1857 if( child->GetName() ==
"clearance" )
1859 wxString to = parseRequiredAttribute<wxString>( child,
"class" );
1860 ECOORD value = parseRequiredAttribute<ECOORD>( child,
"value" );
1879 for( wxXmlNode* child = aPlain->GetChildren(); child; child = child->GetNext() )
1881 if( child->GetName() ==
"polygon" )
1882 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
1883 else if( child->GetName() ==
"wire" )
1884 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
1885 else if( child->GetName() ==
"text" )
1886 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
1887 else if( child->GetName() ==
"dimension" )
1888 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
1889 else if( child->GetName() ==
"circle" )
1890 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
1891 else if( child->GetName() ==
"spline" )
1892 splines.emplace_back( std::make_unique<ESPLINE>( child, aIo ) );
1893 else if( child->GetName() ==
"rectangle" )
1894 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
1895 else if( child->GetName() ==
"frame" )
1896 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
1897 else if( child->GetName() ==
"hole" )
1898 holes.emplace_back( std::make_unique<EHOLE>( child, aIo ) );
1922 name = parseRequiredAttribute<wxString>( aModuleInst,
"name" );
1923 moduleinst = parseRequiredAttribute<wxString>( aModuleInst,
"module" );
1924 moduleVariant = parseOptionalAttribute<wxString>( aModuleInst,
"modulevariant" );
1925 x = parseRequiredAttribute<ECOORD>( aModuleInst,
"x" );
1926 y = parseRequiredAttribute<ECOORD>( aModuleInst,
"y" );
1927 offset = parseOptionalAttribute<int>( aModuleInst,
"offset" );
1928 smashed = parseOptionalAttribute<bool>( aModuleInst,
"smashed" );
1929 rotation = parseOptionalAttribute<EROT>( aModuleInst,
"rot" );
1941 for( wxXmlNode* child = aSheet->GetChildren(); child; child = child->GetNext() )
1943 if( child->GetName() ==
"description" )
1945 description = std::make_optional<EDESCRIPTION>( child, aIo );
1947 else if( child->GetName() ==
"plain" )
1949 plain = std::make_unique<EPLAIN>( child, aIo );
1951 else if( child->GetName() ==
"moduleinsts" )
1953 for( wxXmlNode* moduleinst = child->GetChildren(); moduleinst;
1954 moduleinst = moduleinst->GetNext() )
1956 if( moduleinst->GetName() ==
"moduleinst" )
1958 std::unique_ptr<EMODULEINST> inst = std::make_unique<EMODULEINST>( moduleinst, aIo );
1965 else if( child->GetName() ==
"instances" )
1967 for( wxXmlNode* instance = child->GetChildren(); instance; instance = instance->GetNext() )
1969 if( instance->GetName() ==
"instance" )
1970 instances.emplace_back( std::make_unique<EINSTANCE>( instance, aIo ) );
1975 else if( child->GetName() ==
"busses" )
1977 for( wxXmlNode* bus = child->GetChildren(); bus; bus = bus->GetNext() )
1979 if( bus->GetName() ==
"bus" )
1980 busses.emplace_back( std::make_unique<EBUS>( bus, aIo ) );
1985 else if( child->GetName() ==
"nets" )
1987 for( wxXmlNode* net = child->GetChildren(); net; net = net->GetNext() )
1989 if( net->GetName() ==
"net" )
1990 nets.emplace_back( std::make_unique<ENET>( net, aIo ) );
2018 name = parseRequiredAttribute<wxString>( aSchematicGroup,
"name" );
2019 selectable = parseOptionalAttribute<bool>( aSchematicGroup,
"selectable" );
2020 width = parseOptionalAttribute<ECOORD>( aSchematicGroup,
"width" );
2021 titleSize = parseOptionalAttribute<ECOORD>( aSchematicGroup,
"titleSize" );
2022 titleFont = parseOptionalAttribute<wxString>( aSchematicGroup,
"font" );
2023 wireStyle = parseOptionalAttribute<wxString>( aSchematicGroup,
"style" );
2024 showAnnotations = parseOptionalAttribute<bool>( aSchematicGroup,
"showAnnotations" );
2025 layer = parseOptionalAttribute<int>( aSchematicGroup,
"layer" );
2026 grouprefs = parseOptionalAttribute<wxString>( aSchematicGroup,
"grouprefs" );
2028 for( wxXmlNode* child = aSchematicGroup->GetChildren(); child; child = child->GetNext() )
2030 if( child->GetName() ==
"description" )
2032 description = std::make_optional<EDESCRIPTION>( child, aIo );
2034 else if( child->GetName() ==
"attribute" )
2036 attributes.emplace_back( std::make_unique<EATTR>( child, aIo ) );
2056 name = parseRequiredAttribute<wxString>( aModule,
"name" );
2057 prefix = parseOptionalAttribute<wxString>( aModule,
"prefix" );
2058 dx = parseRequiredAttribute<ECOORD>( aModule,
"dx" );
2059 dy = parseRequiredAttribute<ECOORD>( aModule,
"dy" );
2061 for( wxXmlNode* child = aModule->GetChildren(); child; child = child->GetNext() )
2063 if( child->GetName() ==
"description" )
2065 description = std::make_optional<EDESCRIPTION>( child, aIo );
2067 else if( child->GetName() ==
"ports" )
2069 for( wxXmlNode* port = child->GetChildren(); port; port = port->GetNext() )
2071 if( port->GetName() ==
"port" )
2073 std::unique_ptr<EPORT> tmp = std::make_unique<EPORT>( port, aIo );
2074 ports[ tmp->name ] = std::move( tmp );
2080 else if( child->GetName() ==
"variantdefs" )
2082 for( wxXmlNode* variantdef = child->GetChildren(); variantdef;
2083 variantdef = variantdef->GetNext() )
2085 if( variantdef->GetName() ==
"variantdef" )
2087 std::unique_ptr<EVARIANTDEF> tmp = std::make_unique<EVARIANTDEF>( variantdef,
2095 else if( child->GetName() ==
"groups" )
2099 if(
group->GetName() ==
"schematic_group" )
2101 std::unique_ptr<ESCHEMATIC_GROUP> tmp =
2102 std::make_unique<ESCHEMATIC_GROUP>(
group, aIo );
2103 groups[ tmp->name ] = std::move( tmp );
2109 else if( child->GetName() ==
"parts" )
2111 for( wxXmlNode* part = child->GetChildren(); part; part = part->GetNext() )
2113 if( part->GetName() ==
"part" )
2115 std::unique_ptr<EPART> tmp = std::make_unique<EPART>( part, aIo );
2116 parts[ tmp->name ] = std::move( tmp );
2122 else if( child->GetName() ==
"sheets" )
2124 for( wxXmlNode* sheet = child->GetChildren(); sheet; sheet = sheet->GetNext() )
2126 if( sheet->GetName() ==
"sheet" )
2127 sheets.emplace_back( std::make_unique<ESHEET>( sheet, aIo ) );
2150 name = parseRequiredAttribute<wxString>( aPort,
"name" );
2151 side = parseRequiredAttribute<wxString>( aPort,
"side" );
2152 coord = parseRequiredAttribute<ECOORD>( aPort,
"coord" );
2153 direction = parseOptionalAttribute<wxString>( aPort,
"direction" );
2169 name = parseRequiredAttribute<wxString>( aVariantDef,
"name" );
2170 current = parseOptionalAttribute<bool>( aVariantDef,
"current" );
2187 version = parseRequiredAttribute<double>( aNote,
"version" );
2188 severity = parseRequiredAttribute<wxString>( aNote,
"severity" );
2190 note = aNote->GetNodeContent();
2202 for( wxXmlNode* child = aCompatibility->GetNext(); child; child = child->GetNext() )
2204 if( child->GetName() ==
"note" )
2205 notes.emplace_back( std::make_unique<ENOTE>( child ) );
2223 alwaysvectorfont = parseOptionalAttribute<bool>( aSetting,
"alwaysvectorfont" );
2224 verticaltext = parseOptionalAttribute<wxString>( aSetting,
"verticaltext" );
2225 keepoldvectorfont = parseOptionalAttribute<bool>( aSetting,
"keepoldvectorfont" );
2248 distance = parseOptionalAttribute<double>( aGrid,
"distance" );
2249 unitdist = parseOptionalAttribute<wxString>( aGrid,
"unitdist" );
2250 unit = parseOptionalAttribute<wxString>( aGrid,
"unit" );
2251 style = parseOptionalAttribute<wxString>( aGrid,
"style" );
2252 multiple = parseOptionalAttribute<int>( aGrid,
"multiple" );
2253 display = parseOptionalAttribute<bool>( aGrid,
"display" );
2254 altdistance = parseOptionalAttribute<double>( aGrid,
"altdistance" );
2255 altunitdist = parseOptionalAttribute<wxString>( aGrid,
"altunitdist" );
2256 altunit = parseOptionalAttribute<wxString>( aGrid,
"altunit" );
2272 name = parseRequiredAttribute<wxString>( aFilter,
"name" );
2273 expression = parseRequiredAttribute<wxString>( aFilter,
"expression" );
2295 name = parseRequiredAttribute<wxString>( aPackage,
"name" );
2296 urn = parseOptionalAttribute<EURN>( aPackage,
"urn" );
2297 locally_modified = parseOptionalAttribute<bool>( aPackage,
"locally_modified" );
2298 library_version = parseOptionalAttribute<int>( aPackage,
"library_version" );
2301 for( wxXmlNode* child = aPackage->GetChildren(); child; child = child->GetNext() )
2303 if( child->GetName() ==
"description" )
2305 description = std::make_optional<EDESCRIPTION>( child, aIo );
2307 else if( child->GetName() ==
"polygon" )
2309 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
2311 else if( child->GetName() ==
"wire" )
2313 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
2315 else if( child->GetName() ==
"text" )
2317 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
2319 else if( child->GetName() ==
"dimension" )
2321 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
2323 else if( child->GetName() ==
"circle" )
2325 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
2327 else if( child->GetName() ==
"rectangle" )
2329 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
2331 else if( child->GetName() ==
"frame" )
2333 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
2335 else if( child->GetName() ==
"hole" )
2337 holes.emplace_back( std::make_unique<EHOLE>( child, aIo ) );
2339 else if( child->GetName() ==
"pad" )
2341 thtpads.emplace_back( std::make_unique<EPAD>( child, aIo ) );
2343 else if( child->GetName() ==
"smd" )
2345 smdpads.emplace_back( std::make_unique<ESMD>( child, aIo ) );
2362 name = parseRequiredAttribute<wxString>( aPackageInstance,
"name" );
2383 name = parseRequiredAttribute<wxString>( aPackage3d,
"name" );
2384 urn = parseRequiredAttribute<wxString>( aPackage3d,
"urn" );
2385 type = parseRequiredAttribute<wxString>( aPackage3d,
"type" );
2386 library_version = parseOptionalAttribute<int>( aPackage3d,
"library_version" );
2388 "library_locally_modified" );
2390 for( wxXmlNode* child = aPackage3d->GetChildren(); child; child = child->GetNext() )
2392 if( child->GetName() ==
"description" )
2394 description = std::make_optional<EDESCRIPTION>( child, aIo );
2396 else if( child->GetName() ==
"packageinstances" )
2398 for( wxXmlNode* instance = child->GetChildren(); instance;
2399 instance = instance->GetNext() )
2400 packageinstances.emplace_back( std::make_unique<EPACKAGEINSTANCE>( instance,
2428 name = parseRequiredAttribute<wxString>( aSymbol,
"name" );
2429 urn = parseOptionalAttribute<EURN>( aSymbol,
"urn" );
2430 locally_modified = parseOptionalAttribute<bool>( aSymbol,
"locally_modified" );
2431 library_version = parseOptionalAttribute<int>( aSymbol,
"library_version" );
2434 for( wxXmlNode* child = aSymbol->GetChildren(); child; child = child->GetNext() )
2436 if( child->GetName() ==
"description" )
2438 description = std::make_optional<EDESCRIPTION>( child, aIo );
2440 else if( child->GetName() ==
"polygon" )
2442 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
2444 else if( child->GetName() ==
"wire" )
2446 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
2448 else if( child->GetName() ==
"text" )
2450 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
2452 else if( child->GetName() ==
"dimension" )
2454 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
2456 else if( child->GetName() ==
"pin" )
2458 pins.emplace_back( std::make_unique<EPIN>( child, aIo ) );
2460 else if( child->GetName() ==
"circle" )
2462 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
2464 else if( child->GetName() ==
"rectangle" )
2466 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
2468 else if( child->GetName() ==
"frame" )
2470 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
2492 wxString parentNodeName;
2494 if( aLibrary->GetParent() )
2495 parentNodeName = aLibrary->GetParent()->GetName();
2497 if( parentNodeName ==
"libraries" )
2499 name = parseRequiredAttribute<wxString>( aLibrary,
"name" );
2500 urn = parseOptionalAttribute<EURN>( aLibrary,
"urn" );
2503 for( wxXmlNode* child = aLibrary->GetChildren(); child; child = child->GetNext() )
2505 if( child->GetName() ==
"description" )
2507 description = std::make_optional<EDESCRIPTION>( child, aIo );
2509 else if( child->GetName() ==
"packages" )
2511 for( wxXmlNode* package = child->GetChildren(); package; package = package->GetNext() )
2513 if( package->GetName() ==
"package" )
2515 std::unique_ptr<EPACKAGE> tmp = std::make_unique<EPACKAGE>( package, aIo );
2516 packages[ tmp->name ] = std::move( tmp );
2522 else if( child->GetName() ==
"packages3d" )
2524 for( wxXmlNode* package3d = child->GetChildren(); package3d;
2525 package3d = package3d->GetNext() )
2527 if( package3d->GetName() ==
"package3d" )
2529 std::unique_ptr<EPACKAGE3D> tmp = std::make_unique<EPACKAGE3D>( package3d,
2537 else if( child->GetName() ==
"symbols" )
2539 for( wxXmlNode* symbol = child->GetChildren(); symbol; symbol = symbol->GetNext() )
2541 if( symbol->GetName() ==
"symbol" )
2543 std::unique_ptr<ESYMBOL> tmp = std::make_unique<ESYMBOL>( symbol, aIo );
2544 symbols[ tmp->name ] = std::move( tmp );
2550 else if( child->GetName() ==
"devicesets" )
2552 for( wxXmlNode* deviceset = child->GetChildren(); deviceset;
2553 deviceset = deviceset->GetNext() )
2555 if( deviceset->GetName() ==
"deviceset" )
2557 std::unique_ptr<EDEVICE_SET> tmp = std::make_unique<EDEVICE_SET>( deviceset,
2573 wxString libName =
name;
2598 hash = parseRequiredAttribute<wxString>( aApproved,
"hash" );
2615 xreflabel = parseOptionalAttribute<wxString>( aSchematic,
"xreflabel" );
2616 xrefpart = parseOptionalAttribute<wxString>( aSchematic,
"xrefpart" );
2618 for( wxXmlNode* child = aSchematic->GetChildren(); child; child = child->GetNext() )
2620 if( child->GetName() ==
"description" )
2622 description = std::make_optional<EDESCRIPTION>( child, aIo );
2624 else if( child->GetName() ==
"libraries" )
2628 if(
library->GetName() ==
"library" )
2630 std::unique_ptr<ELIBRARY> tmp = std::make_unique<ELIBRARY>(
library, aIo );
2632 wxString libName = tmp->GetName();
2638 wxString uniqueName;
2639 std::set<wxString> usedNames;
2641 for(
const auto& [setName, setLibrary] :
libraries )
2642 usedNames.emplace( setName );
2644 if( usedNames.find( libName ) != usedNames.end() )
2650 uniqueName.Format( wxS(
"%s_%d" ), libName, i );
2652 }
while( usedNames.find( uniqueName ) != usedNames.end() );
2655 libName = uniqueName;
2658 libraries[ libName ] = std::move( tmp );
2664 else if( child->GetName() ==
"attributes" )
2666 for( wxXmlNode* attribute = child->GetChildren(); attribute;
2667 attribute = attribute->GetNext() )
2669 if( attribute->GetName() ==
"attribute" )
2671 std::unique_ptr<EATTR> tmp = std::make_unique<EATTR>( attribute, aIo );
2678 else if( child->GetName() ==
"variantdefs" )
2680 for( wxXmlNode* variantdef = child->GetChildren(); variantdef;
2681 variantdef = variantdef->GetNext() )
2683 if( variantdef->GetName() ==
"variantdef" )
2685 std::unique_ptr<EVARIANTDEF> tmp = std::make_unique<EVARIANTDEF>( variantdef,
2693 else if( child->GetName() ==
"classes" )
2695 for( wxXmlNode* eclass = child->GetChildren(); eclass; eclass = eclass->GetNext() )
2697 if( eclass->GetName() ==
"class" )
2699 std::unique_ptr<ECLASS> tmp = std::make_unique<ECLASS>( eclass, aIo );
2700 classes[ tmp->number ] = std::move( tmp );
2706 else if( child->GetName() ==
"modules" )
2708 for( wxXmlNode* mod = child->GetChildren(); mod; mod = mod->GetNext() )
2710 if( mod->GetName() ==
"module" )
2712 std::unique_ptr<EMODULE> tmp = std::make_unique<EMODULE>( mod, aIo );
2713 modules[ tmp->name ] = std::move( tmp );
2719 else if( child->GetName() ==
"groups" )
2723 if(
group->GetName() ==
"schematic_group" )
2725 std::unique_ptr<ESCHEMATIC_GROUP> tmp =
2726 std::make_unique<ESCHEMATIC_GROUP>(
group, aIo );
2727 groups[ tmp->name ] = std::move( tmp );
2733 else if( child->GetName() ==
"parts" )
2735 for( wxXmlNode* part = child->GetChildren(); part; part = part->GetNext() )
2737 if( part->GetName() ==
"part" )
2739 std::unique_ptr<EPART> tmp = std::make_unique<EPART>( part, aIo );
2740 parts[ tmp->name ] = std::move( tmp );
2746 else if( child->GetName() ==
"sheets" )
2748 for( wxXmlNode* sheet = child->GetChildren(); sheet; sheet = sheet->GetNext() )
2750 if( sheet->GetName() ==
"sheet" )
2751 sheets.emplace_back( std::make_unique<ESHEET>( sheet, aIo ) );
2756 else if( child->GetName() ==
"errors" )
2758 for( wxXmlNode* error = child->GetChildren(); error; error = error->GetNext() )
2760 if( error->GetName() ==
"approved" )
2761 errors.emplace_back( std::make_unique<EAPPROVED>( error, aIo ) );
2778 for( wxXmlNode* child = aDrawing->GetChildren(); child; child = child->GetNext() )
2780 if( child->GetName() ==
"settings" )
2782 for( wxXmlNode* setting = child->GetChildren(); setting; setting = setting->GetNext() )
2783 settings.emplace_back( std::make_unique<ESETTING>( setting, aIo ) );
2787 else if( child->GetName() ==
"grid" )
2789 grid = std::make_optional<EGRID>( child, aIo );
2791 else if( child->GetName() ==
"filters" )
2795 if(
filter->GetName() ==
"filter" )
2796 filters.emplace_back( std::make_unique<EFILTER>(
filter, aIo ) );
2801 else if( child->GetName() ==
"layers" )
2803 for( wxXmlNode* layer = child->GetChildren(); layer; layer = layer->GetNext() )
2805 if( layer->GetName() ==
"layer" )
2806 layers.emplace_back( std::make_unique<ELAYER>( layer, aIo ) );
2811 else if( child->GetName() ==
"schematic" )
2813 schematic = std::make_optional<ESCHEMATIC>( child, aIo );
2815 else if( child->GetName() ==
"library" )
2817 library = std::make_optional<ELIBRARY>( child, aIo );
2839 version = parseRequiredAttribute<wxString>( aEagleDoc,
"version" );
2841 for( wxXmlNode* child = aEagleDoc->GetChildren(); child; child = child->GetNext() )
2843 if( child->GetName() ==
"compitibility" )
2844 compatibility = std::make_optional<ECOMPATIBILITY>( child, aIo );
2845 else if( child->GetName() ==
"drawing" )
2846 drawing = std::make_unique<EDRAWING>( child, aIo );
virtual void AdvanceProgressPhase()
virtual void Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Model an optional XML attribute.
const T & CGet() const
Return a constant reference to the value of the attribute assuming it is available.
void Set(const wxString &aString)
Attempt to convert a string to the base type.
OPTIONAL_XML_ATTRIBUTE()
Construct a default OPTIONAL_XML_ATTRIBUTE, whose data is not available.
A small class to help profiling.
void Stop()
Save the time when this function was called, and set the counter stane to stop.
double msecs(bool aSinceLast=false)
EURN Convert< EURN >(const wxString &aUrn)
std::string Convert< std::string >(const wxString &aValue)
static int parseAlignment(const wxString &aAlignment)
NODE_MAP MapChildren(wxXmlNode *aCurrentNode)
Provide an easy access to the children of an XML node via their names.
double Convert< double >(const wxString &aValue)
wxString escapeName(const wxString &aNetName)
Translates Eagle special characters to their counterparts in KiCad.
wxString interpretText(const wxString &aText)
Interprets special characters in Eagle text and converts them to KiCAD notation.
bool substituteVariable(wxString *aText)
Translates Eagle special text reference to a KiCad variable reference.
constexpr auto DEFAULT_ALIGNMENT
int Convert< int >(const wxString &aValue)
wxString Convert< wxString >(const wxString &aValue)
size_t GetNodeCount(const wxXmlNode *aNode)
Fetch the number of XML nodes within aNode.
EROT Convert< EROT >(const wxString &aRot)
parse an Eagle XML "rot" field.
T parseRequiredAttribute(wxXmlNode *aNode, const wxString &aAttribute)
Parse aAttribute of the XML node aNode.
bool Convert< bool >(const wxString &aValue)
ECOORD Convert< ECOORD >(const wxString &aCoord)
OPTIONAL_XML_ATTRIBUTE< T > parseOptionalAttribute(wxXmlNode *aNode, const wxString &aAttribute)
Parse option aAttribute of the XML node aNode.
VECTOR2I ConvertArcCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, double aAngle)
Convert an Eagle curve end to a KiCad center for S_ARC.
wxString convertDescription(wxString aDescr)
Converts Eagle's HTML description into KiCad description format.
std::unordered_map< wxString, wxXmlNode * > NODE_MAP
const wxChar *const traceEagleIo
#define THROW_IO_ERROR(msg)
wxString RemoveHTMLTags(const wxString &aInput)
Removes HTML tags from a string.
wxString ConvertToNewOverbarNotation(const wxString &aOldStr)
Convert the old ~...~ overbar notation to the new ~{...} one.
bool ReplaceIllegalFileNameChars(std::string *aName, int aReplaceChar)
Checks aName for illegal file name characters.
void AdvanceProgressPhase()
void Report(const wxString &aMsg, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Send a message to the IO_BASE REPORTER object if one exists.
EAGLE_DOC(wxXmlNode *aEagleDoc, IO_BASE *aIo=nullptr)
std::optional< ECOMPATIBILITY > compatibility
wxString version
The Eagle XML file version.
std::unique_ptr< EDRAWING > drawing
EAPPROVED(wxXmlNode *aApproved, IO_BASE *aIo=nullptr)
EBUS(wxXmlNode *aBus, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< ESEGMENT > > segments
ECIRCLE(wxXmlNode *aCircle, IO_BASE *aIo=nullptr)
std::map< wxString, ECOORD > clearanceMap
ECLASS(wxXmlNode *aClass, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< ENOTE > > notes
ECOMPATIBILITY(wxXmlNode *aCompatibility, IO_BASE *aIo=nullptr)
opt_wxString contactroute
ECONNECT(wxXmlNode *aConnect, IO_BASE *aIo=nullptr)
long long int value
Value expressed in nanometers.
static long long int ConvertToNm(int aValue, enum EAGLE_UNIT aUnit)
Converts a size expressed in a certain unit to nanometers.
EDESCRIPTION(wxXmlNode *aDescription, IO_BASE *aIo=nullptr)
opt_bool library_locally_modified
std::vector< std::unique_ptr< EDEVICE > > devices
opt_bool locally_modified
std::optional< EDESCRIPTION > description
EDEVICE_SET(wxXmlNode *aDeviceSet, IO_BASE *aIo=nullptr)
std::map< wxString, std::unique_ptr< EGATE > > gates
std::optional< ESPICE > spice
std::vector< std::unique_ptr< EPACKAGE3DINST > > package3dinstances
std::vector< std::unique_ptr< ECONNECT > > connects
EDEVICE(wxXmlNode *aDevice, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< ETECHNOLOGY > > technologies
opt_wxString dimensionType
EDIMENSION(wxXmlNode *aDimension, IO_BASE *aIo=nullptr)
std::optional< ESCHEMATIC > schematic
std::optional< ELIBRARY > library
EDRAWING(wxXmlNode *aDrawing, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< ESETTING > > settings
std::vector< std::unique_ptr< ELAYER > > layers
std::optional< EGRID > grid
std::vector< std::unique_ptr< EFILTER > > filters
EELEMENT(wxXmlNode *aElement, IO_BASE *aIo=nullptr)
EFILTER(wxXmlNode *aGrid, IO_BASE *aIo=nullptr)
EFRAME(wxXmlNode *aFrameNode, IO_BASE *aIo=nullptr)
EGATE(wxXmlNode *aGate, IO_BASE *aIo=nullptr)
EGRID(wxXmlNode *aGrid, IO_BASE *aIo=nullptr)
EHOLE(wxXmlNode *aHole, IO_BASE *aIo=nullptr)
std::map< wxString, std::unique_ptr< EATTR > > attributes
EINSTANCE(wxXmlNode *aInstance, IO_BASE *aIo=nullptr)
EJUNCTION(wxXmlNode *aJunction, IO_BASE *aIo=nullptr)
ELABEL(wxXmlNode *aLabel, IO_BASE *aIo=nullptr)
ELAYER(wxXmlNode *aLayer, IO_BASE *aIo=nullptr)
std::map< wxString, std::unique_ptr< EDEVICE_SET > > devicesets
wxString GetName() const
Fetch the fully unique library name.
std::map< wxString, std::unique_ptr< EPACKAGE3D > > packages3d
std::map< wxString, std::unique_ptr< EPACKAGE > > packages
std::optional< EDESCRIPTION > description
std::map< wxString, std::unique_ptr< ESYMBOL > > symbols
ELIBRARY(wxXmlNode *aLibrary, IO_BASE *aIo=nullptr)
EMODEL(wxXmlNode *aModel, IO_BASE *aIo=nullptr)
EMODULEINST(wxXmlNode *aModuleInst, IO_BASE *aIo=nullptr)
opt_wxString moduleVariant
std::map< wxString, std::unique_ptr< EPART > > parts
std::map< wxString, std::unique_ptr< ESCHEMATIC_GROUP > > groups
std::vector< std::unique_ptr< ESHEET > > sheets
std::optional< EDESCRIPTION > description
EMODULE(wxXmlNode *aModule, IO_BASE *aIo=nullptr)
std::map< wxString, std::unique_ptr< EVARIANTDEF > > variantdefs
std::map< wxString, std::unique_ptr< EPORT > > ports
std::vector< std::unique_ptr< ESEGMENT > > segments
ENOTE(wxXmlNode *aNote, IO_BASE *aIo=nullptr)
EPACKAGE3DINST(wxXmlNode *aPackage3dInst, IO_BASE *aIo=nullptr)
opt_bool library_locally_modified
std::optional< EDESCRIPTION > description
std::vector< std::unique_ptr< EPACKAGEINSTANCE > > packageinstances
EPACKAGE3D(wxXmlNode *aPackage3d, IO_BASE *aIo=nullptr)
EPACKAGEINSTANCE(wxXmlNode *aPackageInstance, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< EPOLYGON > > polygons
std::vector< std::unique_ptr< EPAD > > thtpads
std::vector< std::unique_ptr< ECIRCLE > > circles
std::vector< std::unique_ptr< ESMD > > smdpads
std::vector< std::unique_ptr< EDIMENSION > > dimensions
opt_bool library_locally_modified
std::vector< std::unique_ptr< EHOLE > > holes
std::vector< std::unique_ptr< EFRAME > > frames
std::vector< std::unique_ptr< ERECT > > rectangles
std::vector< std::unique_ptr< ETEXT > > texts
std::vector< std::unique_ptr< EWIRE > > wires
std::optional< EDESCRIPTION > description
EPACKAGE(wxXmlNode *aPackage, IO_BASE *aIo=nullptr)
opt_bool locally_modified
Structure holding common properties for through-hole and SMD pads.
EPAD_COMMON(wxXmlNode *aPad, IO_BASE *aIo=nullptr)
EPAD(wxXmlNode *aPad, IO_BASE *aIo=nullptr)
std::unique_ptr< ESPICE > spice
opt_bool override_locally_modified
opt_wxString override_package_urn
std::map< wxString, std::unique_ptr< EATTR > > attributes
opt_wxString override_package3d_urn
EPART(wxXmlNode *aPart, IO_BASE *aIo=nullptr)
opt_wxString package3d_urn
std::map< wxString, std::unique_ptr< EVARIANT > > variants
EPINMAPPING(wxXmlNode *aPinMap, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< EPINMAP > > pinmaps
EPINMAP(wxXmlNode *aPinMap, IO_BASE *aIo=nullptr)
EPINREF(wxXmlNode *aPinRef, IO_BASE *aIo=nullptr)
EPIN(wxXmlNode *aPin, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< EWIRE > > wires
std::vector< std::unique_ptr< EPOLYGON > > polygons
std::vector< std::unique_ptr< ETEXT > > texts
std::vector< std::unique_ptr< ECIRCLE > > circles
EPLAIN(wxXmlNode *aPlain, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< EFRAME > > frames
std::vector< std::unique_ptr< ESPLINE > > splines
std::vector< std::unique_ptr< ERECT > > rectangles
std::vector< std::unique_ptr< EDIMENSION > > dimensions
std::vector< std::unique_ptr< EHOLE > > holes
std::vector< std::unique_ptr< EVERTEX > > vertices
EPOLYGON(wxXmlNode *aPolygon, IO_BASE *aIo=nullptr)
EPORTREF(wxXmlNode *aPortRef, IO_BASE *aIo=nullptr)
EPORT(wxXmlNode *aPort, IO_BASE *aIo=nullptr)
EPROBE(wxXmlNode *aProbe, IO_BASE *aIo=nullptr)
ERECT(wxXmlNode *aRect, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< EATTR > > attributes
ESCHEMATIC_GROUP(wxXmlNode *aSchematicGroup, IO_BASE *aIo=nullptr)
std::optional< EDESCRIPTION > description
std::map< wxString, std::unique_ptr< EMODULE > > modules
std::map< wxString, std::unique_ptr< EATTR > > attributes
std::vector< std::unique_ptr< EAPPROVED > > errors
std::optional< EDESCRIPTION > description
std::map< wxString, std::unique_ptr< ECLASS > > classes
std::vector< std::unique_ptr< ESHEET > > sheets
std::map< wxString, std::unique_ptr< EPART > > parts
ESCHEMATIC(wxXmlNode *aSchematic, IO_BASE *aIo=nullptr)
std::map< wxString, std::unique_ptr< ELIBRARY > > libraries
std::map< wxString, std::unique_ptr< EVARIANTDEF > > variantdefs
std::map< wxString, std::unique_ptr< ESCHEMATIC_GROUP > > groups
std::vector< std::unique_ptr< EPORTREF > > portRefs
std::vector< std::unique_ptr< EPROBE > > probes
std::vector< std::unique_ptr< EPINREF > > pinRefs
ESEGMENT(wxXmlNode *aSegment, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< EWIRE > > wires
std::vector< std::unique_ptr< EJUNCTION > > junctions
std::vector< std::unique_ptr< ELABEL > > labels
opt_bool alwaysvectorfont
opt_bool keepoldvectorfont
opt_wxString verticaltext
ESETTING(wxXmlNode *aSetting, IO_BASE *aIo=nullptr)
ESHEET(wxXmlNode *aSheet, IO_BASE *aIo=nullptr)
std::unique_ptr< EPLAIN > plain
std::vector< std::unique_ptr< ENET > > nets
std::vector< std::unique_ptr< EBUS > > busses
std::vector< std::unique_ptr< EINSTANCE > > instances
std::optional< EDESCRIPTION > description
std::map< wxString, std::unique_ptr< EMODULEINST > > moduleinsts
ESMD(wxXmlNode *aSMD, IO_BASE *aIo=nullptr)
ESPICE(wxXmlNode *aSpice, IO_BASE *aIo=nullptr)
std::unique_ptr< EMODEL > model
std::unique_ptr< EPINMAPPING > pinmapping
std::vector< std::unique_ptr< EVERTEX > > vertices
ESPLINE(wxXmlNode *aSpline, IO_BASE *aIo=nullptr)
std::vector< std::unique_ptr< EFRAME > > frames
std::optional< EDESCRIPTION > description
std::vector< std::unique_ptr< EPIN > > pins
std::vector< std::unique_ptr< ECIRCLE > > circles
opt_bool library_locally_modified
std::vector< std::unique_ptr< ETEXT > > texts
std::vector< std::unique_ptr< EPOLYGON > > polygons
std::vector< std::unique_ptr< ERECT > > rectangles
std::vector< std::unique_ptr< EWIRE > > wires
ESYMBOL(wxXmlNode *aSymbol, IO_BASE *aIo=nullptr)
opt_bool locally_modified
std::vector< std::unique_ptr< EDIMENSION > > dimensions
std::vector< std::unique_ptr< EATTR > > attributes
ETECHNOLOGY(wxXmlNode *aTechnology, IO_BASE *aIo=nullptr)
ETEXT(wxXmlNode *aText, IO_BASE *aIo=nullptr)
VECTOR2I ConvertSize() const
Calculate text size based on font type and size.
Container that parses Eagle library file "urn" definitions.
bool IsValid() const
Check if the string passed to the ctor was a valid Eagle urn.
wxString host
Should always be "urn".
void Parse(const wxString &aUrn)
wxString assetVersion
May be empty depending on the asset type.
wxString assetId
The unique asset identifier for the asset type.
wxString assetType
Must be "symbol", "footprint", "package", "component", or "library".
wxString path
Path to the asset type below.
EVARIANTDEF(wxXmlNode *aVariantDef, IO_BASE *aIo=nullptr)
EVARIANT(wxXmlNode *aVariant, IO_BASE *aIo=nullptr)
EVERTEX(wxXmlNode *aVertex, IO_BASE *aIo=nullptr)
opt_double curve
range is -359.9..359.9
EVIA(wxXmlNode *aVia, IO_BASE *aIo=nullptr)
int layer_back_most
< extent
EWIRE(wxXmlNode *aWire, IO_BASE *aIo=nullptr)
opt_double curve
range is -359.9..359.9
Implement a simple wrapper around runtime_error to isolate the errors thrown by the Eagle XML parser.
wxLogTrace helper definitions.
double DEG2RAD(double deg)
VECTOR2< int32_t > VECTOR2I