54 return it->second.KiCadLayer;
68 return it->second.layerType;
82 return it->second.netNameRef;
91 wxString msg = wxString::Format(
_(
"Undefined P-CAD layer %u substituted with the "
93 unsigned( aPCadLayer ) );
105 for(
size_t i = 1; i < 12; ++i )
165 for(
int i = 0; i < (int)
m_PcbNetlist.GetCount(); i++ )
169 if( net->
m_Name == aNetName )
183 lNode =
FindNode( aNode, wxT(
"compDef" ) );
187 if( lNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
189 lNode->GetAttribute( wxT(
"Name" ), &propValue );
191 if( propValue == aName )
199 lNode = lNode->GetNext();
207 const wxString& aXmlName,
const wxString& aActualConversion )
209 XNODE* tNode, * t1Node;
210 wxString n, nnew, pn, propValue, str;
218 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
221 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
225 tNode =
FindNode( tNode, wxT(
"patternGraphicsRef" ) );
229 if( tNode->GetName().IsSameAs( wxT(
"patternGraphicsRef" ),
false ) )
231 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
234 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
237 if( propValue == pn )
240 str = aTextValue->
text;
244 n = n + wxT(
' ' ) + str;
256 tNode =
FindNode( t1Node, wxT(
"attr" ) );
260 tNode->GetAttribute( wxT(
"Name" ), &propValue );
261 propValue.Trim(
false );
262 propValue.Trim(
true );
264 if( propValue == n || propValue == nnew )
276 wxStatusBar* aStatusBar )
278 XNODE* lNode, * tNode, * mNode;
283 wxString cn, str, propValue;
291 if( lNode->GetName().IsSameAs( wxT(
"pattern" ),
false ) )
293 FindNode( lNode, wxT(
"patternRef" ) )->GetAttribute( wxT(
"Name" ),
296 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
298 if( tNode && cn.Len() > 0 )
306 mNode =
FindNode( lNode, wxT(
"patternGraphicsNameRef" ) );
318 tNode =
FindNode( lNode, wxT(
"refDesRef" ) );
322 tNode->GetAttribute( wxT(
"Name" ), &fp->
m_Name.
text );
329 tNode =
FindNode( lNode, wxT(
"pt" ) );
337 tNode =
FindNode( lNode, wxT(
"rotation" ) );
341 str = tNode->GetNodeContent();
348 if( str.IsSameAs( wxT(
"True" ),
false ) )
353 while( tNode->GetName() != wxT(
"www.lura.sk" ) )
356 tNode =
FindNode( tNode, wxT(
"netlist" ) );
360 tNode =
FindNode( tNode, wxT(
"compInst" ) );
364 tNode->GetAttribute( wxT(
"Name" ), &propValue );
368 if(
FindNode( tNode, wxT(
"compValue" ) ) )
371 wxT(
"compValue" ) )->GetAttribute( wxT(
"Name" ),
377 if(
FindNode( tNode, wxT(
"compRef" ) ) )
380 wxT(
"compRef" ) )->GetAttribute( wxT(
"Name" ),
396 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
409 if( mNode->GetName().IsSameAs( wxT(
"padNum" ),
false ) )
411 str = mNode->GetNodeContent();
417 mNode->GetAttribute( wxT(
"Name" ), &propValue );
437 else if( lNode->GetName().IsSameAs( wxT(
"pad" ),
false ) )
443 else if( lNode->GetName().IsSameAs( wxT(
"via" ),
false ) )
449 else if( lNode->GetName().IsSameAs( wxT(
"polyKeepOut" ),
false ) )
465 const wxString& aNetName )
484 cp->
m_Net = aNetName;
512 default:
return ( layerIndex + 1 ) * 2;
519 wxString lName, layerType;
523 aNode->GetAttribute( wxT(
"Name" ), &lName );
524 lName = lName.MakeUpper();
526 if( lName == wxT(
"TOP ASSY" ) )
530 else if( lName == wxT(
"TOP SILK" ) )
534 else if( lName == wxT(
"TOP PASTE" ) )
538 else if( lName == wxT(
"TOP MASK" ) )
542 else if( lName == wxT(
"TOP" ) )
546 else if( lName == wxT(
"BOTTOM" ) )
550 else if( lName == wxT(
"BOT MASK" ) )
554 else if( lName == wxT(
"BOT PASTE" ) )
558 else if( lName == wxT(
"BOT SILK" ) )
562 else if( lName == wxT(
"BOT ASSY" ) )
566 else if( lName == wxT(
"BOARD" ) )
578 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
579 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
593 if(
FindNode( aNode, wxT(
"layerType" ) ) )
595 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
597 if( layerType.IsSameAs( wxT(
"NonSignal" ),
false ) )
600 if( layerType.IsSameAs( wxT(
"Signal" ),
false ) )
603 if( layerType.IsSameAs( wxT(
"Plane" ),
false ) )
607 if(
auto [it, success] =
m_LayersMap.insert( std::make_pair( num, newlayer ) ); !success )
614 it->second = newlayer;
617 if(
FindNode( aNode, wxT(
"netNameRef" ) ) )
619 FindNode( aNode, wxT(
"netNameRef" ) )->GetAttribute( wxT(
"Name" ),
631 for( i = 0; i < (int) aOutline->GetCount(); i++ )
633 if( *((*aOutline)[i]) == aPoint )
643 return sqrt( ( aPoint1->x - aPoint2->x ) * ( aPoint1->x - aPoint2->x ) +
644 ( aPoint1->y - aPoint2->y ) * ( aPoint1->y - aPoint2->y ) );
649 XNODE* epNode =
nullptr;
653 epNode =
FindNode( lNode, wxT(
"enhancedPolygon" ) );
662 if( epNode->GetName().IsSameAs( wxT(
"polyPoint" ),
false ) )
676 XNODE * iNode, *lNode, *pNode;
678 int x, y, i, j, targetInd;
679 wxRealPoint* xchgPoint;
682 iNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
692 if( iNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
694 if(
FindNode( iNode, wxT(
"layerNumRef" ) ) )
695 FindNode( iNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
703 if( lNode->GetName().IsSameAs( wxT(
"boardOutlineObj" ),
false ) )
708 if( lNode->GetName().IsSameAs( wxT(
"line" ),
false ) )
710 pNode =
FindNode( lNode, wxT(
"pt" ) );
715 &x, &y, aActualConversion );
727 &x, &y, aActualConversion );
778 wxString layerName, layerType;
780 bool stackupIncomplete =
false;
782 rootNode =
FindNode( (
XNODE*) aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
786 aNode =
FindNode( rootNode, wxT(
"layersStackup" ) );
790 aNode =
FindNode( aNode, wxT(
"layerStackupData" ) );
794 if( aNode->GetName() == wxT(
"layerStackupData" ) )
796 aaNode =
FindNode( aNode, wxT(
"layerStackupName" ) );
799 aaNode->GetAttribute( wxT(
"Name" ), &layerName );
800 layerName = layerName.MakeUpper();
811 aNode =
FindNode( rootNode, wxT(
"layerDef" ) );
815 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
817 if(
FindNode( aNode, wxT(
"layerType" ) ) )
821 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
822 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
824 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
826 layerType.IsSameAs( wxT(
"Signal" ),
false ) || layerType.IsSameAs( wxT(
"Plane" ),
false );
830 aNode->GetAttribute( wxT(
"Name" ), &layerName );
831 layerName = layerName.MakeUpper();
833 auto compare = [&layerName](
const auto& el )
835 return layerName.IsSameAs( el.first,
false );
857 stackupIncomplete =
true;
869 if( stackupIncomplete )
875 [&](
const std::pair<wxString, long>& a,
const std::pair<wxString, long>& b )
877 long lhs = a.second == 2 ? std::numeric_limits<long>::max() : a.second;
878 long rhs = b.second == 2 ? std::numeric_limits<long>::max() : b.second;
899 plane_layer->
AssignNet( layer.netNameRef );
910 if(
FindNode( aNode, wxT(
"layerNumRef" ) ) )
911 FindNode( aNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &num );
927 wxString compRef, pinRef;
931 aNode =
FindNode( (
XNODE*) aXmlDoc->GetRoot(), wxT(
"asciiHeader" ) );
935 aNode =
FindNode( aNode, wxT(
"fileUnits" ) );
949 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
953 aNode =
FindNode( aNode, wxT(
"layerDef" ) );
957 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
969 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"netlist" ) );
973 aNode =
FindNode( aNode, wxT(
"net" ) );
990 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
1000 if( aNode->GetName().IsSameAs( wxT(
"multiLayer" ),
false ) )
1004 if( aNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
1019 for( j = 0; j < (int) net->
m_NetNodes.GetCount(); j++ )
1022 compRef.Trim(
false );
1023 compRef.Trim(
true );
1025 pinRef.Trim(
false );
1026 pinRef.Trim(
true );
1093 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
1097 aNode =
FindNode( aNode, wxT(
"compDef" ) );
1103 if( aNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
1107 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
std::set< int > m_reportedLayers
PCAD_NETS_ARRAY m_PcbNetlist
int FindOutlinePoint(const VERTICES_ARRAY *aOutline, wxRealPoint aPoint) const
PCAD_COMPONENTS_ARRAY m_PcbComponents
void ExtractLayerStackup(wxXmlDocument *aXmlDoc)
void reportUnknownLayer(int aPCadLayer) const
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
#define THROW_IO_ERRORF(msg,...)
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.