38#include <wx/tokenzr.h>
48 wxString ret( aNetName );
50 ret.Replace(
"!",
"~" );
58 wxString token = aText;
64 bool sectionOpen =
false;
66 for( wxString::size_type i = 0; i < aText.size(); i++ )
69 if( aText[ i ] ==
'\\' )
71 if( i + 1 != aText.size() )
72 text.Append( aText[ i + 1 ] );
86 if( aText[ i ] ==
'!' )
95 static wxString escapeChars( wxT(
" )]}'\"" ) );
97 if( i + 1 != aText.size() && escapeChars.Find( aText[i + 1] ) == wxNOT_FOUND )
104 text.Append( aText[ i ] );
110 if( aText[i] ==
',' && sectionOpen )
116 text.Append( aText[ i ] );
125 if( aText->StartsWith(
'>' ) && aText->AfterFirst(
' ' ).IsEmpty() )
127 wxString token = aText->Upper();
129 if ( token == wxT(
">NAME" ) ) *aText = wxT(
"${REFERENCE}" );
130 else if( token == wxT(
">VALUE" ) ) *aText = wxT(
"${VALUE}" );
131 else if( token == wxT(
">PART" ) ) *aText = wxT(
"${REFERENCE}" );
132 else if( token == wxT(
">GATE" ) ) *aText = wxT(
"${UNIT}" );
133 else if( token == wxT(
">MODULE" ) ) *aText = wxT(
"${FOOTPRINT_NAME}" );
134 else if( token == wxT(
">SHEETNR" ) ) *aText = wxT(
"${#}" );
135 else if( token == wxT(
">SHEETS" ) ) *aText = wxT(
"${##}" );
136 else if( token == wxT(
">SHEET" ) ) *aText = wxT(
"${#}/${##}" );
137 else if( token == wxT(
">SHEETNR_TOTAL" ) ) *aText = wxT(
"${#}" );
138 else if( token == wxT(
">SHEETS_TOTAL" ) ) *aText = wxT(
"${##}" );
139 else if( token == wxT(
">SHEET_TOTAL" ) ) *aText = wxT(
"${#}/${##}" );
140 else if( token == wxT(
">SHEET_HEADLINE" ) ) *aText = wxT(
"${SHEETNAME}" );
141 else if( token == wxT(
">ASSEMBLY_VARIANT" ) ) *aText = wxT(
"${ASSEMBLY_VARIANT}" );
142 else if( token == wxT(
">DRAWING_NAME" ) ) *aText = wxT(
"${PROJECTNAME}" );
143 else if( token == wxT(
">LAST_DATE_TIME" ) ) *aText = wxT(
"${CURRENT_DATE}" );
144 else if( token == wxT(
">PLOT_DATE_TIME" ) ) *aText = wxT(
"${CURRENT_DATE}" );
145 else *aText = wxString::Format( wxS(
"${%s}" ), aText->Mid( 1 ).Trim() );
156 aDescr.Replace( wxS(
"\n" ), wxS(
" " ) );
157 aDescr.Replace( wxS(
"\r" ), wxEmptyString );
159 wxRegEx( wxS(
"<a\\s+(?:[^>]*?\\s+)?href=\"([^\"]*)\"[^>]*>" ) )
160 .ReplaceAll( &aDescr, wxS(
"\\1 " ) );
162 aDescr.Replace( wxS(
"<p>" ), wxS(
"\n\n" ) );
163 aDescr.Replace( wxS(
"</p>" ), wxS(
"\n\n" ) );
165 aDescr.Replace( wxS(
"<br>" ), wxS(
"\n" ) );
166 aDescr.Replace( wxS(
"<ul>" ), wxS(
"\n" ) );
167 aDescr.Replace( wxS(
"</ul>" ), wxS(
"\n\n" ) );
168 aDescr.Replace( wxS(
"<li></li>" ), wxS(
"\n" ) );
169 aDescr.Replace( wxS(
"<li>" ), wxS(
"\n \u2022 " ) );
173 wxRegEx( wxS(
"\n +" ) ).ReplaceAll( &aDescr, wxS(
"\n" ) );
174 wxRegEx( wxS(
" +\n" ) ).ReplaceAll( &aDescr, wxS(
"\n" ) );
176 wxRegEx( wxS(
"\n{3,}" ) ).ReplaceAll( &aDescr, wxS(
"\n\n" ) );
177 wxRegEx( wxS(
"^\n+" ) ).ReplaceAll( &aDescr, wxEmptyString );
178 wxRegEx( wxS(
"\n+$" ) ).ReplaceAll( &aDescr, wxEmptyString );
190 std::function<size_t(
const wxXmlNode* )> countNodes =
191 [&](
const wxXmlNode* node )
197 if(
const wxXmlNode* child = node->GetChildren() )
198 count += countNodes( child );
202 node = node->GetNext();
208 cnt = countNodes( aNode );
212 wxLogTrace(
traceEagleIo, wxS(
"XML node '%s' count = %zu took %0.4f ms." ),
213 aNode->GetName(), cnt, timer.
msecs() );
220 m_isAvailable = !aData.IsEmpty();
231 constexpr int DIVIDERS[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000 };
232 constexpr unsigned int DIVIDERS_MAX_IDX =
sizeof( DIVIDERS ) /
sizeof( DIVIDERS[0] ) - 1;
234 int integer, fraction, pre_fraction, post_fraction;
238 bool negative = ( aValue[0] ==
'-' );
242 int ret = sscanf( aValue.c_str(),
"%d.%n%d%n", &integer, &pre_fraction, &fraction,
254 int digits = post_fraction - pre_fraction;
258 if( (
unsigned) digits > DIVIDERS_MAX_IDX )
260 int diff = digits - DIVIDERS_MAX_IDX;
261 digits = DIVIDERS_MAX_IDX;
262 fraction /= DIVIDERS[diff];
265 int frac_value =
ConvertToNm( fraction, aUnit ) / DIVIDERS[digits];
280 case EU_NM: ret = aValue;
break;
281 case EU_MM: ret = (
long long) aValue * 1000000;
break;
282 case EU_INCH: ret = (
long long) aValue * 25400000;
break;
283 case EU_MIL: ret = (
long long) aValue * 25400;
break;
286 if( ( ret > 0 ) != ( aValue > 0 ) )
287 wxLogError(
_(
"Invalid size %lld: too large" ), aValue );
301 wxStringTokenizer tokens( aUrn,
":" );
303 host = tokens.GetNextToken();
304 path = tokens.GetNextToken();
308 wxString tmp = tokens.GetNextToken();
310 assetId = tmp.BeforeFirst(
'/' );
323 static std::set<wxString> validAssetTypes =
332 if( validAssetTypes.count(
assetType ) == 0 )
361 return std::string( aValue.ToUTF8() );
370 if( aValue.ToCDouble( &value ) )
374 aValue.ToStdString() +
"'." );
381 if( aValue.IsEmpty() )
382 throw XML_PARSER_ERROR(
"Conversion to int failed. Original value is empty." );
384 return wxAtoi( aValue );
391 if( aValue !=
"yes" && aValue !=
"no" )
393 aValue.ToStdString() +
394 "', is neither 'yes' nor 'no'." );
396 return aValue ==
"yes";
407 value.
spin = aRot.find(
'S' ) != aRot.npos;
408 value.
mirror = aRot.find(
'M' ) != aRot.npos;
409 value.
degrees = strtod( aRot.c_str()
447 if( aNode->GetAttribute( aAttribute, &value ) )
448 return Convert<T>( value );
450 throw XML_PARSER_ERROR(
"The required attribute " + aAttribute +
" is missing at "
451 "line " + wxString::Format(
"%d", aNode->GetLineNumber() ) +
478 aCurrentNode = aCurrentNode->GetChildren();
480 while( aCurrentNode )
485 nodesMap[aCurrentNode->GetName()] = aCurrentNode;
488 aCurrentNode = aCurrentNode->GetNext();
499 double dx = aEnd.
x - aStart.
x, dy = aEnd.
y - aStart.
y;
500 VECTOR2I mid = ( aStart + aEnd ) / 2;
502 double dlen = sqrt( dx*dx + dy*dy );
504 if( !std::isnormal( dlen ) || !std::isnormal( aAngle ) )
506 THROW_IO_ERROR( wxString::Format(
_(
"Invalid Arc with radius %f and angle %f" ),
511 double dist = dlen / ( 2 * tan(
DEG2RAD( aAngle ) / 2 ) );
514 mid.
x + dist * ( dy / dlen ),
515 mid.
y - dist * ( dx / dlen )
526 if( aAlignment ==
"center" )
528 else if( aAlignment ==
"center-right" )
530 else if( aAlignment ==
"top-left" )
532 else if( aAlignment ==
"top-center" )
534 else if( aAlignment ==
"top-right" )
536 else if( aAlignment ==
"bottom-left" )
538 else if( aAlignment ==
"bottom-center" )
540 else if( aAlignment ==
"bottom-right" )
542 else if( aAlignment ==
"center-left" )
586 x1 = parseRequiredAttribute<ECOORD>( aWire,
"x1" );
587 y1 = parseRequiredAttribute<ECOORD>( aWire,
"y1" );
588 x2 = parseRequiredAttribute<ECOORD>( aWire,
"x2" );
589 y2 = parseRequiredAttribute<ECOORD>( aWire,
"y2" );
590 width = parseRequiredAttribute<ECOORD>( aWire,
"width" );
591 layer = parseRequiredAttribute<int>( aWire,
"layer" );
592 curve = parseOptionalAttribute<double>( aWire,
"curve" );
594 opt_wxString s = parseOptionalAttribute<wxString>( aWire,
"style" );
596 if( s ==
"continuous" )
598 else if( s ==
"longdash" )
600 else if( s ==
"shortdash" )
602 else if( s ==
"dashdot" )
605 s = parseOptionalAttribute<wxString>( aWire,
"cap" );
609 else if( s ==
"flat" )
623 for( wxXmlNode* child = aSegment->GetChildren(); child; child = child->GetNext() )
625 if( child->GetName() ==
"pinref" )
626 pinRefs.emplace_back( std::make_unique<EPINREF>( child, aIo ) );
627 else if( child->GetName() ==
"portref" )
628 portRefs.emplace_back( std::make_unique<EPORTREF>( child, aIo ) );
629 else if( child->GetName() ==
"wire" )
630 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
631 else if( child->GetName() ==
"junction" )
632 junctions.emplace_back( std::make_unique<EJUNCTION>( child, aIo ) );
633 else if( child->GetName() ==
"label" )
634 labels.emplace_back( std::make_unique<ELABEL>( child, aIo ) );
635 else if( child->GetName() ==
"probe" )
636 probes.emplace_back( std::make_unique<EPROBE>( child, aIo ) );
652 name = parseRequiredAttribute<wxString>( aBus,
"name" );
654 for( wxXmlNode* child = aBus->GetChildren(); child; child = child->GetNext() )
656 if( child->GetName() ==
"segment" )
657 segments.emplace_back( std::make_unique<ESEGMENT>( child, aIo ) );
675 x = parseRequiredAttribute<ECOORD>( aJunction,
"x" );
676 y = parseRequiredAttribute<ECOORD>( aJunction,
"y" );
702 x = parseRequiredAttribute<ECOORD>( aLabel,
"x" );
703 y = parseRequiredAttribute<ECOORD>( aLabel,
"y" );
704 size = parseRequiredAttribute<ECOORD>( aLabel,
"size" );
705 layer = parseRequiredAttribute<int>( aLabel,
"layer" );
706 font = parseOptionalAttribute<wxString>( aLabel,
"font" );
707 ratio = parseOptionalAttribute<int>( aLabel,
"ratio" );
708 rot = parseOptionalAttribute<EROT>( aLabel,
"rot" );
709 xref = parseOptionalAttribute<wxString>( aLabel,
"xref" );
710 align = parseOptionalAttribute<wxString>( aLabel,
"align" );
726 netname = parseRequiredAttribute<wxString>( aNet,
"name" );
727 netcode = parseRequiredAttribute<int>( aNet,
"class" );
729 for( wxXmlNode* segment = aNet->GetChildren(); segment; segment = segment->GetNext() )
730 segments.emplace_back( std::make_unique<ESEGMENT>( segment ) );
752 x = parseRequiredAttribute<ECOORD>( aVia,
"x" );
753 y = parseRequiredAttribute<ECOORD>( aVia,
"y" );
755 wxString ext = parseRequiredAttribute<wxString>( aVia,
"extent" );
758 drill = parseRequiredAttribute<ECOORD>( aVia,
"drill" );
759 diam = parseOptionalAttribute<ECOORD>( aVia,
"diameter" );
760 shape = parseOptionalAttribute<wxString>( aVia,
"shape" );
780 x = parseRequiredAttribute<ECOORD>( aCircle,
"x" );
781 y = parseRequiredAttribute<ECOORD>( aCircle,
"y" );
782 radius = parseRequiredAttribute<ECOORD>( aCircle,
"radius" );
783 width = parseRequiredAttribute<ECOORD>( aCircle,
"width" );
784 layer = parseRequiredAttribute<int>( aCircle,
"layer" );
805 x1 = parseRequiredAttribute<ECOORD>( aRect,
"x1" );
806 y1 = parseRequiredAttribute<ECOORD>( aRect,
"y1" );
807 x2 = parseRequiredAttribute<ECOORD>( aRect,
"x2" );
808 y2 = parseRequiredAttribute<ECOORD>( aRect,
"y2" );
809 layer = parseRequiredAttribute<int>( aRect,
"layer" );
810 rot = parseOptionalAttribute<EROT>( aRect,
"rot" );
826 text = aDescription->GetNodeContent();
827 language = parseOptionalAttribute<wxString>( aDescription,
"language" );
853 name = parseRequiredAttribute<wxString>( aTree,
"name" );
854 value = parseOptionalAttribute<wxString>( aTree,
"value" );
856 x = parseOptionalAttribute<ECOORD>( aTree,
"x" );
857 y = parseOptionalAttribute<ECOORD>( aTree,
"y" );
858 size = parseOptionalAttribute<ECOORD>( aTree,
"size" );
860 layer = parseOptionalAttribute<int>( aTree,
"layer" );
861 ratio = parseOptionalAttribute<double>( aTree,
"ratio" );
862 rot = parseOptionalAttribute<EROT>( aTree,
"rot" );
864 opt_wxString stemp = parseOptionalAttribute<wxString>( aTree,
"display" );
869 else if( stemp ==
"name" )
871 else if( stemp ==
"both" )
876 stemp = parseOptionalAttribute<wxString>( aTree,
"align" );
895 part = parseRequiredAttribute<wxString>( aPinRef,
"part" );
896 gate = parseRequiredAttribute<wxString>( aPinRef,
"gate" );
897 pin = parseRequiredAttribute<wxString>( aPinRef,
"pin" );
913 moduleinst = parseRequiredAttribute<wxString>( aPortRef,
"moduleinst" );
914 port = parseRequiredAttribute<wxString>( aPortRef,
"port" );
939 x = parseRequiredAttribute<ECOORD>( aProbe,
"x" );
940 y = parseRequiredAttribute<ECOORD>( aProbe,
"y" );
941 size = parseRequiredAttribute<double>( aProbe,
"size" );
942 layer = parseRequiredAttribute<int>( aProbe,
"layer" );
943 font = parseOptionalAttribute<wxString>( aProbe,
"font" );
944 ratio = parseOptionalAttribute<int>( aProbe,
"ratio" );
945 rot = parseOptionalAttribute<EROT>( aProbe,
"rot" );
946 xref = parseOptionalAttribute<bool>( aProbe,
"xref" );
970 x1 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x1" ) );
971 y1 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y1" ) );
972 x2 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x2" ) );
973 y2 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y2" ) );
974 x3 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"x3" ) );
975 y3 = parseRequiredAttribute<ECOORD>( aDimension, wxT(
"y3" ) );
976 textsize = parseOptionalAttribute<ECOORD>( aDimension, wxT(
"textsize" ) );
977 layer = parseRequiredAttribute<int>( aDimension, wxT(
"layer" ) );
978 dimensionType = parseOptionalAttribute<wxString>( aDimension, wxT(
"dtype" ) );
1001 text = aText->GetNodeContent();
1002 x = parseRequiredAttribute<ECOORD>( aText,
"x" );
1003 y = parseRequiredAttribute<ECOORD>( aText,
"y" );
1004 size = parseRequiredAttribute<ECOORD>( aText,
"size" );
1005 layer = parseRequiredAttribute<int>( aText,
"layer" );
1007 font = parseOptionalAttribute<wxString>( aText,
"font" );
1008 ratio = parseOptionalAttribute<double>( aText,
"ratio" );
1009 rot = parseOptionalAttribute<EROT>( aText,
"rot" );
1011 opt_wxString stemp = parseOptionalAttribute<wxString>( aText,
"align" );
1025 const wxString& fontName =
font.
CGet();
1027 if( fontName ==
"vector" )
1031 else if( fontName ==
"fixed" )
1073 x1 = parseRequiredAttribute<ECOORD>( aFrameNode,
"x1" );
1074 y1 = parseRequiredAttribute<ECOORD>( aFrameNode,
"y1" );
1075 x2 = parseRequiredAttribute<ECOORD>( aFrameNode,
"x2" );
1076 y2 = parseRequiredAttribute<ECOORD>( aFrameNode,
"y2" );
1077 columns = parseRequiredAttribute<int>( aFrameNode,
"columns" );
1078 rows = parseRequiredAttribute<int>( aFrameNode,
"rows" );
1079 layer = parseRequiredAttribute<int>( aFrameNode,
"layer" );
1080 border_left = parseOptionalAttribute<bool>( aFrameNode,
"border-left" );
1081 border_top = parseOptionalAttribute<bool>( aFrameNode,
"border-top" );
1082 border_right = parseOptionalAttribute<bool>( aFrameNode,
"border-right" );
1083 border_bottom = parseOptionalAttribute<bool>( aFrameNode,
"border-bottom" );
1093 name = parseRequiredAttribute<wxString>( aPad,
"name" );
1094 x = parseRequiredAttribute<ECOORD>( aPad,
"x" );
1095 y = parseRequiredAttribute<ECOORD>( aPad,
"y" );
1096 rot = parseOptionalAttribute<EROT>( aPad,
"rot" );
1097 stop = parseOptionalAttribute<bool>( aPad,
"stop" );
1098 thermals = parseOptionalAttribute<bool>( aPad,
"thermals" );
1122 drill = parseOptionalAttribute<ECOORD>( aPad,
"drill" );
1125 diameter = parseOptionalAttribute<ECOORD>( aPad,
"diameter" );
1127 opt_wxString s = parseOptionalAttribute<wxString>( aPad,
"shape" );
1132 else if( s ==
"round" )
1134 else if( s ==
"octagon" )
1136 else if( s ==
"long" )
1138 else if( s ==
"offset" )
1141 first = parseOptionalAttribute<bool>( aPad,
"first" );
1167 dx = parseRequiredAttribute<ECOORD>( aSMD,
"dx" );
1168 dy = parseRequiredAttribute<ECOORD>( aSMD,
"dy" );
1169 layer = parseRequiredAttribute<int>( aSMD,
"layer" );
1171 roundness = parseOptionalAttribute<int>( aSMD,
"roundness" );
1172 cream = parseOptionalAttribute<bool>( aSMD,
"cream" );
1197 name = parseRequiredAttribute<wxString>( aPin,
"name" );
1198 x = parseRequiredAttribute<ECOORD>( aPin,
"x" );
1199 y = parseRequiredAttribute<ECOORD>( aPin,
"y" );
1201 visible = parseOptionalAttribute<wxString>( aPin,
"visible" );
1202 length = parseOptionalAttribute<wxString>( aPin,
"length" );
1203 direction = parseOptionalAttribute<wxString>( aPin,
"direction" );
1204 function = parseOptionalAttribute<wxString>( aPin,
"function" );
1205 swaplevel = parseOptionalAttribute<int>( aPin,
"swaplevel" );
1206 rot = parseOptionalAttribute<EROT>( aPin,
"rot" );
1224 x = parseRequiredAttribute<ECOORD>( aVertex,
"x" );
1225 y = parseRequiredAttribute<ECOORD>( aVertex,
"y" );
1226 curve = parseOptionalAttribute<double>( aVertex,
"curve" );
1256 width = parseRequiredAttribute<ECOORD>( aPolygon,
"width" );
1257 layer = parseRequiredAttribute<int>( aPolygon,
"layer" );
1259 spacing = parseOptionalAttribute<ECOORD>( aPolygon,
"spacing" );
1260 isolate = parseOptionalAttribute<ECOORD>( aPolygon,
"isolate" );
1261 opt_wxString s = parseOptionalAttribute<wxString>( aPolygon,
"pour" );
1269 else if( s ==
"cutout" )
1272 orphans = parseOptionalAttribute<bool>( aPolygon,
"orphans" );
1273 thermals = parseOptionalAttribute<bool>( aPolygon,
"thermals" );
1274 rank = parseOptionalAttribute<int>( aPolygon,
"rank" );
1276 for( wxXmlNode* child = aPolygon->GetChildren(); child; child = child->GetNext() )
1278 if( child->GetName() ==
"vertex" )
1279 vertices.emplace_back( std::make_unique<EVERTEX>( child, aIo ) );
1297 width = parseRequiredAttribute<double>( aSpline,
"width" );
1299 for( wxXmlNode* child = aSpline->GetChildren(); child; child = child->GetNext() )
1301 if( child->GetName() ==
"vertex" )
1302 vertices.emplace_back( std::make_unique<EVERTEX>( child, aIo ) );
1322 name = parseRequiredAttribute<wxString>( aVariant,
"name" );
1323 populate = parseOptionalAttribute<bool>( aVariant,
"populate" );
1324 value = parseOptionalAttribute<wxString>( aVariant,
"value" );
1325 technology = parseOptionalAttribute<wxString>( aVariant,
"technology" );
1340 name = parseRequiredAttribute<wxString>( aModel,
"name" );
1341 model = aModel->GetNodeContent();
1358 gate = parseRequiredAttribute<wxString>( aPinMap,
"gate" );
1359 pin = parseRequiredAttribute<wxString>( aPinMap,
"pin" );
1360 pinorder = parseRequiredAttribute<wxString>( aPinMap,
"pinorder" );
1377 isusermap = parseOptionalAttribute<bool>( aPinMapping,
"isusermap" );
1378 iddevicewide = parseOptionalAttribute<bool>( aPinMapping,
"iddevicewide" );
1379 spiceprefix = parseOptionalAttribute<wxString>( aPinMapping,
"spiceprefix" );
1381 for( wxXmlNode* child = aPinMapping->GetChildren(); child; child = child->GetNext() )
1383 if( child->GetName() ==
"pinmap" )
1384 pinmaps.emplace_back( std::make_unique<EPINMAP>( child, aIo ) );
1397 pinmapping = std::make_unique<EPINMAPPING>( aSpice );
1399 if( aSpice->GetName() ==
"model" )
1400 model = std::make_unique<EMODEL>( aSpice );
1419 x = parseRequiredAttribute<ECOORD>( aHole,
"x" );
1420 y = parseRequiredAttribute<ECOORD>( aHole,
"y" );
1421 drill = parseRequiredAttribute<ECOORD>( aHole,
"drill" );
1453 name = parseRequiredAttribute<wxString>( aElement,
"name" );
1454 library = parseRequiredAttribute<wxString>( aElement,
"library" );
1455 value = parseRequiredAttribute<wxString>( aElement,
"value" );
1456 std::string p = parseRequiredAttribute<std::string>( aElement,
"package" );
1458 package = wxString::FromUTF8( p.c_str() );
1460 x = parseRequiredAttribute<ECOORD>( aElement,
"x" );
1461 y = parseRequiredAttribute<ECOORD>( aElement,
"y" );
1464 library_urn = parseOptionalAttribute<EURN>( aElement,
"library_urn" );
1465 locked = parseOptionalAttribute<bool>( aElement,
"locked" );
1466 smashed = parseOptionalAttribute<bool>( aElement,
"smashed" );
1467 rot = parseOptionalAttribute<EROT>( aElement,
"rot" );
1469 for( wxXmlNode* child = aElement->GetChildren(); child; child = child->GetNext() )
1471 if( child->GetName() ==
"attribute" )
1473 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1474 attributes[ attr->name ] = std::move( attr );
1476 else if( child->GetName() ==
"variant" )
1478 std::unique_ptr<EVARIANT> variant = std::make_unique<EVARIANT>( child, aIo );
1479 variants[ variant->name ] = std::move( variant );
1483 AdvanceProgressPhase();
1502 number = parseRequiredAttribute<int>( aLayer,
"number" );
1503 name = parseRequiredAttribute<wxString>( aLayer,
"name" );
1504 color = parseRequiredAttribute<int>( aLayer,
"color" );
1505 fill = parseRequiredAttribute<int>( aLayer,
"fill" );
1506 visible = parseOptionalAttribute<bool>( aLayer,
"visible" );
1507 active = parseOptionalAttribute<bool>( aLayer,
"active" );
1527 name = parseRequiredAttribute<wxString>( aPart,
"name" );
1528 library = parseRequiredAttribute<wxString>( aPart,
"library" );
1529 libraryUrn = parseOptionalAttribute<EURN>( aPart,
"library_urn" );
1530 deviceset = parseRequiredAttribute<wxString>( aPart,
"deviceset" );
1531 device = parseRequiredAttribute<wxString>( aPart,
"device" );
1532 package3d_urn = parseOptionalAttribute<wxString>( aPart,
"package3d_urn" );
1536 technology = parseOptionalAttribute<wxString>( aPart,
"technology" );
1537 value = parseOptionalAttribute<wxString>( aPart,
"value" );
1539 for( wxXmlNode* child = aPart->GetChildren(); child; child = child->GetNext() )
1541 if( child->GetName() ==
"attribute" )
1543 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1544 attributes[ attr->name ] = std::move( attr );
1546 else if( child->GetName() ==
"variant" )
1548 std::unique_ptr<EVARIANT> variant = std::make_unique<EVARIANT>( child, aIo );
1549 variants[ variant->name ] = std::move( variant );
1551 else if( child->GetName() ==
"spice" )
1553 spice = std::make_unique<ESPICE>( child, aIo );
1575 part = parseRequiredAttribute<wxString>( aInstance,
"part" );
1576 gate = parseRequiredAttribute<wxString>( aInstance,
"gate" );
1578 x = parseRequiredAttribute<ECOORD>( aInstance,
"x" );
1579 y = parseRequiredAttribute<ECOORD>( aInstance,
"y" );
1582 smashed = parseOptionalAttribute<bool>( aInstance,
"smashed" );
1583 rot = parseOptionalAttribute<EROT>( aInstance,
"rot" );
1585 for( wxXmlNode* child = aInstance->GetChildren(); child; child = child->GetNext() )
1587 if( child->GetName() ==
"attribute" )
1589 std::unique_ptr<EATTR> attr = std::make_unique<EATTR>( child, aIo );
1590 attributes[ attr->name ] = std::move( attr );
1613 name = parseRequiredAttribute<wxString>( aGate,
"name" );
1614 symbol = parseRequiredAttribute<wxString>( aGate,
"symbol" );
1616 x = parseRequiredAttribute<ECOORD>( aGate,
"x" );
1617 y = parseRequiredAttribute<ECOORD>( aGate,
"y" );
1619 opt_wxString stemp = parseOptionalAttribute<wxString>( aGate,
"addlevel" );
1622 if( stemp ==
"must" )
1624 else if( stemp ==
"can" )
1626 else if( stemp ==
"next" )
1628 else if( stemp ==
"request" )
1630 else if( stemp ==
"always" )
1635 swaplevel = parseOptionalAttribute<int>( aGate,
"swaplevel" );
1653 gate = parseRequiredAttribute<wxString>( aConnect,
"gate" );
1654 pin = parseRequiredAttribute<wxString>( aConnect,
"pin" );
1655 pad = parseRequiredAttribute<wxString>( aConnect,
"pad" );
1656 contactroute = parseOptionalAttribute<wxString>( aConnect,
"contactroute" );
1671 name = parseRequiredAttribute<wxString>( aTechnology,
"name" );
1673 for( wxXmlNode* child = aTechnology->GetChildren(); child; child = child->GetNext() )
1675 if( child->GetName() ==
"attribute" )
1676 attributes.emplace_back( std::make_unique<EATTR>( child, aIo ) );
1692 package3d_urn = parseRequiredAttribute<wxString>( aPackage3dInst,
"package3d_urn" );
1707 name = parseRequiredAttribute<wxString>( aDevice,
"name" );
1708 opt_wxString pack = parseOptionalAttribute<wxString>( aDevice,
"package" );
1712 std::string p( pack->c_str() );
1714 package.
Set( wxString::FromUTF8( p.c_str() ) );
1717 for( wxXmlNode* child = aDevice->GetChildren(); child; child = child->GetNext() )
1719 if( child->GetName() ==
"connects" )
1721 for( wxXmlNode* connect = child->GetChildren(); connect; connect = connect->GetNext() )
1723 if( connect->GetName() ==
"connect" )
1724 connects.emplace_back( std::make_unique<ECONNECT>( connect, aIo ) );
1729 else if( child->GetName() ==
"packages3dinstances" )
1731 for( wxXmlNode* package3dinst = child->GetChildren(); package3dinst;
1732 package3dinst = package3dinst->GetNext() )
1734 if( package3dinst->GetName() ==
"package3dinstance" )
1735 package3dinstances.emplace_back( std::make_unique<EPACKAGE3DINST>( package3dinst, aIo ) );
1740 else if( child->GetName() ==
"technologies" )
1742 for( wxXmlNode* technology = child->GetChildren(); technology;
1743 technology = technology->GetNext() )
1745 if( technology->GetName() ==
"technology" )
1746 technologies.emplace_back( std::make_unique<ETECHNOLOGY>( technology, aIo ) );
1774 name = parseRequiredAttribute<wxString>( aDeviceSet,
"name" );
1775 urn = parseOptionalAttribute<EURN>( aDeviceSet,
"urn" );
1776 locally_modified = parseOptionalAttribute<bool>( aDeviceSet,
"locally_modified" );
1777 prefix = parseOptionalAttribute<wxString>( aDeviceSet,
"prefix" );
1778 uservalue = parseOptionalAttribute<bool>( aDeviceSet,
"uservalue" );
1779 library_version = parseOptionalAttribute<int>( aDeviceSet,
"library_version" );
1781 parseOptionalAttribute<bool>( aDeviceSet,
"library_locally_modified" );
1783 for( wxXmlNode* child = aDeviceSet->GetChildren(); child; child = child->GetNext() )
1785 if( child->GetName() ==
"description" )
1787 description = std::make_optional<EDESCRIPTION>( child, aIo );
1789 else if( child->GetName() ==
"gates" )
1791 for( wxXmlNode* gate = child->GetChildren(); gate; gate = gate->GetNext() )
1793 std::unique_ptr<EGATE> tmp = std::make_unique<EGATE>( gate, aIo );
1794 gates[tmp->name] = std::move( tmp );
1799 else if( child->GetName() ==
"devices" )
1801 for( wxXmlNode* device = child->GetChildren(); device; device = device->GetNext() )
1802 devices.emplace_back( std::make_unique<EDEVICE>( device, aIo ) );
1806 else if( child->GetName() ==
"spice" )
1808 spice = std::make_optional<ESPICE>( child, aIo );
1828 number = parseRequiredAttribute<wxString>( aClass,
"number" );
1829 name = parseRequiredAttribute<wxString>( aClass,
"name" );
1830 width = parseOptionalAttribute<ECOORD>( aClass,
"width" );
1831 drill = parseOptionalAttribute<ECOORD>( aClass,
"drill" );
1833 for( wxXmlNode* child = aClass->GetChildren(); child; child = child->GetNext() )
1835 if( child->GetName() ==
"clearance" )
1837 wxString to = parseRequiredAttribute<wxString>( child,
"class" );
1838 ECOORD value = parseRequiredAttribute<ECOORD>( child,
"value" );
1857 for( wxXmlNode* child = aPlain->GetChildren(); child; child = child->GetNext() )
1859 if( child->GetName() ==
"polygon" )
1860 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
1861 else if( child->GetName() ==
"wire" )
1862 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
1863 else if( child->GetName() ==
"text" )
1864 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
1865 else if( child->GetName() ==
"dimension" )
1866 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
1867 else if( child->GetName() ==
"circle" )
1868 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
1869 else if( child->GetName() ==
"spline" )
1870 splines.emplace_back( std::make_unique<ESPLINE>( child, aIo ) );
1871 else if( child->GetName() ==
"rectangle" )
1872 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
1873 else if( child->GetName() ==
"frame" )
1874 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
1875 else if( child->GetName() ==
"hole" )
1876 holes.emplace_back( std::make_unique<EHOLE>( child, aIo ) );
1900 name = parseRequiredAttribute<wxString>( aModuleInst,
"name" );
1901 moduleinst = parseRequiredAttribute<wxString>( aModuleInst,
"module" );
1902 moduleVariant = parseOptionalAttribute<wxString>( aModuleInst,
"modulevariant" );
1903 x = parseRequiredAttribute<ECOORD>( aModuleInst,
"x" );
1904 y = parseRequiredAttribute<ECOORD>( aModuleInst,
"y" );
1905 offset = parseOptionalAttribute<int>( aModuleInst,
"offset" );
1906 smashed = parseOptionalAttribute<bool>( aModuleInst,
"smashed" );
1907 rotation = parseOptionalAttribute<EROT>( aModuleInst,
"rot" );
1919 description = parseOptionalAttribute<wxString>( aSheet,
"description" );
1921 for( wxXmlNode* child = aSheet->GetChildren(); child; child = child->GetNext() )
1923 if( child->GetName() ==
"plain" )
1925 plain = std::make_unique<EPLAIN>( child, aIo );
1927 else if( child->GetName() ==
"moduleinsts" )
1929 for( wxXmlNode* moduleinst = child->GetChildren(); moduleinst;
1930 moduleinst = moduleinst->GetNext() )
1932 if( moduleinst->GetName() ==
"moduleinst" )
1934 std::unique_ptr<EMODULEINST> inst = std::make_unique<EMODULEINST>( moduleinst,
1942 else if( child->GetName() ==
"instances" )
1944 for( wxXmlNode* instance = child->GetChildren(); instance;
1945 instance = instance->GetNext() )
1947 if( instance->GetName() ==
"instance" )
1948 instances.emplace_back( std::make_unique<EINSTANCE>( instance, aIo ) );
1953 else if( child->GetName() ==
"busses" )
1955 for( wxXmlNode* bus = child->GetChildren(); bus; bus = bus->GetNext() )
1957 if( bus->GetName() ==
"bus" )
1958 busses.emplace_back( std::make_unique<EBUS>( bus, aIo ) );
1963 else if( child->GetName() ==
"nets" )
1965 for( wxXmlNode* net = child->GetChildren(); net; net = net->GetNext() )
1967 if( net->GetName() ==
"net" )
1968 nets.emplace_back( std::make_unique<ENET>( net, aIo ) );
1996 name = parseRequiredAttribute<wxString>( aSchematicGroup,
"name" );
1997 selectable = parseOptionalAttribute<bool>( aSchematicGroup,
"selectable" );
1998 width = parseOptionalAttribute<ECOORD>( aSchematicGroup,
"width" );
1999 titleSize = parseOptionalAttribute<ECOORD>( aSchematicGroup,
"titleSize" );
2000 titleFont = parseOptionalAttribute<wxString>( aSchematicGroup,
"font" );
2001 wireStyle = parseOptionalAttribute<wxString>( aSchematicGroup,
"style" );
2002 showAnnotations = parseOptionalAttribute<bool>( aSchematicGroup,
"showAnnotations" );
2003 layer = parseOptionalAttribute<int>( aSchematicGroup,
"layer" );
2004 grouprefs = parseOptionalAttribute<wxString>( aSchematicGroup,
"grouprefs" );
2006 for( wxXmlNode* child = aSchematicGroup->GetChildren(); child; child = child->GetNext() )
2008 if( child->GetName() ==
"description" )
2010 description = std::make_optional<EDESCRIPTION>( child, aIo );
2012 else if( child->GetName() ==
"attribute" )
2014 attributes.emplace_back( std::make_unique<EATTR>( child, aIo ) );
2034 name = parseRequiredAttribute<wxString>( aModule,
"name" );
2035 prefix = parseOptionalAttribute<wxString>( aModule,
"prefix" );
2036 dx = parseRequiredAttribute<ECOORD>( aModule,
"dx" );
2037 dy = parseRequiredAttribute<ECOORD>( aModule,
"dy" );
2039 for( wxXmlNode* child = aModule->GetChildren(); child; child = child->GetNext() )
2041 if( child->GetName() ==
"description" )
2043 description = std::make_optional<EDESCRIPTION>( child, aIo );
2045 else if( child->GetName() ==
"ports" )
2047 for( wxXmlNode* port = child->GetChildren(); port; port = port->GetNext() )
2049 if( port->GetName() ==
"port" )
2051 std::unique_ptr<EPORT> tmp = std::make_unique<EPORT>( port, aIo );
2052 ports[ tmp->name ] = std::move( tmp );
2058 else if( child->GetName() ==
"variantdefs" )
2060 for( wxXmlNode* variantdef = child->GetChildren(); variantdef;
2061 variantdef = variantdef->GetNext() )
2063 if( variantdef->GetName() ==
"variantdef" )
2065 std::unique_ptr<EVARIANTDEF> tmp = std::make_unique<EVARIANTDEF>( variantdef,
2073 else if( child->GetName() ==
"groups" )
2077 if(
group->GetName() ==
"schematic_group" )
2079 std::unique_ptr<ESCHEMATIC_GROUP> tmp =
2080 std::make_unique<ESCHEMATIC_GROUP>(
group, aIo );
2081 groups[ tmp->name ] = std::move( tmp );
2087 else if( child->GetName() ==
"parts" )
2089 for( wxXmlNode* part = child->GetChildren(); part; part = part->GetNext() )
2091 if( part->GetName() ==
"part" )
2093 std::unique_ptr<EPART> tmp = std::make_unique<EPART>( part, aIo );
2094 parts[ tmp->name ] = std::move( tmp );
2100 else if( child->GetName() ==
"sheets" )
2102 for( wxXmlNode* sheet = child->GetChildren(); sheet; sheet = sheet->GetNext() )
2104 if( sheet->GetName() ==
"sheet" )
2105 sheets.emplace_back( std::make_unique<ESHEET>( sheet, aIo ) );
2128 name = parseRequiredAttribute<wxString>( aPort,
"name" );
2129 side = parseRequiredAttribute<wxString>( aPort,
"side" );
2130 coord = parseRequiredAttribute<ECOORD>( aPort,
"coord" );
2131 direction = parseOptionalAttribute<wxString>( aPort,
"direction" );
2147 name = parseRequiredAttribute<wxString>( aVariantDef,
"name" );
2148 current = parseOptionalAttribute<bool>( aVariantDef,
"current" );
2165 version = parseRequiredAttribute<double>( aNote,
"version" );
2166 severity = parseRequiredAttribute<wxString>( aNote,
"severity" );
2168 note = aNote->GetNodeContent();
2180 for( wxXmlNode* child = aCompatibility->GetNext(); child; child = child->GetNext() )
2182 if( child->GetName() ==
"note" )
2183 notes.emplace_back( std::make_unique<ENOTE>( child ) );
2201 alwaysvectorfont = parseOptionalAttribute<bool>( aSetting,
"alwaysvectorfont" );
2202 verticaltext = parseOptionalAttribute<wxString>( aSetting,
"verticaltext" );
2203 keepoldvectorfont = parseOptionalAttribute<bool>( aSetting,
"keepoldvectorfont" );
2226 distance = parseOptionalAttribute<double>( aGrid,
"distance" );
2227 unitdist = parseOptionalAttribute<wxString>( aGrid,
"unitdist" );
2228 unit = parseOptionalAttribute<wxString>( aGrid,
"unit" );
2229 style = parseOptionalAttribute<wxString>( aGrid,
"style" );
2230 multiple = parseOptionalAttribute<int>( aGrid,
"multiple" );
2231 display = parseOptionalAttribute<bool>( aGrid,
"display" );
2232 altdistance = parseOptionalAttribute<double>( aGrid,
"altdistance" );
2233 altunitdist = parseOptionalAttribute<wxString>( aGrid,
"altunitdist" );
2234 altunit = parseOptionalAttribute<wxString>( aGrid,
"altunit" );
2250 name = parseRequiredAttribute<wxString>( aFilter,
"name" );
2251 expression = parseRequiredAttribute<wxString>( aFilter,
"expression" );
2273 name = parseRequiredAttribute<wxString>( aPackage,
"name" );
2274 urn = parseOptionalAttribute<EURN>( aPackage,
"urn" );
2275 locally_modified = parseOptionalAttribute<bool>( aPackage,
"locally_modified" );
2276 library_version = parseOptionalAttribute<int>( aPackage,
"library_version" );
2279 for( wxXmlNode* child = aPackage->GetChildren(); child; child = child->GetNext() )
2281 if( child->GetName() ==
"description" )
2283 description = std::make_optional<EDESCRIPTION>( child, aIo );
2285 else if( child->GetName() ==
"polygon" )
2287 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
2289 else if( child->GetName() ==
"wire" )
2291 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
2293 else if( child->GetName() ==
"text" )
2295 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
2297 else if( child->GetName() ==
"dimension" )
2299 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
2301 else if( child->GetName() ==
"circle" )
2303 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
2305 else if( child->GetName() ==
"rectangle" )
2307 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
2309 else if( child->GetName() ==
"frame" )
2311 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
2313 else if( child->GetName() ==
"hole" )
2315 holes.emplace_back( std::make_unique<EHOLE>( child, aIo ) );
2317 else if( child->GetName() ==
"pad" )
2319 thtpads.emplace_back( std::make_unique<EPAD>( child, aIo ) );
2321 else if( child->GetName() ==
"smd" )
2323 smdpads.emplace_back( std::make_unique<ESMD>( child, aIo ) );
2340 name = parseRequiredAttribute<wxString>( aPackageInstance,
"name" );
2361 name = parseRequiredAttribute<wxString>( aPackage3d,
"name" );
2362 urn = parseRequiredAttribute<wxString>( aPackage3d,
"urn" );
2363 type = parseRequiredAttribute<wxString>( aPackage3d,
"type" );
2364 library_version = parseOptionalAttribute<int>( aPackage3d,
"library_version" );
2366 "library_locally_modified" );
2368 for( wxXmlNode* child = aPackage3d->GetChildren(); child; child = child->GetNext() )
2370 if( child->GetName() ==
"description" )
2372 description = std::make_optional<EDESCRIPTION>( child, aIo );
2374 else if( child->GetName() ==
"packageinstances" )
2376 for( wxXmlNode* instance = child->GetChildren(); instance;
2377 instance = instance->GetNext() )
2378 packageinstances.emplace_back( std::make_unique<EPACKAGEINSTANCE>( instance,
2406 name = parseRequiredAttribute<wxString>( aSymbol,
"name" );
2407 urn = parseOptionalAttribute<EURN>( aSymbol,
"urn" );
2408 locally_modified = parseOptionalAttribute<bool>( aSymbol,
"locally_modified" );
2409 library_version = parseOptionalAttribute<int>( aSymbol,
"library_version" );
2412 for( wxXmlNode* child = aSymbol->GetChildren(); child; child = child->GetNext() )
2414 if( child->GetName() ==
"description" )
2416 description = std::make_optional<EDESCRIPTION>( child, aIo );
2418 else if( child->GetName() ==
"polygon" )
2420 polygons.emplace_back( std::make_unique<EPOLYGON>( child, aIo ) );
2422 else if( child->GetName() ==
"wire" )
2424 wires.emplace_back( std::make_unique<EWIRE>( child, aIo ) );
2426 else if( child->GetName() ==
"text" )
2428 texts.emplace_back( std::make_unique<ETEXT>( child, aIo ) );
2430 else if( child->GetName() ==
"dimension" )
2432 dimensions.emplace_back( std::make_unique<EDIMENSION>( child, aIo ) );
2434 else if( child->GetName() ==
"pin" )
2436 pins.emplace_back( std::make_unique<EPIN>( child, aIo ) );
2438 else if( child->GetName() ==
"circle" )
2440 circles.emplace_back( std::make_unique<ECIRCLE>( child, aIo ) );
2442 else if( child->GetName() ==
"rectangle" )
2444 rectangles.emplace_back( std::make_unique<ERECT>( child, aIo ) );
2446 else if( child->GetName() ==
"frame" )
2448 frames.emplace_back( std::make_unique<EFRAME>( child, aIo ) );
2470 wxString parentNodeName;
2472 if( aLibrary->GetParent() )
2473 parentNodeName = aLibrary->GetParent()->GetName();
2475 if( parentNodeName ==
"libraries" )
2477 name = parseRequiredAttribute<wxString>( aLibrary,
"name" );
2478 urn = parseOptionalAttribute<EURN>( aLibrary,
"urn" );
2481 for( wxXmlNode* child = aLibrary->GetChildren(); child; child = child->GetNext() )
2483 if( child->GetName() ==
"description" )
2485 description = std::make_optional<EDESCRIPTION>( child, aIo );
2487 else if( child->GetName() ==
"packages" )
2489 for( wxXmlNode* package = child->GetChildren(); package; package = package->GetNext() )
2491 if( package->GetName() ==
"package" )
2493 std::unique_ptr<EPACKAGE> tmp = std::make_unique<EPACKAGE>( package, aIo );
2494 packages[ tmp->name ] = std::move( tmp );
2500 else if( child->GetName() ==
"packages3d" )
2502 for( wxXmlNode* package3d = child->GetChildren(); package3d;
2503 package3d = package3d->GetNext() )
2505 if( package3d->GetName() ==
"package3d" )
2507 std::unique_ptr<EPACKAGE3D> tmp = std::make_unique<EPACKAGE3D>( package3d,
2515 else if( child->GetName() ==
"symbols" )
2517 for( wxXmlNode* symbol = child->GetChildren(); symbol; symbol = symbol->GetNext() )
2519 if( symbol->GetName() ==
"symbol" )
2521 std::unique_ptr<ESYMBOL> tmp = std::make_unique<ESYMBOL>( symbol, aIo );
2522 symbols[ tmp->name ] = std::move( tmp );
2528 else if( child->GetName() ==
"devicesets" )
2530 for( wxXmlNode* deviceset = child->GetChildren(); deviceset;
2531 deviceset = deviceset->GetNext() )
2533 if( deviceset->GetName() ==
"deviceset" )
2535 std::unique_ptr<EDEVICE_SET> tmp = std::make_unique<EDEVICE_SET>( deviceset,
2551 wxString libName =
name;
2576 hash = parseRequiredAttribute<wxString>( aApproved,
"hash" );
2593 xreflabel = parseOptionalAttribute<wxString>( aSchematic,
"xreflabel" );
2594 xrefpart = parseOptionalAttribute<wxString>( aSchematic,
"xrefpart" );
2596 for( wxXmlNode* child = aSchematic->GetChildren(); child; child = child->GetNext() )
2598 if( child->GetName() ==
"description" )
2600 description = std::make_optional<EDESCRIPTION>( child, aIo );
2602 else if( child->GetName() ==
"libraries" )
2606 if(
library->GetName() ==
"library" )
2608 std::unique_ptr<ELIBRARY> tmp = std::make_unique<ELIBRARY>(
library, aIo );
2610 wxString libName = tmp->GetName();
2616 wxString uniqueName;
2617 std::set<wxString> usedNames;
2619 for(
const auto& [setName, setLibrary] :
libraries )
2620 usedNames.emplace( setName );
2622 if( usedNames.find( libName ) != usedNames.end() )
2628 uniqueName.Format( wxS(
"%s_%d" ), libName, i );
2630 }
while( usedNames.find( uniqueName ) != usedNames.end() );
2633 libName = uniqueName;
2636 libraries[ libName ] = std::move( tmp );
2642 else if( child->GetName() ==
"attributes" )
2644 for( wxXmlNode* attribute = child->GetChildren(); attribute;
2645 attribute = attribute->GetNext() )
2647 if( attribute->GetName() ==
"attribute" )
2649 std::unique_ptr<EATTR> tmp = std::make_unique<EATTR>( attribute, aIo );
2656 else if( child->GetName() ==
"variantdefs" )
2658 for( wxXmlNode* variantdef = child->GetChildren(); variantdef;
2659 variantdef = variantdef->GetNext() )
2661 if( variantdef->GetName() ==
"variantdef" )
2663 std::unique_ptr<EVARIANTDEF> tmp = std::make_unique<EVARIANTDEF>( variantdef,
2671 else if( child->GetName() ==
"classes" )
2673 for( wxXmlNode* eclass = child->GetChildren(); eclass; eclass = eclass->GetNext() )
2675 if( eclass->GetName() ==
"class" )
2677 std::unique_ptr<ECLASS> tmp = std::make_unique<ECLASS>( eclass, aIo );
2678 classes[ tmp->number ] = std::move( tmp );
2684 else if( child->GetName() ==
"modules" )
2686 for( wxXmlNode* mod = child->GetChildren(); mod; mod = mod->GetNext() )
2688 if( mod->GetName() ==
"module" )
2690 std::unique_ptr<EMODULE> tmp = std::make_unique<EMODULE>( mod, aIo );
2691 modules[ tmp->name ] = std::move( tmp );
2697 else if( child->GetName() ==
"groups" )
2701 if(
group->GetName() ==
"schematic_group" )
2703 std::unique_ptr<ESCHEMATIC_GROUP> tmp =
2704 std::make_unique<ESCHEMATIC_GROUP>(
group, aIo );
2705 groups[ tmp->name ] = std::move( tmp );
2711 else if( child->GetName() ==
"parts" )
2713 for( wxXmlNode* part = child->GetChildren(); part; part = part->GetNext() )
2715 if( part->GetName() ==
"part" )
2717 std::unique_ptr<EPART> tmp = std::make_unique<EPART>( part, aIo );
2718 parts[ tmp->name ] = std::move( tmp );
2724 else if( child->GetName() ==
"sheets" )
2726 for( wxXmlNode* sheet = child->GetChildren(); sheet; sheet = sheet->GetNext() )
2728 if( sheet->GetName() ==
"sheet" )
2729 sheets.emplace_back( std::make_unique<ESHEET>( sheet, aIo ) );
2734 else if( child->GetName() ==
"errors" )
2736 for( wxXmlNode* error = child->GetChildren(); error; error = error->GetNext() )
2738 if( error->GetName() ==
"approved" )
2739 errors.emplace_back( std::make_unique<EAPPROVED>( error, aIo ) );
2756 for( wxXmlNode* child = aDrawing->GetChildren(); child; child = child->GetNext() )
2758 if( child->GetName() ==
"settings" )
2760 for( wxXmlNode* setting = child->GetChildren(); setting; setting = setting->GetNext() )
2761 settings.emplace_back( std::make_unique<ESETTING>( setting, aIo ) );
2765 else if( child->GetName() ==
"grid" )
2767 grid = std::make_optional<EGRID>( child, aIo );
2769 else if( child->GetName() ==
"filters" )
2773 if(
filter->GetName() ==
"filter" )
2774 filters.emplace_back( std::make_unique<EFILTER>(
filter, aIo ) );
2779 else if( child->GetName() ==
"layers" )
2781 for( wxXmlNode* layer = child->GetChildren(); layer; layer = layer->GetNext() )
2783 if( layer->GetName() ==
"layer" )
2784 layers.emplace_back( std::make_unique<ELAYER>( layer, aIo ) );
2789 else if( child->GetName() ==
"schematic" )
2791 schematic = std::make_optional<ESCHEMATIC>( child, aIo );
2793 else if( child->GetName() ==
"library" )
2795 library = std::make_optional<ELIBRARY>( child, aIo );
2817 version = parseRequiredAttribute<wxString>( aEagleDoc,
"version" );
2819 for( wxXmlNode* child = aEagleDoc->GetChildren(); child; child = child->GetNext() )
2821 if( child->GetName() ==
"compitibility" )
2822 compatibility = std::make_optional<ECOMPATIBILITY>( child, aIo );
2823 else if( child->GetName() ==
"drawing" )
2824 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