KiCad PCB EDA Suite
PCAD2KICAD::PCB_VIA Class Reference

#include <pcb_via.h>

Inheritance diagram for PCAD2KICAD::PCB_VIA:
PCAD2KICAD::PCB_PAD PCAD2KICAD::PCB_COMPONENT

Public Member Functions

 PCB_VIA (PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
 
 ~PCB_VIA ()
 
virtual void Parse (XNODE *aNode, wxString aDefaultMeasurementUnit, wxString aActualConversion) override
 
virtual void Flip () override
 
void AddToModule (MODULE *aModule, int aRotation, bool aEncapsulatedPad)
 
virtual void AddToModule (MODULE *aModule)
 
void AddToBoard () override
 
virtual void SetPosOffset (int aX_offs, int aY_offs)
 
LAYER_ID GetKiCadLayer ()
 
int GetNewTimestamp ()
 
int GetNetCode (wxString aNetName)
 

Public Attributes

int m_number
 
int m_hole
 
bool m_isHolePlated
 
PCB_PAD_SHAPES_ARRAY m_shapes
 
int m_tag
 
char m_objType
 
int m_PCadLayer
 
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

PCB_CALLBACKSm_callbacks
 
BOARDm_board
 

Detailed Description

Definition at line 40 of file pcb_via.h.

Constructor & Destructor Documentation

PCAD2KICAD::PCB_VIA::PCB_VIA ( PCB_CALLBACKS aCallbacks,
BOARD aBoard 
)

Definition at line 38 of file pcb_via.cpp.

References PCAD2KICAD::PCB_COMPONENT::m_objType.

38  : PCB_PAD( aCallbacks, aBoard )
39 {
40  m_objType = wxT( 'V' );
41 }
PCB_PAD(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
Definition: pcb_pad.cpp:38
PCAD2KICAD::PCB_VIA::~PCB_VIA ( )

Definition at line 44 of file pcb_via.cpp.

45 {
46 }

Member Function Documentation

void PCAD2KICAD::PCB_PAD::AddToBoard ( )
overridevirtualinherited

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 301 of file pcb_pad.cpp.

References BOARD::Add(), ADD_APPEND, PCAD2KICAD::PCB_PAD::AddToModule(), DLIST< T >::Append(), B_Cu, F_Cu, IsCopperLayer(), PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_PAD::m_defaultPinDes, PCAD2KICAD::PCB_PAD_SHAPE::m_height, PCAD2KICAD::PCB_PAD::m_hole, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_netCode, PCAD2KICAD::PCB_COMPONENT::m_objType, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, PCAD2KICAD::PCB_PAD::m_shapes, BOARD::m_Track, PCAD2KICAD::PCB_PAD_SHAPE::m_width, VIA::SetDrill(), TRACK::SetEnd(), BOARD_ITEM::SetLayer(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), MODULE::SetPosition(), VIA::SetPosition(), EDA_ITEM::SetTimeStamp(), VIA::SetViaType(), TRACK::SetWidth(), PCAD2KICAD::_TTEXTVALUE::text, and VIA_THROUGH.

302 {
303  PCB_PAD_SHAPE* padShape;
304  int i;
305  int width = 0;
306  int height = 0;
307 
308  if( m_objType == wxT( 'V' ) ) // via
309  {
310  // choose one of the shapes
311  for( i = 0; i < (int) m_shapes.GetCount(); i++ )
312  {
313  padShape = m_shapes[i];
314 
315  if( padShape->m_width > 0 && padShape->m_height > 0 )
316  {
317  if( padShape->m_KiCadLayer == F_Cu
318  || padShape->m_KiCadLayer == B_Cu )
319  {
320  width = padShape->m_width;
321  height = padShape->m_height;
322 
323  break;
324  }
325  }
326  }
327 
328  if( width == 0 || height == 0 )
329  return;
330 
331  if( IsCopperLayer( m_KiCadLayer ) )
332  {
333  VIA* via = new VIA( m_board );
334  m_board->m_Track.Append( via );
335 
336  via->SetTimeStamp( 0 );
337 
340 
341  via->SetWidth( height );
342  via->SetViaType( VIA_THROUGH );
343  via->SetLayerPair( F_Cu, B_Cu );
344  via->SetDrill( m_hole );
345 
346  via->SetLayer( m_KiCadLayer );
347  via->SetNetCode( m_netCode );
348  }
349  }
350  else // pad
351  {
352  MODULE* module = new MODULE( m_board );
353  m_board->Add( module, ADD_APPEND );
354 
356 
358  AddToModule( module, 0, true );
359 
360  }
361 }
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:443
void SetPosition(const wxPoint &aPoint) override
Definition: class_track.h:416
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:116
void Append(T *aNewElement)
Function Append adds aNewElement to the end of the list.
Definition: dlist.h:177
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
void SetWidth(int aWidth)
Definition: class_track.h:113
void SetLayerPair(LAYER_ID aTopLayer, LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_Layer contains the top layer, the other layer is in m_BottomLayer...
void AddToModule(MODULE *aModule, int aRotation, bool aEncapsulatedPad)
Definition: pcb_pad.cpp:187
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
>
wxString m_defaultPinDes
Definition: pcb_pad.h:59
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
void SetPosition(const wxPoint &aPos) override
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:450
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
PCB_PAD_SHAPES_ARRAY m_shapes
Definition: pcb_pad.h:46
DLIST< TRACK > m_Track
Definition: class_board.h:244
void PCAD2KICAD::PCB_PAD::AddToModule ( MODULE aModule,
int  aRotation,
bool  aEncapsulatedPad 
)
inherited

Definition at line 187 of file pcb_pad.cpp.

References BOARD::Add(), LSET::AllCuMask(), B_Cu, B_Mask, B_Paste, F_Cu, F_Mask, F_Paste, BOARD::FindNet(), NETINFO_ITEM::GetNet(), MODULE::GetOrientation(), MODULE::GetPosition(), PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_PAD_SHAPE::m_height, PCAD2KICAD::PCB_PAD::m_hole, PCAD2KICAD::PCB_PAD::m_isHolePlated, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_net, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, PCAD2KICAD::PCB_COMPONENT::m_rotation, PCAD2KICAD::PCB_PAD_SHAPE::m_shape, PCAD2KICAD::PCB_PAD::m_shapes, PCAD2KICAD::PCB_PAD_SHAPE::m_width, PAD_ATTRIB_HOLE_NOT_PLATED, PAD_ATTRIB_SMD, PAD_ATTRIB_STANDARD, PAD_DRILL_SHAPE_CIRCLE, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, MODULE::Pads(), DLIST< T >::PushBack(), RotatePoint(), D_PAD::SetAttribute(), D_PAD::SetDelta(), D_PAD::SetDrillShape(), D_PAD::SetDrillSize(), D_PAD::SetLayerSet(), BOARD_CONNECTED_ITEM::SetNetCode(), D_PAD::SetOffset(), D_PAD::SetOrientation(), D_PAD::SetPadName(), D_PAD::SetPos0(), D_PAD::SetPosition(), D_PAD::SetShape(), D_PAD::SetSize(), and PCAD2KICAD::_TTEXTVALUE::text.

Referenced by PCAD2KICAD::PCB_PAD::AddToBoard().

188 {
189  PCB_PAD_SHAPE* padShape;
190  wxString padShapeName = wxT( "Ellipse" );
191  PAD_ATTR_T padType;
192  int i;
193  int width = 0;
194  int height = 0;
195 
196  D_PAD* pad = new D_PAD( aModule );
197 
198  if( !m_isHolePlated && m_hole )
199  {
200  // mechanical hole
201  pad->SetShape( PAD_SHAPE_CIRCLE );
203 
205  pad->SetDrillSize( wxSize( m_hole, m_hole ) );
206  pad->SetSize( wxSize( m_hole, m_hole ) );
207 
208  pad->SetLayerSet( LSET::AllCuMask() | LSET( 2, B_Mask, F_Mask ) );
209  }
210  else
211  {
212  ( m_hole ) ? padType = PAD_ATTRIB_STANDARD : padType = PAD_ATTRIB_SMD;
213 
214  // form layer mask
215  for( i = 0; i < (int) m_shapes.GetCount(); i++ )
216  {
217  padShape = m_shapes[i];
218 
219  if( padShape->m_width > 0 && padShape->m_height > 0 )
220  {
221  if( padShape->m_KiCadLayer == F_Cu ||
222  padShape->m_KiCadLayer == B_Cu )
223  {
224  padShapeName = padShape->m_shape;
225  width = padShape->m_width;
226  height = padShape->m_height;
227 
228  // assume this is SMD pad
229  if( padShape->m_KiCadLayer == F_Cu )
230  pad->SetLayerSet( LSET( 3, F_Cu, F_Paste, F_Mask ) );
231  else
232  pad->SetLayerSet( LSET( 3, B_Cu, B_Paste, B_Mask ) );
233  break;
234  }
235  }
236  }
237 
238  if( width == 0 || height == 0 )
239  {
240  delete pad;
241  return;
242  }
243 
244  if( padType == PAD_ATTRIB_STANDARD )
245  // actually this is a thru-hole pad
246  pad->SetLayerSet( LSET::AllCuMask() | LSET( 2, B_Mask, F_Mask ) );
247 
248  pad->SetPadName( m_name.text );
249 
250  if( padShapeName == wxT( "Oval" )
251  || padShapeName == wxT( "Ellipse" )
252  || padShapeName == wxT( "MtHole" ) )
253  {
254  if( width != height )
255  pad->SetShape( PAD_SHAPE_OVAL );
256  else
257  pad->SetShape( PAD_SHAPE_CIRCLE );
258  }
259  else if( padShapeName == wxT( "Rect" )
260  || padShapeName == wxT( "RndRect" ) )
261  pad->SetShape( PAD_SHAPE_RECT );
262  else if( padShapeName == wxT( "Polygon" ) )
263  pad->SetShape( PAD_SHAPE_RECT ); // approximation
264 
265  pad->SetSize( wxSize( width, height ) );
266  pad->SetDelta( wxSize( 0, 0 ) );
267  pad->SetOrientation( m_rotation + aRotation );
268 
270  pad->SetOffset( wxPoint( 0, 0 ) );
271  pad->SetDrillSize( wxSize( m_hole, m_hole ) );
272 
273  pad->SetAttribute( padType );
274 
275  // Set the proper net code
276  NETINFO_ITEM* netinfo = m_board->FindNet( m_net );
277  if( netinfo == NULL ) // I believe this should not happen, but just in case
278  {
279  // It is a new net
280  netinfo = new NETINFO_ITEM( m_board, m_net );
281  m_board->Add( netinfo );
282  }
283 
284  pad->SetNetCode( netinfo->GetNet() );
285  }
286 
287  if( !aEncapsulatedPad )
288  {
289  // pad's "Position" is not relative to the module's,
290  // whereas Pos0 is relative to the module's but is the unrotated coordinate.
291  wxPoint padpos( m_positionX, m_positionY );
292  pad->SetPos0( padpos );
293  RotatePoint( &padpos, aModule->GetOrientation() );
294  pad->SetPosition( padpos + aModule->GetPosition() );
295  }
296 
297  aModule->Pads().PushBack( pad );
298 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu LAYER_IDs.
Definition: lset.cpp:638
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
PAD_ATTR_T
Enum PAD_ATTR_T is the set of pad shapes, used with D_PAD::{Set,Get}Attribute() The double name is fo...
Definition: pad_shapes.h:56
const wxPoint & GetPosition() const override
Definition: class_module.h:143
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:59
void SetPosition(const wxPoint &aPos) override
Definition: class_pad.h:169
void SetDrillSize(const wxSize &aSize)
Definition: class_pad.h:187
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
Class LSET is a set of LAYER_IDs.
double GetOrientation() const
Definition: class_module.h:147
void SetPos0(const wxPoint &aPos)
Definition: class_pad.h:175
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
>
void SetSize(const wxSize &aSize)
Definition: class_pad.h:181
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
int GetNet() const
Function GetNet.
void SetAttribute(PAD_ATTR_T aAttribute)
Definition: class_pad.cpp:297
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:234
Class NETINFO_ITEM handles the data for a net.
void SetDrillShape(PAD_DRILL_SHAPE_T aDrillShape)
Definition: class_pad.h:218
Usual pad.
Definition: pad_shapes.h:58
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
void SetShape(PAD_SHAPE_T aShape)
Definition: class_pad.h:167
void SetPadName(const wxString &name)
Set the pad name (sometimes called pad number, although it can be an array ref like AA12 the pad name...
Definition: class_pad.cpp:404
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:306
PCB_PAD_SHAPES_ARRAY m_shapes
Definition: pcb_pad.h:46
DLIST< D_PAD > & Pads()
Definition: class_module.h:133
void SetOffset(const wxPoint &aOffset)
Definition: class_pad.h:190
void SetDelta(const wxSize &aSize)
Definition: class_pad.h:184
void PCAD2KICAD::PCB_COMPONENT::AddToModule ( MODULE aModule)
virtualinherited
void PCAD2KICAD::PCB_PAD::Flip ( )
overridevirtualinherited

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 173 of file pcb_pad.cpp.

References PCAD2KICAD::PCB_COMPONENT::Flip(), FlipLayer(), PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_objType, PCAD2KICAD::PCB_COMPONENT::m_rotation, and PCAD2KICAD::PCB_PAD::m_shapes.

174 {
175  int i;
176 
178 
179  if( m_objType == wxT( 'P' ) )
181 
182  for( i = 0; i < (int)m_shapes.GetCount(); i++ )
184 }
LAYER_ID FlipLayer(LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:444
PCB_PAD_SHAPES_ARRAY m_shapes
Definition: pcb_pad.h:46
int PCAD2KICAD::PCB_COMPONENT::GetNetCode ( wxString  aNetName)
inlineinherited
int PCAD2KICAD::PCB_COMPONENT::GetNewTimestamp ( )
inlineinherited
void PCAD2KICAD::PCB_VIA::Parse ( XNODE aNode,
wxString  aDefaultMeasurementUnit,
wxString  aActualConversion 
)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_PAD.

Definition at line 49 of file pcb_via.cpp.

References PCAD2KICAD::FindNode(), Format(), PCAD2KICAD::PCB_COMPONENT::GetNetCode(), XNODE::GetParent(), PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_callbacks, PCAD2KICAD::PCB_PAD::m_hole, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_net, PCAD2KICAD::PCB_COMPONENT::m_netCode, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, PCAD2KICAD::PCB_COMPONENT::m_rotation, PCAD2KICAD::PCB_PAD::m_shapes, PCAD2KICAD::PCB_VIA_SHAPE::Parse(), PCAD2KICAD::SetPosition(), PCAD2KICAD::SetWidth(), PCAD2KICAD::_TTEXTVALUE::text, and THROW_IO_ERROR.

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), and PCAD2KICAD::PCB_MODULE::Parse().

51 {
52  XNODE* lNode, * tNode;
53  wxString propValue;
54  PCB_VIA_SHAPE* viaShape;
55 
56  m_rotation = 0;
57  lNode = FindNode( aNode, wxT( "viaStyleRef" ) );
58 
59  if( lNode )
60  {
61  lNode->GetAttribute( wxT( "Name" ), &propValue );
62  propValue.Trim( false );
63  propValue.Trim( true );
64  m_name.text = propValue;
65  }
66 
67  lNode = FindNode( aNode, wxT( "pt" ) );
68 
69  if( lNode )
70  SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
71  &m_positionX, &m_positionY, aActualConversion );
72 
73  lNode = FindNode( aNode, wxT( "netNameRef" ) );
74 
75  if( lNode )
76  {
77  lNode->GetAttribute( wxT( "Name" ), &propValue );
78  propValue.Trim( false );
79  propValue.Trim( true );
80  m_net = propValue;
82  }
83 
84  lNode = aNode;
85 
86  while( lNode && lNode->GetName() != wxT( "www.lura.sk" ) )
87  lNode = lNode->GetParent();
88 
89  lNode = FindNode( lNode, wxT( "library" ) );
90 
91  if ( !lNode )
92  THROW_IO_ERROR( wxT( "Unable to find library section" ) );
93 
94  lNode = FindNode( lNode, wxT( "viaStyleDef" ) );
95 
96  while( lNode )
97  {
98  lNode->GetAttribute( wxT( "Name" ), &propValue );
99 
100  if( propValue.IsSameAs( m_name.text, false ) )
101  break;
102 
103  lNode = lNode->GetNext();
104  }
105 
106  if ( !lNode )
107  THROW_IO_ERROR( wxString::Format( wxT( "Unable to find viaStyleDef " ) + m_name.text ) );
108 
109  if( lNode )
110  {
111  tNode = lNode;
112  lNode = FindNode( tNode, wxT( "holeDiam" ) );
113 
114  if( lNode )
115  SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit, &m_hole,
116  aActualConversion );
117 
118  lNode = FindNode( tNode, wxT( "viaShape" ) );
119 
120  while( lNode )
121  {
122  if( lNode->GetName() == wxT( "viaShape" ) )
123  {
124  // we support only Vias on specific layers......
125  // we do not support vias on "Plane", "NonSignal" , "Signal" ... layerr
126  if( FindNode( lNode, wxT( "layerNumRef" ) ) )
127  {
128  viaShape = new PCB_VIA_SHAPE( m_callbacks, m_board );
129  viaShape->Parse( lNode, aDefaultMeasurementUnit, aActualConversion );
130  m_shapes.Add( viaShape );
131  }
132  }
133 
134  lNode = lNode->GetNext();
135  }
136  }
137 }
void SetWidth(wxString aStr, wxString aDefaultMeasurementUnit, int *aWidth, wxString aActualConversion)
XNODE * GetParent() const
Definition: xnode.h:73
void SetPosition(wxString aStr, wxString aDefaultMeasurementUnit, int *aX, int *aY, wxString aActualConversion)
#define THROW_IO_ERROR(x)
Definition: utf8.cpp:60
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
XNODE * FindNode(XNODE *aChild, wxString aTag)
PCB_CALLBACKS * m_callbacks
Definition: pcb_component.h:78
PCB_PAD_SHAPES_ARRAY m_shapes
Definition: pcb_pad.h:46
int GetNetCode(wxString aNetName)
Definition: pcb_component.h:75
void PCAD2KICAD::PCB_COMPONENT::SetPosOffset ( int  aX_offs,
int  aY_offs 
)
virtualinherited

Member Data Documentation

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited
int PCAD2KICAD::PCB_PAD::m_hole
inherited
bool PCAD2KICAD::PCB_PAD::m_isHolePlated
inherited
int PCAD2KICAD::PCB_PAD::m_number
inherited

Definition at line 43 of file pcb_pad.h.

Referenced by PCAD2KICAD::PCB_PAD::Parse(), and PCAD2KICAD::PCB_PAD::PCB_PAD().

wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited
PCB_PAD_SHAPES_ARRAY PCAD2KICAD::PCB_PAD::m_shapes
inherited
int PCAD2KICAD::PCB_COMPONENT::m_tag
inherited

Definition at line 51 of file pcb_component.h.

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


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