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 AddToModule (MODULE *aModule) 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 ()
 
int GetNewTimestamp ()
 
int GetNetCode (wxString aNetName)
 

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
 
int m_timestamp
 
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 42 of file pcb_polygon.h.

Constructor & Destructor Documentation

◆ PCB_POLYGON()

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

◆ ~PCB_POLYGON()

PCAD2KICAD::PCB_POLYGON::~PCB_POLYGON ( )

Definition at line 53 of file pcb_polygon.cpp.

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

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

185 {
186  int i = 0;
187 
188  if( m_outline.GetCount() > 0 )
189  {
190  ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
191  m_board->Add( zone, ADD_MODE::APPEND );
192 
193  zone->SetTimeStamp( m_timestamp );
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( wxPoint( KiROUND( m_outline[i]->x ),
201  KiROUND( m_outline[i]->y ) ), -1 );
202  }
203 
204  zone->SetZoneClearance( m_width );
205 
206  zone->SetPriority( m_priority );
207 
209 
210  if ( m_objType == wxT( 'K' ) )
211  {
212  zone->SetIsKeepout( true );
213  zone->SetDoNotAllowTracks( true );
214  zone->SetDoNotAllowVias( true );
215  zone->SetDoNotAllowCopperPour( true );
216  }
217  else if( m_objType == wxT( 'C' ) )
218  {
219  // convert cutouts to keepouts because standalone cutouts are not supported in KiCad
220  zone->SetIsKeepout( true );
221  zone->SetDoNotAllowCopperPour( true );
222  }
223 
224  //if( m_filled )
225  // zone->BuildFilledPolysListData( m_board );
226  }
227 }
void SetDoNotAllowTracks(bool aEnable)
Definition: class_zone.h:639
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
void SetHatch(ZONE_HATCH_STYLE aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
Definition: class_zone.cpp:958
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
void SetDoNotAllowVias(bool aEnable)
Definition: class_zone.h:638
void SetPriority(unsigned aPriority)
Function SetPriority.
Definition: class_zone.h:94
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:47
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:231
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Sets net using a net code.
void SetZoneClearance(int aZoneClearance)
Definition: class_zone.h:177
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:637
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:61
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: class_zone.cpp:915
void SetIsKeepout(bool aEnable)
Definition: class_zone.h:636
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:212

References BOARD::Add(), APPEND, ZONE_CONTAINER::AppendCorner(), DIAGONAL_EDGE, ZONE_CONTAINER::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, PCAD2KICAD::PCB_COMPONENT::m_timestamp, m_width, ZONE_CONTAINER::SetDoNotAllowCopperPour(), ZONE_CONTAINER::SetDoNotAllowTracks(), ZONE_CONTAINER::SetDoNotAllowVias(), ZONE_CONTAINER::SetHatch(), ZONE_CONTAINER::SetIsKeepout(), ZONE_CONTAINER::SetLayer(), BOARD_CONNECTED_ITEM::SetNetCode(), ZONE_CONTAINER::SetPriority(), EDA_ITEM::SetTimeStamp(), and ZONE_CONTAINER::SetZoneClearance().

◆ AddToModule()

void PCAD2KICAD::PCB_POLYGON::AddToModule ( MODULE aModule)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 160 of file pcb_polygon.cpp.

161 {
163  {
164  EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON );
165  aModule->Add( dwg );
166 
167  dwg->SetWidth( 0 );
168  dwg->SetLayer( m_KiCadLayer );
169 
170  auto outline = new std::vector<wxPoint>;
171  for( auto point : m_outline )
172  outline->push_back( wxPoint( point->x, point->y ) );
173 
174  dwg->SetPolyPoints( *outline );
175  dwg->SetStart0( *outline->begin() );
176  dwg->SetEnd0( outline->back() );
177  dwg->SetDrawCoord();
178 
179  delete( outline );
180  }
181 }
void SetEnd0(const wxPoint &aPoint)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
polygon (not yet used for tracks, but could be in microwave apps)
bool IsNonCopperLayer(LAYER_NUM aLayerId)
Function IsNonCopperLayer tests whether a layer is a non copper layer.
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:47
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
void SetStart0(const wxPoint &aPoint)
void SetWidth(int aWidth)

References MODULE::Add(), IsNonCopperLayer(), PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, m_outline, S_POLYGON, EDGE_MODULE::SetDrawCoord(), EDGE_MODULE::SetEnd0(), BOARD_ITEM::SetLayer(), DRAWSEGMENT::SetPolyPoints(), EDGE_MODULE::SetStart0(), and DRAWSEGMENT::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 230 of file pcb_polygon.cpp.

231 {
233 
235 }
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:485

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

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

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

Referenced by PCAD2KICAD::PCB_MODULE::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)
inlineinherited

◆ GetNewTimestamp()

int PCAD2KICAD::PCB_COMPONENT::GetNewTimestamp ( )
inlineinherited

Definition at line 74 of file pcb_component.h.

74 { return m_callbacks->GetNewTimestamp(); }
virtual int GetNewTimestamp()=0
PCB_CALLBACKS * m_callbacks
Definition: pcb_component.h:78

References PCAD2KICAD::PCB_CALLBACKS::GetNewTimestamp(), and PCAD2KICAD::PCB_COMPONENT::m_callbacks.

Referenced by PCB_POLYGON().

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

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

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_MODULE::DoLayerContentsObjects().

◆ SetOutline()

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

Definition at line 89 of file pcb_polygon.cpp.

90 {
91  int i;
92 
93  m_outline.Empty();
94 
95  for( i = 0; i < (int) aOutline->GetCount(); i++ )
96  m_outline.Add( new wxRealPoint( (*aOutline)[i]->x, (*aOutline)[i]->y ) );
97 
98  if( m_outline.Count() > 0 )
99  {
100  m_positionX = m_outline[0]->x;
101  m_positionY = m_outline[0]->y;
102  }
103 }
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:47

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

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

◆ SetPosOffset()

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

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 238 of file pcb_polygon.cpp.

239 {
240  int i, island;
241 
242  PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
243 
244  for( i = 0; i < (int) m_outline.GetCount(); i++ )
245  {
246  m_outline[i]->x += aX_offs;
247  m_outline[i]->y += aY_offs;
248  }
249 
250  for( island = 0; island < (int) m_islands.GetCount(); island++ )
251  {
252  for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
253  {
254  (*m_islands[island])[i]->x += aX_offs;
255  (*m_islands[island])[i]->y += aY_offs;
256  }
257  }
258 
259  for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
260  {
261  for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
262  {
263  (*m_cutouts[island])[i]->x += aX_offs;
264  (*m_cutouts[island])[i]->y += aY_offs;
265  }
266  }
267 }
ISLANDS_ARRAY m_cutouts
Definition: pcb_polygon.h:49
virtual void SetPosOffset(int aX_offs, int aY_offs)
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:47
ISLANDS_ARRAY m_islands
Definition: pcb_polygon.h:48

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 48 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 46 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 51 of file pcb_component.h.

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

◆ m_timestamp

int PCAD2KICAD::PCB_COMPONENT::m_timestamp
inherited

◆ m_width

int PCAD2KICAD::PCB_POLYGON::m_width

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