48 THROW_IO_ERROR( wxString::Format(
_(
"Unknown PCad layer %u" ),
unsigned( aPCadLayer ) ) );
50 return it->second.KiCadLayer;
59 THROW_IO_ERROR( wxString::Format(
_(
"Unknown PCad layer %u" ),
unsigned( aPCadLayer ) ) );
61 return it->second.layerType;
70 THROW_IO_ERROR( wxString::Format(
_(
"Unknown PCad layer %u" ),
unsigned( aPCadLayer ) ) );
72 return it->second.netNameRef;
81 for(
size_t i = 1; i < 12; ++i )
141 for(
int i = 0; i < (int)
m_PcbNetlist.GetCount(); i++ )
145 if( net->
m_Name == aNetName )
159 lNode =
FindNode( aNode, wxT(
"compDef" ) );
163 if( lNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
165 lNode->GetAttribute( wxT(
"Name" ), &propValue );
167 if( propValue == aName )
175 lNode = lNode->GetNext();
183 const wxString& aXmlName,
const wxString& aActualConversion )
185 XNODE* tNode, * t1Node;
186 wxString n, nnew, pn, propValue, str;
194 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
197 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
201 tNode =
FindNode( tNode, wxT(
"patternGraphicsRef" ) );
205 if( tNode->GetName().IsSameAs( wxT(
"patternGraphicsRef" ),
false ) )
207 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
210 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
213 if( propValue == pn )
216 str = aTextValue->
text;
220 n = n + wxT(
' ' ) + str;
232 tNode =
FindNode( t1Node, wxT(
"attr" ) );
236 tNode->GetAttribute( wxT(
"Name" ), &propValue );
237 propValue.Trim(
false );
238 propValue.Trim(
true );
240 if( propValue == n || propValue == nnew )
252 wxStatusBar* aStatusBar )
254 XNODE* lNode, * tNode, * mNode;
259 wxString cn, str, propValue;
267 if( lNode->GetName().IsSameAs( wxT(
"pattern" ),
false ) )
269 FindNode( lNode, wxT(
"patternRef" ) )->GetAttribute( wxT(
"Name" ),
272 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
274 if( tNode && cn.Len() > 0 )
282 mNode =
FindNode( lNode, wxT(
"patternGraphicsNameRef" ) );
294 tNode =
FindNode( lNode, wxT(
"refDesRef" ) );
298 tNode->GetAttribute( wxT(
"Name" ), &fp->
m_Name.
text );
305 tNode =
FindNode( lNode, wxT(
"pt" ) );
313 tNode =
FindNode( lNode, wxT(
"rotation" ) );
317 str = tNode->GetNodeContent();
324 if( str.IsSameAs( wxT(
"True" ),
false ) )
329 while( tNode->GetName() != wxT(
"www.lura.sk" ) )
332 tNode =
FindNode( tNode, wxT(
"netlist" ) );
336 tNode =
FindNode( tNode, wxT(
"compInst" ) );
340 tNode->GetAttribute( wxT(
"Name" ), &propValue );
344 if(
FindNode( tNode, wxT(
"compValue" ) ) )
347 wxT(
"compValue" ) )->GetAttribute( wxT(
"Name" ),
353 if(
FindNode( tNode, wxT(
"compRef" ) ) )
356 wxT(
"compRef" ) )->GetAttribute( wxT(
"Name" ),
372 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
385 if( mNode->GetName().IsSameAs( wxT(
"padNum" ),
false ) )
387 str = mNode->GetNodeContent();
393 mNode->GetAttribute( wxT(
"Name" ), &propValue );
413 else if( lNode->GetName().IsSameAs( wxT(
"pad" ),
false ) )
419 else if( lNode->GetName().IsSameAs( wxT(
"via" ),
false ) )
425 else if( lNode->GetName().IsSameAs( wxT(
"polyKeepOut" ),
false ) )
441 const wxString& aNetName )
460 cp->
m_Net = aNetName;
488 default:
return ( layerIndex + 1 ) * 2;
495 wxString lName, layerType;
499 aNode->GetAttribute( wxT(
"Name" ), &lName );
500 lName = lName.MakeUpper();
502 if( lName == wxT(
"TOP ASSY" ) )
506 else if( lName == wxT(
"TOP SILK" ) )
510 else if( lName == wxT(
"TOP PASTE" ) )
514 else if( lName == wxT(
"TOP MASK" ) )
518 else if( lName == wxT(
"TOP" ) )
522 else if( lName == wxT(
"BOTTOM" ) )
526 else if( lName == wxT(
"BOT MASK" ) )
530 else if( lName == wxT(
"BOT PASTE" ) )
534 else if( lName == wxT(
"BOT SILK" ) )
538 else if( lName == wxT(
"BOT ASSY" ) )
542 else if( lName == wxT(
"BOARD" ) )
554 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
555 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
558 THROW_IO_ERROR( wxString::Format( wxT(
"layerNum = %ld is out of range" ), num ) );
569 if(
FindNode( aNode, wxT(
"layerType" ) ) )
571 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
573 if( layerType.IsSameAs( wxT(
"NonSignal" ),
false ) )
576 if( layerType.IsSameAs( wxT(
"Signal" ),
false ) )
579 if( layerType.IsSameAs( wxT(
"Plane" ),
false ) )
583 if(
auto [it, success] =
m_LayersMap.insert( std::make_pair( num, newlayer ) ); !success )
590 it->second = newlayer;
593 if(
FindNode( aNode, wxT(
"netNameRef" ) ) )
595 FindNode( aNode, wxT(
"netNameRef" ) )->GetAttribute( wxT(
"Name" ),
607 for( i = 0; i < (int) aOutline->GetCount(); i++ )
609 if( *((*aOutline)[i]) == aPoint )
619 return sqrt( ( aPoint1->x - aPoint2->x ) * ( aPoint1->x - aPoint2->x ) +
620 ( aPoint1->y - aPoint2->y ) * ( aPoint1->y - aPoint2->y ) );
625 XNODE* epNode =
nullptr;
629 epNode =
FindNode( lNode, wxT(
"enhancedPolygon" ) );
638 if( epNode->GetName().IsSameAs( wxT(
"polyPoint" ),
false ) )
652 XNODE * iNode, *lNode, *pNode, *epNode;
654 int x, y, i, j, targetInd;
655 wxRealPoint* xchgPoint;
658 iNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
668 if( iNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
670 if(
FindNode( iNode, wxT(
"layerNumRef" ) ) )
671 FindNode( iNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
679 if( lNode->GetName().IsSameAs( wxT(
"boardOutlineObj" ),
false ) )
684 if( lNode->GetName().IsSameAs( wxT(
"line" ),
false ) )
686 pNode =
FindNode( lNode, wxT(
"pt" ) );
691 &x, &y, aActualConversion );
703 &x, &y, aActualConversion );
754 wxString layerName, layerType;
756 bool stackupIncomplete =
false;
758 rootNode =
FindNode( (
XNODE*) aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
762 aNode =
FindNode( rootNode, wxT(
"layersStackup" ) );
766 aNode =
FindNode( aNode, wxT(
"layerStackupData" ) );
770 if( aNode->GetName() == wxT(
"layerStackupData" ) )
772 aaNode =
FindNode( aNode, wxT(
"layerStackupName" ) );
775 aaNode->GetAttribute( wxT(
"Name" ), &layerName );
776 layerName = layerName.MakeUpper();
787 aNode =
FindNode( rootNode, wxT(
"layerDef" ) );
791 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
793 if(
FindNode( aNode, wxT(
"layerType" ) ) )
797 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
798 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
800 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
802 layerType.IsSameAs( wxT(
"Signal" ),
false ) || layerType.IsSameAs( wxT(
"Plane" ),
false );
806 aNode->GetAttribute( wxT(
"Name" ), &layerName );
807 layerName = layerName.MakeUpper();
809 auto compare = [&layerName](
const auto& el )
811 return layerName.IsSameAs( el.first,
false );
833 stackupIncomplete =
true;
845 if( stackupIncomplete )
851 [&](
const std::pair<wxString, long>& a,
const std::pair<wxString, long>& b )
853 long lhs = a.second == 2 ? std::numeric_limits<long>::max() : a.second;
854 long rhs = b.second == 2 ? std::numeric_limits<long>::max() : b.second;
875 plane_layer->
AssignNet( layer.netNameRef );
886 if(
FindNode( aNode, wxT(
"layerNumRef" ) ) )
887 FindNode( aNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &num );
903 wxString compRef, pinRef;
907 aNode =
FindNode( (
XNODE*) aXmlDoc->GetRoot(), wxT(
"asciiHeader" ) );
911 aNode =
FindNode( aNode, wxT(
"fileUnits" ) );
925 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
929 aNode =
FindNode( aNode, wxT(
"layerDef" ) );
933 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
945 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"netlist" ) );
949 aNode =
FindNode( aNode, wxT(
"net" ) );
966 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
976 if( aNode->GetName().IsSameAs( wxT(
"multiLayer" ),
false ) )
980 if( aNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
995 for( j = 0; j < (int) net->
m_NetNodes.GetCount(); j++ )
998 compRef.Trim(
false );
999 compRef.Trim(
true );
1001 pinRef.Trim(
false );
1002 pinRef.Trim(
true );
1069 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
1073 aNode =
FindNode( aNode, wxT(
"compDef" ) );
1079 if( aNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
1083 aActualConversion );
Information pertinent to a Pcbnew printed circuit board.
Handle the data for a net.
virtual bool Parse(XNODE *aNode, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion) override
PCAD_NET_NODES_ARRAY m_NetNodes
virtual void SetPosOffset(int aX_offs, int aY_offs)
PCAD_CALLBACKS * m_callbacks
PCB_LAYER_ID GetKiCadLayer() const
wxString m_PatGraphRefName
wxString m_DefaultMeasurementUnit
void SetTextProperty(XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aPatGraphRefName, const wxString &aXmlName, const wxString &aActualConversion)
void DoPCBComponents(XNODE *aNode, wxXmlDocument *aXmlDoc, const wxString &aActualConversion, wxStatusBar *aStatusBar)
LAYER_TYPE_T GetLayerType(int aPCadLayer) const override
void ExtractOutlinePointsFromEnhancedPolygon(const wxString &aActualConversion, XNODE *lNode)
int GetNetCode(const wxString &aNetName) const override
std::map< int, TLAYER > m_LayersMap
void ProcessLayerContentsObjects(wxStatusBar *aStatusBar, const wxString &aActualConversion, XNODE *aNode)
void MapLayer(XNODE *aNode)
wxString GetLayerNetNameRef(int aPCadLayer) const override
PCAD_NETS_ARRAY m_PcbNetlist
int FindOutlinePoint(const VERTICES_ARRAY *aOutline, wxRealPoint aPoint) const
PCAD_COMPONENTS_ARRAY m_PcbComponents
void ExtractLayerStackup(wxXmlDocument *aXmlDoc)
std::vector< std::pair< wxString, long > > m_layersStackup
void ParseBoard(wxStatusBar *aStatusBar, wxXmlDocument *aXmlDoc, const wxString &aActualConversion)
XNODE * FindCompDefName(XNODE *aNode, const wxString &aName) const
int FindLayer(const wxString &aLayerName) const
void ConnectPinToNet(const wxString &aCr, const wxString &aPr, const wxString &aNetName)
void AddToBoard(FOOTPRINT *aFootprint=nullptr) override
void GetBoardOutline(wxXmlDocument *aXmlDoc, const wxString &aActualConversion)
void CreatePolygonsForEmptyPowerPlanes()
double GetDistance(const wxRealPoint *aPoint1, const wxRealPoint *aPoint2) const
void SetOutline(VERTICES_ARRAY *aOutline)
void AssignNet(const wxString &aNetName)
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
XNODE * GetParent() const
XNODE * GetChildren() const
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
wxString ValidateName(const wxString &aName)
int StrToInt1Units(const wxString &aStr)
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
XNODE * FindPinMap(XNODE *aNode)
wxString ConvertNetName(const wxString &aName)
wxString FindNodeGetContent(XNODE *aChild, const wxString &aTag)
void SetTextParameters(XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
wxString result
Test unit parsing edge cases and error handling.