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;
80 for(
size_t i = 0; i < 8; ++i )
125 for(
int i = 0; i < (int)
m_PcbNetlist.GetCount(); i++ )
129 if( net->
m_Name == aNetName )
140 XNODE* result =
nullptr, * lNode;
143 lNode =
FindNode( aNode, wxT(
"compDef" ) );
147 if( lNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
149 lNode->GetAttribute( wxT(
"Name" ), &propValue );
151 if( propValue == aName )
167 const wxString& aXmlName,
const wxString& aActualConversion )
169 XNODE* tNode, * t1Node;
170 wxString n, nnew, pn, propValue, str;
178 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
181 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
185 tNode =
FindNode( tNode, wxT(
"patternGraphicsRef" ) );
189 if( tNode->GetName().IsSameAs( wxT(
"patternGraphicsRef" ),
false ) )
191 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
194 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
197 if( propValue == pn )
200 str = aTextValue->
text;
204 n = n + wxT(
' ' ) + str;
216 tNode =
FindNode( t1Node, wxT(
"attr" ) );
220 tNode->GetAttribute( wxT(
"Name" ), &propValue );
221 propValue.Trim(
false );
222 propValue.Trim(
true );
224 if( propValue == n || propValue == nnew )
236 wxStatusBar* aStatusBar )
238 XNODE* lNode, * tNode, * mNode;
243 wxString cn, str, propValue;
251 if( lNode->GetName().IsSameAs( wxT(
"pattern" ),
false ) )
253 FindNode( lNode, wxT(
"patternRef" ) )->GetAttribute( wxT(
"Name" ),
256 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
258 if( tNode && cn.Len() > 0 )
266 mNode =
FindNode( lNode, wxT(
"patternGraphicsNameRef" ) );
278 tNode =
FindNode( lNode, wxT(
"refDesRef" ) );
282 tNode->GetAttribute( wxT(
"Name" ), &fp->
m_Name.
text );
289 tNode =
FindNode( lNode, wxT(
"pt" ) );
297 tNode =
FindNode( lNode, wxT(
"rotation" ) );
301 str = tNode->GetNodeContent();
308 if( str.IsSameAs( wxT(
"True" ),
false ) )
313 while( tNode->GetName() != wxT(
"www.lura.sk" ) )
316 tNode =
FindNode( tNode, wxT(
"netlist" ) );
320 tNode =
FindNode( tNode, wxT(
"compInst" ) );
324 tNode->GetAttribute( wxT(
"Name" ), &propValue );
328 if(
FindNode( tNode, wxT(
"compValue" ) ) )
331 wxT(
"compValue" ) )->GetAttribute( wxT(
"Name" ),
337 if(
FindNode( tNode, wxT(
"compRef" ) ) )
340 wxT(
"compRef" ) )->GetAttribute( wxT(
"Name" ),
356 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
369 if( mNode->GetName().IsSameAs( wxT(
"padNum" ),
false ) )
371 str = mNode->GetNodeContent();
377 mNode->GetAttribute( wxT(
"Name" ), &propValue );
397 else if( lNode->GetName().IsSameAs( wxT(
"pad" ),
false ) )
403 else if( lNode->GetName().IsSameAs( wxT(
"via" ),
false ) )
409 else if( lNode->GetName().IsSameAs( wxT(
"polyKeepOut" ),
false ) )
425 const wxString& aNetName )
444 cp->
m_Net = aNetName;
466 wxString lName, layerType;
470 aNode->GetAttribute( wxT(
"Name" ), &lName );
471 lName = lName.MakeUpper();
473 if( lName == wxT(
"TOP ASSY" ) )
477 else if( lName == wxT(
"TOP SILK" ) )
481 else if( lName == wxT(
"TOP PASTE" ) )
485 else if( lName == wxT(
"TOP MASK" ) )
489 else if( lName == wxT(
"TOP" ) )
493 else if( lName == wxT(
"BOTTOM" ) )
497 else if( lName == wxT(
"BOT MASK" ) )
501 else if( lName == wxT(
"BOT PASTE" ) )
505 else if( lName == wxT(
"BOT SILK" ) )
509 else if( lName == wxT(
"BOT ASSY" ) )
513 else if( lName == wxT(
"BOARD" ) )
527 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
528 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
531 THROW_IO_ERROR( wxString::Format( wxT(
"layerNum = %ld is out of range" ), num ) );
536 if(
FindNode( aNode, wxT(
"layerType" ) ) )
538 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
540 if( layerType.IsSameAs( wxT(
"NonSignal" ),
false ) )
543 if( layerType.IsSameAs( wxT(
"Signal" ),
false ) )
546 if( layerType.IsSameAs( wxT(
"Plane" ),
false ) )
550 m_LayersMap.insert( std::make_pair( num, newlayer ) );
552 if(
FindNode( aNode, wxT(
"netNameRef" ) ) )
554 FindNode( aNode, wxT(
"netNameRef" ) )->GetAttribute( wxT(
"Name" ),
563 for( i = 0; i < (int) aOutline->GetCount(); i++ )
565 if( *((*aOutline)[i]) == aPoint )
575 return sqrt( ( aPoint1->x - aPoint2->x ) * ( aPoint1->x - aPoint2->x ) +
576 ( aPoint1->y - aPoint2->y ) * ( aPoint1->y - aPoint2->y ) );
581 XNODE* iNode, *lNode, *pNode;
583 int x, y, i, j, targetInd;
584 wxRealPoint* xchgPoint;
587 iNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
597 if( iNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
599 if(
FindNode( iNode, wxT(
"layerNumRef" ) ) )
600 FindNode( iNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
608 if( lNode->GetName().IsSameAs( wxT(
"line" ),
false ) )
610 pNode =
FindNode( lNode, wxT(
"pt" ) );
615 &x, &y, aActualConversion );
627 &x, &y, aActualConversion );
674 const wxString& aActualConversion )
680 wxString compRef, pinRef, layerName, layerType;
684 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"asciiHeader" ) );
688 aNode =
FindNode( aNode, wxT(
"fileUnits" ) );
699 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
729 aNode =
FindNode( aNode, wxT(
"layerDef" ) );
733 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
735 if(
FindNode( aNode, wxT(
"layerType" ) ) )
739 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
740 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
742 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
745 if( num > 0 && ( layerType.IsSameAs( wxT(
"Signal" ),
false )
746 || layerType.IsSameAs( wxT(
"Plane" ),
false ) ) )
748 aNode->GetAttribute( wxT(
"Name" ), &layerName );
749 layerName = layerName.MakeUpper();
764 [&](
const std::pair<wxString, long>& a,
const std::pair<wxString, long>& b ) {
765 long lhs = a.second == 2 ? std::numeric_limits<long>::max() : a.second;
766 long rhs = b.second == 2 ? std::numeric_limits<long>::max() : b.second;
773 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
777 aNode =
FindNode( aNode, wxT(
"layerDef" ) );
781 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
793 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"netlist" ) );
797 aNode =
FindNode( aNode, wxT(
"net" ) );
814 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
824 if( aNode->GetName().IsSameAs( wxT(
"multiLayer" ),
false ) )
828 if( aNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
842 for( j = 0; j < (int) net->
m_NetNodes.GetCount(); j++ )
845 compRef.Trim(
false );
846 compRef.Trim(
true );
848 pinRef.Trim(
false );
916 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
920 aNode =
FindNode( aNode, wxT(
"compDef" ) );
926 if( aNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
void SetCopperLayerCount(int aCount)
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
int GetNetCode(const wxString &aNetName) const override
std::map< int, TLAYER > m_LayersMap
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
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)
double GetDistance(const wxRealPoint *aPoint1, const wxRealPoint *aPoint2) const
Hold an XML or S-expression element.
XNODE * GetParent() const
XNODE * GetChildren() const
#define THROW_IO_ERROR(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 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)