KiCad PCB EDA Suite
PCAD2KICAD::PCB_CUTOUT Class Reference

#include <pcb_cutout.h>

Inheritance diagram for PCAD2KICAD::PCB_CUTOUT:
PCAD2KICAD::PCB_POLYGON PCAD2KICAD::PCB_COMPONENT

Public Member Functions

 PCB_CUTOUT (PCB_CALLBACKS *aCallbacks, BOARD *aBoard, int aPCadLayer)
 
 ~PCB_CUTOUT ()
 
virtual bool Parse (XNODE *aNode, wxString aDefaultMeasurementUnit, wxString aActualConversion) override
 
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 39 of file pcb_cutout.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file pcb_cutout.cpp.

References PCAD2KICAD::PCB_COMPONENT::m_objType.

37  :
38  PCB_POLYGON( aCallbacks, aBoard, aPCadLayer )
39 {
40  m_objType = wxT( 'C' );
41 }
PCB_POLYGON(PCB_CALLBACKS *aCallbacks, BOARD *aBoard, int aPCadLayer)
Definition: pcb_polygon.cpp:39
PCAD2KICAD::PCB_CUTOUT::~PCB_CUTOUT ( )

Definition at line 44 of file pcb_cutout.cpp.

45 {
46 }

Member Function Documentation

void PCAD2KICAD::PCB_POLYGON::AddToBoard ( )
overridevirtualinherited

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 163 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, PCAD2KICAD::PCB_POLYGON::m_outline, PCAD2KICAD::PCB_POLYGON::m_priority, PCAD2KICAD::PCB_COMPONENT::m_timestamp, PCAD2KICAD::PCB_POLYGON::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().

164 {
165  int i = 0;
166 
167  if( m_outline.GetCount() > 0 )
168  {
169  ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
170  m_board->Add( zone, ADD_APPEND );
171 
172  zone->SetTimeStamp( m_timestamp );
173  zone->SetLayer( m_KiCadLayer );
174  zone->SetNetCode( m_netCode );
175 
176  // add outline
177  int outline_hatch = ZONE_CONTAINER::DIAGONAL_EDGE;
178 
179  for( i = 0; i < (int) m_outline.GetCount(); i++ )
180  {
181  zone->AppendCorner( wxPoint( KiROUND( m_outline[i]->x ),
182  KiROUND( m_outline[i]->y ) ), -1 );
183  }
184 
185  zone->SetZoneClearance( m_width );
186 
187  zone->SetPriority( m_priority );
188 
189  zone->SetHatch( outline_hatch, zone->GetDefaultHatchPitch(), true );
190 
191  if ( m_objType == wxT( 'K' ) )
192  {
193  zone->SetIsKeepout( true );
194  zone->SetDoNotAllowTracks( true );
195  zone->SetDoNotAllowVias( true );
196  zone->SetDoNotAllowCopperPour( true );
197  }
198  else if( m_objType == wxT( 'C' ) )
199  {
200  // convert cutouts to keepouts because standalone cutouts are not supported in KiCad
201  zone->SetIsKeepout( true );
202  zone->SetDoNotAllowCopperPour( true );
203  }
204 
205  //if( m_filled )
206  // zone->BuildFilledPolysListData( m_board );
207  }
208 }
void SetDoNotAllowTracks(bool aEnable)
Definition: class_zone.h:610
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
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
void SetHatch(int aHatchStyle, int aHatchPitch, bool aRebuildHatch)
Function SetHatch sets all hatch parameters for the zone.
static int GetDefaultHatchPitch()
Function GetDefaultHatchPitchMils.
void SetDoNotAllowVias(bool aEnable)
Definition: class_zone.h:609
void SetPriority(unsigned aPriority)
Function SetPriority.
Definition: class_zone.h:95
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.
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
Definition: class_zone.cpp:205
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
void SetZoneClearance(int aZoneClearance)
Definition: class_zone.h:193
void SetDoNotAllowCopperPour(bool aEnable)
Definition: class_zone.h:608
bool AppendCorner(wxPoint aPosition, int aHoleIdx, bool aAllowDuplication=false)
Add a new corner to the zone outline (to the main outline or a hole)
void SetIsKeepout(bool aEnable)
Definition: class_zone.h:607
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:230
void PCAD2KICAD::PCB_POLYGON::AddToModule ( MODULE aModule)
overridevirtualinherited

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 158 of file pcb_polygon.cpp.

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

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(), Parse(), PCAD2KICAD::PCB_COPPER_POUR::Parse(), and PCAD2KICAD::PCB_POLYGON::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::GetNewTimestamp ( )
inlineinherited
bool PCAD2KICAD::PCB_CUTOUT::Parse ( XNODE aNode,
wxString  aDefaultMeasurementUnit,
wxString  aActualConversion 
)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_POLYGON.

Definition at line 49 of file pcb_cutout.cpp.

References PCAD2KICAD::FindNode(), PCAD2KICAD::PCB_POLYGON::FormPolygon(), PCAD2KICAD::PCB_POLYGON::m_outline, PCAD2KICAD::PCB_COMPONENT::m_positionX, and PCAD2KICAD::PCB_COMPONENT::m_positionY.

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

52 {
53  XNODE* lNode;
54 
55  lNode = FindNode( aNode, wxT( "pcbPoly" ) );
56 
57  if( lNode )
58  {
59  // retrieve cutout outline
60  FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
61 
62  m_positionX = m_outline[0]->x;
63  m_positionY = m_outline[0]->y;
64  }
65  else
66  {
67  return false;
68  }
69 
70  return true;
71 }
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
XNODE * FindNode(XNODE *aChild, wxString aTag)
void PCAD2KICAD::PCB_POLYGON::SetOutline ( VERTICES_ARRAY *  aOutline)
inherited

Definition at line 88 of file pcb_polygon.cpp.

References PCAD2KICAD::PCB_POLYGON::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 
)
overridevirtualinherited

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 211 of file pcb_polygon.cpp.

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

212 {
213  int i, island;
214 
215  PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
216 
217  for( i = 0; i < (int) m_outline.GetCount(); i++ )
218  {
219  m_outline[i]->x += aX_offs;
220  m_outline[i]->y += aY_offs;
221  }
222 
223  for( island = 0; island < (int) m_islands.GetCount(); island++ )
224  {
225  for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
226  {
227  (*m_islands[island])[i]->x += aX_offs;
228  (*m_islands[island])[i]->y += aY_offs;
229  }
230  }
231 
232  for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
233  {
234  for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
235  {
236  (*m_cutouts[island])[i]->x += aX_offs;
237  (*m_cutouts[island])[i]->y += aY_offs;
238  }
239  }
240 }
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
inherited
bool PCAD2KICAD::PCB_POLYGON::m_filled
protectedinherited
ISLANDS_ARRAY PCAD2KICAD::PCB_POLYGON::m_islands
inherited
wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited
int PCAD2KICAD::PCB_POLYGON::m_priority
inherited
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_POLYGON::m_width
inherited

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