KiCad PCB EDA Suite
PCAD2KICAD::PCB_FOOTPRINT Class Reference

#include <pcb_footprint.h>

Inheritance diagram for PCAD2KICAD::PCB_FOOTPRINT:
PCAD2KICAD::PCB_COMPONENT PCAD2KICAD::PCB

Public Member Functions

 PCB_FOOTPRINT (PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
 
 ~PCB_FOOTPRINT ()
 
XNODEFindModulePatternDefName (XNODE *aNode, const wxString &aName)
 
void DoLayerContentsObjects (XNODE *aNode, PCB_FOOTPRINT *aFootprint, PCB_COMPONENTS_ARRAY *aList, wxStatusBar *aStatusBar, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
 
void SetName (const wxString &aPin, const wxString &aName)
 
virtual void Parse (XNODE *aNode, wxStatusBar *aStatusBar, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
 
virtual void Flip () override
 
void AddToBoard () override
 
virtual void SetPosOffset (int aX_offs, int aY_offs)
 
virtual void AddToFootprint (FOOTPRINT *aFootprint)
 
PCB_LAYER_ID GetKiCadLayer () const
 
int GetNetCode (wxString aNetName) const
 

Public Attributes

TTEXTVALUE m_Value
 
PCB_COMPONENTS_ARRAY m_FootprintItems
 
int m_Mirror
 
VERTICES_ARRAY m_BoardOutline
 
int m_tag
 
char m_objType
 
int m_PCadLayer
 
PCB_LAYER_ID m_KiCadLayer
 
KIID m_uuid
 
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
 

Private Member Functions

XNODEFindPatternMultilayerSection (XNODE *aNode, wxString *aPatGraphRefName)
 
wxString ModuleLayer (int aMirror)
 

Detailed Description

Definition at line 36 of file pcb_footprint.h.

Constructor & Destructor Documentation

◆ PCB_FOOTPRINT()

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

Definition at line 43 of file pcb_footprint.cpp.

43  :
44  PCB_COMPONENT( aCallbacks, aBoard )
45 {
47  m_Mirror = 0;
48  m_objType = wxT( 'M' ); // FOOTPRINT
49  m_KiCadLayer = F_SilkS; // default
50 }
void InitTTextValue(TTEXTVALUE *aTextValue)
PCB_COMPONENT(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)

References F_SilkS, PCAD2KICAD::InitTTextValue(), PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, m_Mirror, PCAD2KICAD::PCB_COMPONENT::m_objType, and m_Value.

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), and PCAD2KICAD::PCB::ParseBoard().

◆ ~PCB_FOOTPRINT()

PCAD2KICAD::PCB_FOOTPRINT::~PCB_FOOTPRINT ( )

Definition at line 53 of file pcb_footprint.cpp.

54 {
55  int i;
56 
57  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
58  {
59  delete m_FootprintItems[i];
60  }
61 }
PCB_COMPONENTS_ARRAY m_FootprintItems
Definition: pcb_footprint.h:40

References m_FootprintItems.

Member Function Documentation

◆ AddToBoard()

void PCAD2KICAD::PCB_FOOTPRINT::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 492 of file pcb_footprint.cpp.

493 {
494  int i;
495  int r;
496 
497  // transform text positions
500 
503 
504  FOOTPRINT* footprint = new FOOTPRINT( m_board );
505  m_board->Add( footprint, ADD_MODE::APPEND );
506 
507  footprint->SetPosition( wxPoint( m_positionX, m_positionY ) );
508  footprint->SetLayer( m_Mirror ? B_Cu : F_Cu );
509  footprint->SetOrientation( m_rotation );
510  footprint->SetLastEditTime( 0 );
511 
512  LIB_ID fpID;
513  fpID.Parse( m_compRef, true );
514  footprint->SetFPID( fpID );
515 
516  // reference text
517  FP_TEXT* ref_text = &footprint->Reference();
518 
519  ref_text->SetText( ValidateReference( m_name.text ) );
520  ref_text->SetType( FP_TEXT::TEXT_is_REFERENCE );
521 
522  ref_text->SetPos0( wxPoint( m_name.correctedPositionX, m_name.correctedPositionY ) );
523  if( m_name.isTrueType )
525  else
527 
529  ref_text->SetTextAngle( r );
530  ref_text->SetKeepUpright( false );
531 
532  ref_text->SetItalic( m_name.isItalic );
534 
535  ref_text->SetMirrored( m_name.mirror );
536  ref_text->SetVisible( m_name.textIsVisible );
537 
539 
540  // Calculate the actual position.
541  ref_text->SetDrawCoord();
542 
543  // value text
544  FP_TEXT* val_text = &footprint->Value();
545 
546  val_text->SetText( m_Value.text );
547  val_text->SetType( FP_TEXT::TEXT_is_VALUE );
548 
550  if( m_Value.isTrueType )
552  else
554 
556  val_text->SetTextAngle( r );
557  val_text->SetKeepUpright( false );
558 
559  val_text->SetItalic( m_Value.isItalic );
561 
562  val_text->SetMirrored( m_Value.mirror );
563  val_text->SetVisible( m_Value.textIsVisible );
564 
566 
567  // Calculate the actual position.
568  val_text->SetDrawCoord();
569 
570  // TEXTS
571  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
572  {
573  if( m_FootprintItems[i]->m_objType == wxT( 'T' ) )
574  {
575  ( (PCB_TEXT*) m_FootprintItems[i] )->m_tag = i + 2;
576  m_FootprintItems[ i ]->AddToFootprint( footprint );
577  }
578  }
579 
580  // FOOTPRINT LINES
581  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
582  {
583  if( m_FootprintItems[i]->m_objType == wxT( 'L' ) )
584  m_FootprintItems[ i ]->AddToFootprint( footprint );
585  }
586 
587  // FOOTPRINT ARCS
588  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
589  {
590  if( m_FootprintItems[i]->m_objType == wxT( 'A' ) )
591  m_FootprintItems[ i ]->AddToFootprint( footprint );
592  }
593 
594  // FOOTPRINT POLYGONS
595  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
596  {
597  if( m_FootprintItems[i]->m_objType == wxT( 'Z' ) )
598  m_FootprintItems[ i ]->AddToFootprint( footprint );
599  }
600 
601  // PADS
602  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
603  {
604  if( m_FootprintItems[i]->m_objType == wxT( 'P' ) )
605  ((PCB_PAD*) m_FootprintItems[ i ] )->AddToFootprint( footprint, m_rotation, false );
606  }
607 
608  // VIAS
609  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
610  {
611  if( m_FootprintItems[i]->m_objType == wxT( 'V' ) )
612  ((PCB_VIA*) m_FootprintItems[ i ] )->AddToFootprint( footprint, m_rotation, false );
613  }
614 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:195
virtual void AddToFootprint(FOOTPRINT *aFootprint)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:194
void SetTextAngle(double aAngle) override
Definition: fp_text.cpp:70
void SetItalic(bool isItalic)
Definition: eda_text.h:186
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:521
void SetVisible(bool aVisible)
Definition: eda_text.h:192
void SetDrawCoord()
Set relative coordinates.
Definition: fp_text.cpp:187
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void SetType(TEXT_TYPE aType)
Definition: fp_text.h:140
void SetTextSizeFromTrueTypeFontHeight(EDA_TEXT *aText, int aTextHeight)
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:462
FP_TEXT & Reference()
Definition: footprint.h:463
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:563
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
void SetOrientation(double aNewAngle)
Definition: footprint.cpp:1557
wxString ValidateReference(wxString aRef)
void SetPos0(const wxPoint &aPos)
Definition: fp_text.h:165
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:191
void SetKeepUpright(bool aKeepUpright)
Definition: fp_text.h:115
PCB_COMPONENTS_ARRAY m_FootprintItems
Definition: pcb_footprint.h:40
int Parse(const UTF8 &aId, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
void SetLastEditTime(timestamp_t aTime)
Definition: footprint.h:330
void CorrectTextPosition(TTEXTVALUE *aValue)
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:166
void SetTextSizeFromStrokeFontHeight(EDA_TEXT *aText, int aTextHeight)
void SetPosition(const wxPoint &aPos) override
Definition: footprint.cpp:1438

References BOARD::Add(), PCAD2KICAD::PCB_COMPONENT::AddToFootprint(), APPEND, B_Cu, PCAD2KICAD::_TTEXTVALUE::correctedPositionX, PCAD2KICAD::_TTEXTVALUE::correctedPositionY, PCAD2KICAD::CorrectTextPosition(), F_Cu, FlipLayer(), PCAD2KICAD::_TTEXTVALUE::isItalic, PCAD2KICAD::_TTEXTVALUE::isTrueType, PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_compRef, m_FootprintItems, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, m_Mirror, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_objType, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, PCAD2KICAD::PCB_COMPONENT::m_rotation, m_Value, PCAD2KICAD::_TTEXTVALUE::mirror, LIB_ID::Parse(), FOOTPRINT::Reference(), RotatePoint(), FP_TEXT::SetDrawCoord(), FOOTPRINT::SetFPID(), EDA_TEXT::SetItalic(), FP_TEXT::SetKeepUpright(), FOOTPRINT::SetLastEditTime(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), FOOTPRINT::SetOrientation(), FP_TEXT::SetPos0(), FOOTPRINT::SetPosition(), EDA_TEXT::SetText(), FP_TEXT::SetTextAngle(), PCAD2KICAD::SetTextSizeFromStrokeFontHeight(), PCAD2KICAD::SetTextSizeFromTrueTypeFontHeight(), EDA_TEXT::SetTextThickness(), FP_TEXT::SetType(), EDA_TEXT::SetVisible(), PCAD2KICAD::_TTEXTVALUE::text, FP_TEXT::TEXT_is_REFERENCE, FP_TEXT::TEXT_is_VALUE, PCAD2KICAD::_TTEXTVALUE::textHeight, PCAD2KICAD::_TTEXTVALUE::textIsVisible, PCAD2KICAD::_TTEXTVALUE::textRotation, PCAD2KICAD::_TTEXTVALUE::textstrokeWidth, PCAD2KICAD::ValidateReference(), and FOOTPRINT::Value().

◆ AddToFootprint()

void PCAD2KICAD::PCB_COMPONENT::AddToFootprint ( FOOTPRINT aFootprint)
virtualinherited

Reimplemented in PCAD2KICAD::PCB_POLYGON, PCAD2KICAD::PCB_ARC, PCAD2KICAD::PCB_LINE, PCAD2KICAD::PCB_PAD, and PCAD2KICAD::PCB_TEXT.

Definition at line 64 of file pcb_component.cpp.

65 {
66 }

Referenced by AddToBoard().

◆ DoLayerContentsObjects()

void PCAD2KICAD::PCB_FOOTPRINT::DoLayerContentsObjects ( XNODE aNode,
PCB_FOOTPRINT aFootprint,
PCB_COMPONENTS_ARRAY *  aList,
wxStatusBar *  aStatusBar,
const wxString &  aDefaultMeasurementUnit,
const wxString &  aActualConversion 
)

Definition at line 210 of file pcb_footprint.cpp.

216 {
217  PCB_ARC* arc;
218  PCB_POLYGON* polygon;
219  PCB_POLYGON *plane_layer = NULL;
220  PCB_COPPER_POUR* copperPour;
221  PCB_CUTOUT* cutout;
222  PCB_PLANE* plane;
223  VERTICES_ARRAY* plane_layer_polygon;
224  PCB_LINE* line;
225  PCB_TEXT* text;
226  XNODE* lNode, * tNode;
227  wxString propValue;
228  long long i;
229  int PCadLayer;
230  long num = 0;
231 
232  i = 0;
233  // aStatusBar->SetStatusText( wxT( "Processing LAYER CONTENT OBJECTS " ) );
234  if( FindNode( aNode, wxT( "layerNumRef" ) ) )
235  FindNode( aNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &num );
236 
237  PCadLayer = (int) num;
238 
239  if( m_callbacks->GetLayerType( PCadLayer ) == LAYER_TYPE_PLANE )
240  {
241  plane_layer = new PCB_POLYGON( m_callbacks, m_board, PCadLayer );
242  plane_layer->AssignNet( m_callbacks->GetLayerNetNameRef( PCadLayer ) );
243  plane_layer->SetOutline( &m_BoardOutline );
244  aList->Add( plane_layer );
245 
246  // fill the polygon with the same contour as its outline is
247  //plane_layer->AddIsland( &m_boardOutline );
248  }
249 
250  lNode = aNode->GetChildren();
251 
252  while( lNode )
253  {
254  i++;
255  // aStatusBar->SetStatusText( wxString::Format( "Processing LAYER CONTENT OBJECTS :%lld",
256  // i ) );
257 
258  if( lNode->GetName() == wxT( "line" ) )
259  {
260  line = new PCB_LINE( m_callbacks, m_board );
261  line->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
262  aList->Add( line );
263  }
264 
265  if( lNode->GetName() == wxT( "text" ) )
266  {
267  text = new PCB_TEXT( m_callbacks, m_board );
268  text->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
269  aList->Add( text );
270  }
271 
272  // added as Sergeys request 02/2008
273  if( lNode->GetName() == wxT( "attr" ) )
274  {
275  // assign fonts to Module Name,Value,Type,....s
276  lNode->GetAttribute( wxT( "Name" ), &propValue );
277  propValue.Trim( false );
278  propValue.Trim( true );
279 
280  if( propValue == wxT( "RefDes" ) )
281  {
282  tNode = FindNode( lNode, wxT( "textStyleRef" ) );
283 
284  if( tNode && aFootprint )
285  {
286  // TODO: to understand and may be repair
287  // Alexander Lunev: originally in Delphi version of the project there was
288  // a strange access to pcbModule->m_name (it was global variable). This access
289  // is necessary when the function DoLayerContentsObjects() is called from
290  // function CreatePCBModule(). However it is not clear whether the access is
291  // required when the function DoLayerContentsObjects() is called from
292  // function ProcessXMLtoPCBLib().
293  SetFontProperty( tNode,
294  &aFootprint->m_name,
295  aDefaultMeasurementUnit,
296  aActualConversion );
297  }
298  }
299  }
300 
301  // added as Sergeys request 02/2008
302  if( lNode->GetName() == wxT( "arc" ) || lNode->GetName() == wxT( "triplePointArc" ) )
303  {
304  arc = new PCB_ARC( m_callbacks, m_board );
305  arc->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
306  aList->Add( arc );
307  }
308 
309  if( lNode->GetName() == wxT( "pcbPoly" ) )
310  {
311  if( m_callbacks->GetLayerType( PCadLayer ) == LAYER_TYPE_PLANE )
312  {
313  plane_layer_polygon = new VERTICES_ARRAY;
314  wxASSERT( plane_layer );
315  plane_layer->FormPolygon( lNode, plane_layer_polygon, aDefaultMeasurementUnit, aActualConversion );
316  plane_layer->m_cutouts.Add( plane_layer_polygon );
317  }
318  else
319  {
320  polygon = new PCB_POLYGON( m_callbacks, m_board, PCadLayer );
321  if( polygon->Parse( lNode,
322  aDefaultMeasurementUnit,
323  aActualConversion ) )
324  aList->Add( polygon );
325  else
326  delete polygon;
327  }
328  }
329 
330  if( lNode->GetName() == wxT( "copperPour95" ) )
331  {
332  copperPour = new PCB_COPPER_POUR( m_callbacks, m_board, PCadLayer );
333 
334  if( copperPour->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
335  aList->Add( copperPour );
336  else
337  delete copperPour;
338  }
339 
340  if( lNode->GetName() == wxT( "polyCutOut" ) )
341  {
342  cutout = new PCB_CUTOUT( m_callbacks, m_board, PCadLayer );
343 
344  if( cutout->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
345  aList->Add( cutout );
346  else
347  delete cutout;
348  }
349 
350  if( lNode->GetName() == wxT( "planeObj" ) )
351  {
352  plane = new PCB_PLANE( m_callbacks, m_board, PCadLayer );
353 
354  if( plane->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
355  aList->Add( plane );
356  else
357  delete plane;
358  }
359 
360  lNode = lNode->GetNext();
361  }
362 }
void SetFontProperty(XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
virtual wxString GetLayerNetNameRef(int aPCadLayer) const =0
virtual LAYER_TYPE_T GetLayerType(int aPCadLayer) const =0
XNODE * GetChildren() const
Definition: xnode.h:62
#define NULL
VERTICES_ARRAY m_BoardOutline
Definition: pcb_footprint.h:42
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:67
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
PCB_CALLBACKS * m_callbacks
Definition: pcb_component.h:74

References PCAD2KICAD::PCB_POLYGON::AssignNet(), PCAD2KICAD::FindNode(), PCAD2KICAD::PCB_POLYGON::FormPolygon(), XNODE::GetChildren(), PCAD2KICAD::PCB_CALLBACKS::GetLayerNetNameRef(), PCAD2KICAD::PCB_CALLBACKS::GetLayerType(), XNODE::GetNext(), LAYER_TYPE_PLANE, PCAD2KICAD::PCB_COMPONENT::m_board, m_BoardOutline, PCAD2KICAD::PCB_COMPONENT::m_callbacks, PCAD2KICAD::PCB_POLYGON::m_cutouts, PCAD2KICAD::PCB_COMPONENT::m_name, NULL, PCAD2KICAD::PCB_PLANE::Parse(), PCAD2KICAD::PCB_CUTOUT::Parse(), PCAD2KICAD::PCB_COPPER_POUR::Parse(), PCAD2KICAD::PCB_ARC::Parse(), PCAD2KICAD::PCB_LINE::Parse(), PCAD2KICAD::PCB_POLYGON::Parse(), PCAD2KICAD::SetFontProperty(), PCAD2KICAD::PCB_POLYGON::SetOutline(), and text.

Referenced by Parse(), and PCAD2KICAD::PCB::ParseBoard().

◆ FindModulePatternDefName()

XNODE * PCAD2KICAD::PCB_FOOTPRINT::FindModulePatternDefName ( XNODE aNode,
const wxString &  aName 
)

Definition at line 64 of file pcb_footprint.cpp.

65 {
66  XNODE* result, * lNode;
67  wxString propValue1, propValue2;
68 
69  result = NULL;
70  lNode = FindNode( aNode, wxT( "patternDef" ) );
71 
72  while( lNode )
73  {
74  if( lNode->GetName() == wxT( "patternDef" ) )
75  {
76  lNode->GetAttribute( wxT( "Name" ), &propValue1 );
77  FindNode( lNode,
78  wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), &propValue2 );
79 
80  if( ValidateName( propValue1 ) == aName
81  || ValidateName( propValue2 ) == aName )
82  {
83  result = lNode;
84  lNode = NULL;
85  }
86  }
87 
88  if( lNode )
89  lNode = lNode->GetNext();
90  }
91 
92  if( result == NULL )
93  {
94  lNode = FindNode( aNode, wxT( "patternDefExtended" ) ); // New file format
95 
96  while( lNode )
97  {
98  if( lNode->GetName() == wxT( "patternDefExtended" ) )
99  {
100  lNode->GetAttribute( wxT( "Name" ), &propValue1 );
101 
102  if( ValidateName( propValue1 ) == aName )
103  {
104  result = lNode;
105  lNode = NULL;
106  }
107  }
108 
109  if( lNode )
110  lNode = lNode->GetNext();
111  }
112  }
113 
114  return result;
115 }
wxString ValidateName(wxString aName)
#define NULL
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:67
XNODE * FindNode(XNODE *aChild, const wxString &aTag)

References PCAD2KICAD::FindNode(), XNODE::GetNext(), NULL, and PCAD2KICAD::ValidateName().

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), and FindPatternMultilayerSection().

◆ FindPatternMultilayerSection()

XNODE * PCAD2KICAD::PCB_FOOTPRINT::FindPatternMultilayerSection ( XNODE aNode,
wxString *  aPatGraphRefName 
)
private

Definition at line 118 of file pcb_footprint.cpp.

119 {
120  XNODE* result, * pNode, * lNode;
121  wxString propValue, patName;
122 
123  result = NULL;
124  pNode = aNode; // pattern;
125  lNode = aNode;
126 
127  // calling from library conversion we need to find pattern
128  if( lNode->GetName() == wxT( "compDef" ) )
129  {
130  lNode->GetAttribute( wxT( "Name" ), &propValue );
131  propValue.Trim( false );
132  patName = ValidateName( propValue );
133 
134  if( FindNode( lNode, wxT( "attachedPattern" ) ) )
135  {
136  FindNode( FindNode( lNode, wxT( "attachedPattern" ) ),
137  wxT( "patternName" ) )->GetAttribute( wxT( "Name" ), &propValue );
138  propValue.Trim( false );
139  propValue.Trim( true );
140  patName = ValidateName( propValue );
141  }
142 
143  lNode = FindModulePatternDefName( lNode->GetParent(), patName );
144  pNode = lNode; // pattern;
145  }
146 
147  lNode = NULL;
148 
149  if( pNode )
150  lNode = FindNode( pNode, wxT( "multiLayer" ) ); // Old file format
151 
152  if( lNode )
153  {
154  *aPatGraphRefName = wxEmptyString; // default
155  result = lNode;
156  }
157  else
158  {
159  // New file format
160 
161  if( *aPatGraphRefName == wxEmptyString ) // default
162  {
163  if( FindNode( aNode, wxT( "patternGraphicsNameRef" ) ) )
164  {
165  FindNode( aNode,
166  wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
167  aPatGraphRefName );
168  }
169  }
170 
171  if( FindNode( aNode, wxT( "patternGraphicsDef" ) ) )
172  lNode = FindNode( aNode, wxT( "patternGraphicsDef" ) );
173  else if( pNode )
174  lNode = FindNode( pNode, wxT( "patternGraphicsDef" ) );
175 
176  if( *aPatGraphRefName == wxEmptyString ) // no patern delection, the first is actual...
177  {
178  if( lNode )
179  {
180  result = FindNode( lNode, wxT( "multiLayer" ) );
181  lNode = NULL;
182  }
183  }
184 
185  while( lNode ) // selected by name
186  {
187  if( lNode->GetName() == wxT( "patternGraphicsDef" ) )
188  {
189  FindNode( lNode,
190  wxT( "patternGraphicsNameDef" ) )->GetAttribute( wxT( "Name" ),
191  &propValue );
192 
193  if( propValue == *aPatGraphRefName )
194  {
195  result = FindNode( lNode, wxT( "multiLayer" ) );
196  lNode = NULL;
197  }
198  else
199  lNode = lNode->GetNext();
200  }
201  else
202  lNode = lNode->GetNext();
203  }
204  }
205 
206  return result;
207 }
XNODE * FindModulePatternDefName(XNODE *aNode, const wxString &aName)
wxString ValidateName(wxString aName)
#define NULL
XNODE * GetParent() const
Definition: xnode.h:72
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:67
XNODE * FindNode(XNODE *aChild, const wxString &aTag)

References FindModulePatternDefName(), PCAD2KICAD::FindNode(), XNODE::GetNext(), XNODE::GetParent(), NULL, and PCAD2KICAD::ValidateName().

Referenced by Parse().

◆ Flip()

void PCAD2KICAD::PCB_FOOTPRINT::Flip ( )
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 617 of file pcb_footprint.cpp.

618 {
619  int i;
620 
621  if( m_Mirror == 1 )
622  {
624 
625  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
626  {
627  if( m_FootprintItems[i]->m_objType == wxT( 'L' ) || // lines
628  m_FootprintItems[i]->m_objType == wxT( 'A' ) || // arcs
629  m_FootprintItems[i]->m_objType == wxT( 'Z' ) || // polygons
630  m_FootprintItems[i]->m_objType == wxT( 'P' ) || // pads
631  m_FootprintItems[i]->m_objType == wxT( 'V' ) ) // vias
632  {
633  m_FootprintItems[i]->Flip();
634  }
635  }
636  }
637 }
PCB_COMPONENTS_ARRAY m_FootprintItems
Definition: pcb_footprint.h:40

References m_FootprintItems, m_Mirror, PCAD2KICAD::PCB_COMPONENT::m_objType, and PCAD2KICAD::PCB_COMPONENT::m_rotation.

Referenced by PCAD2KICAD::PCB::ParseBoard().

◆ GetKiCadLayer()

◆ GetNetCode()

int PCAD2KICAD::PCB_COMPONENT::GetNetCode ( wxString  aNetName) const
inlineinherited

◆ ModuleLayer()

wxString PCAD2KICAD::PCB_FOOTPRINT::ModuleLayer ( int  aMirror)
private

Definition at line 475 of file pcb_footprint.cpp.

476 {
477  wxString result;
478 
479  // ///NOT ! {IntToStr(KiCadLayer)} NOT !
480  // / FOOTPRINTs ARE HARD PLACED ON COMPONENT OR COPPER LAYER.
481  // / IsFLIPPED--> MIRROR attribute is decision Point!!!
482 
483  if( aMirror == 0 )
484  result = wxT( "15" ); // Components side
485  else
486  result = wxT( "0" ); // Copper side
487 
488  return result;
489 }

◆ Parse()

void PCAD2KICAD::PCB_FOOTPRINT::Parse ( XNODE aNode,
wxStatusBar *  aStatusBar,
const wxString &  aDefaultMeasurementUnit,
const wxString &  aActualConversion 
)
virtual

Definition at line 383 of file pcb_footprint.cpp.

386 {
387  XNODE* lNode, * tNode, * mNode;
388  PCB_PAD* pad;
389  PCB_VIA* via;
390  wxString propValue, str;
391 
392  FindNode( aNode, wxT( "originalName" ) )->GetAttribute( wxT( "Name" ),
393  &propValue );
394  propValue.Trim( false );
395  m_name.text = propValue;
396 
397  // aStatusBar->SetStatusText( wxT( "Creating Component : " ) + m_name.text );
398  lNode = aNode;
400 
401  if( lNode )
402  {
403  tNode = lNode;
404  tNode = tNode->GetChildren();
405 
406  while( tNode )
407  {
408  if( tNode->GetName() == wxT( "pad" ) )
409  {
410  pad = new PCB_PAD( m_callbacks, m_board );
411  pad->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
412  m_FootprintItems.Add( pad );
413  }
414 
415  if( tNode->GetName() == wxT( "via" ) )
416  {
417  via = new PCB_VIA( m_callbacks, m_board );
418  via->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
419  m_FootprintItems.Add( via );
420  }
421 
422  tNode = tNode->GetNext();
423  }
424 
425  lNode = lNode->GetParent();
426  }
427 
428  if( lNode )
429  lNode = FindNode( lNode, wxT( "layerContents" ) );
430 
431  while( lNode )
432  {
433  if( lNode->GetName() == wxT( "layerContents" ) )
434  DoLayerContentsObjects( lNode, this, &m_FootprintItems, aStatusBar,
435  aDefaultMeasurementUnit, aActualConversion );
436 
437  lNode = lNode->GetNext();
438  }
439 
440  // map pins
441  lNode = FindPinMap( aNode );
442 
443  if( lNode )
444  {
445  mNode = lNode->GetChildren();
446 
447  while( mNode )
448  {
449  if( mNode->GetName() == wxT( "padNum" ) )
450  {
451  str = mNode->GetNodeContent();
452  mNode = mNode->GetNext();
453 
454  if( !mNode )
455  break;
456 
457  mNode->GetAttribute( wxT( "Name" ), &propValue );
458  SetName( str, propValue );
459  mNode = mNode->GetNext();
460  }
461  else
462  {
463  mNode = mNode->GetNext();
464 
465  if( !mNode )
466  break;
467 
468  mNode = mNode->GetNext();
469  }
470  }
471  }
472 }
void DoLayerContentsObjects(XNODE *aNode, PCB_FOOTPRINT *aFootprint, PCB_COMPONENTS_ARRAY *aList, wxStatusBar *aStatusBar, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
XNODE * FindPatternMultilayerSection(XNODE *aNode, wxString *aPatGraphRefName)
void SetName(const wxString &aPin, const wxString &aName)
XNODE * GetChildren() const
Definition: xnode.h:62
XNODE * GetParent() const
Definition: xnode.h:72
Hold an XML or S-expression element.
Definition: xnode.h:43
PCB_COMPONENTS_ARRAY m_FootprintItems
Definition: pcb_footprint.h:40
XNODE * GetNext() const
Definition: xnode.h:67
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
PCB_CALLBACKS * m_callbacks
Definition: pcb_component.h:74
XNODE * FindPinMap(XNODE *aNode)

References DoLayerContentsObjects(), PCAD2KICAD::FindNode(), FindPatternMultilayerSection(), PCAD2KICAD::FindPinMap(), XNODE::GetChildren(), XNODE::GetNext(), XNODE::GetParent(), PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_callbacks, m_FootprintItems, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName, pad, SetName(), PCAD2KICAD::_TTEXTVALUE::text, and via.

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), and PCAD2KICAD::PCB::ParseBoard().

◆ SetName()

void PCAD2KICAD::PCB_FOOTPRINT::SetName ( const wxString &  aPin,
const wxString &  aName 
)

Definition at line 365 of file pcb_footprint.cpp.

366 {
367  int i;
368  long num;
369 
370  aPin.ToLong( &num );
371 
372  for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
373  {
374  if( m_FootprintItems[i]->m_objType == wxT( 'P' ) )
375  if(( (PCB_PAD*) m_FootprintItems[i] )->m_Number == num )
376  ( (PCB_PAD*) m_FootprintItems[i] )->m_name.text = aName;
377 
378 
379  }
380 }
PCB_COMPONENTS_ARRAY m_FootprintItems
Definition: pcb_footprint.h:40

References m_FootprintItems, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_objType, and PCAD2KICAD::_TTEXTVALUE::text.

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

◆ SetPosOffset()

void PCAD2KICAD::PCB_COMPONENT::SetPosOffset ( int  aX_offs,
int  aY_offs 
)
virtualinherited

Member Data Documentation

◆ m_board

◆ m_BoardOutline

VERTICES_ARRAY PCAD2KICAD::PCB_FOOTPRINT::m_BoardOutline

Definition at line 42 of file pcb_footprint.h.

Referenced by DoLayerContentsObjects(), and PCAD2KICAD::PCB::GetBoardOutline().

◆ m_callbacks

◆ m_compRef

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited

◆ m_FootprintItems

PCB_COMPONENTS_ARRAY PCAD2KICAD::PCB_FOOTPRINT::m_FootprintItems

◆ m_KiCadLayer

◆ m_Mirror

int PCAD2KICAD::PCB_FOOTPRINT::m_Mirror

Definition at line 41 of file pcb_footprint.h.

Referenced by AddToBoard(), PCAD2KICAD::PCB::DoPCBComponents(), Flip(), and PCB_FOOTPRINT().

◆ m_name

◆ m_net

◆ m_netCode

◆ m_objType

◆ m_patGraphRefName

wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited

◆ m_PCadLayer

◆ m_positionX

◆ m_positionY

◆ m_rotation

◆ m_tag

int PCAD2KICAD::PCB_COMPONENT::m_tag
inherited

Definition at line 48 of file pcb_component.h.

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

◆ m_uuid

KIID PCAD2KICAD::PCB_COMPONENT::m_uuid
inherited

Definition at line 52 of file pcb_component.h.

◆ m_Value

TTEXTVALUE PCAD2KICAD::PCB_FOOTPRINT::m_Value

Definition at line 39 of file pcb_footprint.h.

Referenced by AddToBoard(), PCAD2KICAD::PCB::DoPCBComponents(), and PCB_FOOTPRINT().


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