44 THROW_IO_ERROR( wxString::Format(
_(
"Unknown PCad layer %u" ),
unsigned( aPCadLayer ) ) );
46 return it->second.KiCadLayer;
55 THROW_IO_ERROR( wxString::Format(
_(
"Unknown PCad layer %u" ),
unsigned( aPCadLayer ) ) );
57 return it->second.layerType;
66 THROW_IO_ERROR( wxString::Format(
_(
"Unknown PCad layer %u" ),
unsigned( aPCadLayer ) ) );
68 return it->second.netNameRef;
77 for(
size_t i = 1; i < 12; ++i )
137 for(
int i = 0; i < (int)
m_PcbNetlist.GetCount(); i++ )
141 if( net->
m_Name == aNetName )
155 lNode =
FindNode( aNode, wxT(
"compDef" ) );
159 if( lNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
161 lNode->GetAttribute( wxT(
"Name" ), &propValue );
163 if( propValue == aName )
171 lNode = lNode->GetNext();
179 const wxString& aXmlName,
const wxString& aActualConversion )
181 XNODE* tNode, * t1Node;
182 wxString n, nnew, pn, propValue, str;
190 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
193 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
197 tNode =
FindNode( tNode, wxT(
"patternGraphicsRef" ) );
201 if( tNode->GetName().IsSameAs( wxT(
"patternGraphicsRef" ),
false ) )
203 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
206 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
209 if( propValue == pn )
212 str = aTextValue->
text;
216 n = n + wxT(
' ' ) + str;
228 tNode =
FindNode( t1Node, wxT(
"attr" ) );
232 tNode->GetAttribute( wxT(
"Name" ), &propValue );
233 propValue.Trim(
false );
234 propValue.Trim(
true );
236 if( propValue == n || propValue == nnew )
248 wxStatusBar* aStatusBar )
250 XNODE* lNode, * tNode, * mNode;
255 wxString cn, str, propValue;
263 if( lNode->GetName().IsSameAs( wxT(
"pattern" ),
false ) )
265 FindNode( lNode, wxT(
"patternRef" ) )->GetAttribute( wxT(
"Name" ),
268 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
270 if( tNode && cn.Len() > 0 )
278 mNode =
FindNode( lNode, wxT(
"patternGraphicsNameRef" ) );
290 tNode =
FindNode( lNode, wxT(
"refDesRef" ) );
294 tNode->GetAttribute( wxT(
"Name" ), &fp->
m_Name.
text );
301 tNode =
FindNode( lNode, wxT(
"pt" ) );
309 tNode =
FindNode( lNode, wxT(
"rotation" ) );
313 str = tNode->GetNodeContent();
320 if( str.IsSameAs( wxT(
"True" ),
false ) )
325 while( tNode->GetName() != wxT(
"www.lura.sk" ) )
328 tNode =
FindNode( tNode, wxT(
"netlist" ) );
332 tNode =
FindNode( tNode, wxT(
"compInst" ) );
336 tNode->GetAttribute( wxT(
"Name" ), &propValue );
340 if(
FindNode( tNode, wxT(
"compValue" ) ) )
343 wxT(
"compValue" ) )->GetAttribute( wxT(
"Name" ),
349 if(
FindNode( tNode, wxT(
"compRef" ) ) )
352 wxT(
"compRef" ) )->GetAttribute( wxT(
"Name" ),
368 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
381 if( mNode->GetName().IsSameAs( wxT(
"padNum" ),
false ) )
383 str = mNode->GetNodeContent();
389 mNode->GetAttribute( wxT(
"Name" ), &propValue );
409 else if( lNode->GetName().IsSameAs( wxT(
"pad" ),
false ) )
415 else if( lNode->GetName().IsSameAs( wxT(
"via" ),
false ) )
421 else if( lNode->GetName().IsSameAs( wxT(
"polyKeepOut" ),
false ) )
437 const wxString& aNetName )
456 cp->
m_Net = aNetName;
484 default:
return ( layerIndex + 1 ) * 2;
491 wxString lName, layerType;
495 aNode->GetAttribute( wxT(
"Name" ), &lName );
496 lName = lName.MakeUpper();
498 if( lName == wxT(
"TOP ASSY" ) )
502 else if( lName == wxT(
"TOP SILK" ) )
506 else if( lName == wxT(
"TOP PASTE" ) )
510 else if( lName == wxT(
"TOP MASK" ) )
514 else if( lName == wxT(
"TOP" ) )
518 else if( lName == wxT(
"BOTTOM" ) )
522 else if( lName == wxT(
"BOT MASK" ) )
526 else if( lName == wxT(
"BOT PASTE" ) )
530 else if( lName == wxT(
"BOT SILK" ) )
534 else if( lName == wxT(
"BOT ASSY" ) )
538 else if( lName == wxT(
"BOARD" ) )
550 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
551 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
554 THROW_IO_ERROR( wxString::Format( wxT(
"layerNum = %ld is out of range" ), num ) );
565 if(
FindNode( aNode, wxT(
"layerType" ) ) )
567 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
569 if( layerType.IsSameAs( wxT(
"NonSignal" ),
false ) )
572 if( layerType.IsSameAs( wxT(
"Signal" ),
false ) )
575 if( layerType.IsSameAs( wxT(
"Plane" ),
false ) )
579 if(
auto [it, success] =
m_LayersMap.insert( std::make_pair( num, newlayer ) ); !success )
586 it->second = newlayer;
589 if(
FindNode( aNode, wxT(
"netNameRef" ) ) )
591 FindNode( aNode, wxT(
"netNameRef" ) )->GetAttribute( wxT(
"Name" ),
603 for( i = 0; i < (int) aOutline->GetCount(); i++ )
605 if( *((*aOutline)[i]) == aPoint )
615 return sqrt( ( aPoint1->x - aPoint2->x ) * ( aPoint1->x - aPoint2->x ) +
616 ( aPoint1->y - aPoint2->y ) * ( aPoint1->y - aPoint2->y ) );
621 XNODE* epNode =
nullptr;
625 epNode =
FindNode( lNode, wxT(
"enhancedPolygon" ) );
634 if( epNode->GetName().IsSameAs( wxT(
"polyPoint" ),
false ) )
648 XNODE * iNode, *lNode, *pNode;
650 int x, y, i, j, targetInd;
651 wxRealPoint* xchgPoint;
654 iNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
664 if( iNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
666 if(
FindNode( iNode, wxT(
"layerNumRef" ) ) )
667 FindNode( iNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
675 if( lNode->GetName().IsSameAs( wxT(
"boardOutlineObj" ),
false ) )
680 if( lNode->GetName().IsSameAs( wxT(
"line" ),
false ) )
682 pNode =
FindNode( lNode, wxT(
"pt" ) );
687 &x, &y, aActualConversion );
699 &x, &y, aActualConversion );
750 wxString layerName, layerType;
752 bool stackupIncomplete =
false;
754 rootNode =
FindNode( (
XNODE*) aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
758 aNode =
FindNode( rootNode, wxT(
"layersStackup" ) );
762 aNode =
FindNode( aNode, wxT(
"layerStackupData" ) );
766 if( aNode->GetName() == wxT(
"layerStackupData" ) )
768 aaNode =
FindNode( aNode, wxT(
"layerStackupName" ) );
771 aaNode->GetAttribute( wxT(
"Name" ), &layerName );
772 layerName = layerName.MakeUpper();
783 aNode =
FindNode( rootNode, wxT(
"layerDef" ) );
787 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
789 if(
FindNode( aNode, wxT(
"layerType" ) ) )
793 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
794 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
796 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
798 layerType.IsSameAs( wxT(
"Signal" ),
false ) || layerType.IsSameAs( wxT(
"Plane" ),
false );
802 aNode->GetAttribute( wxT(
"Name" ), &layerName );
803 layerName = layerName.MakeUpper();
805 auto compare = [&layerName](
const auto& el )
807 return layerName.IsSameAs( el.first,
false );
829 stackupIncomplete =
true;
841 if( stackupIncomplete )
847 [&](
const std::pair<wxString, long>& a,
const std::pair<wxString, long>& b )
849 long lhs = a.second == 2 ? std::numeric_limits<long>::max() : a.second;
850 long rhs = b.second == 2 ? std::numeric_limits<long>::max() : b.second;
871 plane_layer->
AssignNet( layer.netNameRef );
882 if(
FindNode( aNode, wxT(
"layerNumRef" ) ) )
883 FindNode( aNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &num );
899 wxString compRef, pinRef;
903 aNode =
FindNode( (
XNODE*) aXmlDoc->GetRoot(), wxT(
"asciiHeader" ) );
907 aNode =
FindNode( aNode, wxT(
"fileUnits" ) );
921 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
925 aNode =
FindNode( aNode, wxT(
"layerDef" ) );
929 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
941 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"netlist" ) );
945 aNode =
FindNode( aNode, wxT(
"net" ) );
962 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
972 if( aNode->GetName().IsSameAs( wxT(
"multiLayer" ),
false ) )
976 if( aNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
991 for( j = 0; j < (int) net->
m_NetNodes.GetCount(); j++ )
994 compRef.Trim(
false );
995 compRef.Trim(
true );
997 pinRef.Trim(
false );
1065 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
1069 aNode =
FindNode( aNode, wxT(
"compDef" ) );
1075 if( aNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
1079 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.