KiCad PCB EDA Suite
PCAD2KICAD::PCB_PLANE Class Reference

#include <pcb_plane.h>

Inheritance diagram for PCAD2KICAD::PCB_PLANE:
PCAD2KICAD::PCB_POLYGON PCAD2KICAD::PCB_COMPONENT

Public Member Functions

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

Constructor & Destructor Documentation

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

Definition at line 38 of file pcb_plane.cpp.

References PCAD2KICAD::PCB_POLYGON::m_priority.

40  :
41  PCB_POLYGON( aCallbacks, aBoard, aPCadLayer )
42 {
43  m_priority = 1;
44 }
PCB_POLYGON(PCB_CALLBACKS *aCallbacks, BOARD *aBoard, int aPCadLayer)
Definition: pcb_polygon.cpp:39
PCAD2KICAD::PCB_PLANE::~PCB_PLANE ( )

Definition at line 47 of file pcb_plane.cpp.

48 {
49 }

Member Function Documentation

void PCAD2KICAD::PCB_POLYGON::AddToBoard ( )
overridevirtualinherited

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 183 of file pcb_polygon.cpp.

References BOARD::Add(), ADD_APPEND, ZONE_CONTAINER::AppendCorner(), ZONE_CONTAINER::DIAGONAL_EDGE, ZONE_CONTAINER::GetDefaultHatchPitch(), i, 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().

184 {
185  int i = 0;
186 
187  if( m_outline.GetCount() > 0 )
188  {
189  ZONE_CONTAINER* zone = new ZONE_CONTAINER( m_board );
190  m_board->Add( zone, ADD_APPEND );
191 
192  zone->SetTimeStamp( m_timestamp );
193  zone->SetLayer( m_KiCadLayer );
194  zone->SetNetCode( m_netCode );
195 
196  // add outline
197  int outline_hatch = ZONE_CONTAINER::DIAGONAL_EDGE;
198 
199  for( i = 0; i < (int) m_outline.GetCount(); i++ )
200  {
201  zone->AppendCorner( wxPoint( KiROUND( m_outline[i]->x ),
202  KiROUND( m_outline[i]->y ) ), -1 );
203  }
204 
205  zone->SetZoneClearance( m_width );
206 
207  zone->SetPriority( m_priority );
208 
209  zone->SetHatch( outline_hatch, zone->GetDefaultHatchPitch(), true );
210 
211  if ( m_objType == wxT( 'K' ) )
212  {
213  zone->SetIsKeepout( true );
214  zone->SetDoNotAllowTracks( true );
215  zone->SetDoNotAllowVias( true );
216  zone->SetDoNotAllowCopperPour( true );
217  }
218  else if( m_objType == wxT( 'C' ) )
219  {
220  // convert cutouts to keepouts because standalone cutouts are not supported in KiCad
221  zone->SetIsKeepout( true );
222  zone->SetDoNotAllowCopperPour( true );
223  }
224 
225  //if( m_filled )
226  // zone->BuildFilledPolysListData( m_board );
227  }
228 }
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)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:106
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:202
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
size_t i
Definition: json11.cpp:597
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:214
void PCAD2KICAD::PCB_POLYGON::AddToModule ( MODULE aModule)
overridevirtualinherited

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 159 of file pcb_polygon.cpp.

References MODULE::GraphicalItemsList(), IsNonCopperLayer(), PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_POLYGON::m_outline, DLIST< T >::PushBack(), S_POLYGON, EDGE_MODULE::SetDrawCoord(), EDGE_MODULE::SetEnd0(), BOARD_ITEM::SetLayer(), DRAWSEGMENT::SetPolyPoints(), EDGE_MODULE::SetStart0(), and DRAWSEGMENT::SetWidth().

160 {
162  {
163  EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_POLYGON );
164  aModule->GraphicalItemsList().PushBack( dwg );
165 
166  dwg->SetWidth( 0 );
167  dwg->SetLayer( m_KiCadLayer );
168 
169  auto outline = new std::vector<wxPoint>;
170  for( auto point : m_outline )
171  outline->push_back( wxPoint( point->x, point->y ) );
172 
173  dwg->SetPolyPoints( *outline );
174  dwg->SetStart0( *outline->begin() );
175  dwg->SetEnd0( outline->back() );
176  dwg->SetDrawCoord();
177 
178  delete( outline );
179  }
180 }
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.
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:47
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
void SetStart0(const wxPoint &aPoint)
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
void SetWidth(int aWidth)
void PCAD2KICAD::PCB_POLYGON::AssignNet ( const wxString &  aNetName)
inherited
void PCAD2KICAD::PCB_POLYGON::Flip ( )
overridevirtualinherited

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 231 of file pcb_polygon.cpp.

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

232 {
234 
236 }
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:472
void PCAD2KICAD::PCB_POLYGON::FormPolygon ( XNODE aNode,
VERTICES_ARRAY *  aPolygon,
const wxString &  aDefaultMeasurementUnit,
const 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(), Parse(), PCAD2KICAD::PCB_CUTOUT::Parse(), PCAD2KICAD::PCB_COPPER_POUR::Parse(), and PCAD2KICAD::PCB_POLYGON::Parse().

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

Reimplemented from PCAD2KICAD::PCB_POLYGON.

Definition at line 52 of file pcb_plane.cpp.

References PCAD2KICAD::FindNode(), PCAD2KICAD::PCB_POLYGON::FormPolygon(), PCAD2KICAD::PCB_COMPONENT::GetNetCode(), PCAD2KICAD::PCB_COMPONENT::m_net, PCAD2KICAD::PCB_COMPONENT::m_netCode, PCAD2KICAD::PCB_POLYGON::m_outline, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, PCAD2KICAD::PCB_POLYGON::m_width, PCAD2KICAD::SetWidth(), and str.

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

55 {
56  XNODE* lNode;
57  wxString pourType, str, propValue;
58 
59  lNode = FindNode( aNode, wxT( "netNameRef" ) );
60 
61  if( lNode )
62  {
63  lNode->GetAttribute( wxT( "Name" ), &propValue );
64  propValue.Trim( false );
65  propValue.Trim( true );
66  m_net = propValue;
68  }
69 
70  if( FindNode( aNode, wxT( "width" ) ) )
71  SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
72  aDefaultMeasurementUnit, &m_width, aActualConversion );
73 
74  lNode = FindNode( aNode, wxT( "pcbPoly" ) );
75 
76  if( lNode )
77  {
78  // retrieve plane outline
79  FormPolygon( lNode, &m_outline, aDefaultMeasurementUnit, aActualConversion );
80 
81  m_positionX = m_outline[0]->x;
82  m_positionY = m_outline[0]->y;
83  }
84  else
85  {
86  return false;
87  }
88 
89  return true;
90 }
void SetWidth(wxString aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
const string & str
Definition: json11.cpp:596
VERTICES_ARRAY m_outline
Definition: pcb_polygon.h:47
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
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
void PCAD2KICAD::PCB_POLYGON::SetOutline ( VERTICES_ARRAY *  aOutline)
inherited

Definition at line 88 of file pcb_polygon.cpp.

References i, 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
size_t i
Definition: json11.cpp:597
void PCAD2KICAD::PCB_POLYGON::SetPosOffset ( int  aX_offs,
int  aY_offs 
)
overridevirtualinherited

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 239 of file pcb_polygon.cpp.

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

240 {
241  int i, island;
242 
243  PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
244 
245  for( i = 0; i < (int) m_outline.GetCount(); i++ )
246  {
247  m_outline[i]->x += aX_offs;
248  m_outline[i]->y += aY_offs;
249  }
250 
251  for( island = 0; island < (int) m_islands.GetCount(); island++ )
252  {
253  for( i = 0; i < (int) m_islands[island]->GetCount(); i++ )
254  {
255  (*m_islands[island])[i]->x += aX_offs;
256  (*m_islands[island])[i]->y += aY_offs;
257  }
258  }
259 
260  for( island = 0; island < (int) m_cutouts.GetCount(); island++ )
261  {
262  for( i = 0; i < (int) m_cutouts[island]->GetCount(); i++ )
263  {
264  (*m_cutouts[island])[i]->x += aX_offs;
265  (*m_cutouts[island])[i]->y += aY_offs;
266  }
267  }
268 }
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
size_t i
Definition: json11.cpp:597

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: