KiCad PCB EDA Suite
PCAD2KICAD::PCB_POLYGON Class Reference

#include <pcb_polygon.h>

Inheritance diagram for PCAD2KICAD::PCB_POLYGON:
PCAD2KICAD::PCB_COMPONENT PCAD2KICAD::PCB_COPPER_POUR PCAD2KICAD::PCB_CUTOUT PCAD2KICAD::PCB_KEEPOUT PCAD2KICAD::PCB_PLANE

Public Member Functions

 PCB_POLYGON (PCB_CALLBACKS *aCallbacks, BOARD *aBoard, int aPCadLayer)
 
 ~PCB_POLYGON ()
 
virtual bool Parse (XNODE *aNode, const wxString &aDefaultUnits, const wxString &aActualConversion)
 
virtual void SetPosOffset (int aX_offs, int aY_offs) override
 
virtual void Flip () override
 
void AddToFootprint (FOOTPRINT *aFootprint) override
 
void AddToBoard () override
 
void AssignNet (const wxString &aNetName)
 
void SetOutline (VERTICES_ARRAY *aOutline)
 
void FormPolygon (XNODE *aNode, VERTICES_ARRAY *aPolygon, const wxString &aDefaultUnits, const wxString &actualConversion)
 
PCB_LAYER_ID GetKiCadLayer () const
 
int GetNetCode (const wxString &aNetName) const
 

Public Attributes

int m_width
 
int m_priority
 
VERTICES_ARRAY m_outline
 
ISLANDS_ARRAY m_islands
 
ISLANDS_ARRAY m_cutouts
 
int m_tag
 
char m_objType
 
int m_PCadLayer
 
PCB_LAYER_ID m_KiCadLayer
 
KIID m_uuid
 
int m_positionX
 
int m_positionY
 
EDA_ANGLE m_rotation
 
TTEXTVALUE m_name
 
wxString m_net
 
int m_netCode
 
wxString m_compRef
 
wxString m_patGraphRefName
 

Protected Attributes

bool m_filled
 
PCB_CALLBACKSm_callbacks
 
BOARDm_board
 

Detailed Description

Definition at line 39 of file pcb_polygon.h.

Constructor & Destructor Documentation

◆ PCB_POLYGON()

PCAD2KICAD::PCB_POLYGON::PCB_POLYGON ( PCB_CALLBACKS aCallbacks,
BOARD aBoard,
int  aPCadLayer 
)

Definition at line 39 of file pcb_polygon.cpp.

39 :
40 PCB_COMPONENT( aCallbacks, aBoard )
41{
42 m_width = 0;
43
44 // P-CAD polygons are similar to zones (and we're going to convert them as such), except
45 // that they don't avoid other copper pours. So effectively they're very-high-priority
46 // zones.
47 m_priority = 100000;
48
49 m_objType = wxT( 'Z' );
50 m_PCadLayer = aPCadLayer;
52 m_filled = true;
53}
PCB_LAYER_ID GetKiCadLayer() const
Definition: pcb_component.h:56
PCB_COMPONENT(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)

References PCAD2KICAD::PCB_COMPONENT::GetKiCadLayer(), m_filled, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_objType, PCAD2KICAD::PCB_COMPONENT::m_PCadLayer, m_priority, and m_width.

◆ ~PCB_POLYGON()

PCAD2KICAD::PCB_POLYGON::~PCB_POLYGON ( )

Definition at line 56 of file pcb_polygon.cpp.

57{
58 int i, island;
59
60 for( i = 0; i < (int) m_outline.GetCount(); i++ )
61 {
62 delete m_outline[i];
63 }
64
65 for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
66 {
67 for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
68 {
69 delete (*m_cutouts[island])[i];
70 }
71
72 delete m_cutouts[island];
73 }
74
75 for( island = 0; island < (int) m_islands.GetCount(); island++ )
76 {
77 for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
78 {
79 delete (*m_islands[island])[i];
80 }
81
82 delete m_islands[island];
83 }
84}
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:66
ISLANDS_ARRAY m_cutouts
Definition: pcb_polygon.h:68
ISLANDS_ARRAY m_islands
Definition: pcb_polygon.h:67

References m_cutouts, m_islands, and m_outline.

Member Function Documentation

◆ AddToBoard()

void PCAD2KICAD::PCB_POLYGON::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 185 of file pcb_polygon.cpp.

186{
187 int i = 0;
188
189 if( m_outline.GetCount() > 0 )
190 {
191 ZONE* zone = new ZONE( m_board );
192 m_board->Add( zone, ADD_MODE::APPEND );
193
194 zone->SetLayer( m_KiCadLayer );
195 zone->SetNetCode( m_netCode );
196
197 // add outline
198 for( i = 0; i < (int) m_outline.GetCount(); i++ )
199 {
200 zone->AppendCorner( VECTOR2I( KiROUND( m_outline[i]->x ),
201 KiROUND( m_outline[i]->y ) ), -1 );
202 }
203
204 zone->SetLocalClearance( m_width );
205
207
209 zone->GetDefaultHatchPitch(), true );
210
211 if ( m_objType == wxT( 'K' ) )
212 {
213 zone->SetIsRuleArea( true );
214 zone->SetDoNotAllowTracks( true );
215 zone->SetDoNotAllowVias( true );
216 zone->SetDoNotAllowPads( true );
217 zone->SetDoNotAllowCopperPour( true );
218 zone->SetDoNotAllowFootprints( false );
219 }
220 else if( m_objType == wxT( 'C' ) )
221 {
222 // convert cutouts to keepouts because standalone cutouts are not supported in KiCad
223 zone->SetIsRuleArea( true );
224 zone->SetDoNotAllowCopperPour( true );
225 zone->SetDoNotAllowTracks( false );
226 zone->SetDoNotAllowVias( false );
227 zone->SetDoNotAllowPads( false );
228 zone->SetDoNotAllowFootprints( false );
229 }
230
231 //if( m_filled )
232 // zone->BuildFilledPolysListData( m_board );
233 }
234}
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:711
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:708
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aBorderHatchStyle, int aBorderHatchPitch, bool aRebuilBorderdHatch)
Set all hatch parameters for the zone.
Definition: zone.cpp:817
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:705
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:257
void SetIsRuleArea(bool aEnable)
Definition: zone.h:704
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:707
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:706
void SetLocalClearance(int aClearance)
Definition: zone.h:153
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:709
bool AppendCorner(VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
Definition: zone.cpp:757
void SetAssignedPriority(unsigned aPriority)
Definition: zone.h:107
static int GetDefaultHatchPitch()
Definition: zone.cpp:982
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References BOARD::Add(), APPEND, ZONE::AppendCorner(), DIAGONAL_EDGE, ZONE::GetDefaultHatchPitch(), KiROUND(), PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_netCode, PCAD2KICAD::PCB_COMPONENT::m_objType, m_outline, m_priority, m_width, ZONE::SetAssignedPriority(), ZONE::SetBorderDisplayStyle(), ZONE::SetDoNotAllowCopperPour(), ZONE::SetDoNotAllowFootprints(), ZONE::SetDoNotAllowPads(), ZONE::SetDoNotAllowTracks(), ZONE::SetDoNotAllowVias(), ZONE::SetIsRuleArea(), ZONE::SetLayer(), ZONE::SetLocalClearance(), and BOARD_CONNECTED_ITEM::SetNetCode().

◆ AddToFootprint()

void PCAD2KICAD::PCB_POLYGON::AddToFootprint ( FOOTPRINT aFootprint)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 161 of file pcb_polygon.cpp.

162{
164 {
165 FP_SHAPE* dwg = new FP_SHAPE( aFootprint, SHAPE_T::POLY );
166 aFootprint->Add( dwg );
167
168 dwg->SetStroke( STROKE_PARAMS( 0 ) );
169 dwg->SetLayer( m_KiCadLayer );
170
171 auto outline = new std::vector<VECTOR2I>;
172 for( auto point : m_outline )
173 outline->push_back( VECTOR2I( point->x, point->y ) );
174
175 dwg->SetPolyPoints( *outline );
176 dwg->SetStart0( *outline->begin() );
177 dwg->SetEnd0( outline->back() );
178 dwg->SetDrawCoord();
179
180 delete( outline );
181 }
182}
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:214
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
Definition: eda_shape.cpp:1109
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:561
void SetEnd0(const VECTOR2I &aPoint)
Definition: fp_shape.h:94
void SetStart0(const VECTOR2I &aPoint)
Definition: fp_shape.h:91
virtual void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:80
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:72
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88
bool IsNonCopperLayer(int aLayerId)
Test whether a layer is a non copper layer.
Definition: layer_ids.h:836

References FOOTPRINT::Add(), IsNonCopperLayer(), PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, m_outline, POLY, FP_SHAPE::SetDrawCoord(), FP_SHAPE::SetEnd0(), BOARD_ITEM::SetLayer(), EDA_SHAPE::SetPolyPoints(), FP_SHAPE::SetStart0(), and PCB_SHAPE::SetStroke().

◆ AssignNet()

void PCAD2KICAD::PCB_POLYGON::AssignNet ( const wxString &  aNetName)

◆ Flip()

void PCAD2KICAD::PCB_POLYGON::Flip ( )
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 237 of file pcb_polygon.cpp.

238{
240
242}
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:544

References PCAD2KICAD::PCB_COMPONENT::Flip(), FlipLayer(), and PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer.

◆ FormPolygon()

void PCAD2KICAD::PCB_POLYGON::FormPolygon ( XNODE aNode,
VERTICES_ARRAY *  aPolygon,
const wxString &  aDefaultUnits,
const wxString &  actualConversion 
)

Definition at line 108 of file pcb_polygon.cpp.

110{
111 XNODE* lNode;
112 double x, y;
113
114 lNode = FindNode( aNode, wxT( "pt" ) );
115
116 while( lNode )
117 {
118 if( lNode->GetName() == wxT( "pt" ) )
119 {
120 SetDoublePrecisionPosition( lNode->GetNodeContent(), aDefaultUnits, &x, &y,
121 aActualConversion );
122 aPolygon->Add( new wxRealPoint( x, y ) );
123 }
124
125 lNode = lNode->GetNext();
126 }
127}
Hold an XML or S-expression element.
Definition: xnode.h:44
XNODE * GetNext() const
Definition: xnode.h:67
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
void SetDoublePrecisionPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, double *aX, double *aY, const wxString &aActualConversion)

References PCAD2KICAD::FindNode(), XNODE::GetNext(), and PCAD2KICAD::SetDoublePrecisionPosition().

Referenced by PCAD2KICAD::PCB_FOOTPRINT::DoLayerContentsObjects(), PCAD2KICAD::PCB_KEEPOUT::Parse(), PCAD2KICAD::PCB_CUTOUT::Parse(), Parse(), PCAD2KICAD::PCB_COPPER_POUR::Parse(), and PCAD2KICAD::PCB_PLANE::Parse().

◆ GetKiCadLayer()

◆ GetNetCode()

int PCAD2KICAD::PCB_COMPONENT::GetNetCode ( const wxString &  aNetName) const
inlineinherited

◆ Parse()

bool PCAD2KICAD::PCB_POLYGON::Parse ( XNODE aNode,
const wxString &  aDefaultUnits,
const wxString &  aActualConversion 
)
virtual

Reimplemented in PCAD2KICAD::PCB_KEEPOUT, PCAD2KICAD::PCB_CUTOUT, PCAD2KICAD::PCB_COPPER_POUR, and PCAD2KICAD::PCB_PLANE.

Definition at line 130 of file pcb_polygon.cpp.

132{
133 XNODE* lNode;
134 wxString propValue;
135
136 lNode = FindNode( aNode, wxT( "netNameRef" ) );
137
138 if( lNode )
139 {
140 lNode->GetAttribute( wxT( "Name" ), &propValue );
141 propValue.Trim( false );
142 propValue.Trim( true );
143 m_net = propValue;
145 }
146
147 // retrieve polygon outline
148 FormPolygon( aNode, &m_outline, aDefaultUnits, aActualConversion );
149
150 m_positionX = m_outline[0]->x;
151 m_positionY = m_outline[0]->y;
152
153 // fill the polygon with the same contour as its outline is
154 m_islands.Add( new VERTICES_ARRAY );
155 FormPolygon( aNode, m_islands[0], aDefaultUnits, aActualConversion );
156
157 return true;
158}
void FormPolygon(XNODE *aNode, VERTICES_ARRAY *aPolygon, const wxString &aDefaultUnits, const wxString &actualConversion)

References PCAD2KICAD::FindNode(), FormPolygon(), PCAD2KICAD::PCB_COMPONENT::GetNetCode(), m_islands, PCAD2KICAD::PCB_COMPONENT::m_net, PCAD2KICAD::PCB_COMPONENT::m_netCode, m_outline, PCAD2KICAD::PCB_COMPONENT::m_positionX, and PCAD2KICAD::PCB_COMPONENT::m_positionY.

Referenced by PCAD2KICAD::PCB_FOOTPRINT::DoLayerContentsObjects().

◆ SetOutline()

void PCAD2KICAD::PCB_POLYGON::SetOutline ( VERTICES_ARRAY *  aOutline)

Definition at line 92 of file pcb_polygon.cpp.

93{
94 int i;
95
96 m_outline.Empty();
97
98 for( i = 0; i < (int) aOutline->GetCount(); i++ )
99 m_outline.Add( new wxRealPoint( (*aOutline)[i]->x, (*aOutline)[i]->y ) );
100
101 if( m_outline.Count() > 0 )
102 {
103 m_positionX = m_outline[0]->x;
104 m_positionY = m_outline[0]->y;
105 }
106}

References m_outline, PCAD2KICAD::PCB_COMPONENT::m_positionX, and PCAD2KICAD::PCB_COMPONENT::m_positionY.

Referenced by PCAD2KICAD::PCB_FOOTPRINT::DoLayerContentsObjects().

◆ SetPosOffset()

void PCAD2KICAD::PCB_POLYGON::SetPosOffset ( int  aX_offs,
int  aY_offs 
)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 245 of file pcb_polygon.cpp.

246{
247 int i, island;
248
249 PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
250
251 for( i = 0; i < (int) m_outline.GetCount(); i++ )
252 {
253 m_outline[i]->x += aX_offs;
254 m_outline[i]->y += aY_offs;
255 }
256
257 for( island = 0; island < (int) m_islands.GetCount(); island++ )
258 {
259 for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
260 {
261 (*m_islands[island])[i]->x += aX_offs;
262 (*m_islands[island])[i]->y += aY_offs;
263 }
264 }
265
266 for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
267 {
268 for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
269 {
270 (*m_cutouts[island])[i]->x += aX_offs;
271 (*m_cutouts[island])[i]->y += aY_offs;
272 }
273 }
274}
virtual void SetPosOffset(int aX_offs, int aY_offs)

References m_cutouts, m_islands, m_outline, and PCAD2KICAD::PCB_COMPONENT::SetPosOffset().

Member Data Documentation

◆ m_board

◆ m_callbacks

◆ m_compRef

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited

◆ m_cutouts

ISLANDS_ARRAY PCAD2KICAD::PCB_POLYGON::m_cutouts

◆ m_filled

bool PCAD2KICAD::PCB_POLYGON::m_filled
protected

◆ m_islands

ISLANDS_ARRAY PCAD2KICAD::PCB_POLYGON::m_islands

Definition at line 67 of file pcb_polygon.h.

Referenced by Parse(), SetPosOffset(), and ~PCB_POLYGON().

◆ m_KiCadLayer

◆ m_name

◆ m_net

◆ m_netCode

◆ m_objType

◆ m_outline

◆ m_patGraphRefName

wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited

◆ m_PCadLayer

◆ m_positionX

◆ m_positionY

◆ m_priority

int PCAD2KICAD::PCB_POLYGON::m_priority

Definition at line 65 of file pcb_polygon.h.

Referenced by AddToBoard(), PCAD2KICAD::PCB_PLANE::PCB_PLANE(), and PCB_POLYGON().

◆ m_rotation

◆ m_tag

int PCAD2KICAD::PCB_COMPONENT::m_tag
inherited

Definition at line 63 of file pcb_component.h.

Referenced by PCAD2KICAD::PCB_COMPONENT::PCB_COMPONENT().

◆ m_uuid

KIID PCAD2KICAD::PCB_COMPONENT::m_uuid
inherited

Definition at line 67 of file pcb_component.h.

◆ m_width

int PCAD2KICAD::PCB_POLYGON::m_width

The documentation for this class was generated from the following files: