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, wxString aDefaultMeasurementUnit, wxString aActualConversion, wxStatusBar *aStatusBar)
 
virtual void SetPosOffset (int aX_offs, int aY_offs) override
 
void AddToModule (MODULE *aModule) override
 
void AddToBoard () override
 
void AssignNet (wxString aNetName)
 
void SetOutline (VERTICES_ARRAY *aOutline)
 
void FormPolygon (XNODE *aNode, VERTICES_ARRAY *aPolygon, wxString aDefaultMeasurementUnit, wxString actualConversion)
 
virtual void Flip ()
 
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

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

Definition at line 52 of file pcb_polygon.cpp.

References m_cutouts, m_islands, and m_outline.

53 {
54  int i, island;
55 
56  for( i = 0; i < (int) m_outline.GetCount(); i++ )
57  {
58  delete m_outline[i];
59  }
60 
61  for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
62  {
63  for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
64  {
65  delete (*m_cutouts[island])[i];
66  }
67 
68  delete m_cutouts[island];
69  }
70 
71  for( island = 0; island < (int) m_islands.GetCount(); island++ )
72  {
73  for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
74  {
75  delete (*m_islands[island])[i];
76  }
77 
78  delete m_islands[island];
79  }
80 }
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

Member Function Documentation

void PCAD2KICAD::PCB_POLYGON::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 166 of file pcb_polygon.cpp.

References BOARD::Add(), ADD_APPEND, ZONE_CONTAINER::AppendCorner(), ZONE_CONTAINER::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(), BOARD_ITEM::SetLayer(), BOARD_CONNECTED_ITEM::SetNetCode(), ZONE_CONTAINER::SetPriority(), EDA_ITEM::SetTimeStamp(), and ZONE_CONTAINER::SetZoneClearance().

167 {
168  int i = 0;
169 
170  if( m_outline.GetCount() > 0 )
171  {
172  ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
173  m_board->Add( zone, ADD_APPEND );
174 
175  zone->SetTimeStamp( m_timestamp );
176  zone->SetLayer( m_KiCadLayer );
177  zone->SetNetCode( m_netCode );
178 
179  // add outline
180  int outline_hatch = ZONE_CONTAINER::DIAGONAL_EDGE;
181 
182  for( i = 0; i < (int) m_outline.GetCount(); i++ )
183  {
184  zone->AppendCorner( wxPoint( KiROUND( m_outline[i]->x ),
185  KiROUND( m_outline[i]->y ) ), -1 );
186  }
187 
188  zone->SetZoneClearance( m_width );
189 
190  zone->SetPriority( m_priority );
191 
192  zone->SetHatch( outline_hatch, zone->GetDefaultHatchPitch(), true );
193 
194  if ( m_objType == wxT( 'K' ) )
195  {
196  zone->SetIsKeepout( true );
197  zone->SetDoNotAllowTracks( true );
198  zone->SetDoNotAllowVias( true );
199  zone->SetDoNotAllowCopperPour( true );
200  }
201  else if( m_objType == wxT( 'C' ) )
202  {
203  // convert cutouts to keepouts because standalone cutouts are not supported in KiCad
204  zone->SetIsKeepout( true );
205  zone->SetDoNotAllowCopperPour( true );
206  }
207 
208  //if( m_filled )
209  // zone->BuildFilledPolysListData( m_board );
210  }
211 }
void SetDoNotAllowTracks(bool aEnable)
Definition: class_zone.h:662
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetHatch(int aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
Definition: class_zone.cpp:926
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
void SetDoNotAllowVias(bool aEnable)
Definition: class_zone.h:661
void SetPriority(unsigned aPriority)
Function SetPriority.
Definition: class_zone.h:113
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:47
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
void SetZoneClearance(int aZoneClearance)
Definition: class_zone.h:204
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:660
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:852
void SetIsKeepout(bool aEnable)
Definition: class_zone.h:659
void PCAD2KICAD::PCB_POLYGON::AddToModule ( MODULE aModule)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 161 of file pcb_polygon.cpp.

162 {
163 }
void PCAD2KICAD::PCB_POLYGON::AssignNet ( wxString  aNetName)
void PCAD2KICAD::PCB_COMPONENT::Flip ( )
virtualinherited
void PCAD2KICAD::PCB_POLYGON::FormPolygon ( XNODE aNode,
VERTICES_ARRAY *  aPolygon,
wxString  aDefaultMeasurementUnit,
wxString  actualConversion 
)

Definition at line 104 of file pcb_polygon.cpp.

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().

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

Definition at line 74 of file pcb_component.h.

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

Referenced by PCB_POLYGON().

74 { return m_callbacks->GetNewTimestamp(); }
virtual int GetNewTimestamp()=0
PCB_CALLBACKS * m_callbacks
Definition: pcb_component.h:78
bool PCAD2KICAD::PCB_POLYGON::Parse ( XNODE aNode,
wxString  aDefaultMeasurementUnit,
wxString  aActualConversion,
wxStatusBar *  aStatusBar 
)
virtual

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

Definition at line 126 of file pcb_polygon.cpp.

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().

130 {
131  XNODE* lNode;
132  wxString propValue;
133 
134  // aStatusBar->SetStatusText( aStatusBar->GetStatusText() + wxT( " Polygon..." ) );
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, aDefaultMeasurementUnit, 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], aDefaultMeasurementUnit, aActualConversion );
156 
157  return true;
158 }
void FormPolygon(XNODE *aNode, VERTICES_ARRAY *aPolygon, wxString aDefaultMeasurementUnit, wxString actualConversion)
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:47
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
ISLANDS_ARRAY m_islands
Definition: pcb_polygon.h:48
XNODE * FindNode(XNODE *aChild, wxString aTag)
int GetNetCode(wxString aNetName)
Definition: pcb_component.h:75
void PCAD2KICAD::PCB_POLYGON::SetOutline ( VERTICES_ARRAY *  aOutline)

Definition at line 88 of file pcb_polygon.cpp.

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

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

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

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 214 of file pcb_polygon.cpp.

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

215 {
216  int i, island;
217 
218  PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
219 
220  for( i = 0; i < (int) m_outline.GetCount(); i++ )
221  {
222  m_outline[i]->x += aX_offs;
223  m_outline[i]->y += aY_offs;
224  }
225 
226  for( island = 0; island < (int) m_islands.GetCount(); island++ )
227  {
228  for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
229  {
230  (*m_islands[island])[i]->x += aX_offs;
231  (*m_islands[island])[i]->y += aY_offs;
232  }
233  }
234 
235  for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
236  {
237  for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
238  {
239  (*m_cutouts[island])[i]->x += aX_offs;
240  (*m_cutouts[island])[i]->y += aY_offs;
241  }
242  }
243 }
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

Member Data Documentation

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited
ISLANDS_ARRAY PCAD2KICAD::PCB_POLYGON::m_cutouts
bool PCAD2KICAD::PCB_POLYGON::m_filled
protected
ISLANDS_ARRAY PCAD2KICAD::PCB_POLYGON::m_islands

Definition at line 48 of file pcb_polygon.h.

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

wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited
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().

int PCAD2KICAD::PCB_COMPONENT::m_tag
inherited

Definition at line 51 of file pcb_component.h.

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

int PCAD2KICAD::PCB_COMPONENT::m_timestamp
inherited
int PCAD2KICAD::PCB_POLYGON::m_width

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