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;
410 value.
degrees = strtod( aRot.c_str()
448 if( aNode->GetAttribute( aAttribute, &value ) )
449 return Convert<T>( value );
451 throw XML_PARSER_ERROR(
"The required attribute " + aAttribute +
" is missing at "
452 "line " + wxString::Format(
"%d", aNode->GetLineNumber() ) +
479 aCurrentNode = aCurrentNode->GetChildren();
481 while( aCurrentNode )
486 nodesMap[aCurrentNode->GetName()] = aCurrentNode;
489 aCurrentNode = aCurrentNode->GetNext();
500 double dx = aEnd.
x - aStart.
x, dy = aEnd.
y - aStart.
y;
501 VECTOR2I mid = ( aStart + aEnd ) / 2;
503 double dlen = sqrt( dx*dx + dy*dy );
505 if( !std::isnormal( dlen ) || !std::isnormal( aAngle ) )
507 THROW_IO_ERROR( wxString::Format(
_(
"Invalid Arc with radius %f and angle %f" ),
512 double dist = dlen / ( 2 * tan(
DEG2RAD( aAngle ) / 2 ) );
515 mid.
x + dist * ( dy / dlen ),
516 mid.
y - dist * ( dx / dlen )
527 if( aAlignment ==
"center" )
529 else if( aAlignment ==
"center-right" )
531 else if( aAlignment ==
"top-left" )
533 else if( aAlignment ==
"top-center" )
535 else if( aAlignment ==
"top-right" )
537 else if( aAlignment ==
"bottom-left" )
539 else if( aAlignment ==
"bottom-center" )
541 else if( aAlignment ==
"bottom-right" )
543 else if( aAlignment ==
"center-left" )
587 x1 = parseRequiredAttribute<ECOORD>( aWire,
"x1" );
588 y1 = parseRequiredAttribute<ECOORD>( aWire,
"y1" );
589 x2 = parseRequiredAttribute<ECOORD>( aWire,
"x2" );
590 y2 = parseRequiredAttribute<ECOORD>( aWire,
"y2" );
591 width = parseRequiredAttribute<ECOORD>( aWire,
"width" );
592 layer = parseRequiredAttribute<int>( aWire,
"layer" );
593 curve = parseOptionalAttribute<double>( aWire,
"curve" );
595 opt_wxString s = parseOptionalAttribute<wxString>( aWire,
"style" );
597 if( s ==
"continuous" )
599 else if( s ==
"longdash" )
601 else if( s ==
"shortdash" )
603 else if( s ==
"dashdot" )
606 s = parseOptionalAttribute<wxString>( aWire,
"cap" );
610 else if( s ==
"flat" )
624 for( wxXmlNode* child = aSegment->GetChildren(); child; child = child->GetNext() )
626 if( child->GetName() ==
"pinref" )
627 pinRefs.emplace_back( std::make_unique<EPINREF>( child, aIo ) );
628 else if( child->GetName() ==
"portref" )
629 portRefs.emplace_back( std::make_unique<EPORTREF>( child, aIo ) );
630 else if( child->GetName() ==
"wire" )
631 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
632 else if( child->GetName() ==
"junction" )
633 junctions.emplace_back( std::make_unique<EJUNCTION>( child, aIo ) );
634 else if( child->GetName() ==
"label" )
635 labels.emplace_back( std::make_unique<ELABEL>( child, aIo ) );
636 else if( child->GetName() ==
"probe" )
637 probes.emplace_back( std::make_unique<EPROBE>( child, aIo ) );
653 name = parseRequiredAttribute<wxString>( aBus,
"name" );
655 for( wxXmlNode* child = aBus->GetChildren(); child; child = child->GetNext() )
657 if( child->GetName() ==
"segment" )
658 segments.emplace_back( std::make_unique<ESEGMENT>( child, aIo ) );
676 x = parseRequiredAttribute<ECOORD>( aJunction,
"x" );
677 y = parseRequiredAttribute<ECOORD>( aJunction,
"y" );
703 x = parseRequiredAttribute<ECOORD>( aLabel,
"x" );
704 y = parseRequiredAttribute<ECOORD>( aLabel,
"y" );
705 size = parseRequiredAttribute<ECOORD>( aLabel,
"size" );
706 layer = parseRequiredAttribute<int>( aLabel,
"layer" );
707 font = parseOptionalAttribute<wxString>( aLabel,
"font" );
708 ratio = parseOptionalAttribute<int>( aLabel,
"ratio" );
709 rot = parseOptionalAttribute<EROT>( aLabel,
"rot" );
710 xref = parseOptionalAttribute<wxString>( aLabel,
"xref" );
711 align = parseOptionalAttribute<wxString>( aLabel,
"align" );
727 netname = parseRequiredAttribute<wxString>( aNet,
"name" );
728 netcode = parseRequiredAttribute<int>( aNet,
"class" );
730 for( wxXmlNode* segment = aNet->GetChildren(); segment; segment = segment->GetNext() )
731 segments.emplace_back( std::make_unique<ESEGMENT>( segment ) );
753 x = parseRequiredAttribute<ECOORD>( aVia,
"x" );
754 y = parseRequiredAttribute<ECOORD>( aVia,
"y" );
756 wxString ext = parseRequiredAttribute<wxString>( aVia,
"extent" );
759 drill = parseRequiredAttribute<ECOORD>( aVia,
"drill" );
760 diam = parseOptionalAttribute<ECOORD>( aVia,
"diameter" );
761 shape = parseOptionalAttribute<wxString>( aVia,
"shape" );
781 x = parseRequiredAttribute<ECOORD>( aCircle,
"x" );
782 y = parseRequiredAttribute<ECOORD>( aCircle,
"y" );
783 radius = parseRequiredAttribute<ECOORD>( aCircle,
"radius" );
784 width = parseRequiredAttribute<ECOORD>( aCircle,
"width" );
785 layer = parseRequiredAttribute<int>( aCircle,
"layer" );
806 x1 = parseRequiredAttribute<ECOORD>( aRect,
"x1" );
807 y1 = parseRequiredAttribute<ECOORD>( aRect,
"y1" );
808 x2 = parseRequiredAttribute<ECOORD>( aRect,
"x2" );
809 y2 = parseRequiredAttribute<ECOORD>( aRect,
"y2" );
810 layer = parseRequiredAttribute<int>( aRect,
"layer" );
811 rot = parseOptionalAttribute<EROT>( aRect,
"rot" );
827 text = aDescription->GetNodeContent();
828 language = parseOptionalAttribute<wxString>( aDescription,
"language" );
854 name = parseRequiredAttribute<wxString>( aTree,
"name" );
855 value = parseOptionalAttribute<wxString>( aTree,
"value" );
857 x = parseOptionalAttribute<ECOORD>( aTree,
"x" );
858 y = parseOptionalAttribute<ECOORD>( aTree,
"y" );
859 size = parseOptionalAttribute<ECOORD>( aTree,
"size" );
861 layer = parseOptionalAttribute<int>( aTree,
"layer" );
862 ratio = parseOptionalAttribute<double>( aTree,
"ratio" );
863 rot = parseOptionalAttribute<EROT>( aTree,
"rot" );
865 opt_wxString stemp = parseOptionalAttribute<wxString>( aTree,
"display" );
870 else if( stemp ==
"name" )
872 else if( stemp ==
"both" )
877 stemp = parseOptionalAttribute<wxString>( aTree,
"align" );
896 part = parseRequiredAttribute<wxString>( aPinRef,
"part" );
897 gate = parseRequiredAttribute<wxString>( aPinRef,
"gate" );
898 pin = parseRequiredAttribute<wxString>( aPinRef,
"pin" );
914 moduleinst = parseRequiredAttribute<wxString>( aPortRef,
"moduleinst" );
915 port = parseRequiredAttribute<wxString>( aPortRef,
"port" );
940 x = parseRequiredAttribute<ECOORD>( aProbe,
"x" );
941 y = parseRequiredAttribute<ECOORD>( aProbe,
"y" );
942 size = parseRequiredAttribute<double>( aProbe,
"size" );
943 layer = parseRequiredAttribute<int>( aProbe,
"layer" );
944 font = parseOptionalAttribute<wxString>( aProbe,
"font" );
945 ratio = parseOptionalAttribute<int>( aProbe,
"ratio" );
946 rot = parseOptionalAttribute<EROT>( aProbe,
"rot" );
947 xref = parseOptionalAttribute<bool>( aProbe,
"xref" );
971 x1 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x1" ) );
972 y1 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y1" ) );
973 x2 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x2" ) );
974 y2 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y2" ) );
975 x3 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x3" ) );
976 y3 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y3" ) );
977 textsize = parseOptionalAttribute<ECOORD>( aDimension, wxT(
"textsize" ) );
978 layer = parseRequiredAttribute<int>( aDimension, wxT(
"layer" ) );
979 dimensionType = parseOptionalAttribute<wxString>( aDimension, wxT(
"dtype" ) );
1002 text = aText->GetNodeContent();
1003 x = parseRequiredAttribute<ECOORD>( aText,
"x" );
1004 y = parseRequiredAttribute<ECOORD>( aText,
"y" );
1005 size = parseRequiredAttribute<ECOORD>( aText,
"size" );
1006 layer = parseRequiredAttribute<int>( aText,
"layer" );
1008 font = parseOptionalAttribute<wxString>( aText,
"font" );
1009 ratio = parseOptionalAttribute<double>( aText,
"ratio" );
1010 rot = parseOptionalAttribute<EROT>( aText,
"rot" );
1012 opt_wxString stemp = parseOptionalAttribute<wxString>( aText,
"align" );
1026 const wxString& fontName =
font.
CGet();
1028 if( fontName ==
"vector" )
1032 else if( fontName ==
"fixed" )
1074 x1 = parseRequiredAttribute<ECOORD>( aFrameNode,
"x1" );
1075 y1 = parseRequiredAttribute<ECOORD>( aFrameNode,
"y1" );
1076 x2 = parseRequiredAttribute<ECOORD>( aFrameNode,
"x2" );
1077 y2 = parseRequiredAttribute<ECOORD>( aFrameNode,
"y2" );
1078 columns = parseRequiredAttribute<int>( aFrameNode,
"columns" );
1079 rows = parseRequiredAttribute<int>( aFrameNode,
"rows" );
1080 layer = parseRequiredAttribute<int>( aFrameNode,
"layer" );
1081 border_left = parseOptionalAttribute<bool>( aFrameNode,
"border-left" );
1082 border_top = parseOptionalAttribute<bool>( aFrameNode,
"border-top" );
1083 border_right = parseOptionalAttribute<bool>( aFrameNode,
"border-right" );
1084 border_bottom = parseOptionalAttribute<bool>( aFrameNode,
"border-bottom" );
1094 name = parseRequiredAttribute<wxString>( aPad,
"name" );
1095 x = parseRequiredAttribute<ECOORD>( aPad,
"x" );
1096 y = parseRequiredAttribute<ECOORD>( aPad,
"y" );
1097 rot = parseOptionalAttribute<EROT>( aPad,
"rot" );
1098 stop = parseOptionalAttribute<bool>( aPad,
"stop" );
1099 thermals = parseOptionalAttribute<bool>( aPad,
"thermals" );
1123 drill = parseOptionalAttribute<ECOORD>( aPad,
"drill" );
1126 diameter = parseOptionalAttribute<ECOORD>( aPad,
"diameter" );
1128 opt_wxString s = parseOptionalAttribute<wxString>( aPad,
"shape" );
1133 else if( s ==
"round" )
1135 else if( s ==
"octagon" )
1137 else if( s ==
"long" )
1139 else if( s ==
"offset" )
1142 first = parseOptionalAttribute<bool>( aPad,
"first" );
1168 dx = parseRequiredAttribute<ECOORD>( aSMD,
"dx" );
1169 dy = parseRequiredAttribute<ECOORD>( aSMD,
"dy" );
1170 layer = parseRequiredAttribute<int>( aSMD,
"layer" );
1172 roundness = parseOptionalAttribute<int>( aSMD,
"roundness" );
1173 cream = parseOptionalAttribute<bool>( aSMD,
"cream" );
1198 name = parseRequiredAttribute<wxString>( aPin,
"name" );
1199 x = parseRequiredAttribute<ECOORD>( aPin,
"x" );
1200 y = parseRequiredAttribute<ECOORD>( aPin,
"y" );
1202 visible = parseOptionalAttribute<wxString>( aPin,
"visible" );
1203 length = parseOptionalAttribute<wxString>( aPin,
"length" );
1204 direction = parseOptionalAttribute<wxString>( aPin,
"direction" );
1205 function = parseOptionalAttribute<wxString>( aPin,
"function" );
1206 swaplevel = parseOptionalAttribute<int>( aPin,
"swaplevel" );
1207 rot = parseOptionalAttribute<EROT>( aPin,
"rot" );
1225 x = parseRequiredAttribute<ECOORD>( aVertex,
"x" );
1226 y = parseRequiredAttribute<ECOORD>( aVertex,
"y" );
1227 curve = parseOptionalAttribute<double>( aVertex,
"curve" );
1257 width = parseRequiredAttribute<ECOORD>( aPolygon,
"width" );
1258 layer = parseRequiredAttribute<int>( aPolygon,
"layer" );
1260 spacing = parseOptionalAttribute<ECOORD>( aPolygon,
"spacing" );
1261 isolate = parseOptionalAttribute<ECOORD>( aPolygon,
"isolate" );
1262 opt_wxString s = parseOptionalAttribute<wxString>( aPolygon,
"pour" );
1270 else if( s ==
"cutout" )
1273 orphans = parseOptionalAttribute<bool>( aPolygon,
"orphans" );
1274 thermals = parseOptionalAttribute<bool>( aPolygon,
"thermals" );
1275 rank = parseOptionalAttribute<int>( aPolygon,
"rank" );
1277 for( wxXmlNode* child = aPolygon->GetChildren(); child; child = child->GetNext() )
1279 if( child->GetName() ==
"vertex" )
1280 vertices.emplace_back( std::make_unique<EVERTEX>( child, aIo ) );
1298 width = parseRequiredAttribute<double>( aSpline,
"width" );
1300 for( wxXmlNode* child = aSpline->GetChildren(); child; child = child->GetNext() )
1302 if( child->GetName() ==
"vertex" )
1303 vertices.emplace_back( std::make_unique<EVERTEX>( child, aIo ) );
1323 name = parseRequiredAttribute<wxString>( aVariant,
"name" );
1324 populate = parseOptionalAttribute<bool>( aVariant,
"populate" );
1325 value = parseOptionalAttribute<wxString>( aVariant,
"value" );
1326 technology = parseOptionalAttribute<wxString>( aVariant,
"technology" );
1341 name = parseRequiredAttribute<wxString>( aModel,
"name" );
1342 model = aModel->GetNodeContent();
1359 gate = parseRequiredAttribute<wxString>( aPinMap,
"gate" );
1360 pin = parseRequiredAttribute<wxString>( aPinMap,
"pin" );
1361 pinorder = parseRequiredAttribute<wxString>( aPinMap,
"pinorder" );
1378 isusermap = parseOptionalAttribute<bool>( aPinMapping,
"isusermap" );
1379 iddevicewide = parseOptionalAttribute<bool>( aPinMapping,
"iddevicewide" );
1380 spiceprefix = parseOptionalAttribute<wxString>( aPinMapping,
"spiceprefix" );
1382 for( wxXmlNode* child = aPinMapping->GetChildren(); child; child = child->GetNext() )
1384 if( child->GetName() ==
"pinmap" )
1385 pinmaps.emplace_back( std::make_unique<EPINMAP>( child, aIo ) );
1398 pinmapping = std::make_unique<EPINMAPPING>( aSpice );
1400 if( aSpice->GetName() ==
"model" )
1401 model = std::make_unique<EMODEL>( aSpice );
1420 x = parseRequiredAttribute<ECOORD>( aHole,
"x" );
1421 y = parseRequiredAttribute<ECOORD>( aHole,
"y" );
1422 drill = parseRequiredAttribute<ECOORD>( aHole,
"drill" );
1454 name = parseRequiredAttribute<wxString>( aElement,
"name" );
1455 library = parseRequiredAttribute<wxString>( aElement,
"library" );
1456 value = parseRequiredAttribute<wxString>( aElement,
"value" );
1457 std::string p = parseRequiredAttribute<std::string>( aElement,
"package" );
1459 package = wxString::FromUTF8( p.c_str() );
1461 x = parseRequiredAttribute<ECOORD>( aElement,
"x" );
1462 y = parseRequiredAttribute<ECOORD>( aElement,
"y" );
1465 library_urn = parseOptionalAttribute<EURN>( aElement,
"library_urn" );
1466 locked = parseOptionalAttribute<bool>( aElement,
"locked" );
1467 smashed = parseOptionalAttribute<bool>( aElement,
"smashed" );
1468 rot = parseOptionalAttribute<EROT>( aElement,
"rot" );
1470 for( wxXmlNode* child = aElement->GetChildren(); child; child = child->GetNext() )
1472 if( child->GetName() ==
"attribute" )
1474 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1475 attributes[ attr->name ] = std::move( attr );
1477 else if( child->GetName() ==
"variant" )
1479 std::unique_ptr<EVARIANT> variant = std::make_unique<EVARIANT>( child, aIo );
1480 variants[ variant->name ] = std::move( variant );
1484 AdvanceProgressPhase();
1503 number = parseRequiredAttribute<int>( aLayer,
"number" );
1504 name = parseRequiredAttribute<wxString>( aLayer,
"name" );
1505 color = parseRequiredAttribute<int>( aLayer,
"color" );
1506 fill = parseRequiredAttribute<int>( aLayer,
"fill" );
1507 visible = parseOptionalAttribute<bool>( aLayer,
"visible" );
1508 active = parseOptionalAttribute<bool>( aLayer,
"active" );
1528 name = parseRequiredAttribute<wxString>( aPart,
"name" );
1529 library = parseRequiredAttribute<wxString>( aPart,
"library" );
1530 libraryUrn = parseOptionalAttribute<EURN>( aPart,
"library_urn" );
1531 deviceset = parseRequiredAttribute<wxString>( aPart,
"deviceset" );
1532 device = parseRequiredAttribute<wxString>( aPart,
"device" );
1533 package3d_urn = parseOptionalAttribute<wxString>( aPart,
"package3d_urn" );
1537 technology = parseOptionalAttribute<wxString>( aPart,
"technology" );
1538 value = parseOptionalAttribute<wxString>( aPart,
"value" );
1540 for( wxXmlNode* child = aPart->GetChildren(); child; child = child->GetNext() )
1542 if( child->GetName() ==
"attribute" )
1544 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1545 attributes[ attr->name ] = std::move( attr );
1547 else if( child->GetName() ==
"variant" )
1549 std::unique_ptr<EVARIANT> variant = std::make_unique<EVARIANT>( child, aIo );
1550 variants[ variant->name ] = std::move( variant );
1552 else if( child->GetName() ==
"spice" )
1554 spice = std::make_unique<ESPICE>( child, aIo );
1576 part = parseRequiredAttribute<wxString>( aInstance,
"part" );
1577 gate = parseRequiredAttribute<wxString>( aInstance,
"gate" );
1579 x = parseRequiredAttribute<ECOORD>( aInstance,
"x" );
1580 y = parseRequiredAttribute<ECOORD>( aInstance,
"y" );
1583 smashed = parseOptionalAttribute<bool>( aInstance,
"smashed" );
1584 rot = parseOptionalAttribute<EROT>( aInstance,
"rot" );
1586 for( wxXmlNode* child = aInstance->GetChildren(); child; child = child->GetNext() )
1588 if( child->GetName() ==
"attribute" )
1590 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1591 attributes[ attr->name ] = std::move( attr );
1614 name = parseRequiredAttribute<wxString>( aGate,
"name" );
1615 symbol = parseRequiredAttribute<wxString>( aGate,
"symbol" );
1617 x = parseRequiredAttribute<ECOORD>( aGate,
"x" );
1618 y = parseRequiredAttribute<ECOORD>( aGate,
"y" );
1620 opt_wxString stemp = parseOptionalAttribute<wxString>( aGate,
"addlevel" );
1623 if( stemp ==
"must" )
1625 else if( stemp ==
"can" )
1627 else if( stemp ==
"next" )
1629 else if( stemp ==
"request" )
1631 else if( stemp ==
"always" )
1636 swaplevel = parseOptionalAttribute<int>( aGate,
"swaplevel" );
1654 gate = parseRequiredAttribute<wxString>( aConnect,
"gate" );
1655 pin = parseRequiredAttribute<wxString>( aConnect,
"pin" );
1656 pad = parseRequiredAttribute<wxString>( aConnect,
"pad" );
1657 contactroute = parseOptionalAttribute<wxString>( aConnect,
"contactroute" );
1672 name = parseRequiredAttribute<wxString>( aTechnology,
"name" );
1674 for( wxXmlNode* child = aTechnology->GetChildren(); child; child = child->GetNext() )
1676 if( child->GetName() ==
"attribute" )
1677 attributes.emplace_back( std::make_unique<EATTR>( child, aIo ) );
1693 package3d_urn = parseRequiredAttribute<wxString>( aPackage3dInst,
"package3d_urn" );
1708 name = parseRequiredAttribute<wxString>( aDevice,
"name" );
1709 opt_wxString pack = parseOptionalAttribute<wxString>( aDevice,
"package" );
1713 std::string p( pack->c_str() );
1715 package.
Set( wxString::FromUTF8( p.c_str() ) );
1718 for( wxXmlNode* child = aDevice->GetChildren(); child; child = child->GetNext() )
1720 if( child->GetName() ==
"connects" )
1722 for( wxXmlNode* connect = child->GetChildren(); connect; connect = connect->GetNext() )
1724 if( connect->GetName() ==
"connect" )
1725 connects.emplace_back( std::make_unique<ECONNECT>( connect, aIo ) );
1730 else if( child->GetName() ==
"packages3dinstances" )
1732 for( wxXmlNode* package3dinst = child->GetChildren(); package3dinst;
1733 package3dinst = package3dinst->GetNext() )
1735 if( package3dinst->GetName() ==
"package3dinstance" )
1736 package3dinstances.emplace_back( std::make_unique<EPACKAGE3DINST>( package3dinst, aIo ) );
1741 else if( child->GetName() ==
"technologies" )
1743 for( wxXmlNode* technology = child->GetChildren(); technology;
1744 technology = technology->GetNext() )
1746 if( technology->GetName() ==
"technology" )
1747 technologies.emplace_back( std::make_unique<ETECHNOLOGY>( technology, aIo ) );
1775 name = parseRequiredAttribute<wxString>( aDeviceSet,
"name" );
1776 urn = parseOptionalAttribute<EURN>( aDeviceSet,
"urn" );
1777 locally_modified = parseOptionalAttribute<bool>( aDeviceSet,
"locally_modified" );
1778 prefix = parseOptionalAttribute<wxString>( aDeviceSet,
"prefix" );
1779 uservalue = parseOptionalAttribute<bool>( aDeviceSet,
"uservalue" );
1780 library_version = parseOptionalAttribute<int>( aDeviceSet,
"library_version" );
1782 parseOptionalAttribute<bool>( aDeviceSet,
"library_locally_modified" );
1784 for( wxXmlNode* child = aDeviceSet->GetChildren(); child; child = child->GetNext() )
1786 if( child->GetName() ==
"description" )
1788 description = std::make_optional<EDESCRIPTION>( child, aIo );
1790 else if( child->GetName() ==
"gates" )
1792 for( wxXmlNode* gate = child->GetChildren(); gate; gate = gate->GetNext() )
1794 std::unique_ptr<EGATE> tmp = std::make_unique<EGATE>( gate, aIo );
1795 gates[tmp->name] = std::move( tmp );
1800 else if( child->GetName() ==
"devices" )
1802 for( wxXmlNode* device = child->GetChildren(); device; device = device->GetNext() )
1803 devices.emplace_back( std::make_unique<EDEVICE>( device, aIo ) );
1807 else if( child->GetName() ==
"spice" )
1809 spice = std::make_optional<ESPICE>( child, aIo );
1829 number = parseRequiredAttribute<wxString>( aClass,
"number" );
1830 name = parseRequiredAttribute<wxString>( aClass,
"name" );
1831 width = parseOptionalAttribute<ECOORD>( aClass,
"width" );
1832 drill = parseOptionalAttribute<ECOORD>( aClass,
"drill" );
1834 for( wxXmlNode* child = aClass->GetChildren(); child; child = child->GetNext() )
1836 if( child->GetName() ==
"clearance" )
1838 wxString to = parseRequiredAttribute<wxString>( child,
"class" );
1839 ECOORD value = parseRequiredAttribute<ECOORD>( child,
"value" );
1858 for( wxXmlNode* child = aPlain->GetChildren(); child; child = child->GetNext() )
1860 if( child->GetName() ==
"polygon" )
1861 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
1862 else if( child->GetName() ==
"wire" )
1863 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
1864 else if( child->GetName() ==
"text" )
1865 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
1866 else if( child->GetName() ==
"dimension" )
1867 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
1868 else if( child->GetName() ==
"circle" )
1869 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
1870 else if( child->GetName() ==
"spline" )
1871 splines.emplace_back( std::make_unique<ESPLINE>( child, aIo ) );
1872 else if( child->GetName() ==
"rectangle" )
1873 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
1874 else if( child->GetName() ==
"frame" )
1875 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
1876 else if( child->GetName() ==
"hole" )
1877 holes.emplace_back( std::make_unique<EHOLE>( child, aIo ) );
1901 name = parseRequiredAttribute<wxString>( aModuleInst,
"name" );
1902 moduleinst = parseRequiredAttribute<wxString>( aModuleInst,
"module" );
1903 moduleVariant = parseOptionalAttribute<wxString>( aModuleInst,
"modulevariant" );
1904 x = parseRequiredAttribute<ECOORD>( aModuleInst,
"x" );
1905 y = parseRequiredAttribute<ECOORD>( aModuleInst,
"y" );
1906 offset = parseOptionalAttribute<int>( aModuleInst,
"offset" );
1907 smashed = parseOptionalAttribute<bool>( aModuleInst,
"smashed" );
1908 rotation = parseOptionalAttribute<EROT>( aModuleInst,
"rot" );
1920 description = parseOptionalAttribute<wxString>( aSheet,
"description" );
1922 for( wxXmlNode* child = aSheet->GetChildren(); child; child = child->GetNext() )
1924 if( child->GetName() ==
"plain" )
1926 plain = std::make_unique<EPLAIN>( child, aIo );
1928 else if( child->GetName() ==
"moduleinsts" )
1930 for( wxXmlNode* moduleinst = child->GetChildren(); moduleinst;
1931 moduleinst = moduleinst->GetNext() )
1933 if( moduleinst->GetName() ==
"moduleinst" )
1935 std::unique_ptr<EMODULEINST> inst = std::make_unique<EMODULEINST>( moduleinst,
1943 else if( child->GetName() ==
"instances" )
1945 for( wxXmlNode* instance = child->GetChildren(); instance;
1946 instance = instance->GetNext() )
1948 if( instance->GetName() ==
"instance" )
1949 instances.emplace_back( std::make_unique<EINSTANCE>( instance, aIo ) );
1954 else if( child->GetName() ==
"busses" )
1956 for( wxXmlNode* bus = child->GetChildren(); bus; bus = bus->GetNext() )
1958 if( bus->GetName() ==
"bus" )
1959 busses.emplace_back( std::make_unique<EBUS>( bus, aIo ) );
1964 else if( child->GetName() ==
"nets" )
1966 for( wxXmlNode* net = child->GetChildren(); net; net = net->GetNext() )
1968 if( net->GetName() ==
"net" )
1969 nets.emplace_back( std::make_unique<ENET>( net, aIo ) );
1997 name = parseRequiredAttribute<wxString>( aSchematicGroup,
"name" );
1998 selectable = parseOptionalAttribute<bool>( aSchematicGroup,
"selectable" );
1999 width = parseOptionalAttribute<ECOORD>( aSchematicGroup,
"width" );
2000 titleSize = parseOptionalAttribute<ECOORD>( aSchematicGroup,
"titleSize" );
2001 titleFont = parseOptionalAttribute<wxString>( aSchematicGroup,
"font" );
2002 wireStyle = parseOptionalAttribute<wxString>( aSchematicGroup,
"style" );
2003 showAnnotations = parseOptionalAttribute<bool>( aSchematicGroup,
"showAnnotations" );
2004 layer = parseOptionalAttribute<int>( aSchematicGroup,
"layer" );
2005 grouprefs = parseOptionalAttribute<wxString>( aSchematicGroup,
"grouprefs" );
2007 for( wxXmlNode* child = aSchematicGroup->GetChildren(); child; child = child->GetNext() )
2009 if( child->GetName() ==
"description" )
2011 description = std::make_optional<EDESCRIPTION>( child, aIo );
2013 else if( child->GetName() ==
"attribute" )
2015 attributes.emplace_back( std::make_unique<EATTR>( child, aIo ) );
2035 name = parseRequiredAttribute<wxString>( aModule,
"name" );
2036 prefix = parseOptionalAttribute<wxString>( aModule,
"prefix" );
2037 dx = parseRequiredAttribute<ECOORD>( aModule,
"dx" );
2038 dy = parseRequiredAttribute<ECOORD>( aModule,
"dy" );
2040 for( wxXmlNode* child = aModule->GetChildren(); child; child = child->GetNext() )
2042 if( child->GetName() ==
"description" )
2044 description = std::make_optional<EDESCRIPTION>( child, aIo );
2046 else if( child->GetName() ==
"ports" )
2048 for( wxXmlNode* port = child->GetChildren(); port; port = port->GetNext() )
2050 if( port->GetName() ==
"port" )
2052 std::unique_ptr<EPORT> tmp = std::make_unique<EPORT>( port, aIo );
2053 ports[ tmp->name ] = std::move( tmp );
2059 else if( child->GetName() ==
"variantdefs" )
2061 for( wxXmlNode* variantdef = child->GetChildren(); variantdef;
2062 variantdef = variantdef->GetNext() )
2064 if( variantdef->GetName() ==
"variantdef" )
2066 std::unique_ptr<EVARIANTDEF> tmp = std::make_unique<EVARIANTDEF>( variantdef,
2074 else if( child->GetName() ==
"groups" )
2078 if(
group->GetName() ==
"schematic_group" )
2080 std::unique_ptr<ESCHEMATIC_GROUP> tmp =
2081 std::make_unique<ESCHEMATIC_GROUP>(
group, aIo );
2082 groups[ tmp->name ] = std::move( tmp );
2088 else if( child->GetName() ==
"parts" )
2090 for( wxXmlNode* part = child->GetChildren(); part; part = part->GetNext() )
2092 if( part->GetName() ==
"part" )
2094 std::unique_ptr<EPART> tmp = std::make_unique<EPART>( part, aIo );
2095 parts[ tmp->name ] = std::move( tmp );
2101 else if( child->GetName() ==
"sheets" )
2103 for( wxXmlNode* sheet = child->GetChildren(); sheet; sheet = sheet->GetNext() )
2105 if( sheet->GetName() ==
"sheet" )
2106 sheets.emplace_back( std::make_unique<ESHEET>( sheet, aIo ) );
2129 name = parseRequiredAttribute<wxString>( aPort,
"name" );
2130 side = parseRequiredAttribute<wxString>( aPort,
"side" );
2131 coord = parseRequiredAttribute<ECOORD>( aPort,
"coord" );
2132 direction = parseOptionalAttribute<wxString>( aPort,
"direction" );
2148 name = parseRequiredAttribute<wxString>( aVariantDef,
"name" );
2149 current = parseOptionalAttribute<bool>( aVariantDef,
"current" );
2166 version = parseRequiredAttribute<double>( aNote,
"version" );
2167 severity = parseRequiredAttribute<wxString>( aNote,
"severity" );
2169 note = aNote->GetNodeContent();
2181 for( wxXmlNode* child = aCompatibility->GetNext(); child; child = child->GetNext() )
2183 if( child->GetName() ==
"note" )
2184 notes.emplace_back( std::make_unique<ENOTE>( child ) );
2202 alwaysvectorfont = parseOptionalAttribute<bool>( aSetting,
"alwaysvectorfont" );
2203 verticaltext = parseOptionalAttribute<wxString>( aSetting,
"verticaltext" );
2204 keepoldvectorfont = parseOptionalAttribute<bool>( aSetting,
"keepoldvectorfont" );
2227 distance = parseOptionalAttribute<double>( aGrid,
"distance" );
2228 unitdist = parseOptionalAttribute<wxString>( aGrid,
"unitdist" );
2229 unit = parseOptionalAttribute<wxString>( aGrid,
"unit" );
2230 style = parseOptionalAttribute<wxString>( aGrid,
"style" );
2231 multiple = parseOptionalAttribute<int>( aGrid,
"multiple" );
2232 display = parseOptionalAttribute<bool>( aGrid,
"display" );
2233 altdistance = parseOptionalAttribute<double>( aGrid,
"altdistance" );
2234 altunitdist = parseOptionalAttribute<wxString>( aGrid,
"altunitdist" );
2235 altunit = parseOptionalAttribute<wxString>( aGrid,
"altunit" );
2251 name = parseRequiredAttribute<wxString>( aFilter,
"name" );
2252 expression = parseRequiredAttribute<wxString>( aFilter,
"expression" );
2274 name = parseRequiredAttribute<wxString>( aPackage,
"name" );
2275 urn = parseOptionalAttribute<EURN>( aPackage,
"urn" );
2276 locally_modified = parseOptionalAttribute<bool>( aPackage,
"locally_modified" );
2277 library_version = parseOptionalAttribute<int>( aPackage,
"library_version" );
2280 for( wxXmlNode* child = aPackage->GetChildren(); child; child = child->GetNext() )
2282 if( child->GetName() ==
"description" )
2284 description = std::make_optional<EDESCRIPTION>( child, aIo );
2286 else if( child->GetName() ==
"polygon" )
2288 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
2290 else if( child->GetName() ==
"wire" )
2292 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
2294 else if( child->GetName() ==
"text" )
2296 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
2298 else if( child->GetName() ==
"dimension" )
2300 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
2302 else if( child->GetName() ==
"circle" )
2304 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
2306 else if( child->GetName() ==
"rectangle" )
2308 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
2310 else if( child->GetName() ==
"frame" )
2312 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
2314 else if( child->GetName() ==
"hole" )
2316 holes.emplace_back( std::make_unique<EHOLE>( child, aIo ) );
2318 else if( child->GetName() ==
"pad" )
2320 thtpads.emplace_back( std::make_unique<EPAD>( child, aIo ) );
2322 else if( child->GetName() ==
"smd" )
2324 smdpads.emplace_back( std::make_unique<ESMD>( child, aIo ) );
2341 name = parseRequiredAttribute<wxString>( aPackageInstance,
"name" );
2362 name = parseRequiredAttribute<wxString>( aPackage3d,
"name" );
2363 urn = parseRequiredAttribute<wxString>( aPackage3d,
"urn" );
2364 type = parseRequiredAttribute<wxString>( aPackage3d,
"type" );
2365 library_version = parseOptionalAttribute<int>( aPackage3d,
"library_version" );
2367 "library_locally_modified" );
2369 for( wxXmlNode* child = aPackage3d->GetChildren(); child; child = child->GetNext() )
2371 if( child->GetName() ==
"description" )
2373 description = std::make_optional<EDESCRIPTION>( child, aIo );
2375 else if( child->GetName() ==
"packageinstances" )
2377 for( wxXmlNode* instance = child->GetChildren(); instance;
2378 instance = instance->GetNext() )
2379 packageinstances.emplace_back( std::make_unique<EPACKAGEINSTANCE>( instance,
2407 name = parseRequiredAttribute<wxString>( aSymbol,
"name" );
2408 urn = parseOptionalAttribute<EURN>( aSymbol,
"urn" );
2409 locally_modified = parseOptionalAttribute<bool>( aSymbol,
"locally_modified" );
2410 library_version = parseOptionalAttribute<int>( aSymbol,
"library_version" );
2413 for( wxXmlNode* child = aSymbol->GetChildren(); child; child = child->GetNext() )
2415 if( child->GetName() ==
"description" )
2417 description = std::make_optional<EDESCRIPTION>( child, aIo );
2419 else if( child->GetName() ==
"polygon" )
2421 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
2423 else if( child->GetName() ==
"wire" )
2425 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
2427 else if( child->GetName() ==
"text" )
2429 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
2431 else if( child->GetName() ==
"dimension" )
2433 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
2435 else if( child->GetName() ==
"pin" )
2437 pins.emplace_back( std::make_unique<EPIN>( child, aIo ) );
2439 else if( child->GetName() ==
"circle" )
2441 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
2443 else if( child->GetName() ==
"rectangle" )
2445 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
2447 else if( child->GetName() ==
"frame" )
2449 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
2471 wxString parentNodeName;
2473 if( aLibrary->GetParent() )
2474 parentNodeName = aLibrary->GetParent()->GetName();
2476 if( parentNodeName ==
"libraries" )
2478 name = parseRequiredAttribute<wxString>( aLibrary,
"name" );
2479 urn = parseOptionalAttribute<EURN>( aLibrary,
"urn" );
2482 for( wxXmlNode* child = aLibrary->GetChildren(); child; child = child->GetNext() )
2484 if( child->GetName() ==
"description" )
2486 description = std::make_optional<EDESCRIPTION>( child, aIo );
2488 else if( child->GetName() ==
"packages" )
2490 for( wxXmlNode* package = child->GetChildren(); package; package = package->GetNext() )
2492 if( package->GetName() ==
"package" )
2494 std::unique_ptr<EPACKAGE> tmp = std::make_unique<EPACKAGE>( package, aIo );
2495 packages[ tmp->name ] = std::move( tmp );
2501 else if( child->GetName() ==
"packages3d" )
2503 for( wxXmlNode* package3d = child->GetChildren(); package3d;
2504 package3d = package3d->GetNext() )
2506 if( package3d->GetName() ==
"package3d" )
2508 std::unique_ptr<EPACKAGE3D> tmp = std::make_unique<EPACKAGE3D>( package3d,
2516 else if( child->GetName() ==
"symbols" )
2518 for( wxXmlNode* symbol = child->GetChildren(); symbol; symbol = symbol->GetNext() )
2520 if( symbol->GetName() ==
"symbol" )
2522 std::unique_ptr<ESYMBOL> tmp = std::make_unique<ESYMBOL>( symbol, aIo );
2523 symbols[ tmp->name ] = std::move( tmp );
2529 else if( child->GetName() ==
"devicesets" )
2531 for( wxXmlNode* deviceset = child->GetChildren(); deviceset;
2532 deviceset = deviceset->GetNext() )
2534 if( deviceset->GetName() ==
"deviceset" )
2536 std::unique_ptr<EDEVICE_SET> tmp = std::make_unique<EDEVICE_SET>( deviceset,
2552 wxString libName =
name;
2577 hash = parseRequiredAttribute<wxString>( aApproved,
"hash" );
2594 xreflabel = parseOptionalAttribute<wxString>( aSchematic,
"xreflabel" );
2595 xrefpart = parseOptionalAttribute<wxString>( aSchematic,
"xrefpart" );
2597 for( wxXmlNode* child = aSchematic->GetChildren(); child; child = child->GetNext() )
2599 if( child->GetName() ==
"description" )
2601 description = std::make_optional<EDESCRIPTION>( child, aIo );
2603 else if( child->GetName() ==
"libraries" )
2607 if(
library->GetName() ==
"library" )
2609 std::unique_ptr<ELIBRARY> tmp = std::make_unique<ELIBRARY>(
library, aIo );
2611 wxString libName = tmp->GetName();
2617 wxString uniqueName;
2618 std::set<wxString> usedNames;
2620 for(
const auto& [setName, setLibrary] :
libraries )
2621 usedNames.emplace( setName );
2623 if( usedNames.find( libName ) != usedNames.end() )
2629 uniqueName.Format( wxS(
"%s_%d" ), libName, i );
2631 }
while( usedNames.find( uniqueName ) != usedNames.end() );
2634 libName = uniqueName;
2637 libraries[ libName ] = std::move( tmp );
2643 else if( child->GetName() ==
"attributes" )
2645 for( wxXmlNode* attribute = child->GetChildren(); attribute;
2646 attribute = attribute->GetNext() )
2648 if( attribute->GetName() ==
"attribute" )
2650 std::unique_ptr<EATTR> tmp = std::make_unique<EATTR>( attribute, aIo );
2657 else if( child->GetName() ==
"variantdefs" )
2659 for( wxXmlNode* variantdef = child->GetChildren(); variantdef;
2660 variantdef = variantdef->GetNext() )
2662 if( variantdef->GetName() ==
"variantdef" )
2664 std::unique_ptr<EVARIANTDEF> tmp = std::make_unique<EVARIANTDEF>( variantdef,
2672 else if( child->GetName() ==
"classes" )
2674 for( wxXmlNode* eclass = child->GetChildren(); eclass; eclass = eclass->GetNext() )
2676 if( eclass->GetName() ==
"class" )
2678 std::unique_ptr<ECLASS> tmp = std::make_unique<ECLASS>( eclass, aIo );
2679 classes[ tmp->number ] = std::move( tmp );
2685 else if( child->GetName() ==
"modules" )
2687 for( wxXmlNode* mod = child->GetChildren(); mod; mod = mod->GetNext() )
2689 if( mod->GetName() ==
"module" )
2691 std::unique_ptr<EMODULE> tmp = std::make_unique<EMODULE>( mod, aIo );
2692 modules[ tmp->name ] = std::move( tmp );
2698 else if( child->GetName() ==
"groups" )
2702 if(
group->GetName() ==
"schematic_group" )
2704 std::unique_ptr<ESCHEMATIC_GROUP> tmp =
2705 std::make_unique<ESCHEMATIC_GROUP>(
group, aIo );
2706 groups[ tmp->name ] = std::move( tmp );
2712 else if( child->GetName() ==
"parts" )
2714 for( wxXmlNode* part = child->GetChildren(); part; part = part->GetNext() )
2716 if( part->GetName() ==
"part" )
2718 std::unique_ptr<EPART> tmp = std::make_unique<EPART>( part, aIo );
2719 parts[ tmp->name ] = std::move( tmp );
2725 else if( child->GetName() ==
"sheets" )
2727 for( wxXmlNode* sheet = child->GetChildren(); sheet; sheet = sheet->GetNext() )
2729 if( sheet->GetName() ==
"sheet" )
2730 sheets.emplace_back( std::make_unique<ESHEET>( sheet, aIo ) );
2735 else if( child->GetName() ==
"errors" )
2737 for( wxXmlNode* error = child->GetChildren(); error; error = error->GetNext() )
2739 if( error->GetName() ==
"approved" )
2740 errors.emplace_back( std::make_unique<EAPPROVED>( error, aIo ) );
2757 for( wxXmlNode* child = aDrawing->GetChildren(); child; child = child->GetNext() )
2759 if( child->GetName() ==
"settings" )
2761 for( wxXmlNode* setting = child->GetChildren(); setting; setting = setting->GetNext() )
2762 settings.emplace_back( std::make_unique<ESETTING>( setting, aIo ) );
2766 else if( child->GetName() ==
"grid" )
2768 grid = std::make_optional<EGRID>( child, aIo );
2770 else if( child->GetName() ==
"filters" )
2774 if(
filter->GetName() ==
"filter" )
2775 filters.emplace_back( std::make_unique<EFILTER>(
filter, aIo ) );
2780 else if( child->GetName() ==
"layers" )
2782 for( wxXmlNode* layer = child->GetChildren(); layer; layer = layer->GetNext() )
2784 if( layer->GetName() ==
"layer" )
2785 layers.emplace_back( std::make_unique<ELAYER>( layer, aIo ) );
2790 else if( child->GetName() ==
"schematic" )
2792 schematic = std::make_optional<ESCHEMATIC>( child, aIo );
2794 else if( child->GetName() ==
"library" )
2796 library = std::make_optional<ELIBRARY>( child, aIo );
2818 version = parseRequiredAttribute<wxString>( aEagleDoc,
"version" );
2820 for( wxXmlNode* child = aEagleDoc->GetChildren(); child; child = child->GetNext() )
2822 if( child->GetName() ==
"compitibility" )
2823 compatibility = std::make_optional<ECOMPATIBILITY>( child, aIo );
2824 else if( child->GetName() ==
"drawing" )
2825 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::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