KiCad PCB EDA Suite
PCAD2KICAD::PCB Class Reference

#include <pcb.h>

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

Public Member Functions

 PCB (BOARD *aBoard)
 
 ~PCB ()
 
PCB_LAYER_ID GetKiCadLayer (int aPCadLayer) override
 
LAYER_TYPE_T GetLayerType (int aPCadLayer) override
 
wxString GetLayerNetNameRef (int aPCadLayer) override
 
int GetNewTimestamp () override
 
int GetNetCode (wxString aNetName) override
 
void Parse (wxStatusBar *aStatusBar, wxXmlDocument *aXmlDoc, wxString aActualConversion)
 
void AddToBoard () override
 
XNODEFindModulePatternDefName (XNODE *aNode, wxString aName)
 
void DoLayerContentsObjects (XNODE *aNode, PCB_MODULE *aPCBModule, PCB_COMPONENTS_ARRAY *aList, wxStatusBar *aStatusBar, wxString aDefaultMeasurementUnit, wxString aActualConversion)
 
void SetPadName (wxString aPin, wxString aName)
 
virtual void Parse (XNODE *aNode, wxStatusBar *aStatusBar, wxString aDefaultMeasurementUnit, wxString aActualConversion)
 
virtual void Flip () override
 
virtual void SetPosOffset (int aX_offs, int aY_offs)
 
virtual void AddToModule (MODULE *aModule)
 
PCB_LAYER_ID GetKiCadLayer ()
 

Public Attributes

PCB_COMPONENTS_ARRAY m_pcbComponents
 
PCB_NETS_ARRAY m_pcbNetlist
 
wxString m_defaultMeasurementUnit
 
TLAYER m_layersMap [MAX_PCAD_LAYER_QTY]
 
int m_sizeX
 
int m_sizeY
 
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
 
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
 

Private Member Functions

XNODEFindCompDefName (XNODE *aNode, wxString aName)
 
void SetTextProperty (XNODE *aNode, TTEXTVALUE *aTextValue, wxString aPatGraphRefName, wxString aXmlName, wxString aActualConversion)
 
void DoPCBComponents (XNODE *aNode, wxXmlDocument *aXmlDoc, wxString aActualConversion, wxStatusBar *aStatusBar)
 
void ConnectPinToNet (wxString aCr, wxString aPr, wxString aNetName)
 
int FindLayer (wxString aLayerName)
 
void MapLayer (XNODE *aNode)
 
int FindOutlinePoint (VERTICES_ARRAY *aOutline, wxRealPoint aPoint)
 
double GetDistance (wxRealPoint *aPoint1, wxRealPoint *aPoint2)
 
void GetBoardOutline (wxXmlDocument *aXmlDoc, wxString aActualConversion)
 

Private Attributes

int m_timestamp_cnt
 
wxArrayString m_layersStackup
 

Detailed Description

Definition at line 43 of file pcb.h.

Constructor & Destructor Documentation

PCAD2KICAD::PCB::PCB ( BOARD aBoard)

Definition at line 69 of file pcb.cpp.

References B_Cu, B_SilkS, Eco2_User, F_Cu, F_Mask, F_SilkS, _TLAYER::KiCadLayer, LAYER_TYPE_NONSIGNAL, LAYER_TYPE_SIGNAL, _TLAYER::layerType, m_defaultMeasurementUnit, m_layersMap, m_sizeX, m_sizeY, m_timestamp_cnt, MAX_PCAD_LAYER_QTY, and _TLAYER::netNameRef.

69  : PCB_MODULE( this, aBoard )
70 {
71  int i;
72 
73  m_defaultMeasurementUnit = wxT( "mil" );
74 
75  for( i = 0; i < MAX_PCAD_LAYER_QTY; i++ )
76  {
77  m_layersMap[i].KiCadLayer = F_Mask; // default
79  m_layersMap[i].netNameRef = wxT( "" ); // default
80  }
81 
82  m_sizeX = 0;
83  m_sizeY = 0;
84 
87 
90 
94  m_timestamp_cnt = 0x10000000;
95 }
wxString netNameRef
Definition: pcb_callbacks.h:47
int m_sizeX
Definition: pcb.h:50
#define MAX_PCAD_LAYER_QTY
Definition: pcb.h:41
TLAYER m_layersMap[MAX_PCAD_LAYER_QTY]
Definition: pcb.h:49
int m_sizeY
Definition: pcb.h:51
PCB_MODULE(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
Definition: pcb_module.cpp:50
PCB_LAYER_ID KiCadLayer
Definition: pcb_callbacks.h:45
int m_timestamp_cnt
Definition: pcb.h:69
LAYER_TYPE_T layerType
Definition: pcb_callbacks.h:46
wxString m_defaultMeasurementUnit
Definition: pcb.h:48
PCAD2KICAD::PCB::~PCB ( )

Definition at line 98 of file pcb.cpp.

References m_pcbComponents, and m_pcbNetlist.

99 {
100  int i;
101 
102  for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
103  {
104  delete m_pcbComponents[i];
105  }
106 
107  for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ )
108  {
109  delete m_pcbNetlist[i];
110  }
111 }
PCB_NETS_ARRAY m_pcbNetlist
Definition: pcb.h:47
PCB_COMPONENTS_ARRAY m_pcbComponents
Definition: pcb.h:46

Member Function Documentation

void PCAD2KICAD::PCB::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 917 of file pcb.cpp.

References BOARD::Add(), PCAD2KICAD::PCB_COMPONENT::m_board, m_layersStackup, PCAD2KICAD::PCB_NET::m_name, PCAD2KICAD::PCB_NET::m_netCode, m_pcbComponents, m_pcbNetlist, and BOARD::SetCopperLayerCount().

Referenced by PCAD_PLUGIN::Load().

918 {
919  int i;
920  PCB_NET* net;
921 
923 
924  for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ )
925  {
926  net = m_pcbNetlist[i];
927 
928  m_board->Add( new NETINFO_ITEM( m_board, net->m_name, net->m_netCode ) );
929  }
930 
931  for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
932  {
933  m_pcbComponents[i]->AddToBoard();
934  }
935 }
PCB_NETS_ARRAY m_pcbNetlist
Definition: pcb.h:47
void SetCopperLayerCount(int aCount)
wxArrayString m_layersStackup
Definition: pcb.h:70
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
Adds an item to the container.
Class NETINFO_ITEM handles the data for a net.
Definition: class_netinfo.h:69
PCB_COMPONENTS_ARRAY m_pcbComponents
Definition: pcb.h:46
void PCAD2KICAD::PCB_COMPONENT::AddToModule ( MODULE aModule)
virtualinherited
void PCAD2KICAD::PCB::ConnectPinToNet ( wxString  aCr,
wxString  aPr,
wxString  aNetName 
)
private

Definition at line 423 of file pcb.cpp.

References PCAD2KICAD::PCB_MODULE::m_moduleObjects, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_net, PCAD2KICAD::PCB_COMPONENT::m_objType, m_pcbComponents, and PCAD2KICAD::_TTEXTVALUE::text.

Referenced by Parse().

424 {
425  PCB_MODULE* module;
426  PCB_PAD* cp;
427  int i, j;
428 
429  for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
430  {
431  module = (PCB_MODULE*) m_pcbComponents[i];
432 
433  if( module->m_objType == wxT( 'M' ) && module->m_name.text == aCompRef )
434  {
435  for( j = 0; j < (int) module->m_moduleObjects.GetCount(); j++ )
436  {
437  if( module->m_moduleObjects[j]->m_objType == wxT( 'P' ) )
438  {
439  cp = (PCB_PAD*) module->m_moduleObjects[j];
440 
441  if( cp->m_name.text == aPinRef )
442  cp->m_net = aNetName;
443  }
444  }
445  }
446  }
447 }
PCB_MODULE(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
Definition: pcb_module.cpp:50
PCB_COMPONENTS_ARRAY m_pcbComponents
Definition: pcb.h:46
void PCAD2KICAD::PCB_MODULE::DoLayerContentsObjects ( XNODE aNode,
PCB_MODULE aPCBModule,
PCB_COMPONENTS_ARRAY *  aList,
wxStatusBar *  aStatusBar,
wxString  aDefaultMeasurementUnit,
wxString  aActualConversion 
)
inherited

Definition at line 217 of file pcb_module.cpp.

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, PCAD2KICAD::PCB_MODULE::m_boardOutline, PCAD2KICAD::PCB_COMPONENT::m_callbacks, PCAD2KICAD::PCB_POLYGON::m_cutouts, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_PLANE::Parse(), PCAD2KICAD::PCB_CUTOUT::Parse(), PCAD2KICAD::PCB_COPPER_POUR::Parse(), PCAD2KICAD::PCB_TEXT::Parse(), PCAD2KICAD::PCB_ARC::Parse(), PCAD2KICAD::PCB_LINE::Parse(), PCAD2KICAD::PCB_POLYGON::Parse(), PCAD2KICAD::SetFontProperty(), and PCAD2KICAD::PCB_POLYGON::SetOutline().

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

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

Definition at line 234 of file pcb.cpp.

References FindCompDefName(), PCAD2KICAD::PCB_MODULE::FindModulePatternDefName(), PCAD2KICAD::FindNode(), PCAD2KICAD::FindNodeGetContent(), PCAD2KICAD::FindPinMap(), XNODE::GetChildren(), XNODE::GetNext(), XNODE::GetParent(), PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_callbacks, PCAD2KICAD::PCB_COMPONENT::m_compRef, m_defaultMeasurementUnit, PCAD2KICAD::PCB_MODULE::m_mirror, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName, m_pcbComponents, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, PCAD2KICAD::PCB_COMPONENT::m_rotation, PCAD2KICAD::PCB_MODULE::m_value, PCAD2KICAD::PCB_KEEPOUT::Parse(), PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_PAD::Parse(), PCAD2KICAD::PCB_MODULE::Parse(), PCAD2KICAD::PCB_MODULE::PCB_MODULE(), PCAD2KICAD::PCB_MODULE::SetPadName(), PCAD2KICAD::SetPosition(), SetTextProperty(), PCAD2KICAD::StrToInt1Units(), PCAD2KICAD::_TTEXTVALUE::text, and PCAD2KICAD::ValidateName().

Referenced by Parse().

238 {
239  XNODE* lNode, * tNode, * mNode;
240  PCB_MODULE* mc;
241  PCB_PAD* pad;
242  PCB_VIA* via;
243  PCB_KEEPOUT* keepOut;
244  wxString cn, str, propValue;
245 
246  lNode = aNode->GetChildren();
247 
248  while( lNode )
249  {
250  mc = NULL;
251 
252  if( lNode->GetName() == wxT( "pattern" ) )
253  {
254  FindNode( lNode, wxT( "patternRef" ) )->GetAttribute( wxT( "Name" ),
255  &cn );
256  cn = ValidateName( cn );
257  tNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
258 
259  if( tNode && cn.Len() > 0 )
260  {
261  tNode = FindModulePatternDefName( tNode, cn );
262 
263  if( tNode )
264  {
265  mc = new PCB_MODULE( this, m_board );
266 
267  mNode = FindNode( lNode, wxT( "patternGraphicsNameRef" ) );
268  if( mNode )
269  mNode->GetAttribute( wxT( "Name" ), &mc->m_patGraphRefName );
270 
271  mc->Parse( tNode, aStatusBar, m_defaultMeasurementUnit, aActualConversion );
272  }
273  }
274 
275  if( mc )
276  {
277  mc->m_compRef = cn; // default - in new version of file it is updated later....
278  tNode = FindNode( lNode, wxT( "refDesRef" ) );
279 
280  if( tNode )
281  {
282  tNode->GetAttribute( wxT( "Name" ), &mc->m_name.text );
283  SetTextProperty( lNode, &mc->m_name, mc->m_patGraphRefName, wxT(
284  "RefDes" ), aActualConversion );
285  SetTextProperty( lNode, &mc->m_value, mc->m_patGraphRefName, wxT(
286  "Value" ), aActualConversion );
287  }
288 
289  tNode = FindNode( lNode, wxT( "pt" ) );
290 
291  if( tNode )
292  SetPosition( tNode->GetNodeContent(),
294  &mc->m_positionX,
295  &mc->m_positionY,
296  aActualConversion );
297 
298  tNode = FindNode( lNode, wxT( "rotation" ) );
299 
300  if( tNode )
301  {
302  str = tNode->GetNodeContent();
303  str.Trim( false );
304  mc->m_rotation = StrToInt1Units( str );
305  }
306 
307  str = FindNodeGetContent( lNode, wxT( "isFlipped" ) );
308 
309  if( str == wxT( "True" ) )
310  mc->m_mirror = 1;
311 
312  tNode = aNode;
313 
314  while( tNode->GetName() != wxT( "www.lura.sk" ) )
315  tNode = tNode->GetParent();
316 
317  tNode = FindNode( tNode, wxT( "netlist" ) );
318 
319  if( tNode )
320  {
321  tNode = FindNode( tNode, wxT( "compInst" ) );
322 
323  while( tNode )
324  {
325  tNode->GetAttribute( wxT( "Name" ), &propValue );
326 
327  if( propValue == mc->m_name.text )
328  {
329  if( FindNode( tNode, wxT( "compValue" ) ) )
330  {
331  FindNode( tNode,
332  wxT( "compValue" ) )->GetAttribute( wxT( "Name" ),
333  &mc->m_value.text );
334  mc->m_value.text.Trim( false );
335  mc->m_value.text.Trim( true );
336  }
337 
338  if( FindNode( tNode, wxT( "compRef" ) ) )
339  {
340  FindNode( tNode,
341  wxT( "compRef" ) )->GetAttribute( wxT( "Name" ),
342  &mc->m_compRef );
343  mc->m_compRef.Trim( false );
344  mc->m_compRef.Trim( true );
345  }
346 
347  tNode = NULL;
348  }
349  else
350  tNode = tNode->GetNext();
351  }
352  }
353 
354  // map pins
355  tNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
356  tNode = FindCompDefName( tNode, mc->m_compRef );
357 
358  if( tNode )
359  {
360  tNode = FindPinMap( tNode );
361 
362  if( tNode )
363  {
364  mNode = tNode->GetChildren();
365 
366  while( mNode )
367  {
368  if( mNode->GetName() == wxT( "padNum" ) )
369  {
370  str = mNode->GetNodeContent();
371  mNode = mNode->GetNext();
372 
373  if( !mNode )
374  break;
375 
376  mNode->GetAttribute( wxT( "Name" ), &propValue );
377  mc->SetPadName( str, propValue );
378  mNode = mNode->GetNext();
379  }
380  else
381  {
382  mNode = mNode->GetNext();
383 
384  if( !mNode )
385  break;
386 
387  mNode = mNode->GetNext();
388  }
389  }
390  }
391  }
392 
393  m_pcbComponents.Add( mc );
394  }
395  }
396  else if( lNode->GetName() == wxT( "pad" ) )
397  {
398  pad = new PCB_PAD( this, m_board );
399  pad->Parse( lNode, m_defaultMeasurementUnit, aActualConversion );
400  m_pcbComponents.Add( pad );
401  }
402  else if( lNode->GetName() == wxT( "via" ) )
403  {
404  via = new PCB_VIA( this, m_board );
405  via->Parse( lNode, m_defaultMeasurementUnit, aActualConversion );
406  m_pcbComponents.Add( via );
407  }
408  else if( lNode->GetName() == wxT( "polyKeepOut" ) )
409  {
410  keepOut = new PCB_KEEPOUT( m_callbacks, m_board, 0 );
411 
412  if( keepOut->Parse( lNode, m_defaultMeasurementUnit, aActualConversion ) )
413  m_pcbComponents.Add( keepOut );
414  else
415  delete keepOut;
416  }
417 
418  lNode = lNode->GetNext();
419  }
420 }
XNODE * FindCompDefName(XNODE *aNode, wxString aName)
Definition: pcb.cpp:136
int StrToInt1Units(wxString aStr)
XNODE * FindModulePatternDefName(XNODE *aNode, wxString aName)
Definition: pcb_module.cpp:71
XNODE * GetParent() const
Definition: xnode.h:73
wxString FindNodeGetContent(XNODE *aChild, wxString aTag)
wxString ValidateName(wxString aName)
PCB_MODULE(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
Definition: pcb_module.cpp:50
void SetTextProperty(XNODE *aNode, TTEXTVALUE *aTextValue, wxString aPatGraphRefName, wxString aXmlName, wxString aActualConversion)
Definition: pcb.cpp:164
XNODE * GetChildren() const
Definition: xnode.h:63
void SetPosition(wxString aStr, wxString aDefaultMeasurementUnit, int *aX, int *aY, wxString aActualConversion)
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
PCB_COMPONENTS_ARRAY m_pcbComponents
Definition: pcb.h:46
XNODE * FindNode(XNODE *aChild, wxString aTag)
PCB_CALLBACKS * m_callbacks
Definition: pcb_component.h:78
XNODE * GetNext() const
Definition: xnode.h:68
XNODE * FindPinMap(XNODE *aNode)
wxString m_defaultMeasurementUnit
Definition: pcb.h:48
XNODE * PCAD2KICAD::PCB::FindCompDefName ( XNODE aNode,
wxString  aName 
)
private

Definition at line 136 of file pcb.cpp.

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

Referenced by DoPCBComponents().

137 {
138  XNODE* result = NULL, * lNode;
139  wxString propValue;
140 
141  lNode = FindNode( aNode, wxT( "compDef" ) );
142 
143  while( lNode )
144  {
145  if( lNode->GetName() == wxT( "compDef" ) )
146  {
147  lNode->GetAttribute( wxT( "Name" ), &propValue );
148 
149  if( propValue == aName )
150  {
151  result = lNode;
152  lNode = NULL;
153  }
154  }
155 
156  if( lNode )
157  lNode = lNode->GetNext();
158  }
159 
160  return result;
161 }
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
int PCAD2KICAD::PCB::FindLayer ( wxString  aLayerName)
private

Definition at line 450 of file pcb.cpp.

References m_layersStackup.

Referenced by MapLayer().

451 {
452  for( LAYER_NUM i = 0; i < (int)m_layersStackup.GetCount(); ++i )
453  {
454  if( m_layersStackup[i] == aLayerName )
455  return i;
456  }
457 
458  return -1;
459 }
wxArrayString m_layersStackup
Definition: pcb.h:70
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
XNODE * PCAD2KICAD::PCB_MODULE::FindModulePatternDefName ( XNODE aNode,
wxString  aName 
)
inherited

Definition at line 71 of file pcb_module.cpp.

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

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

72 {
73  XNODE* result, * lNode;
74  wxString propValue1, propValue2;
75 
76  result = NULL;
77  lNode = FindNode( aNode, wxT( "patternDef" ) );
78 
79  while( lNode )
80  {
81  if( lNode->GetName() == wxT( "patternDef" ) )
82  {
83  lNode->GetAttribute( wxT( "Name" ), &propValue1 );
84  FindNode( lNode,
85  wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), &propValue2 );
86 
87  if( ValidateName( propValue1 ) == aName
88  || ValidateName( propValue2 ) == aName )
89  {
90  result = lNode;
91  lNode = NULL;
92  }
93  }
94 
95  if( lNode )
96  lNode = lNode->GetNext();
97  }
98 
99  if( result == NULL )
100  {
101  lNode = FindNode( aNode, wxT( "patternDefExtended" ) ); // New file format
102 
103  while( lNode )
104  {
105  if( lNode->GetName() == wxT( "patternDefExtended" ) )
106  {
107  lNode->GetAttribute( wxT( "Name" ), &propValue1 );
108 
109  if( ValidateName( propValue1 ) == aName )
110  {
111  result = lNode;
112  lNode = NULL;
113  }
114  }
115 
116  if( lNode )
117  lNode = lNode->GetNext();
118  }
119  }
120 
121  return result;
122 }
wxString ValidateName(wxString aName)
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
int PCAD2KICAD::PCB::FindOutlinePoint ( VERTICES_ARRAY *  aOutline,
wxRealPoint  aPoint 
)
private

Definition at line 552 of file pcb.cpp.

Referenced by GetBoardOutline().

553 {
554  int i;
555 
556  for( i = 0; i < (int) aOutline->GetCount(); i++ )
557  if( *((*aOutline)[i]) == aPoint )
558  return i;
559 
560  return -1;
561 }
void PCAD2KICAD::PCB_MODULE::Flip ( )
overridevirtualinherited

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 615 of file pcb_module.cpp.

References FlipLayer(), PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_MODULE::m_mirror, PCAD2KICAD::PCB_MODULE::m_moduleObjects, PCAD2KICAD::PCB_COMPONENT::m_objType, and PCAD2KICAD::PCB_COMPONENT::m_rotation.

Referenced by Parse().

616 {
617  int i;
618 
619  if( m_mirror == 1 )
620  {
621  // Flipped
624 
625  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
626  {
627  if( m_moduleObjects[i]->m_objType == wxT( 'L' ) || // lines
628  m_moduleObjects[i]->m_objType == wxT( 'A' ) || // arcs
629  m_moduleObjects[i]->m_objType == wxT( 'P' ) || // pads
630  m_moduleObjects[i]->m_objType == wxT( 'V' ) ) // vias
631  {
632  m_moduleObjects[i]->Flip();
633  }
634  }
635  }
636 }
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:445
PCB_COMPONENTS_ARRAY m_moduleObjects
Definition: pcb_module.h:44
void PCAD2KICAD::PCB::GetBoardOutline ( wxXmlDocument *  aXmlDoc,
wxString  aActualConversion 
)
private

Definition at line 578 of file pcb.cpp.

References Edge_Cuts, PCAD2KICAD::FindNode(), FindOutlinePoint(), XNODE::GetChildren(), GetDistance(), PCAD2KICAD::PCB_COMPONENT::GetKiCadLayer(), XNODE::GetNext(), PCAD2KICAD::PCB_MODULE::m_boardOutline, m_defaultMeasurementUnit, and PCAD2KICAD::SetPosition().

Referenced by Parse().

579 {
580  XNODE* iNode, *lNode, *pNode;
581  long PCadLayer = 0;
582  int x, y, i, j, targetInd;
583  wxRealPoint* xchgPoint;
584  double minDistance, distance;
585 
586  iNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
587 
588  if( iNode )
589  {
590  // COMPONENTS AND OBJECTS
591  iNode = iNode->GetChildren();
592 
593  while( iNode )
594  {
595  // objects
596  if( iNode->GetName() == wxT( "layerContents" ) )
597  {
598  if( FindNode( iNode, wxT( "layerNumRef" ) ) )
599  FindNode( iNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
600 
601  if( GetKiCadLayer( PCadLayer ) == Edge_Cuts )
602  {
603  lNode = iNode->GetChildren();
604  while( lNode )
605  {
606  if( lNode->GetName() == wxT( "line" ) )
607  {
608  pNode = FindNode( lNode, wxT( "pt" ) );
609 
610  if( pNode )
611  {
612  SetPosition( pNode->GetNodeContent(), m_defaultMeasurementUnit,
613  &x, &y, aActualConversion );
614 
615  if( FindOutlinePoint( &m_boardOutline, wxRealPoint( x, y) ) == -1 )
616  m_boardOutline.Add( new wxRealPoint( x, y ) );
617  }
618 
619  if( pNode )
620  pNode = pNode->GetNext();
621 
622  if( pNode )
623  {
624  SetPosition( pNode->GetNodeContent(), m_defaultMeasurementUnit,
625  &x, &y, aActualConversion );
626 
627  if( FindOutlinePoint( &m_boardOutline, wxRealPoint( x, y) ) == -1 )
628  m_boardOutline.Add( new wxRealPoint( x, y ) );
629  }
630  }
631 
632  lNode = lNode->GetNext();
633  }
634 
635  //m_boardOutline.Sort( cmpFunc );
636  // sort vertices according to the distances between them
637  if( m_boardOutline.GetCount() > 3 )
638  {
639  for( i = 0; i < (int) m_boardOutline.GetCount() - 1; i++ )
640  {
641  minDistance = GetDistance( m_boardOutline[i], m_boardOutline[i + 1] );
642  targetInd = i + 1;
643 
644  for( j = i + 2; j < (int) m_boardOutline.GetCount(); j++ )
645  {
646  distance = GetDistance( m_boardOutline[i], m_boardOutline[j] );
647  if( distance < minDistance )
648  {
649  minDistance = distance;
650  targetInd = j;
651  }
652  }
653 
654  xchgPoint = m_boardOutline[i + 1];
655  m_boardOutline[i + 1] = m_boardOutline[targetInd];
656  m_boardOutline[targetInd] = xchgPoint;
657  }
658  }
659 
660  break;
661  }
662  }
663 
664  iNode = iNode->GetNext();
665  }
666  }
667 }
PCB_LAYER_ID GetKiCadLayer()
Definition: pcb_component.h:73
int FindOutlinePoint(VERTICES_ARRAY *aOutline, wxRealPoint aPoint)
Definition: pcb.cpp:552
XNODE * GetChildren() const
Definition: xnode.h:63
void SetPosition(wxString aStr, wxString aDefaultMeasurementUnit, int *aX, int *aY, wxString aActualConversion)
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
double GetDistance(wxRealPoint *aPoint1, wxRealPoint *aPoint2)
Definition: pcb.cpp:570
XNODE * FindNode(XNODE *aChild, wxString aTag)
XNODE * GetNext() const
Definition: xnode.h:68
wxString m_defaultMeasurementUnit
Definition: pcb.h:48
VERTICES_ARRAY m_boardOutline
Definition: pcb_module.h:46
double PCAD2KICAD::PCB::GetDistance ( wxRealPoint *  aPoint1,
wxRealPoint *  aPoint2 
)
private

Definition at line 570 of file pcb.cpp.

Referenced by GetBoardOutline().

571 {
572  return sqrt( ( aPoint1->x - aPoint2->x ) *
573  ( aPoint1->x - aPoint2->x ) +
574  ( aPoint1->y - aPoint2->y ) *
575  ( aPoint1->y - aPoint2->y ) );
576 }
PCB_LAYER_ID PCAD2KICAD::PCB::GetKiCadLayer ( int  aPCadLayer)
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 51 of file pcb.cpp.

References _TLAYER::KiCadLayer, m_layersMap, and MAX_PCAD_LAYER_QTY.

52 {
53  wxASSERT( aPCadLayer >= 0 && aPCadLayer < MAX_PCAD_LAYER_QTY );
54  return m_layersMap[aPCadLayer].KiCadLayer;
55 }
#define MAX_PCAD_LAYER_QTY
Definition: pcb.h:41
TLAYER m_layersMap[MAX_PCAD_LAYER_QTY]
Definition: pcb.h:49
PCB_LAYER_ID KiCadLayer
Definition: pcb_callbacks.h:45
wxString PCAD2KICAD::PCB::GetLayerNetNameRef ( int  aPCadLayer)
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 63 of file pcb.cpp.

References m_layersMap, MAX_PCAD_LAYER_QTY, and _TLAYER::netNameRef.

64 {
65  wxASSERT( aPCadLayer >= 0 && aPCadLayer < MAX_PCAD_LAYER_QTY );
66  return m_layersMap[aPCadLayer].netNameRef;
67 }
wxString netNameRef
Definition: pcb_callbacks.h:47
#define MAX_PCAD_LAYER_QTY
Definition: pcb.h:41
TLAYER m_layersMap[MAX_PCAD_LAYER_QTY]
Definition: pcb.h:49
LAYER_TYPE_T PCAD2KICAD::PCB::GetLayerType ( int  aPCadLayer)
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 57 of file pcb.cpp.

References _TLAYER::layerType, m_layersMap, and MAX_PCAD_LAYER_QTY.

58 {
59  wxASSERT( aPCadLayer >= 0 && aPCadLayer < MAX_PCAD_LAYER_QTY );
60  return m_layersMap[aPCadLayer].layerType;
61 }
#define MAX_PCAD_LAYER_QTY
Definition: pcb.h:41
TLAYER m_layersMap[MAX_PCAD_LAYER_QTY]
Definition: pcb.h:49
LAYER_TYPE_T layerType
Definition: pcb_callbacks.h:46
int PCAD2KICAD::PCB::GetNetCode ( wxString  aNetName)
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 119 of file pcb.cpp.

References PCAD2KICAD::PCB_NET::m_name, PCAD2KICAD::PCB_NET::m_netCode, and m_pcbNetlist.

120 {
121  PCB_NET* net;
122 
123  for( int i = 0; i < (int) m_pcbNetlist.GetCount(); i++ )
124  {
125  net = m_pcbNetlist[i];
126 
127  if( net->m_name == aNetName )
128  {
129  return net->m_netCode;
130  }
131  }
132 
133  return 0;
134 }
PCB_NETS_ARRAY m_pcbNetlist
Definition: pcb.h:47
int PCAD2KICAD::PCB::GetNewTimestamp ( )
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 114 of file pcb.cpp.

References m_timestamp_cnt.

115 {
116  return m_timestamp_cnt++;
117 }
int m_timestamp_cnt
Definition: pcb.h:69
void PCAD2KICAD::PCB::MapLayer ( XNODE aNode)
private

Definition at line 480 of file pcb.cpp.

References B_Cu, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Edge_Cuts, F_Cu, F_Mask, F_Paste, F_SilkS, FindLayer(), PCAD2KICAD::FindNode(), FIRST_COPPER_LAYER, Format(), LAYER_TYPE_NONSIGNAL, LAYER_TYPE_PLANE, LAYER_TYPE_SIGNAL, _TLAYER::layerType, m_layersMap, m_layersStackup, MAX_PCAD_LAYER_QTY, THROW_IO_ERROR, and ToLAYER_ID().

Referenced by Parse().

481 {
482  wxString lName, layerType;
483  PCB_LAYER_ID KiCadLayer;
484  long num = 0;
485 
486  aNode->GetAttribute( wxT( "Name" ), &lName );
487  lName = lName.MakeUpper();
488 
489  if( lName == wxT( "TOP ASSY" ) )
490  KiCadLayer = Cmts_User;
491  else if( lName == wxT( "TOP SILK" ) )
492  KiCadLayer = F_SilkS;
493  else if( lName == wxT( "TOP PASTE" ) )
494  KiCadLayer = F_Paste;
495  else if( lName == wxT( "TOP MASK" ) )
496  KiCadLayer = F_Mask;
497  else if( lName == wxT( "TOP" ) )
498  KiCadLayer = F_Cu;
499  else if( lName == wxT( "BOTTOM" ) )
500  KiCadLayer = B_Cu;
501  else if( lName == wxT( "BOT MASK" ) )
502  KiCadLayer = B_Mask;
503  else if( lName == wxT( "BOT PASTE" ) )
504  KiCadLayer = B_Paste;
505  else if( lName == wxT( "BOT SILK" ) )
506  KiCadLayer = B_SilkS;
507  else if( lName == wxT( "BOT ASSY" ) )
508  KiCadLayer = Dwgs_User;
509  else if( lName == wxT( "BOARD" ) )
510  KiCadLayer = Edge_Cuts;
511  else
512  {
513  int layernum = FindLayer( lName );
514 
515  if( layernum == -1 )
516  KiCadLayer = Dwgs_User; // default
517  else
518 #if 0 // was:
519  KiCadLayer = FIRST_COPPER_LAYER + m_layersStackup.GetCount() - 1 - layernum;
520 #else
521  KiCadLayer = ToLAYER_ID( layernum );
522 #endif
523  }
524 
525  if( FindNode( aNode, wxT( "layerNum" ) ) )
526  FindNode( aNode, wxT( "layerNum" ) )->GetNodeContent().ToLong( &num );
527 
528  if( num < 0 || num >= MAX_PCAD_LAYER_QTY )
529  THROW_IO_ERROR( wxString::Format( wxT( "layerNum = %ld is out of range" ), num ) );
530 
531  m_layersMap[(int) num].KiCadLayer = KiCadLayer;
532 
533  if( FindNode( aNode, wxT( "layerType" ) ) )
534  {
535  layerType = FindNode( aNode, wxT( "layerType" ) )->GetNodeContent().Trim( false );
536 
537  if( layerType == wxT( "NonSignal" ) )
538  m_layersMap[(int) num].layerType = LAYER_TYPE_NONSIGNAL;
539  if( layerType == wxT( "Signal" ) )
541  if( layerType == wxT( "Plane" ) )
543  }
544 
545  if( FindNode( aNode, wxT( "netNameRef" ) ) )
546  {
547  FindNode( aNode, wxT( "netNameRef" ) )->GetAttribute( wxT( "Name" ),
548  &m_layersMap[(int) num].netNameRef );
549  }
550 }
#define MAX_PCAD_LAYER_QTY
Definition: pcb.h:41
TLAYER m_layersMap[MAX_PCAD_LAYER_QTY]
Definition: pcb.h:49
PCB_LAYER_ID
A quick note on layer IDs:
wxArrayString m_layersStackup
Definition: pcb.h:70
int FindLayer(wxString aLayerName)
Definition: pcb.cpp:450
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
#define FIRST_COPPER_LAYER
XNODE * FindNode(XNODE *aChild, wxString aTag)
LAYER_TYPE_T layerType
Definition: pcb_callbacks.h:46
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
void PCAD2KICAD::PCB::Parse ( wxStatusBar *  aStatusBar,
wxXmlDocument *  aXmlDoc,
wxString  aActualConversion 
)

Definition at line 669 of file pcb.cpp.

References ConnectPinToNet(), PCAD2KICAD::PCB_MODULE::DoLayerContentsObjects(), DoPCBComponents(), PCAD2KICAD::FindNode(), PCAD2KICAD::PCB_MODULE::Flip(), GetBoardOutline(), XNODE::GetChildren(), XNODE::GetNext(), PCAD2KICAD::PCB_COMPONENT::m_board, m_defaultMeasurementUnit, m_layersStackup, PCAD2KICAD::PCB_NET::m_name, PCAD2KICAD::PCB_NET::m_netNodes, PCAD2KICAD::PCB_COMPONENT::m_objType, m_pcbComponents, m_pcbNetlist, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, m_sizeX, m_sizeY, MapLayer(), PCAD2KICAD::PCB_NET::Parse(), PCAD2KICAD::PCB_MODULE::Parse(), PCAD2KICAD::PCB_MODULE::PCB_MODULE(), and PCAD2KICAD::PCB_COMPONENT::SetPosOffset().

Referenced by PCAD_PLUGIN::Load().

670 {
671  XNODE* aNode;//, *aaNode;
672  PCB_NET* net;
673  PCB_COMPONENT* comp;
674  PCB_MODULE* module;
675  wxString compRef, pinRef, layerName, layerType;
676  int i, j, netCode;
677 
678  // Defaut measurement units
679  aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "asciiHeader" ) );
680 
681  if( aNode )
682  {
683  aNode = FindNode( aNode, wxT( "fileUnits" ) );
684 
685  if( aNode )
686  {
687  m_defaultMeasurementUnit = aNode->GetNodeContent().Lower();
688  m_defaultMeasurementUnit.Trim( true );
689  m_defaultMeasurementUnit.Trim( false );
690  }
691  }
692 
693  // Determine layers stackup
694  aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
695 
696  /*if( aNode )
697  {
698  aNode = FindNode( aNode, wxT( "layersStackup" ) );
699 
700  if( aNode )
701  {
702  aNode = FindNode( aNode, wxT( "layerStackupData" ) );
703 
704  while( aNode )
705  {
706  if( aNode->GetName() == wxT( "layerStackupData" ) )
707  {
708  aaNode = FindNode( aNode, wxT( "layerStackupName" ) );
709 
710  if( aaNode ) {
711  aaNode->GetAttribute( wxT( "Name" ), &layerName );
712  layerName = layerName.MakeUpper();
713  m_layersStackup.Add( layerName );
714  }
715  }
716 
717  aNode = aNode->GetNext();
718  }
719  }
720  }*/
721 
722  if( aNode )
723  {
724  aNode = FindNode( aNode, wxT( "layerDef" ) );
725 
726  while( aNode )
727  {
728  if( aNode->GetName() == wxT( "layerDef" ) )
729  {
730  if( FindNode( aNode, wxT( "layerType" ) ) )
731  {
732  layerType = FindNode( aNode,
733  wxT( "layerType" ) )->GetNodeContent().Trim( false );
734 
735  if( layerType == wxT( "Signal" ) || layerType == wxT( "Plane" ) )
736  {
737  aNode->GetAttribute( wxT( "Name" ), &layerName );
738  layerName = layerName.MakeUpper();
739  m_layersStackup.Add( layerName );
740  }
741  }
742  }
743 
744  aNode = aNode->GetNext();
745  }
746  }
747 
748  // Layers mapping
749  aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
750 
751  if( aNode )
752  {
753  aNode = FindNode( aNode, wxT( "layerDef" ) );
754 
755  while( aNode )
756  {
757  if( aNode->GetName() == wxT( "layerDef" ) )
758  MapLayer( aNode );
759 
760  aNode = aNode->GetNext();
761  }
762  }
763 
764  GetBoardOutline( aXmlDoc, aActualConversion );
765 
766  // NETLIST
767  // aStatusBar->SetStatusText( wxT( "Loading NETLIST " ) );
768 
769  aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "netlist" ) );
770 
771  if( aNode )
772  {
773  aNode = FindNode( aNode, wxT( "net" ) );
774 
775  netCode = 1;
776 
777  while( aNode )
778  {
779  net = new PCB_NET( netCode++ );
780  net->Parse( aNode );
781  m_pcbNetlist.Add( net );
782 
783  aNode = aNode->GetNext();
784  }
785  }
786 
787  // BOARD FILE
788  // aStatusBar->SetStatusText( wxT( "Loading BOARD DEFINITION " ) );
789 
790  aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
791 
792  if( aNode )
793  {
794  // COMPONENTS AND OBJECTS
795  aNode = aNode->GetChildren();
796 
797  while( aNode )
798  {
799  // Components/modules
800  if( aNode->GetName() == wxT( "multiLayer" ) )
801  DoPCBComponents( aNode, aXmlDoc, aActualConversion, aStatusBar );
802 
803  // objects
804  if( aNode->GetName() == wxT( "layerContents" ) )
805  DoLayerContentsObjects( aNode, NULL, &m_pcbComponents, aStatusBar,
806  m_defaultMeasurementUnit, aActualConversion );
807 
808  aNode = aNode->GetNext();
809  }
810 
811  // POSTPROCESS -- SET NETLIST REFERENCES
812  // aStatusBar->SetStatusText( wxT( "Processing NETLIST " ) );
813 
814  for( i = 0; i < (int) m_pcbNetlist.GetCount(); i++ )
815  {
816  net = m_pcbNetlist[i];
817 
818  for( j = 0; j < (int) net->m_netNodes.GetCount(); j++ )
819  {
820  compRef = net->m_netNodes[j]->m_compRef;
821  compRef.Trim( false );
822  compRef.Trim( true );
823  pinRef = net->m_netNodes[j]->m_pinRef;
824  pinRef.Trim( false );
825  pinRef.Trim( true );
826  ConnectPinToNet( compRef, pinRef, net->m_name );
827  }
828  }
829 
830  // POSTPROCESS -- FLIP COMPONENTS
831  for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
832  {
833  if( m_pcbComponents[i]->m_objType == wxT( 'M' ) )
834  ( (PCB_MODULE*) m_pcbComponents[i] )->Flip();
835  }
836 
837  // POSTPROCESS -- SET/OPTIMIZE NEW PCB POSITION
838  // aStatusBar->SetStatusText( wxT( "Optimizing BOARD POSITION " ) );
839 
840  m_sizeX = 10000000;
841  m_sizeY = 0;
842 
843  for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
844  {
845  comp = m_pcbComponents[i];
846 
847  if( comp->m_positionY < m_sizeY )
848  m_sizeY = comp->m_positionY; // max Y
849 
850  if( comp->m_positionX < m_sizeX && comp->m_positionX > 0 )
851  m_sizeX = comp->m_positionX; // Min X
852  }
853 
854  m_sizeY -= 10000;
855  m_sizeX -= 10000;
856  // aStatusBar->SetStatusText( wxT( " POSITIONING POSTPROCESS " ) );
857 
858  for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
860 
861  m_sizeX = 0;
862  m_sizeY = 0;
863 
864  for( i = 0; i < (int) m_pcbComponents.GetCount(); i++ )
865  {
866  comp = m_pcbComponents[i];
867 
868  if( comp->m_positionY < m_sizeY )
869  m_sizeY = comp->m_positionY; // max Y
870 
871  if( comp->m_positionX > m_sizeX )
872  m_sizeX = comp->m_positionX; // Min X
873  }
874 
875  // SHEET SIZE CALCULATION
876  m_sizeY = -m_sizeY; // it is in absolute units
877  m_sizeX += 10000;
878  m_sizeY += 10000;
879 
880  // A4 is minimum $Descr A4 11700 8267
881  if( m_sizeX < 11700 )
882  m_sizeX = 11700;
883 
884  if( m_sizeY < 8267 )
885  m_sizeY = 8267;
886  }
887  else
888  {
889  // LIBRARY FILE
890  // aStatusBar->SetStatusText( wxT( "Processing LIBRARY FILE " ) );
891 
892  aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
893 
894  if( aNode )
895  {
896  aNode = FindNode( aNode, wxT( "compDef" ) );
897 
898  while( aNode )
899  {
900  // aStatusBar->SetStatusText( wxT( "Processing COMPONENTS " ) );
901 
902  if( aNode->GetName() == wxT( "compDef" ) )
903  {
904  module = new PCB_MODULE( this, m_board );
905  module->Parse( aNode, aStatusBar, m_defaultMeasurementUnit,
906  aActualConversion );
907  m_pcbComponents.Add( module );
908  }
909 
910  aNode = aNode->GetNext();
911  }
912  }
913  }
914 }
void ConnectPinToNet(wxString aCr, wxString aPr, wxString aNetName)
Definition: pcb.cpp:423
int m_sizeX
Definition: pcb.h:50
void GetBoardOutline(wxXmlDocument *aXmlDoc, wxString aActualConversion)
Definition: pcb.cpp:578
PCB_NETS_ARRAY m_pcbNetlist
Definition: pcb.h:47
virtual void SetPosOffset(int aX_offs, int aY_offs)
void DoPCBComponents(XNODE *aNode, wxXmlDocument *aXmlDoc, wxString aActualConversion, wxStatusBar *aStatusBar)
Definition: pcb.cpp:234
wxArrayString m_layersStackup
Definition: pcb.h:70
int m_sizeY
Definition: pcb.h:51
PCB_MODULE(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
Definition: pcb_module.cpp:50
virtual void Flip() override
Definition: pcb_module.cpp:615
XNODE * GetChildren() const
Definition: xnode.h:63
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
void MapLayer(XNODE *aNode)
Definition: pcb.cpp:480
PCB_COMPONENTS_ARRAY m_pcbComponents
Definition: pcb.h:46
XNODE * FindNode(XNODE *aChild, wxString aTag)
void DoLayerContentsObjects(XNODE *aNode, PCB_MODULE *aPCBModule, PCB_COMPONENTS_ARRAY *aList, wxStatusBar *aStatusBar, wxString aDefaultMeasurementUnit, wxString aActualConversion)
Definition: pcb_module.cpp:217
XNODE * GetNext() const
Definition: xnode.h:68
PCB_COMPONENT(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
wxString m_defaultMeasurementUnit
Definition: pcb.h:48
void PCAD2KICAD::PCB_MODULE::Parse ( XNODE aNode,
wxStatusBar *  aStatusBar,
wxString  aDefaultMeasurementUnit,
wxString  aActualConversion 
)
virtualinherited

Definition at line 393 of file pcb_module.cpp.

References PCAD2KICAD::PCB_MODULE::DoLayerContentsObjects(), PCAD2KICAD::FindNode(), PCAD2KICAD::PCB_MODULE::FindPatternMultilayerSection(), PCAD2KICAD::FindPinMap(), XNODE::GetChildren(), XNODE::GetNext(), XNODE::GetParent(), PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_callbacks, PCAD2KICAD::PCB_MODULE::m_moduleObjects, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName, PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_PAD::Parse(), PCAD2KICAD::PCB_MODULE::SetPadName(), and PCAD2KICAD::_TTEXTVALUE::text.

Referenced by DoPCBComponents(), and Parse().

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

Definition at line 375 of file pcb_module.cpp.

References PCAD2KICAD::PCB_MODULE::m_moduleObjects, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_objType, and PCAD2KICAD::_TTEXTVALUE::text.

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

376 {
377  int i;
378  long num;
379 
380  aPin.ToLong( &num );
381 
382  for( i = 0; i < (int) m_moduleObjects.GetCount(); i++ )
383  {
384  if( m_moduleObjects[i]->m_objType == wxT( 'P' ) )
385  if( ( (PCB_PAD*) m_moduleObjects[i] )->m_number == num )
386  ( (PCB_PAD*) m_moduleObjects[i] )->m_name.text = aName;
387 
388 
389  }
390 }
PCB_COMPONENTS_ARRAY m_moduleObjects
Definition: pcb_module.h:44
void PCAD2KICAD::PCB_COMPONENT::SetPosOffset ( int  aX_offs,
int  aY_offs 
)
virtualinherited
void PCAD2KICAD::PCB::SetTextProperty ( XNODE aNode,
TTEXTVALUE aTextValue,
wxString  aPatGraphRefName,
wxString  aXmlName,
wxString  aActualConversion 
)
private

Definition at line 164 of file pcb.cpp.

References PCAD2KICAD::FindNode(), XNODE::GetNext(), m_defaultMeasurementUnit, PCAD2KICAD::SetTextParameters(), and PCAD2KICAD::_TTEXTVALUE::text.

Referenced by DoPCBComponents().

167 {
168  XNODE* tNode, * t1Node;
169  wxString n, nnew, pn, propValue, str;
170 
171  // aNode is pattern now
172  tNode = aNode;
173  t1Node = aNode;
174  n = aXmlName;
175 
176  // new file format version
177  if( FindNode( tNode, wxT( "patternGraphicsNameRef" ) ) )
178  {
179  FindNode( tNode,
180  wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
181  &pn );
182  pn.Trim( false );
183  pn.Trim( true );
184  tNode = FindNode( tNode, wxT( "patternGraphicsRef" ) );
185 
186  while( tNode )
187  {
188  if( tNode->GetName() == wxT( "patternGraphicsRef" ) )
189  {
190  if( FindNode( tNode, wxT( "patternGraphicsNameRef" ) ) )
191  {
192  FindNode( tNode,
193  wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
194  &propValue );
195 
196  if( propValue == pn )
197  {
198  t1Node = tNode; // find correct section with same name.
199  str = aTextValue->text;
200  str.Trim( false );
201  str.Trim( true );
202  nnew = n; // new file version
203  n = n + wxT( ' ' ) + str; // old file version
204  tNode = NULL;
205  }
206  }
207  }
208 
209  if( tNode )
210  tNode = tNode->GetNext();
211  }
212  }
213 
214  // old version and compatibile fr both from this point
215  tNode = FindNode( t1Node, wxT( "attr" ) );
216 
217  while( tNode )
218  {
219  tNode->GetAttribute( wxT( "Name" ), &propValue );
220  propValue.Trim( false );
221  propValue.Trim( true );
222 
223  if( propValue == n || propValue == nnew )
224  break;
225 
226  tNode = tNode->GetNext();
227  }
228 
229  if( tNode )
230  SetTextParameters( tNode, aTextValue, m_defaultMeasurementUnit, aActualConversion );
231 }
void SetTextParameters(XNODE *aNode, TTEXTVALUE *aTextValue, wxString aDefaultMeasurementUnit, wxString aActualConversion)
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
wxString m_defaultMeasurementUnit
Definition: pcb.h:48

Member Data Documentation

VERTICES_ARRAY PCAD2KICAD::PCB_MODULE::m_boardOutline
inherited

Definition at line 46 of file pcb_module.h.

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

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited
wxString PCAD2KICAD::PCB::m_defaultMeasurementUnit

Definition at line 48 of file pcb.h.

Referenced by DoPCBComponents(), GetBoardOutline(), Parse(), PCB(), and SetTextProperty().

TLAYER PCAD2KICAD::PCB::m_layersMap[MAX_PCAD_LAYER_QTY]

Definition at line 49 of file pcb.h.

Referenced by GetKiCadLayer(), GetLayerNetNameRef(), GetLayerType(), MapLayer(), and PCB().

wxArrayString PCAD2KICAD::PCB::m_layersStackup
private

Definition at line 70 of file pcb.h.

Referenced by AddToBoard(), FindLayer(), MapLayer(), and Parse().

int PCAD2KICAD::PCB_MODULE::m_mirror
inherited
wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited
PCB_COMPONENTS_ARRAY PCAD2KICAD::PCB::m_pcbComponents

Definition at line 46 of file pcb.h.

Referenced by AddToBoard(), ConnectPinToNet(), DoPCBComponents(), Parse(), and ~PCB().

PCB_NETS_ARRAY PCAD2KICAD::PCB::m_pcbNetlist

Definition at line 47 of file pcb.h.

Referenced by AddToBoard(), GetNetCode(), Parse(), and ~PCB().

int PCAD2KICAD::PCB::m_sizeX

Definition at line 50 of file pcb.h.

Referenced by Parse(), and PCB().

int PCAD2KICAD::PCB::m_sizeY

Definition at line 51 of file pcb.h.

Referenced by Parse(), and PCB().

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::m_timestamp_cnt
private

Definition at line 69 of file pcb.h.

Referenced by GetNewTimestamp(), and PCB().

TTEXTVALUE PCAD2KICAD::PCB_MODULE::m_value
inherited

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