40 #include <wx/gdicmn.h> 41 #include <wx/string.h> 53 return it->second.KiCadLayer;
64 return it->second.layerType;
75 return it->second.netNameRef;
84 for(
size_t i = 0; i < 8; ++i )
129 for(
int i = 0; i < (int)
m_PcbNetlist.GetCount(); i++ )
133 if( net->
m_Name == aNetName )
144 XNODE* result =
nullptr, * lNode;
147 lNode =
FindNode( aNode, wxT(
"compDef" ) );
151 if( lNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
153 lNode->GetAttribute( wxT(
"Name" ), &propValue );
155 if( propValue == aName )
171 const wxString& aXmlName,
const wxString& aActualConversion )
173 XNODE* tNode, * t1Node;
174 wxString n, nnew, pn, propValue, str;
182 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
185 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
189 tNode =
FindNode( tNode, wxT(
"patternGraphicsRef" ) );
193 if( tNode->GetName().IsSameAs( wxT(
"patternGraphicsRef" ),
false ) )
195 if(
FindNode( tNode, wxT(
"patternGraphicsNameRef" ) ) )
198 wxT(
"patternGraphicsNameRef" ) )->GetAttribute( wxT(
"Name" ),
201 if( propValue == pn )
204 str = aTextValue->
text;
208 n = n + wxT(
' ' ) + str;
220 tNode =
FindNode( t1Node, wxT(
"attr" ) );
224 tNode->GetAttribute( wxT(
"Name" ), &propValue );
225 propValue.Trim(
false );
226 propValue.Trim(
true );
228 if( propValue == n || propValue == nnew )
240 wxStatusBar* aStatusBar )
242 XNODE* lNode, * tNode, * mNode;
247 wxString cn, str, propValue;
255 if( lNode->GetName().IsSameAs( wxT(
"pattern" ),
false ) )
257 FindNode( lNode, wxT(
"patternRef" ) )->GetAttribute( wxT(
"Name" ),
260 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
262 if( tNode && cn.Len() > 0 )
270 mNode =
FindNode( lNode, wxT(
"patternGraphicsNameRef" ) );
282 tNode =
FindNode( lNode, wxT(
"refDesRef" ) );
286 tNode->GetAttribute( wxT(
"Name" ), &fp->
m_name.
text );
293 tNode =
FindNode( lNode, wxT(
"pt" ) );
301 tNode =
FindNode( lNode, wxT(
"rotation" ) );
305 str = tNode->GetNodeContent();
312 if( str.IsSameAs( wxT(
"True" ),
false ) )
317 while( tNode->GetName() != wxT(
"www.lura.sk" ) )
320 tNode =
FindNode( tNode, wxT(
"netlist" ) );
324 tNode =
FindNode( tNode, wxT(
"compInst" ) );
328 tNode->GetAttribute( wxT(
"Name" ), &propValue );
332 if(
FindNode( tNode, wxT(
"compValue" ) ) )
335 wxT(
"compValue" ) )->GetAttribute( wxT(
"Name" ),
341 if(
FindNode( tNode, wxT(
"compRef" ) ) )
344 wxT(
"compRef" ) )->GetAttribute( wxT(
"Name" ),
360 tNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
373 if( mNode->GetName().IsSameAs( wxT(
"padNum" ),
false ) )
375 str = mNode->GetNodeContent();
381 mNode->GetAttribute( wxT(
"Name" ), &propValue );
401 else if( lNode->GetName().IsSameAs( wxT(
"pad" ),
false ) )
407 else if( lNode->GetName().IsSameAs( wxT(
"via" ),
false ) )
413 else if( lNode->GetName().IsSameAs( wxT(
"polyKeepOut" ),
false ) )
429 const wxString& aNetName )
448 cp->
m_net = aNetName;
470 wxString lName, layerType;
474 aNode->GetAttribute( wxT(
"Name" ), &lName );
475 lName = lName.MakeUpper();
477 if( lName == wxT(
"TOP ASSY" ) )
481 else if( lName == wxT(
"TOP SILK" ) )
485 else if( lName == wxT(
"TOP PASTE" ) )
489 else if( lName == wxT(
"TOP MASK" ) )
493 else if( lName == wxT(
"TOP" ) )
497 else if( lName == wxT(
"BOTTOM" ) )
501 else if( lName == wxT(
"BOT MASK" ) )
505 else if( lName == wxT(
"BOT PASTE" ) )
509 else if( lName == wxT(
"BOT SILK" ) )
513 else if( lName == wxT(
"BOT ASSY" ) )
517 else if( lName == wxT(
"BOARD" ) )
531 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
532 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
540 if(
FindNode( aNode, wxT(
"layerType" ) ) )
542 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
false );
544 if( layerType.IsSameAs( wxT(
"NonSignal" ),
false ) )
547 if( layerType.IsSameAs( wxT(
"Signal" ),
false ) )
550 if( layerType.IsSameAs( wxT(
"Plane" ),
false ) )
554 m_LayersMap.insert( std::make_pair( num, newlayer ) );
556 if(
FindNode( aNode, wxT(
"netNameRef" ) ) )
558 FindNode( aNode, wxT(
"netNameRef" ) )->GetAttribute( wxT(
"Name" ),
567 for( i = 0; i < (int) aOutline->GetCount(); i++ )
569 if( *((*aOutline)[i]) == aPoint )
579 return sqrt( ( aPoint1->x - aPoint2->x ) * ( aPoint1->x - aPoint2->x ) +
580 ( aPoint1->y - aPoint2->y ) * ( aPoint1->y - aPoint2->y ) );
585 XNODE* iNode, *lNode, *pNode;
587 int x, y, i, j, targetInd;
588 wxRealPoint* xchgPoint;
591 iNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
601 if( iNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
603 if(
FindNode( iNode, wxT(
"layerNumRef" ) ) )
604 FindNode( iNode, wxT(
"layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
612 if( lNode->GetName().IsSameAs( wxT(
"line" ),
false ) )
614 pNode =
FindNode( lNode, wxT(
"pt" ) );
619 &x, &y, aActualConversion );
631 &x, &y, aActualConversion );
678 const wxString& aActualConversion )
684 wxString compRef, pinRef, layerName, layerType;
688 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"asciiHeader" ) );
692 aNode =
FindNode( aNode, wxT(
"fileUnits" ) );
703 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
733 aNode =
FindNode( aNode, wxT(
"layerDef" ) );
737 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
739 if(
FindNode( aNode, wxT(
"layerType" ) ) )
743 if(
FindNode( aNode, wxT(
"layerNum" ) ) )
744 FindNode( aNode, wxT(
"layerNum" ) )->GetNodeContent().ToLong( &num );
746 layerType =
FindNode( aNode, wxT(
"layerType" ) )->GetNodeContent().Trim(
749 if( num > 0 && ( layerType.IsSameAs( wxT(
"Signal" ),
false )
750 || layerType.IsSameAs( wxT(
"Plane" ),
false ) ) )
752 aNode->GetAttribute( wxT(
"Name" ), &layerName );
753 layerName = layerName.MakeUpper();
768 [&](
const std::pair<wxString, long>& a,
const std::pair<wxString, long>& b ) {
769 long lhs = a.second == 2 ? std::numeric_limits<long>::max() : a.second;
770 long rhs = b.second == 2 ? std::numeric_limits<long>::max() : b.second;
777 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
781 aNode =
FindNode( aNode, wxT(
"layerDef" ) );
785 if( aNode->GetName().IsSameAs( wxT(
"layerDef" ),
false ) )
797 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"netlist" ) );
801 aNode =
FindNode( aNode, wxT(
"net" ) );
807 net =
new PCB_NET( netCode++ );
818 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"pcbDesign" ) );
828 if( aNode->GetName().IsSameAs( wxT(
"multiLayer" ),
false ) )
832 if( aNode->GetName().IsSameAs( wxT(
"layerContents" ),
false ) )
846 for( j = 0; j < (int) net->
m_NetNodes.GetCount(); j++ )
849 compRef.Trim(
false );
850 compRef.Trim(
true );
852 pinRef.Trim(
false );
920 aNode =
FindNode( (
XNODE *)aXmlDoc->GetRoot(), wxT(
"library" ) );
924 aNode =
FindNode( aNode, wxT(
"compDef" ) );
930 if( aNode->GetName().IsSameAs( wxT(
"compDef" ),
false ) )
int GetNetCode(const wxString &aNetName) const override
LAYER_TYPE_T GetLayerType(int aPCadLayer) const override
void ParseBoard(wxStatusBar *aStatusBar, wxXmlDocument *aXmlDoc, const wxString &aActualConversion)
wxString ValidateName(const wxString &aName)
int FindOutlinePoint(const VERTICES_ARRAY *aOutline, wxRealPoint aPoint) const
void SetCopperLayerCount(int aCount)
int LAYER_NUM
This can be replaced with int and removed.
PCB_NET_NODES_ARRAY m_NetNodes
PCB_COMPONENTS_ARRAY m_PcbComponents
void SetTextProperty(XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aPatGraphRefName, const wxString &aXmlName, const wxString &aActualConversion)
int FindLayer(const wxString &aLayerName) const
PCB_NETS_ARRAY m_PcbNetlist
virtual void SetPosOffset(int aX_offs, int aY_offs)
void ConnectPinToNet(const wxString &aCr, const wxString &aPr, const wxString &aNetName)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
std::map< int, TLAYER > m_LayersMap
void AddToBoard() override
wxString m_DefaultMeasurementUnit
XNODE * GetChildren() const
void DoPCBComponents(XNODE *aNode, wxXmlDocument *aXmlDoc, const wxString &aActualConversion, wxStatusBar *aStatusBar)
XNODE * GetParent() const
wxString FindNodeGetContent(XNODE *aChild, const wxString &aTag)
void SetTextParameters(XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
double GetDistance(const wxRealPoint *aPoint1, const wxRealPoint *aPoint2) const
XNODE * FindCompDefName(XNODE *aNode, const wxString &aName) const
void GetBoardOutline(wxXmlDocument *aXmlDoc, const wxString &aActualConversion)
wxString GetLayerNetNameRef(int aPCadLayer) const override
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
PCB_LAYER_ID GetKiCadLayer() const
virtual bool Parse(XNODE *aNode, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion) override
Hold an XML or S-expression element.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
std::vector< std::pair< wxString, long > > m_layersStackup
Handle the data for a net.
Information pertinent to a Pcbnew printed circuit board.
PCB_LAYER_ID
A quick note on layer IDs:
void MapLayer(XNODE *aNode)
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
PCB_CALLBACKS * m_callbacks
XNODE * FindPinMap(XNODE *aNode)
int StrToInt1Units(const wxString &aStr)
#define THROW_IO_ERROR(msg)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
wxString m_patGraphRefName