KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcad_copper_pour.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-2013 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
23
24#include <common.h>
25#include <xnode.h>
26
27#include <wx/string.h>
28
29namespace PCAD2KICAD {
30
31PCAD_COPPER_POUR::PCAD_COPPER_POUR( PCAD_CALLBACKS* aCallbacks, BOARD* aBoard, int aPCadLayer ) :
32 PCAD_POLYGON( aCallbacks, aBoard, aPCadLayer )
33{
34 m_filled = false;
35}
36
37
41
42
43bool PCAD_COPPER_POUR::Parse( XNODE* aNode, const wxString& aDefaultUnits,
44 const wxString& aActualConversion )
45{
46 XNODE* lNode;
47 wxString pourType, str, propValue;
48 int pourSpacing, thermalWidth;
49
50 lNode = FindNode( aNode, wxT( "netNameRef" ) );
51
52 if( lNode )
53 {
54 lNode->GetAttribute( wxT( "Name" ), &propValue );
55 propValue.Trim( false );
56 propValue.Trim( true );
57 m_Net = propValue;
59 }
60
61 if( FindNode( aNode, wxT( "width" ) ) )
62 {
63 SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultUnits, &m_Width,
64 aActualConversion );
65 }
66
67 if( FindNode( aNode, wxT( "pourSpacing" ) ) )
68 {
69 SetWidth( FindNode( aNode, wxT( "pourSpacing" ) )->GetNodeContent(), aDefaultUnits,
70 &pourSpacing, aActualConversion );
71 }
72
73 if( FindNode( aNode, wxT( "thermalWidth" ) ) )
74 {
75 SetWidth( FindNode( aNode, wxT( "thermalWidth" ) )->GetNodeContent(), aDefaultUnits,
76 &thermalWidth, aActualConversion );
77 }
78
79 if( FindNode( aNode, wxT( "island" ) ) )
80 m_filled = true;
81
82 lNode = FindNode( aNode, wxT( "pcbPoly" ) );
83
84 // If the pour doesn't have the newer `pcbPoly` tag, check for the older `pourOutline` tag
85 if( !lNode )
86 lNode = FindNode( aNode, wxT( "pourOutline" ) );
87
88 if( lNode )
89 {
90 // retrieve copper pour outline
91 FormPolygon( lNode, &m_Outline, aDefaultUnits, aActualConversion );
92
93 if( m_Outline.GetCount() <= 0 )
94 {
95 // empty polygon may have been in the file
96 return false;
97 }
98
99 m_PositionX = m_Outline[0]->x;
100 m_PositionY = m_Outline[0]->y;
101 }
102 else
103 {
104 return false;
105 }
106
107 return true;
108}
109
110} // namespace PCAD2KICAD
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
virtual bool Parse(XNODE *aNode, const wxString &aDefaultUnits, const wxString &aActualConversion) override
PCAD_COPPER_POUR(PCAD_CALLBACKS *aCallbacks, BOARD *aBoard, int aPCadLayer)
int GetNetCode(const wxString &aNetName) const
VERTICES_ARRAY m_Outline
void FormPolygon(XNODE *aNode, VERTICES_ARRAY *aPolygon, const wxString &aDefaultUnits, const wxString &actualConversion)
PCAD_POLYGON(PCAD_CALLBACKS *aCallbacks, BOARD *aBoard, int aPCadLayer)
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
Definition xnode.h:67
The common library.
void SetWidth(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
XNODE * FindNode(XNODE *aChild, const wxString &aTag)