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 &aDefaultMeasurementUnit, 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 &aDefaultMeasurementUnit, const wxString &actualConversion)
 
PCB_LAYER_ID GetKiCadLayer () const
 
int GetNetCode (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
 
int 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 41 of file pcb_polygon.cpp.

41  :
42  PCB_COMPONENT( aCallbacks, aBoard )
43 {
44  m_width = 0;
45 
46  // P-CAD polygons are similar to zones (and we're going to convert them as such), except
47  // that they don't avoid other copper pours. So effectively they're very-high-priority
48  // zones.
49  m_priority = 100000;
50 
51  m_objType = wxT( 'Z' );
52  m_PCadLayer = aPCadLayer;
54  m_filled = true;
55 }
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 58 of file pcb_polygon.cpp.

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

190 {
191  int i = 0;
192 
193  if( m_outline.GetCount() > 0 )
194  {
195  ZONE* zone = new ZONE( m_board );
196  m_board->Add( zone, ADD_MODE::APPEND );
197 
198  zone->SetLayer( m_KiCadLayer );
199  zone->SetNetCode( m_netCode );
200 
201  // add outline
202  for( i = 0; i < (int) m_outline.GetCount(); i++ )
203  {
204  zone->AppendCorner( wxPoint( KiROUND( m_outline[i]->x ),
205  KiROUND( m_outline[i]->y ) ), -1 );
206  }
207 
208  zone->SetLocalClearance( m_width );
209 
210  zone->SetPriority( m_priority );
211 
213  zone->GetDefaultHatchPitch(), true );
214 
215  if ( m_objType == wxT( 'K' ) )
216  {
217  zone->SetIsRuleArea( true );
218  zone->SetDoNotAllowTracks( true );
219  zone->SetDoNotAllowVias( true );
220  zone->SetDoNotAllowPads( true );
221  zone->SetDoNotAllowCopperPour( true );
222  zone->SetDoNotAllowFootprints( false );
223  }
224  else if( m_objType == wxT( 'C' ) )
225  {
226  // convert cutouts to keepouts because standalone cutouts are not supported in KiCad
227  zone->SetIsRuleArea( true );
228  zone->SetDoNotAllowCopperPour( true );
229  zone->SetDoNotAllowTracks( false );
230  zone->SetDoNotAllowVias( false );
231  zone->SetDoNotAllowPads( false );
232  zone->SetDoNotAllowFootprints( false );
233  }
234 
235  //if( m_filled )
236  // zone->BuildFilledPolysListData( m_board );
237  }
238 }
void SetDoNotAllowTracks(bool aEnable)
Definition: zone.h:742
void SetBorderDisplayStyle(ZONE_BORDER_DISPLAY_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Set all hatch parameters for the zone.
Definition: zone.cpp:898
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
void SetPriority(unsigned aPriority)
Definition: zone.h:117
void SetIsRuleArea(bool aEnable)
Definition: zone.h:739
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:606
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:66
static int GetDefaultHatchPitch()
Definition: zone.cpp:1092
void SetDoNotAllowPads(bool aEnable)
Definition: zone.h:743
void SetDoNotAllowVias(bool aEnable)
Definition: zone.h:741
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
Definition: zone.cpp:838
void SetDoNotAllowCopperPour(bool aEnable)
Definition: zone.h:740
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:70
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: zone.cpp:238
void SetLocalClearance(int aClearance)
Definition: zone.h:158
void SetDoNotAllowFootprints(bool aEnable)
Definition: zone.h:744

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::SetBorderDisplayStyle(), ZONE::SetDoNotAllowCopperPour(), ZONE::SetDoNotAllowFootprints(), ZONE::SetDoNotAllowPads(), ZONE::SetDoNotAllowTracks(), ZONE::SetDoNotAllowVias(), ZONE::SetIsRuleArea(), ZONE::SetLayer(), ZONE::SetLocalClearance(), BOARD_CONNECTED_ITEM::SetNetCode(), and ZONE::SetPriority().

◆ AddToFootprint()

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

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 165 of file pcb_polygon.cpp.

166 {
168  {
169  FP_SHAPE* dwg = new FP_SHAPE( aFootprint, PCB_SHAPE_TYPE::POLYGON );
170  aFootprint->Add( dwg );
171 
172  dwg->SetWidth( 0 );
173  dwg->SetLayer( m_KiCadLayer );
174 
175  auto outline = new std::vector<wxPoint>;
176  for( auto point : m_outline )
177  outline->push_back( wxPoint( point->x, point->y ) );
178 
179  dwg->SetPolyPoints( *outline );
180  dwg->SetStart0( *outline->begin() );
181  dwg->SetEnd0( outline->back() );
182  dwg->SetDrawCoord();
183 
184  delete( outline );
185  }
186 }
void SetEnd0(const wxPoint &aPoint)
Definition: fp_shape.h:114
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
bool IsNonCopperLayer(LAYER_NUM aLayerId)
Test whether a layer is a non copper layer.
polygon (not yet used for tracks, but could be in microwave apps)
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:66
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:82
void SetStart0(const wxPoint &aPoint)
Definition: fp_shape.h:111
void SetWidth(int aWidth)
Definition: pcb_shape.h:96
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:472
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
Definition: pcb_shape.cpp:1103

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

◆ AssignNet()

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

◆ Flip()

void PCAD2KICAD::PCB_POLYGON::Flip ( )
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 241 of file pcb_polygon.cpp.

242 {
244 
246 }
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:521

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 &  aDefaultMeasurementUnit,
const wxString &  actualConversion 
)

Definition at line 110 of file pcb_polygon.cpp.

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

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

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

◆ GetKiCadLayer()

◆ GetNetCode()

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

◆ Parse()

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

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

Definition at line 133 of file pcb_polygon.cpp.

136 {
137  XNODE* lNode;
138  wxString propValue;
139 
140  lNode = FindNode( aNode, wxT( "netNameRef" ) );
141 
142  if( lNode )
143  {
144  lNode->GetAttribute( wxT( "Name" ), &propValue );
145  propValue.Trim( false );
146  propValue.Trim( true );
147  m_net = propValue;
149  }
150 
151  // retrieve polygon outline
152  FormPolygon( aNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
153 
154  m_positionX = m_outline[0]->x;
155  m_positionY = m_outline[0]->y;
156 
157  // fill the polygon with the same contour as its outline is
158  m_islands.Add( new VERTICES_ARRAY );
159  FormPolygon( aNode, m_islands[0], aDefaultMeasurementUnit, aActualConversion );
160 
161  return true;
162 }
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:66
int GetNetCode(wxString aNetName) const
Definition: pcb_component.h:57
Hold an XML or S-expression element.
Definition: xnode.h:43
ISLANDS_ARRAY m_islands
Definition: pcb_polygon.h:67
void FormPolygon(XNODE *aNode, VERTICES_ARRAY *aPolygon, const wxString &aDefaultMeasurementUnit, const wxString &actualConversion)
XNODE * FindNode(XNODE *aChild, const wxString &aTag)

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 94 of file pcb_polygon.cpp.

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

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 249 of file pcb_polygon.cpp.

250 {
251  int i, island;
252 
253  PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
254 
255  for( i = 0; i < (int) m_outline.GetCount(); i++ )
256  {
257  m_outline[i]->x += aX_offs;
258  m_outline[i]->y += aY_offs;
259  }
260 
261  for( island = 0; island < (int) m_islands.GetCount(); island++ )
262  {
263  for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
264  {
265  (*m_islands[island])[i]->x += aX_offs;
266  (*m_islands[island])[i]->y += aY_offs;
267  }
268  }
269 
270  for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
271  {
272  for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
273  {
274  (*m_cutouts[island])[i]->x += aX_offs;
275  (*m_cutouts[island])[i]->y += aY_offs;
276  }
277  }
278 }
ISLANDS_ARRAY m_cutouts
Definition: pcb_polygon.h:68
virtual void SetPosOffset(int aX_offs, int aY_offs)
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:66
ISLANDS_ARRAY m_islands
Definition: pcb_polygon.h:67

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 59 of file pcb_component.h.

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

◆ m_uuid

KIID PCAD2KICAD::PCB_COMPONENT::m_uuid
inherited

Definition at line 63 of file pcb_component.h.

◆ m_width

int PCAD2KICAD::PCB_POLYGON::m_width

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