KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcad_via.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2007, 2008 Lubo Racko <[email protected]>
5 * Copyright (C) 2007, 2008, 2012 Alexander Lunev <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <pcad/pcad_via.h>
23#include <pcad/pcad_via_shape.h>
24
25#include <richio.h>
26#include <xnode.h>
27
28#include <wx/string.h>
29#include <wx/translation.h>
30
31namespace PCAD2KICAD {
32
33PCAD_VIA::PCAD_VIA( PCAD_CALLBACKS* aCallbacks, BOARD* aBoard ) : PCAD_PAD( aCallbacks, aBoard )
34{
35 m_ObjType = wxT( 'V' );
36}
37
38
42
43
44void PCAD_VIA::Parse( XNODE* aNode, const wxString& aDefaultUnits,
45 const wxString& aActualConversion )
46{
47 XNODE* lNode, * tNode;
48 wxString propValue;
49 PCAD_VIA_SHAPE* viaShape;
50
52 lNode = FindNode( aNode, wxT( "viaStyleRef" ) );
53
54 if( lNode )
55 {
56 lNode->GetAttribute( wxT( "Name" ), &propValue );
57 propValue.Trim( false );
58 propValue.Trim( true );
59 m_Name.text = propValue;
60 }
61
62 lNode = FindNode( aNode, wxT( "pt" ) );
63
64 if( lNode )
65 {
66 SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_PositionX, &m_PositionY,
67 aActualConversion );
68 }
69
70 lNode = FindNode( aNode, wxT( "netNameRef" ) );
71
72 if( lNode )
73 {
74 lNode->GetAttribute( wxT( "Name" ), &propValue );
75 propValue.Trim( false );
76 propValue.Trim( true );
77 m_Net = propValue;
79 }
80
81 lNode = aNode;
82
83 while( lNode && lNode->GetName() != wxT( "www.lura.sk" ) )
84 lNode = lNode->GetParent();
85
86 lNode = FindNode( lNode, wxT( "library" ) );
87
88 if ( !lNode )
89 THROW_IO_ERROR( _( "Unable to find library section." ) );
90
91 lNode = FindNode( lNode, wxT( "viaStyleDef" ) );
92
93 while( lNode )
94 {
95 lNode->GetAttribute( wxT( "Name" ), &propValue );
96
97 if( propValue.IsSameAs( m_Name.text, false ) )
98 break;
99
100 lNode = lNode->GetNext();
101 }
102
103 if ( !lNode )
104 THROW_IO_ERROR( wxString::Format( _( "Unable to find viaStyleDef %s." ), m_Name.text ) );
105
106 if( lNode )
107 {
108 tNode = lNode;
109 lNode = FindNode( tNode, wxT( "holeDiam" ) );
110
111 if( lNode )
112 SetWidth( lNode->GetNodeContent(), aDefaultUnits, &m_Hole, aActualConversion );
113
114 lNode = FindNode( tNode, wxT( "viaShape" ) );
115
116 while( lNode )
117 {
118 if( lNode->GetName() == wxT( "viaShape" ) )
119 {
120 // we support only Vias on specific layers......
121 // we do not support vias on "Plane", "NonSignal" , "Signal" ... layerr
122 if( FindNode( lNode, wxT( "layerNumRef" ) ) )
123 {
124 viaShape = new PCAD_VIA_SHAPE( m_callbacks, m_board );
125 viaShape->Parse( lNode, aDefaultUnits, aActualConversion );
126 m_Shapes.Add( viaShape );
127 }
128 }
129
130 lNode = lNode->GetNext();
131 }
132 }
133}
134
135} // namespace PCAD2KICAD
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
PCAD_PAD_SHAPES_ARRAY m_Shapes
Definition pcad_pad.h:53
PCAD_PAD(PCAD_CALLBACKS *aCallbacks, BOARD *aBoard)
Definition pcad_pad.cpp:37
int GetNetCode(const wxString &aNetName) const
virtual void Parse(XNODE *aNode, const wxString &aDefaultUnits, const wxString &aActualConversion) override
PCAD_VIA(PCAD_CALLBACKS *aCallbacks, BOARD *aBoard)
Definition pcad_via.cpp:33
virtual void Parse(XNODE *aNode, const wxString &aDefaultUnits, const wxString &aActualConversion) override
Definition pcad_via.cpp:44
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
Definition xnode.h:67
XNODE * GetParent() const
Definition xnode.h:107
XNODE * GetNext() const
Definition xnode.h:102
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:411
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
void SetWidth(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)