KiCad PCB EDA Suite
PCAD2KICAD::PCB Class Reference

#include <pcb.h>

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

Public Member Functions

 PCB (BOARD *aBoard)
 
 ~PCB ()
 
PCB_LAYER_ID GetKiCadLayer (int aPCadLayer) const override
 
LAYER_TYPE_T GetLayerType (int aPCadLayer) const override
 
wxString GetLayerNetNameRef (int aPCadLayer) const override
 
int GetNetCode (const wxString &aNetName) const override
 
void ParseBoard (wxStatusBar *aStatusBar, wxXmlDocument *aXmlDoc, const wxString &aActualConversion)
 
void AddToBoard () override
 
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
 
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

PCB_COMPONENTS_ARRAY m_PcbComponents
 
PCB_NETS_ARRAY m_PcbNetlist
 
wxString m_DefaultMeasurementUnit
 
std::map< int, TLAYERm_LayersMap
 
int m_SizeX
 
int m_SizeY
 
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

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

Private Attributes

wxArrayString m_layersStackup
 

Detailed Description

Definition at line 42 of file pcb.h.

Constructor & Destructor Documentation

◆ PCB()

PCAD2KICAD::PCB::PCB ( BOARD aBoard)

Definition at line 74 of file pcb.cpp.

74  :
75  PCB_FOOTPRINT( this, aBoard )
76 {
77  m_DefaultMeasurementUnit = wxT( "mil" );
78 
79  for( size_t i = 0; i < 8; ++i )
80  {
81  TLAYER layer;
82  layer.KiCadLayer = F_Mask; // default
83  layer.layerType = LAYER_TYPE_NONSIGNAL; // default
84  layer.netNameRef = wxT( "" ); // default
85 
86  m_LayersMap.insert( std::make_pair( i, layer ) );
87  }
88 
89  m_SizeX = 0;
90  m_SizeY = 0;
91 
92  m_LayersMap[1].KiCadLayer = F_Cu;
93  m_LayersMap[1].layerType = LAYER_TYPE_SIGNAL;
94 
95  m_LayersMap[2].KiCadLayer = B_Cu;
96  m_LayersMap[2].layerType = LAYER_TYPE_SIGNAL;
97 
98  m_LayersMap[3].KiCadLayer = Eco2_User;
99  m_LayersMap[6].KiCadLayer = F_SilkS;
100  m_LayersMap[7].KiCadLayer = B_SilkS;
101 }
int m_SizeX
Definition: pcb.h:49
wxString netNameRef
Definition: pcb_callbacks.h:47
std::map< int, TLAYER > m_LayersMap
Definition: pcb.h:48
wxString m_DefaultMeasurementUnit
Definition: pcb.h:47
int m_SizeY
Definition: pcb.h:50
PCB_LAYER_ID KiCadLayer
Definition: pcb_callbacks.h:45
PCB_FOOTPRINT(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
LAYER_TYPE_T layerType
Definition: pcb_callbacks.h:46

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, and _TLAYER::netNameRef.

◆ ~PCB()

PCAD2KICAD::PCB::~PCB ( )

Definition at line 104 of file pcb.cpp.

105 {
106  int i;
107 
108  for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
109  {
110  delete m_PcbComponents[i];
111  }
112 
113  for( i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
114  {
115  delete m_PcbNetlist[i];
116  }
117 }
PCB_COMPONENTS_ARRAY m_PcbComponents
Definition: pcb.h:45
PCB_NETS_ARRAY m_PcbNetlist
Definition: pcb.h:46

References m_PcbComponents, and m_PcbNetlist.

Member Function Documentation

◆ AddToBoard()

void PCAD2KICAD::PCB::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 925 of file pcb.cpp.

926 {
927  int i;
928  PCB_NET* net;
929 
931 
932  for( i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
933  {
934  net = m_PcbNetlist[i];
935 
936  m_board->Add( new NETINFO_ITEM( m_board, net->m_Name, net->m_NetCode ) );
937  }
938 
939  for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
940  {
941  m_PcbComponents[i]->AddToBoard();
942  }
943 }
void SetCopperLayerCount(int aCount)
Definition: board.cpp:441
PCB_COMPONENTS_ARRAY m_PcbComponents
Definition: pcb.h:45
PCB_NETS_ARRAY m_PcbNetlist
Definition: pcb.h:46
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:563
wxArrayString m_layersStackup
Definition: pcb.h:66
Handle the data for a net.
Definition: netinfo.h:64

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().

◆ AddToFootprint()

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

◆ ConnectPinToNet()

void PCAD2KICAD::PCB::ConnectPinToNet ( const wxString &  aCr,
const wxString &  aPr,
const wxString &  aNetName 
)
private

Definition at line 424 of file pcb.cpp.

426 {
427  PCB_FOOTPRINT* footprint;
428  PCB_PAD* cp;
429  int i, j;
430 
431  for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
432  {
433  footprint = (PCB_FOOTPRINT*) m_PcbComponents[i];
434 
435  if( footprint->m_objType == wxT( 'M' ) && footprint->m_name.text == aCompRef )
436  {
437  for( j = 0; j < (int) footprint->m_FootprintItems.GetCount(); j++ )
438  {
439  if( footprint->m_FootprintItems[j]->m_objType == wxT( 'P' ) )
440  {
441  cp = (PCB_PAD*) footprint->m_FootprintItems[j];
442 
443  if( cp->m_name.text == aPinRef )
444  cp->m_net = aNetName;
445  }
446  }
447  }
448  }
449 }
PCB_COMPONENTS_ARRAY m_PcbComponents
Definition: pcb.h:45
PCB_FOOTPRINT(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)

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

Referenced by ParseBoard().

◆ DoLayerContentsObjects()

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

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

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

◆ DoPCBComponents()

void PCAD2KICAD::PCB::DoPCBComponents ( XNODE aNode,
wxXmlDocument *  aXmlDoc,
const wxString &  aActualConversion,
wxStatusBar *  aStatusBar 
)
private

Definition at line 236 of file pcb.cpp.

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

References FindCompDefName(), PCAD2KICAD::PCB_FOOTPRINT::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_FOOTPRINT::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_FOOTPRINT::m_Value, NULL, pad, PCAD2KICAD::PCB_KEEPOUT::Parse(), PCAD2KICAD::PCB_FOOTPRINT::Parse(), PCAD2KICAD::PCB_FOOTPRINT::PCB_FOOTPRINT(), PCAD2KICAD::PCB_FOOTPRINT::SetName(), PCAD2KICAD::SetPosition(), SetTextProperty(), PCAD2KICAD::StrToInt1Units(), PCAD2KICAD::_TTEXTVALUE::text, PCAD2KICAD::ValidateName(), and via.

Referenced by ParseBoard().

◆ FindCompDefName()

XNODE * PCAD2KICAD::PCB::FindCompDefName ( XNODE aNode,
const wxString &  aName 
) const
private

Definition at line 137 of file pcb.cpp.

138 {
139  XNODE* result = NULL, * lNode;
140  wxString propValue;
141 
142  lNode = FindNode( aNode, wxT( "compDef" ) );
143 
144  while( lNode )
145  {
146  if( lNode->GetName() == wxT( "compDef" ) )
147  {
148  lNode->GetAttribute( wxT( "Name" ), &propValue );
149 
150  if( propValue == aName )
151  {
152  result = lNode;
153  lNode = NULL;
154  }
155  }
156 
157  if( lNode )
158  lNode = lNode->GetNext();
159  }
160 
161  return result;
162 }
#define NULL
Hold an XML or S-expression element.
Definition: xnode.h:43
XNODE * FindNode(XNODE *aChild, const wxString &aTag)

References PCAD2KICAD::FindNode(), and NULL.

Referenced by DoPCBComponents().

◆ FindLayer()

int PCAD2KICAD::PCB::FindLayer ( const wxString &  aLayerName) const
private

Definition at line 452 of file pcb.cpp.

453 {
454  for( LAYER_NUM i = 0; i < (int)m_layersStackup.GetCount(); ++i )
455  {
456  if( m_layersStackup[i] == aLayerName )
457  return i;
458  }
459 
460  return -1;
461 }
wxArrayString m_layersStackup
Definition: pcb.h:66
int LAYER_NUM
This can be replaced with int and removed.

References m_layersStackup.

Referenced by MapLayer().

◆ FindModulePatternDefName()

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

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 DoPCBComponents(), and PCAD2KICAD::PCB_FOOTPRINT::FindPatternMultilayerSection().

◆ FindOutlinePoint()

int PCAD2KICAD::PCB::FindOutlinePoint ( const VERTICES_ARRAY *  aOutline,
wxRealPoint  aPoint 
) const
private

Definition at line 557 of file pcb.cpp.

558 {
559  int i;
560 
561  for( i = 0; i < (int) aOutline->GetCount(); i++ )
562  if( *((*aOutline)[i]) == aPoint )
563  return i;
564 
565  return -1;
566 }

Referenced by GetBoardOutline().

◆ Flip()

void PCAD2KICAD::PCB_FOOTPRINT::Flip ( )
overridevirtualinherited

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 PCAD2KICAD::PCB_FOOTPRINT::m_FootprintItems, PCAD2KICAD::PCB_FOOTPRINT::m_Mirror, PCAD2KICAD::PCB_COMPONENT::m_objType, and PCAD2KICAD::PCB_COMPONENT::m_rotation.

Referenced by ParseBoard().

◆ GetBoardOutline()

void PCAD2KICAD::PCB::GetBoardOutline ( wxXmlDocument *  aXmlDoc,
const wxString &  aActualConversion 
)
private

Definition at line 583 of file pcb.cpp.

584 {
585  XNODE* iNode, *lNode, *pNode;
586  long PCadLayer = 0;
587  int x, y, i, j, targetInd;
588  wxRealPoint* xchgPoint;
589  double minDistance, distance;
590 
591  iNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
592 
593  if( iNode )
594  {
595  // COMPONENTS AND OBJECTS
596  iNode = iNode->GetChildren();
597 
598  while( iNode )
599  {
600  // objects
601  if( iNode->GetName() == wxT( "layerContents" ) )
602  {
603  if( FindNode( iNode, wxT( "layerNumRef" ) ) )
604  FindNode( iNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
605 
606  if( GetKiCadLayer( PCadLayer ) == Edge_Cuts )
607  {
608  lNode = iNode->GetChildren();
609  while( lNode )
610  {
611  if( lNode->GetName() == wxT( "line" ) )
612  {
613  pNode = FindNode( lNode, wxT( "pt" ) );
614 
615  if( pNode )
616  {
617  SetPosition( pNode->GetNodeContent(), m_DefaultMeasurementUnit,
618  &x, &y, aActualConversion );
619 
620  if( FindOutlinePoint( &m_BoardOutline, wxRealPoint( x, y) ) == -1 )
621  m_BoardOutline.Add( new wxRealPoint( x, y ) );
622  }
623 
624  if( pNode )
625  pNode = pNode->GetNext();
626 
627  if( pNode )
628  {
629  SetPosition( pNode->GetNodeContent(), m_DefaultMeasurementUnit,
630  &x, &y, aActualConversion );
631 
632  if( FindOutlinePoint( &m_BoardOutline, wxRealPoint( x, y) ) == -1 )
633  m_BoardOutline.Add( new wxRealPoint( x, y ) );
634  }
635  }
636 
637  lNode = lNode->GetNext();
638  }
639 
640  //m_boardOutline.Sort( cmpFunc );
641  // sort vertices according to the distances between them
642  if( m_BoardOutline.GetCount() > 3 )
643  {
644  for( i = 0; i < (int) m_BoardOutline.GetCount() - 1; i++ )
645  {
646  minDistance = GetDistance( m_BoardOutline[i], m_BoardOutline[ i + 1] );
647  targetInd = i + 1;
648 
649  for( j = i + 2; j < (int) m_BoardOutline.GetCount(); j++ )
650  {
652  if( distance < minDistance )
653  {
654  minDistance = distance;
655  targetInd = j;
656  }
657  }
658 
659  xchgPoint = m_BoardOutline[ i + 1];
660  m_BoardOutline[ i + 1] = m_BoardOutline[targetInd];
661  m_BoardOutline[targetInd] = xchgPoint;
662  }
663  }
664 
665  break;
666  }
667  }
668 
669  iNode = iNode->GetNext();
670  }
671  }
672 }
void SetPosition(wxString aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
int FindOutlinePoint(const VERTICES_ARRAY *aOutline, wxRealPoint aPoint) const
Definition: pcb.cpp:557
wxString m_DefaultMeasurementUnit
Definition: pcb.h:47
XNODE * GetChildren() const
Definition: xnode.h:62
VERTICES_ARRAY m_BoardOutline
Definition: pcb_footprint.h:42
double GetDistance(const wxRealPoint *aPoint1, const wxRealPoint *aPoint2) const
Definition: pcb.cpp:575
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
PCB_LAYER_ID GetKiCadLayer() const
Definition: pcb_component.h:70
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 distance(), Edge_Cuts, PCAD2KICAD::FindNode(), FindOutlinePoint(), XNODE::GetChildren(), GetDistance(), PCAD2KICAD::PCB_COMPONENT::GetKiCadLayer(), XNODE::GetNext(), PCAD2KICAD::PCB_FOOTPRINT::m_BoardOutline, m_DefaultMeasurementUnit, and PCAD2KICAD::SetPosition().

Referenced by ParseBoard().

◆ GetDistance()

double PCAD2KICAD::PCB::GetDistance ( const wxRealPoint *  aPoint1,
const wxRealPoint *  aPoint2 
) const
private

Definition at line 575 of file pcb.cpp.

576 {
577  return sqrt( ( aPoint1->x - aPoint2->x ) *
578  ( aPoint1->x - aPoint2->x ) +
579  ( aPoint1->y - aPoint2->y ) *
580  ( aPoint1->y - aPoint2->y ) );
581 }

Referenced by GetBoardOutline().

◆ GetKiCadLayer() [1/2]

PCB_LAYER_ID PCAD2KICAD::PCB::GetKiCadLayer ( int  aPCadLayer) const
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 44 of file pcb.cpp.

45 {
46  auto it = m_LayersMap.find( aPCadLayer );
47 
48  if( it == m_LayersMap.end() )
49  THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
50 
51  return it->second.KiCadLayer;
52 }
std::map< int, TLAYER > m_LayersMap
Definition: pcb.h:48
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), m_LayersMap, and THROW_IO_ERROR.

◆ GetKiCadLayer() [2/2]

◆ GetLayerNetNameRef()

wxString PCAD2KICAD::PCB::GetLayerNetNameRef ( int  aPCadLayer) const
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 64 of file pcb.cpp.

65 {
66  auto it = m_LayersMap.find( aPCadLayer );
67 
68  if( it == m_LayersMap.end() )
69  THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
70 
71  return it->second.netNameRef;
72 }
std::map< int, TLAYER > m_LayersMap
Definition: pcb.h:48
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), m_LayersMap, and THROW_IO_ERROR.

◆ GetLayerType()

LAYER_TYPE_T PCAD2KICAD::PCB::GetLayerType ( int  aPCadLayer) const
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 54 of file pcb.cpp.

55 {
56  auto it = m_LayersMap.find( aPCadLayer );
57 
58  if( it == m_LayersMap.end() )
59  THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
60 
61  return it->second.layerType;
62 }
std::map< int, TLAYER > m_LayersMap
Definition: pcb.h:48
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
#define _(s)
Definition: 3d_actions.cpp:33
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38

References _, Format(), m_LayersMap, and THROW_IO_ERROR.

◆ GetNetCode() [1/2]

int PCAD2KICAD::PCB::GetNetCode ( const wxString &  aNetName) const
overridevirtual

Implements PCAD2KICAD::PCB_CALLBACKS.

Definition at line 120 of file pcb.cpp.

121 {
122  const PCB_NET* net;
123 
124  for( int i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
125  {
126  net = m_PcbNetlist[i];
127 
128  if( net->m_Name == aNetName )
129  {
130  return net->m_NetCode;
131  }
132  }
133 
134  return 0;
135 }
PCB_NETS_ARRAY m_PcbNetlist
Definition: pcb.h:46

References PCAD2KICAD::PCB_NET::m_Name, PCAD2KICAD::PCB_NET::m_NetCode, and m_PcbNetlist.

◆ GetNetCode() [2/2]

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

◆ MapLayer()

void PCAD2KICAD::PCB::MapLayer ( XNODE aNode)
private

Definition at line 482 of file pcb.cpp.

483 {
484  wxString lName, layerType;
485  PCB_LAYER_ID KiCadLayer;
486  long num = 0;
487 
488  aNode->GetAttribute( wxT( "Name" ), &lName );
489  lName = lName.MakeUpper();
490 
491  if( lName == wxT( "TOP ASSY" ) )
492  KiCadLayer = F_Fab;
493  else if( lName == wxT( "TOP SILK" ) )
494  KiCadLayer = F_SilkS;
495  else if( lName == wxT( "TOP PASTE" ) )
496  KiCadLayer = F_Paste;
497  else if( lName == wxT( "TOP MASK" ) )
498  KiCadLayer = F_Mask;
499  else if( lName == wxT( "TOP" ) )
500  KiCadLayer = F_Cu;
501  else if( lName == wxT( "BOTTOM" ) )
502  KiCadLayer = B_Cu;
503  else if( lName == wxT( "BOT MASK" ) )
504  KiCadLayer = B_Mask;
505  else if( lName == wxT( "BOT PASTE" ) )
506  KiCadLayer = B_Paste;
507  else if( lName == wxT( "BOT SILK" ) )
508  KiCadLayer = B_SilkS;
509  else if( lName == wxT( "BOT ASSY" ) )
510  KiCadLayer = B_Fab;
511  else if( lName == wxT( "BOARD" ) )
512  KiCadLayer = Edge_Cuts;
513  else
514  {
515  int layernum = FindLayer( lName );
516 
517  if( layernum == -1 )
518  KiCadLayer = Dwgs_User; // default
519  else
520 #if 0 // was:
521  KiCadLayer = FIRST_COPPER_LAYER + m_layersStackup.GetCount() - 1 - layernum;
522 #else
523  KiCadLayer = ToLAYER_ID( layernum );
524 #endif
525  }
526 
527  if( FindNode( aNode, wxT( "layerNum" ) ) )
528  FindNode( aNode, wxT( "layerNum" ) )->GetNodeContent().ToLong( &num );
529 
530  if( num < 0 )
531  THROW_IO_ERROR( wxString::Format( wxT( "layerNum = %ld is out of range" ), num ) );
532 
533  TLAYER newlayer;
534  newlayer.KiCadLayer = KiCadLayer;
535 
536  if( FindNode( aNode, wxT( "layerType" ) ) )
537  {
538  layerType = FindNode( aNode, wxT( "layerType" ) )->GetNodeContent().Trim( false );
539 
540  if( layerType == wxT( "NonSignal" ) )
541  newlayer.layerType = LAYER_TYPE_NONSIGNAL;
542  if( layerType == wxT( "Signal" ) )
543  newlayer.layerType = LAYER_TYPE_SIGNAL;
544  if( layerType == wxT( "Plane" ) )
545  newlayer.layerType = LAYER_TYPE_PLANE;
546  }
547 
548  m_LayersMap.insert( std::make_pair( num, newlayer ) );
549 
550  if( FindNode( aNode, wxT( "netNameRef" ) ) )
551  {
552  FindNode( aNode, wxT( "netNameRef" ) )->GetAttribute( wxT( "Name" ),
553  &m_LayersMap[(int) num].netNameRef );
554  }
555 }
int FindLayer(const wxString &aLayerName) const
Definition: pcb.cpp:452
std::map< int, TLAYER > m_LayersMap
Definition: pcb.h:48
PCB_LAYER_ID
A quick note on layer IDs:
wxArrayString m_layersStackup
Definition: pcb.h:66
PCB_LAYER_ID KiCadLayer
Definition: pcb_callbacks.h:45
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
LAYER_TYPE_T layerType
Definition: pcb_callbacks.h:46
#define FIRST_COPPER_LAYER
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905

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

Referenced by ParseBoard().

◆ Parse()

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

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 PCAD2KICAD::PCB_FOOTPRINT::DoLayerContentsObjects(), PCAD2KICAD::FindNode(), PCAD2KICAD::PCB_FOOTPRINT::FindPatternMultilayerSection(), PCAD2KICAD::FindPinMap(), XNODE::GetChildren(), XNODE::GetNext(), XNODE::GetParent(), PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_callbacks, PCAD2KICAD::PCB_FOOTPRINT::m_FootprintItems, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName, pad, PCAD2KICAD::PCB_FOOTPRINT::SetName(), PCAD2KICAD::_TTEXTVALUE::text, and via.

Referenced by DoPCBComponents(), and ParseBoard().

◆ ParseBoard()

void PCAD2KICAD::PCB::ParseBoard ( wxStatusBar *  aStatusBar,
wxXmlDocument *  aXmlDoc,
const wxString &  aActualConversion 
)

Definition at line 674 of file pcb.cpp.

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

References _, ConnectPinToNet(), PCAD2KICAD::PCB_FOOTPRINT::DoLayerContentsObjects(), DoPCBComponents(), PCAD2KICAD::FindNode(), PCAD2KICAD::PCB_FOOTPRINT::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(), NULL, PCAD2KICAD::PCB_FOOTPRINT::Parse(), PCAD2KICAD::PCB_NET::Parse(), PCAD2KICAD::PCB_FOOTPRINT::PCB_FOOTPRINT(), PCAD2KICAD::PCB_COMPONENT::SetPosOffset(), and THROW_IO_ERROR.

Referenced by PCAD_PLUGIN::Load().

◆ SetName()

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

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 PCAD2KICAD::PCB_FOOTPRINT::m_FootprintItems, PCAD2KICAD::PCB_COMPONENT::m_name, PCAD2KICAD::PCB_COMPONENT::m_objType, and PCAD2KICAD::_TTEXTVALUE::text.

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

◆ SetPosOffset()

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

◆ SetTextProperty()

void PCAD2KICAD::PCB::SetTextProperty ( XNODE aNode,
TTEXTVALUE aTextValue,
const wxString &  aPatGraphRefName,
const wxString &  aXmlName,
const wxString &  aActualConversion 
)
private

Definition at line 165 of file pcb.cpp.

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

Referenced by DoPCBComponents().

Member Data Documentation

◆ m_board

◆ m_BoardOutline

VERTICES_ARRAY PCAD2KICAD::PCB_FOOTPRINT::m_BoardOutline
inherited

◆ m_callbacks

◆ m_compRef

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited

◆ m_DefaultMeasurementUnit

wxString PCAD2KICAD::PCB::m_DefaultMeasurementUnit

Definition at line 47 of file pcb.h.

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

◆ m_FootprintItems

◆ m_KiCadLayer

◆ m_LayersMap

std::map<int, TLAYER> PCAD2KICAD::PCB::m_LayersMap

Definition at line 48 of file pcb.h.

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

◆ m_layersStackup

wxArrayString PCAD2KICAD::PCB::m_layersStackup
private

Definition at line 66 of file pcb.h.

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

◆ m_Mirror

int PCAD2KICAD::PCB_FOOTPRINT::m_Mirror
inherited

◆ m_name

◆ m_net

◆ m_netCode

◆ m_objType

◆ m_patGraphRefName

wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited

◆ m_PCadLayer

◆ m_PcbComponents

PCB_COMPONENTS_ARRAY PCAD2KICAD::PCB::m_PcbComponents

Definition at line 45 of file pcb.h.

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

◆ m_PcbNetlist

PCB_NETS_ARRAY PCAD2KICAD::PCB::m_PcbNetlist

Definition at line 46 of file pcb.h.

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

◆ m_positionX

◆ m_positionY

◆ m_rotation

◆ m_SizeX

int PCAD2KICAD::PCB::m_SizeX

Definition at line 49 of file pcb.h.

Referenced by ParseBoard(), and PCB().

◆ m_SizeY

int PCAD2KICAD::PCB::m_SizeY

Definition at line 50 of file pcb.h.

Referenced by ParseBoard(), and PCB().

◆ 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
inherited

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