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 ) );
107 for(
size_t i = 1; i < 12; ++i )
167 for(
int i = 0; i < (int)
m_PcbNetlist.GetCount(); i++ )
171 if( net->
m_Name == aNetName )
185 lNode =
FindNode( aNode, wxT(
"compDef" ) );
189 if( lNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
191 lNode->GetAttribute( wxT(
"Name" ), &propValue );
193 if( propValue == aName )
201 lNode = lNode->GetNext();
209 const wxString& aXmlName,
const wxString& aActualConversion )
211 XNODE* tNode, * t1Node;
212 wxString n, nnew, pn, propValue, str;
220 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
223 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
227 tNode =
FindNode( tNode, wxT(
"patternGraphicsRef" ) );
231 if( tNode->GetName().IsSameAs( wxT(
"patternGraphicsRef" ),
false ) )
233 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
236 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
239 if( propValue == pn )
242 str = aTextValue->
text;
246 n = n + wxT(
' ' ) + str;
258 tNode =
FindNode( t1Node, wxT(
"attr" ) );
262 tNode->GetAttribute( wxT(
"Name" ), &propValue );
263 propValue.Trim(
false );
264 propValue.Trim(
true );
266 if( propValue == n || propValue == nnew )
278 wxStatusBar* aStatusBar )
280 XNODE* lNode, * tNode, * mNode;
285 wxString cn, str, propValue;
293 if( lNode->GetName().IsSameAs( wxT(
"pattern" ),
false ) )
295 FindNode( lNode, wxT(
"patternRef" ) )->GetAttribute( wxT(
"Name" ),
298 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
300 if( tNode && cn.Len() > 0 )
308 mNode =
FindNode( lNode, wxT(
"patternGraphicsNameRef" ) );
320 tNode =
FindNode( lNode, wxT(
"refDesRef" ) );
324 tNode->GetAttribute( wxT(
"Name" ), &fp->
m_Name.
text );
331 tNode =
FindNode( lNode, wxT(
"pt" ) );
339 tNode =
FindNode( lNode, wxT(
"rotation" ) );
343 str = tNode->GetNodeContent();
350 if( str.IsSameAs( wxT(
"True" ),
false ) )
355 while( tNode->GetName() != wxT(
"www.lura.sk" ) )
358 tNode =
FindNode( tNode, wxT(
"netlist" ) );
362 tNode =
FindNode( tNode, wxT(
"compInst" ) );
366 tNode->GetAttribute( wxT(
"Name" ), &propValue );
370 if(
FindNode( tNode, wxT(
"compValue" ) ) )
373 wxT(
"compValue" ) )->GetAttribute( wxT(
"Name" ),
379 if(
FindNode( tNode, wxT(
"compRef" ) ) )
382 wxT(
"compRef" ) )->GetAttribute( wxT(
"Name" ),
398 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
411 if( mNode->GetName().IsSameAs( wxT(
"padNum" ),
false ) )
413 str = mNode->GetNodeContent();
419 mNode->GetAttribute( wxT(
"Name" ), &propValue );
439 else if( lNode->GetName().IsSameAs( wxT(
"pad" ),
false ) )
445 else if( lNode->GetName().IsSameAs( wxT(
"via" ),
false ) )
451 else if( lNode->GetName().IsSameAs( wxT(
"polyKeepOut" ),
false ) )
467 const wxString& aNetName )
486 cp->
m_Net = aNetName;
514 default:
return ( layerIndex + 1 ) * 2;
521 wxString lName, layerType;
525 aNode->GetAttribute( wxT(
"Name" ), &lName );
526 lName = lName.MakeUpper();
528 if( lName == wxT(
"TOP ASSY" ) )
532 else if( lName == wxT(
"TOP SILK" ) )
536 else if( lName == wxT(
"TOP PASTE" ) )
540 else if( lName == wxT(
"TOP MASK" ) )
544 else if( lName == wxT(
"TOP" ) )
548 else if( lName == wxT(
"BOTTOM" ) )
552 else if( lName == wxT(
"BOT MASK" ) )
556 else if( lName == wxT(
"BOT PASTE" ) )
560 else if( lName == wxT(
"BOT SILK" ) )
564 else if( lName == wxT(
"BOT ASSY" ) )
568 else if( lName == wxT(
"BOARD" ) )
580 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
581 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
584 THROW_IO_ERROR( wxString::Format( wxT(
"layerNum = %ld is out of range" ), num ) );
595 if(
FindNode( aNode, wxT(
"layerType" ) ) )
597 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
599 if( layerType.IsSameAs( wxT(
"NonSignal" ),
false ) )
602 if( layerType.IsSameAs( wxT(
"Signal" ),
false ) )
605 if( layerType.IsSameAs( wxT(
"Plane" ),
false ) )
609 if(
auto [it, success] =
m_LayersMap.insert( std::make_pair( num, newlayer ) ); !success )
616 it->second = newlayer;
619 if(
FindNode( aNode, wxT(
"netNameRef" ) ) )
621 FindNode( aNode, wxT(
"netNameRef" ) )->GetAttribute( wxT(
"Name" ),
633 for( i = 0; i < (int) aOutline->GetCount(); i++ )
635 if( *((*aOutline)[i]) == aPoint )
645 return sqrt( ( aPoint1->x - aPoint2->x ) * ( aPoint1->x - aPoint2->x ) +
646 ( aPoint1->y - aPoint2->y ) * ( aPoint1->y - aPoint2->y ) );
651 XNODE* epNode =
nullptr;
655 epNode =
FindNode( lNode, wxT(
"enhancedPolygon" ) );
664 if( epNode->GetName().IsSameAs( wxT(
"polyPoint" ),
false ) )
678 XNODE * iNode, *lNode, *pNode;
680 int x, y, i, j, targetInd;
681 wxRealPoint* xchgPoint;
684 iNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
694 if( iNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
696 if(
FindNode( iNode, wxT(
"layerNumRef" ) ) )
697 FindNode( iNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
705 if( lNode->GetName().IsSameAs( wxT(
"boardOutlineObj" ),
false ) )
710 if( lNode->GetName().IsSameAs( wxT(
"line" ),
false ) )
712 pNode =
FindNode( lNode, wxT(
"pt" ) );
717 &x, &y, aActualConversion );
729 &x, &y, aActualConversion );
780 wxString layerName, layerType;
782 bool stackupIncomplete =
false;
784 rootNode =
FindNode( (
XNODE*) aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
788 aNode =
FindNode( rootNode, wxT(
"layersStackup" ) );
792 aNode =
FindNode( aNode, wxT(
"layerStackupData" ) );
796 if( aNode->GetName() == wxT(
"layerStackupData" ) )
798 aaNode =
FindNode( aNode, wxT(
"layerStackupName" ) );
801 aaNode->GetAttribute( wxT(
"Name" ), &layerName );
802 layerName = layerName.MakeUpper();
813 aNode =
FindNode( rootNode, wxT(
"layerDef" ) );
817 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
819 if(
FindNode( aNode, wxT(
"layerType" ) ) )
823 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
824 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
826 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
828 layerType.IsSameAs( wxT(
"Signal" ),
false ) || layerType.IsSameAs( wxT(
"Plane" ),
false );
832 aNode->GetAttribute( wxT(
"Name" ), &layerName );
833 layerName = layerName.MakeUpper();
835 auto compare = [&layerName](
const auto& el )
837 return layerName.IsSameAs( el.first,
false );
859 stackupIncomplete =
true;
871 if( stackupIncomplete )
877 [&](
const std::pair<wxString, long>& a,
const std::pair<wxString, long>& b )
879 long lhs = a.second == 2 ? std::numeric_limits<long>::max() : a.second;
880 long rhs = b.second == 2 ? std::numeric_limits<long>::max() : b.second;
901 plane_layer->
AssignNet( layer.netNameRef );
912 if(
FindNode( aNode, wxT(
"layerNumRef" ) ) )
913 FindNode( aNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &num );
929 wxString compRef, pinRef;
933 aNode =
FindNode( (
XNODE*) aXmlDoc->GetRoot(), wxT(
"asciiHeader" ) );
937 aNode =
FindNode( aNode, wxT(
"fileUnits" ) );
951 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
955 aNode =
FindNode( aNode, wxT(
"layerDef" ) );
959 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
971 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"netlist" ) );
975 aNode =
FindNode( aNode, wxT(
"net" ) );
992 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
1002 if( aNode->GetName().IsSameAs( wxT(
"multiLayer" ),
false ) )
1006 if( aNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
1021 for( j = 0; j < (int) net->
m_NetNodes.GetCount(); j++ )
1024 compRef.Trim(
false );
1025 compRef.Trim(
true );
1027 pinRef.Trim(
false );
1028 pinRef.Trim(
true );
1095 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
1099 aNode =
FindNode( aNode, wxT(
"compDef" ) );
1105 if( aNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
1109 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
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.