KiCad PCB EDA Suite
PCAD2KICAD::PCB_MODULE Class Reference

#include <pcb_module.h>

Inheritance diagram for PCAD2KICAD::PCB_MODULE:
PCAD2KICAD::PCB_COMPONENT PCAD2KICAD::PCB

Public Member Functions

 PCB_MODULE (PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
 
 ~PCB_MODULE ()
 
XNODEFindModulePatternDefName (XNODE *aNode, const wxString &aName)
 
void DoLayerContentsObjects (XNODE *aNode, PCB_MODULE *aPCBModule, 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 AddToModule (MODULE *aModule)
 
PCB_LAYER_ID GetKiCadLayer ()
 
int GetNetCode (wxString aNetName)
 

Public Attributes

TTEXTVALUE m_value
 
PCB_COMPONENTS_ARRAY m_moduleObjects
 
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 40 of file pcb_module.h.

Constructor & Destructor Documentation

◆ PCB_MODULE()

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

Definition at line 49 of file pcb_module.cpp.

49  : PCB_COMPONENT( aCallbacks,
50  aBoard )
51 {
53  m_mirror = 0;
54  m_objType = wxT( 'M' ); // MODULE
55  m_KiCadLayer = F_SilkS; // default
56 }
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_MODULE()

PCAD2KICAD::PCB_MODULE::~PCB_MODULE ( )

Definition at line 59 of file pcb_module.cpp.

60 {
61  int i;
62 
63  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
64  {
65  delete m_moduleObjects[i];
66  }
67 }
PCB_COMPONENTS_ARRAY m_moduleObjects
Definition: pcb_module.h:44

References m_moduleObjects.

Member Function Documentation

◆ AddToBoard()

void PCAD2KICAD::PCB_MODULE::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 499 of file pcb_module.cpp.

500 {
501  int i;
502  int r;
503 
504  // transform text positions
507  (double) -m_rotation );
508 
511  (double) -m_rotation );
512 
513  MODULE* module = new MODULE( m_board );
514  m_board->Add( module, ADD_MODE::APPEND );
515 
517  module->SetLayer( m_mirror ? B_Cu : F_Cu );
518  module->SetOrientation( m_rotation );
519  module->SetLastEditTime( 0 );
520 
521  LIB_ID fpID;
522  fpID.Parse( m_compRef, LIB_ID::ID_PCB, true );
523  module->SetFPID( fpID );
524 
525  module->SetAttributes( MOD_DEFAULT | MOD_CMS );
526 
527  // reference text
528  TEXTE_MODULE* ref_text = &module->Reference();
529 
530  ref_text->SetText( ValidateReference( m_name.text ) );
532 
534  if( m_name.isTrueType )
536  else
538 
540  ref_text->SetTextAngle( r );
541  ref_text->SetKeepUpright( false );
542 
543  ref_text->SetItalic( m_name.isItalic );
544  ref_text->SetThickness( m_name.textstrokeWidth );
545 
546  ref_text->SetMirrored( m_name.mirror );
547  ref_text->SetVisible( m_name.textIsVisible );
548 
550 
551  // Calculate the actual position.
552  ref_text->SetDrawCoord();
553 
554  // value text
555  TEXTE_MODULE* val_text = &module->Value();
556 
557  val_text->SetText( m_value.text );
559 
561  if( m_value.isTrueType )
563  else
565 
567  val_text->SetTextAngle( r );
568  val_text->SetKeepUpright( false );
569 
570  val_text->SetItalic( m_value.isItalic );
571  val_text->SetThickness( m_value.textstrokeWidth );
572 
573  val_text->SetMirrored( m_value.mirror );
574  val_text->SetVisible( m_value.textIsVisible );
575 
577 
578  // Calculate the actual position.
579  val_text->SetDrawCoord();
580 
581  // TEXTS
582  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
583  {
584  if( m_moduleObjects[i]->m_objType == wxT( 'T' ) )
585  {
586  ( (PCB_TEXT*) m_moduleObjects[i] )->m_tag = i + 2;
587  m_moduleObjects[i]->AddToModule( module );
588  }
589  }
590 
591  // MODULE LINES
592  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
593  {
594  if( m_moduleObjects[i]->m_objType == wxT( 'L' ) )
595  m_moduleObjects[i]->AddToModule( module );
596  }
597 
598  // MODULE Arcs
599  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
600  {
601  if( m_moduleObjects[i]->m_objType == wxT( 'A' ) )
602  m_moduleObjects[i]->AddToModule( module );
603  }
604 
605  // MODULE POLYGONS
606  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
607  {
608  if( m_moduleObjects[i]->m_objType == wxT( 'Z' ) )
609  m_moduleObjects[i]->AddToModule( module );
610  }
611 
612  // PADS
613  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
614  {
615  if( m_moduleObjects[i]->m_objType == wxT( 'P' ) )
616  ( (PCB_PAD*) m_moduleObjects[i] )->AddToModule( module, m_rotation, false );
617  }
618 
619  // VIAS
620  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
621  {
622  if( m_moduleObjects[i]->m_objType == wxT( 'V' ) )
623  ( (PCB_VIA*) m_moduleObjects[i] )->AddToModule( module, m_rotation, false );
624  }
625 
626  module->CalculateBoundingBox();
627 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:172
void SetKeepUpright(bool aKeepUpright)
TEXTE_MODULE & Reference()
Definition: class_module.h:477
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void CalculateBoundingBox()
Function CalculateBoundingBox calculates the bounding box in board coordinates.
void SetItalic(bool isItalic)
Definition: eda_text.h:163
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:485
void SetVisible(bool aVisible)
Definition: eda_text.h:169
Set for modules listed in the automatic insertion list (usually SMD footprints)
Definition: class_module.h:74
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void SetTextSizeFromTrueTypeFontHeight(EDA_TEXT *aText, int aTextHeight)
virtual void AddToModule(MODULE *aModule)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:476
void SetLastEditTime(timestamp_t aTime)
Definition: class_module.h:347
wxString ValidateReference(wxString aRef)
void SetPosition(const wxPoint &aPos) override
void SetType(TEXT_TYPE aType)
void SetPos0(const wxPoint &aPos)
default
Definition: class_module.h:73
void SetOrientation(double newangle)
void CorrectTextPosition(TTEXTVALUE *aValue)
void SetDrawCoord()
Set absolute coordinates.
PCB_COMPONENTS_ARRAY m_moduleObjects
Definition: pcb_module.h:44
void SetTextSizeFromStrokeFontHeight(EDA_TEXT *aText, int aTextHeight)
void SetTextAngle(double aAngle)
int Parse(const UTF8 &aId, LIB_ID_TYPE aType, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
void SetFPID(const LIB_ID &aFPID)
Definition: class_module.h:220
void SetThickness(int aNewThickness)
Set the pen width.
Definition: eda_text.h:143
void SetAttributes(int aAttributes)
Definition: class_module.h:260

References BOARD::Add(), PCAD2KICAD::PCB_COMPONENT::AddToModule(), APPEND, B_Cu, MODULE::CalculateBoundingBox(), PCAD2KICAD::_TTEXTVALUE::correctedPositionX, PCAD2KICAD::_TTEXTVALUE::correctedPositionY, PCAD2KICAD::CorrectTextPosition(), F_Cu, FlipLayer(), LIB_ID::ID_PCB, PCAD2KICAD::_TTEXTVALUE::isItalic, PCAD2KICAD::_TTEXTVALUE::isTrueType, PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_compRef, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, m_mirror, m_moduleObjects, 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, MOD_CMS, MOD_DEFAULT, LIB_ID::Parse(), MODULE::Reference(), RotatePoint(), MODULE::SetAttributes(), TEXTE_MODULE::SetDrawCoord(), MODULE::SetFPID(), EDA_TEXT::SetItalic(), TEXTE_MODULE::SetKeepUpright(), MODULE::SetLastEditTime(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), MODULE::SetOrientation(), TEXTE_MODULE::SetPos0(), MODULE::SetPosition(), EDA_TEXT::SetText(), TEXTE_MODULE::SetTextAngle(), PCAD2KICAD::SetTextSizeFromStrokeFontHeight(), PCAD2KICAD::SetTextSizeFromTrueTypeFontHeight(), EDA_TEXT::SetThickness(), TEXTE_MODULE::SetType(), EDA_TEXT::SetVisible(), PCAD2KICAD::_TTEXTVALUE::text, TEXTE_MODULE::TEXT_is_REFERENCE, TEXTE_MODULE::TEXT_is_VALUE, PCAD2KICAD::_TTEXTVALUE::textHeight, PCAD2KICAD::_TTEXTVALUE::textIsVisible, PCAD2KICAD::_TTEXTVALUE::textRotation, PCAD2KICAD::_TTEXTVALUE::textstrokeWidth, PCAD2KICAD::ValidateReference(), and MODULE::Value().

◆ AddToModule()

void PCAD2KICAD::PCB_COMPONENT::AddToModule ( MODULE aModule)
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_MODULE::DoLayerContentsObjects ( XNODE aNode,
PCB_MODULE aPCBModule,
PCB_COMPONENTS_ARRAY *  aList,
wxStatusBar *  aStatusBar,
const wxString &  aDefaultMeasurementUnit,
const wxString &  aActualConversion 
)

Definition at line 216 of file pcb_module.cpp.

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

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_TEXT::Parse(), PCAD2KICAD::PCB_LINE::Parse(), PCAD2KICAD::PCB_ARC::Parse(), PCAD2KICAD::PCB_POLYGON::Parse(), PCAD2KICAD::SetFontProperty(), and PCAD2KICAD::PCB_POLYGON::SetOutline().

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

◆ FindModulePatternDefName()

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

Definition at line 70 of file pcb_module.cpp.

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

Definition at line 124 of file pcb_module.cpp.

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

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 630 of file pcb_module.cpp.

631 {
632  int i;
633 
634  if( m_mirror == 1 )
635  {
637 
638  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
639  {
640  if( m_moduleObjects[i]->m_objType == wxT( 'L' ) || // lines
641  m_moduleObjects[i]->m_objType == wxT( 'A' ) || // arcs
642  m_moduleObjects[i]->m_objType == wxT( 'Z' ) || // polygons
643  m_moduleObjects[i]->m_objType == wxT( 'P' ) || // pads
644  m_moduleObjects[i]->m_objType == wxT( 'V' ) ) // vias
645  {
646  m_moduleObjects[i]->Flip();
647  }
648  }
649  }
650 }
PCB_COMPONENTS_ARRAY m_moduleObjects
Definition: pcb_module.h:44

References m_mirror, m_moduleObjects, PCAD2KICAD::PCB_COMPONENT::m_objType, and PCAD2KICAD::PCB_COMPONENT::m_rotation.

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

◆ GetKiCadLayer()

◆ GetNetCode()

◆ ModuleLayer()

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

Definition at line 482 of file pcb_module.cpp.

483 {
484  wxString result;
485 
486  // ///NOT ! {IntToStr(KiCadLayer)} NOT !
487  // / MODULES ARE HARD PLACED ON COMPONENT OR COPPER LAYER.
488  // / IsFLIPPED--> MIRROR attribute is decision Point!!!
489 
490  if( aMirror == 0 )
491  result = wxT( "15" ); // Components side
492  else
493  result = wxT( "0" ); // Copper side
494 
495  return result;
496 }

◆ Parse()

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

Definition at line 389 of file pcb_module.cpp.

392 {
393  XNODE* lNode, * tNode, * mNode;
394  PCB_PAD* pad;
395  PCB_VIA* via;
396  wxString propValue, str;
397 
398  FindNode( aNode, wxT( "originalName" ) )->GetAttribute( wxT( "Name" ),
399  &propValue );
400  propValue.Trim( false );
401  m_name.text = propValue;
402 
403  // aStatusBar->SetStatusText( wxT( "Creating Component : " ) + m_name.text );
404  lNode = aNode;
406 
407  if( lNode )
408  {
409  tNode = lNode;
410  tNode = tNode->GetChildren();
411 
412  while( tNode )
413  {
414  if( tNode->GetName() == wxT( "pad" ) )
415  {
416  pad = new PCB_PAD( m_callbacks, m_board );
417  pad->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
418  m_moduleObjects.Add( pad );
419  }
420 
421  if( tNode->GetName() == wxT( "via" ) )
422  {
423  via = new PCB_VIA( m_callbacks, m_board );
424  via->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
425  m_moduleObjects.Add( via );
426  }
427 
428  tNode = tNode->GetNext();
429  }
430  }
431 
432  if( lNode )
433  lNode = lNode->GetParent();
434 
435  if( lNode )
436  lNode = FindNode( lNode, wxT( "layerContents" ) );
437 
438  while( lNode )
439  {
440  if( lNode->GetName() == wxT( "layerContents" ) )
441  DoLayerContentsObjects( lNode, this, &m_moduleObjects, aStatusBar,
442  aDefaultMeasurementUnit, aActualConversion );
443 
444  lNode = lNode->GetNext();
445  }
446 
447  // map pins
448  lNode = FindPinMap( aNode );
449 
450  if( lNode )
451  {
452  mNode = lNode->GetChildren();
453 
454  while( mNode )
455  {
456  if( mNode->GetName() == wxT( "padNum" ) )
457  {
458  str = mNode->GetNodeContent();
459  mNode = mNode->GetNext();
460 
461  if( !mNode )
462  break;
463 
464  mNode->GetAttribute( wxT( "Name" ), &propValue );
465  SetName( str, propValue );
466  mNode = mNode->GetNext();
467  }
468  else
469  {
470  mNode = mNode->GetNext();
471 
472  if( !mNode )
473  break;
474 
475  mNode = mNode->GetNext();
476  }
477  }
478  }
479 }
void SetName(const wxString &aPin, const wxString &aName)
Definition: pcb_module.cpp:371
XNODE * FindPatternMultilayerSection(XNODE *aNode, wxString *aPatGraphRefName)
Definition: pcb_module.cpp:124
XNODE * GetChildren() const
Definition: xnode.h:63
XNODE * GetParent() const
Definition: xnode.h:73
XNODE holds an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:68
void DoLayerContentsObjects(XNODE *aNode, PCB_MODULE *aPCBModule, PCB_COMPONENTS_ARRAY *aList, wxStatusBar *aStatusBar, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
Definition: pcb_module.cpp:216
PCB_COMPONENTS_ARRAY m_moduleObjects
Definition: pcb_module.h:44
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
PCB_CALLBACKS * m_callbacks
Definition: pcb_component.h:77
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_moduleObjects, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName, PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_PAD::Parse(), SetName(), and PCAD2KICAD::_TTEXTVALUE::text.

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

◆ SetName()

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

Definition at line 371 of file pcb_module.cpp.

372 {
373  int i;
374  long num;
375 
376  aPin.ToLong( &num );
377 
378  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
379  {
380  if( m_moduleObjects[i]->m_objType == wxT( 'P' ) )
381  if( ( (PCB_PAD*) m_moduleObjects[i] )->m_number == num )
382  ( (PCB_PAD*) m_moduleObjects[i] )->m_name.text = aName;
383 
384 
385  }
386 }
PCB_COMPONENTS_ARRAY m_moduleObjects
Definition: pcb_module.h:44

References m_moduleObjects, 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_MODULE::m_boardOutline

Definition at line 46 of file pcb_module.h.

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

◆ m_callbacks

◆ m_compRef

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited

◆ m_KiCadLayer

◆ m_mirror

int PCAD2KICAD::PCB_MODULE::m_mirror

Definition at line 45 of file pcb_module.h.

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

◆ m_moduleObjects

PCB_COMPONENTS_ARRAY PCAD2KICAD::PCB_MODULE::m_moduleObjects

◆ 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 51 of file pcb_component.h.

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

◆ m_uuid

KIID PCAD2KICAD::PCB_COMPONENT::m_uuid
inherited

Definition at line 55 of file pcb_component.h.

◆ m_value

TTEXTVALUE PCAD2KICAD::PCB_MODULE::m_value

Definition at line 43 of file pcb_module.h.

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


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