2012-12-29 09:54:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
|
2013-03-09 19:36:31 +00:00
|
|
|
* Copyright (C) 2007, 2008, 2012-2013 Alexander Lunev <al.lunev@yahoo.com>
|
2020-11-14 21:21:54 +00:00
|
|
|
* Copyright (C) 2012-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
|
2012-12-29 09:54:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file pcb.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <wx/wx.h>
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
|
|
|
|
#include <pcb.h>
|
|
|
|
#include <pcb_keepout.h>
|
2020-11-14 21:21:54 +00:00
|
|
|
#include <pcb_footprint.h>
|
2012-12-29 09:54:25 +00:00
|
|
|
#include <pcb_pad.h>
|
|
|
|
#include <pcb_text.h>
|
|
|
|
#include <pcb_via.h>
|
|
|
|
#include <s_expr_loader.h>
|
|
|
|
|
|
|
|
namespace PCAD2KICAD {
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
PCB_LAYER_ID PCB::GetKiCadLayer( int aPCadLayer ) const
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
auto it = m_LayersMap.find( aPCadLayer );
|
2020-02-28 19:43:37 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( it == m_LayersMap.end() )
|
2020-02-28 19:43:37 +00:00
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
|
|
|
|
|
|
|
|
return it->second.KiCadLayer;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
LAYER_TYPE_T PCB::GetLayerType( int aPCadLayer ) const
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
auto it = m_LayersMap.find( aPCadLayer );
|
2020-02-28 19:43:37 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( it == m_LayersMap.end() )
|
2020-02-28 19:43:37 +00:00
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
|
|
|
|
|
|
|
|
return it->second.layerType;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
wxString PCB::GetLayerNetNameRef( int aPCadLayer ) const
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
auto it = m_LayersMap.find( aPCadLayer );
|
2020-02-28 19:43:37 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( it == m_LayersMap.end() )
|
2020-02-28 19:43:37 +00:00
|
|
|
THROW_IO_ERROR( wxString::Format( _( "Unknown PCad layer %u" ), unsigned( aPCadLayer ) ) );
|
|
|
|
|
|
|
|
return it->second.netNameRef;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
PCB::PCB( BOARD* aBoard ) :
|
|
|
|
PCB_FOOTPRINT( this, aBoard )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
m_DefaultMeasurementUnit = wxT( "mil" );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-02-28 19:43:37 +00:00
|
|
|
for( size_t i = 0; i < 8; ++i )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-02-28 19:43:37 +00:00
|
|
|
TLAYER layer;
|
|
|
|
layer.KiCadLayer = F_Mask; // default
|
|
|
|
layer.layerType = LAYER_TYPE_NONSIGNAL; // default
|
|
|
|
layer.netNameRef = wxT( "" ); // default
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_LayersMap.insert( std::make_pair( i, layer ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_SizeX = 0;
|
|
|
|
m_SizeY = 0;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_LayersMap[1].KiCadLayer = F_Cu;
|
|
|
|
m_LayersMap[1].layerType = LAYER_TYPE_SIGNAL;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_LayersMap[2].KiCadLayer = B_Cu;
|
|
|
|
m_LayersMap[2].layerType = LAYER_TYPE_SIGNAL;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_LayersMap[3].KiCadLayer = Eco2_User;
|
|
|
|
m_LayersMap[6].KiCadLayer = F_SilkS;
|
|
|
|
m_LayersMap[7].KiCadLayer = B_SilkS;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB::~PCB()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
delete m_PcbComponents[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
delete m_PcbNetlist[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
int PCB::GetNetCode( const wxString& aNetName ) const
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-18 19:50:36 +00:00
|
|
|
const PCB_NET* net;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( int i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
net = m_PcbNetlist[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( net->m_Name == aNetName )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
return net->m_NetCode;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
XNODE* PCB::FindCompDefName( XNODE* aNode, const wxString& aName ) const
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
XNODE* result = NULL, * lNode;
|
|
|
|
wxString propValue;
|
|
|
|
|
|
|
|
lNode = FindNode( aNode, wxT( "compDef" ) );
|
|
|
|
|
|
|
|
while( lNode )
|
|
|
|
{
|
|
|
|
if( lNode->GetName() == wxT( "compDef" ) )
|
|
|
|
{
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
|
|
|
|
if( propValue == aName )
|
|
|
|
{
|
|
|
|
result = lNode;
|
|
|
|
lNode = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
lNode = lNode->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB::SetTextProperty( XNODE* aNode, TTEXTVALUE* aTextValue,
|
2017-09-23 09:20:10 +00:00
|
|
|
const wxString& aPatGraphRefName,
|
|
|
|
const wxString& aXmlName,
|
|
|
|
const wxString& aActualConversion )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
XNODE* tNode, * t1Node;
|
2016-02-24 11:56:40 +00:00
|
|
|
wxString n, nnew, pn, propValue, str;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
// aNode is pattern now
|
|
|
|
tNode = aNode;
|
|
|
|
t1Node = aNode;
|
|
|
|
n = aXmlName;
|
|
|
|
|
2013-03-09 19:36:31 +00:00
|
|
|
// new file format version
|
2012-12-29 09:54:25 +00:00
|
|
|
if( FindNode( tNode, wxT( "patternGraphicsNameRef" ) ) )
|
|
|
|
{
|
|
|
|
FindNode( tNode,
|
|
|
|
wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
|
|
|
|
&pn );
|
|
|
|
pn.Trim( false );
|
|
|
|
pn.Trim( true );
|
|
|
|
tNode = FindNode( tNode, wxT( "patternGraphicsRef" ) );
|
|
|
|
|
|
|
|
while( tNode )
|
|
|
|
{
|
|
|
|
if( tNode->GetName() == wxT( "patternGraphicsRef" ) )
|
|
|
|
{
|
|
|
|
if( FindNode( tNode, wxT( "patternGraphicsNameRef" ) ) )
|
|
|
|
{
|
|
|
|
FindNode( tNode,
|
|
|
|
wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
|
|
|
|
&propValue );
|
|
|
|
|
|
|
|
if( propValue == pn )
|
|
|
|
{
|
|
|
|
t1Node = tNode; // find correct section with same name.
|
|
|
|
str = aTextValue->text;
|
|
|
|
str.Trim( false );
|
|
|
|
str.Trim( true );
|
2016-02-24 11:56:40 +00:00
|
|
|
nnew = n; // new file version
|
|
|
|
n = n + wxT( ' ' ) + str; // old file version
|
2012-12-29 09:54:25 +00:00
|
|
|
tNode = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( tNode )
|
|
|
|
tNode = tNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// old version and compatibile fr both from this point
|
|
|
|
tNode = FindNode( t1Node, wxT( "attr" ) );
|
|
|
|
|
|
|
|
while( tNode )
|
|
|
|
{
|
|
|
|
tNode->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
propValue.Trim( false );
|
|
|
|
propValue.Trim( true );
|
|
|
|
|
2016-02-24 11:56:40 +00:00
|
|
|
if( propValue == n || propValue == nnew )
|
2012-12-29 09:54:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
tNode = tNode->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( tNode )
|
2020-11-14 21:21:54 +00:00
|
|
|
SetTextParameters( tNode, aTextValue, m_DefaultMeasurementUnit, aActualConversion );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB::DoPCBComponents( XNODE* aNode,
|
|
|
|
wxXmlDocument* aXmlDoc,
|
2017-09-23 09:20:10 +00:00
|
|
|
const wxString& aActualConversion,
|
2012-12-29 09:54:25 +00:00
|
|
|
wxStatusBar* aStatusBar )
|
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
XNODE* lNode, * tNode, * mNode;
|
|
|
|
PCB_FOOTPRINT* fp;
|
|
|
|
PCB_PAD* pad;
|
|
|
|
PCB_VIA* via;
|
|
|
|
PCB_KEEPOUT* keepOut;
|
|
|
|
wxString cn, str, propValue;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
lNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
while( lNode )
|
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
fp = NULL;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
if( lNode->GetName() == wxT( "pattern" ) )
|
|
|
|
{
|
|
|
|
FindNode( lNode, wxT( "patternRef" ) )->GetAttribute( wxT( "Name" ),
|
|
|
|
&cn );
|
|
|
|
cn = ValidateName( cn );
|
|
|
|
tNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
|
|
|
|
|
|
|
|
if( tNode && cn.Len() > 0 )
|
|
|
|
{
|
|
|
|
tNode = FindModulePatternDefName( tNode, cn );
|
|
|
|
|
|
|
|
if( tNode )
|
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
fp = new PCB_FOOTPRINT( this, m_board );
|
2013-03-09 19:36:31 +00:00
|
|
|
|
|
|
|
mNode = FindNode( lNode, wxT( "patternGraphicsNameRef" ) );
|
|
|
|
if( mNode )
|
2020-11-14 21:21:54 +00:00
|
|
|
mNode->GetAttribute( wxT( "Name" ), &fp->m_patGraphRefName );
|
2013-03-09 19:36:31 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
fp->Parse( tNode, aStatusBar, m_DefaultMeasurementUnit, aActualConversion );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( fp )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
fp->m_compRef = cn; // default - in new version of file it is updated later....
|
2012-12-29 09:54:25 +00:00
|
|
|
tNode = FindNode( lNode, wxT( "refDesRef" ) );
|
|
|
|
|
|
|
|
if( tNode )
|
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
tNode->GetAttribute( wxT( "Name" ), &fp->m_name.text );
|
|
|
|
SetTextProperty( lNode, &fp->m_name, fp->m_patGraphRefName, wxT( "RefDes" ),
|
|
|
|
aActualConversion );
|
|
|
|
SetTextProperty( lNode, &fp->m_Value, fp->m_patGraphRefName, wxT( "Value" ),
|
|
|
|
aActualConversion );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tNode = FindNode( lNode, wxT( "pt" ) );
|
|
|
|
|
|
|
|
if( tNode )
|
2020-11-14 21:21:54 +00:00
|
|
|
{
|
|
|
|
SetPosition( tNode->GetNodeContent(), m_DefaultMeasurementUnit,
|
|
|
|
&fp->m_positionX, &fp->m_positionY, aActualConversion );
|
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
tNode = FindNode( lNode, wxT( "rotation" ) );
|
|
|
|
|
|
|
|
if( tNode )
|
|
|
|
{
|
|
|
|
str = tNode->GetNodeContent();
|
|
|
|
str.Trim( false );
|
2020-11-14 21:21:54 +00:00
|
|
|
fp->m_rotation = StrToInt1Units( str );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
str = FindNodeGetContent( lNode, wxT( "isFlipped" ) );
|
|
|
|
|
|
|
|
if( str == wxT( "True" ) )
|
2020-11-14 21:21:54 +00:00
|
|
|
fp->m_Mirror = 1;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
tNode = aNode;
|
|
|
|
|
|
|
|
while( tNode->GetName() != wxT( "www.lura.sk" ) )
|
|
|
|
tNode = tNode->GetParent();
|
|
|
|
|
|
|
|
tNode = FindNode( tNode, wxT( "netlist" ) );
|
|
|
|
|
|
|
|
if( tNode )
|
|
|
|
{
|
|
|
|
tNode = FindNode( tNode, wxT( "compInst" ) );
|
|
|
|
|
|
|
|
while( tNode )
|
|
|
|
{
|
|
|
|
tNode->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( propValue == fp->m_name.text )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
if( FindNode( tNode, wxT( "compValue" ) ) )
|
|
|
|
{
|
|
|
|
FindNode( tNode,
|
|
|
|
wxT( "compValue" ) )->GetAttribute( wxT( "Name" ),
|
2020-11-14 21:21:54 +00:00
|
|
|
&fp->m_Value.text );
|
|
|
|
fp->m_Value.text.Trim( false );
|
|
|
|
fp->m_Value.text.Trim( true );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( FindNode( tNode, wxT( "compRef" ) ) )
|
|
|
|
{
|
|
|
|
FindNode( tNode,
|
|
|
|
wxT( "compRef" ) )->GetAttribute( wxT( "Name" ),
|
2020-11-14 21:21:54 +00:00
|
|
|
&fp->m_compRef );
|
|
|
|
fp->m_compRef.Trim( false );
|
|
|
|
fp->m_compRef.Trim( true );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tNode = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
tNode = tNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// map pins
|
|
|
|
tNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
|
2020-11-14 21:21:54 +00:00
|
|
|
tNode = FindCompDefName( tNode, fp->m_compRef );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
if( tNode )
|
|
|
|
{
|
|
|
|
tNode = FindPinMap( tNode );
|
|
|
|
|
|
|
|
if( tNode )
|
|
|
|
{
|
|
|
|
mNode = tNode->GetChildren();
|
|
|
|
|
|
|
|
while( mNode )
|
|
|
|
{
|
|
|
|
if( mNode->GetName() == wxT( "padNum" ) )
|
|
|
|
{
|
|
|
|
str = mNode->GetNodeContent();
|
|
|
|
mNode = mNode->GetNext();
|
|
|
|
|
|
|
|
if( !mNode )
|
|
|
|
break;
|
|
|
|
|
|
|
|
mNode->GetAttribute( wxT( "Name" ), &propValue );
|
2020-11-14 21:21:54 +00:00
|
|
|
fp->SetName( str, propValue );
|
2012-12-29 09:54:25 +00:00
|
|
|
mNode = mNode->GetNext();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mNode = mNode->GetNext();
|
|
|
|
|
|
|
|
if( !mNode )
|
|
|
|
break;
|
|
|
|
|
|
|
|
mNode = mNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_PcbComponents.Add( fp );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( lNode->GetName() == wxT( "pad" ) )
|
|
|
|
{
|
|
|
|
pad = new PCB_PAD( this, m_board );
|
2020-11-14 21:21:54 +00:00
|
|
|
pad->Parse( lNode, m_DefaultMeasurementUnit, aActualConversion );
|
|
|
|
m_PcbComponents.Add( pad );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
else if( lNode->GetName() == wxT( "via" ) )
|
|
|
|
{
|
|
|
|
via = new PCB_VIA( this, m_board );
|
2020-11-14 21:21:54 +00:00
|
|
|
via->Parse( lNode, m_DefaultMeasurementUnit, aActualConversion );
|
|
|
|
m_PcbComponents.Add( via );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
else if( lNode->GetName() == wxT( "polyKeepOut" ) )
|
|
|
|
{
|
|
|
|
keepOut = new PCB_KEEPOUT( m_callbacks, m_board, 0 );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( keepOut->Parse( lNode, m_DefaultMeasurementUnit, aActualConversion ) )
|
|
|
|
m_PcbComponents.Add( keepOut );
|
2012-12-29 09:54:25 +00:00
|
|
|
else
|
|
|
|
delete keepOut;
|
|
|
|
}
|
|
|
|
|
|
|
|
lNode = lNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
void PCB::ConnectPinToNet( const wxString& aCompRef, const wxString& aPinRef,
|
2017-09-23 09:20:10 +00:00
|
|
|
const wxString& aNetName )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
PCB_FOOTPRINT* footprint;
|
|
|
|
PCB_PAD* cp;
|
|
|
|
int i, j;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
footprint = (PCB_FOOTPRINT*) m_PcbComponents[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( footprint->m_objType == wxT( 'M' ) && footprint->m_name.text == aCompRef )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
for( j = 0; j < (int) footprint->m_FootprintItems.GetCount(); j++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( footprint->m_FootprintItems[j]->m_objType == wxT( 'P' ) )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
cp = (PCB_PAD*) footprint->m_FootprintItems[j];
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
if( cp->m_name.text == aPinRef )
|
|
|
|
cp->m_net = aNetName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
int PCB::FindLayer( const wxString& aLayerName ) const
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LAYER_NUM i = 0; i < (int)m_layersStackup.GetCount(); ++i )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
if( m_layersStackup[i] == aLayerName )
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
/* KiCad layers
|
|
|
|
* 0 Copper layer
|
|
|
|
* 1 to 14 Inner layers
|
|
|
|
* 15 Component layer
|
|
|
|
* 16 Copper side adhesive layer Technical layers
|
|
|
|
* 17 Component side adhesive layer
|
|
|
|
* 18 Copper side Solder paste layer
|
|
|
|
* 19 Component Solder paste layer
|
|
|
|
* 20 Copper side Silk screen layer
|
|
|
|
* 21 Component Silk screen layer
|
|
|
|
* 22 Copper side Solder mask layer
|
|
|
|
* 23 Component Solder mask layer
|
|
|
|
* 24 Draw layer (Used for general drawings)
|
|
|
|
* 25 Comment layer (Other layer used for general drawings)
|
|
|
|
* 26 ECO1 layer (Other layer used for general drawings) // BUG
|
|
|
|
* 26 ECO2 layer (Other layer used for general drawings) // BUG 27
|
|
|
|
* 27 Edge layer. Items on Edge layer are seen on all layers // BUG 28
|
|
|
|
*/
|
|
|
|
void PCB::MapLayer( XNODE* aNode )
|
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
wxString lName, layerType;
|
|
|
|
PCB_LAYER_ID KiCadLayer;
|
|
|
|
long num = 0;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
aNode->GetAttribute( wxT( "Name" ), &lName );
|
|
|
|
lName = lName.MakeUpper();
|
|
|
|
|
|
|
|
if( lName == wxT( "TOP ASSY" ) )
|
2017-12-13 17:47:03 +00:00
|
|
|
KiCadLayer = F_Fab;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "TOP SILK" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = F_SilkS;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "TOP PASTE" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = F_Paste;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "TOP MASK" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = F_Mask;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "TOP" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = F_Cu;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "BOTTOM" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = B_Cu;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "BOT MASK" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = B_Mask;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "BOT PASTE" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = B_Paste;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "BOT SILK" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = B_SilkS;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "BOT ASSY" ) )
|
2017-12-13 17:47:03 +00:00
|
|
|
KiCadLayer = B_Fab;
|
2012-12-29 09:54:25 +00:00
|
|
|
else if( lName == wxT( "BOARD" ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = Edge_Cuts;
|
2012-12-29 09:54:25 +00:00
|
|
|
else
|
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
int layernum = FindLayer( lName );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
if( layernum == -1 )
|
2014-06-24 16:17:18 +00:00
|
|
|
KiCadLayer = Dwgs_User; // default
|
2012-12-29 09:54:25 +00:00
|
|
|
else
|
2014-06-24 16:17:18 +00:00
|
|
|
#if 0 // was:
|
2013-03-31 13:27:46 +00:00
|
|
|
KiCadLayer = FIRST_COPPER_LAYER + m_layersStackup.GetCount() - 1 - layernum;
|
2014-06-24 16:17:18 +00:00
|
|
|
#else
|
2014-06-29 13:05:51 +00:00
|
|
|
KiCadLayer = ToLAYER_ID( layernum );
|
2014-06-24 16:17:18 +00:00
|
|
|
#endif
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( FindNode( aNode, wxT( "layerNum" ) ) )
|
|
|
|
FindNode( aNode, wxT( "layerNum" ) )->GetNodeContent().ToLong( &num );
|
|
|
|
|
2020-02-28 19:43:37 +00:00
|
|
|
if( num < 0 )
|
2013-03-09 19:36:31 +00:00
|
|
|
THROW_IO_ERROR( wxString::Format( wxT( "layerNum = %ld is out of range" ), num ) );
|
|
|
|
|
2020-02-28 19:43:37 +00:00
|
|
|
TLAYER newlayer;
|
|
|
|
newlayer.KiCadLayer = KiCadLayer;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
if( FindNode( aNode, wxT( "layerType" ) ) )
|
|
|
|
{
|
|
|
|
layerType = FindNode( aNode, wxT( "layerType" ) )->GetNodeContent().Trim( false );
|
|
|
|
|
|
|
|
if( layerType == wxT( "NonSignal" ) )
|
2020-02-28 19:43:37 +00:00
|
|
|
newlayer.layerType = LAYER_TYPE_NONSIGNAL;
|
2012-12-29 09:54:25 +00:00
|
|
|
if( layerType == wxT( "Signal" ) )
|
2020-02-28 19:43:37 +00:00
|
|
|
newlayer.layerType = LAYER_TYPE_SIGNAL;
|
2012-12-29 09:54:25 +00:00
|
|
|
if( layerType == wxT( "Plane" ) )
|
2020-02-28 19:43:37 +00:00
|
|
|
newlayer.layerType = LAYER_TYPE_PLANE;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_LayersMap.insert( std::make_pair( num, newlayer ) );
|
2020-02-28 19:43:37 +00:00
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
if( FindNode( aNode, wxT( "netNameRef" ) ) )
|
|
|
|
{
|
|
|
|
FindNode( aNode, wxT( "netNameRef" ) )->GetAttribute( wxT( "Name" ),
|
2020-11-14 21:21:54 +00:00
|
|
|
&m_LayersMap[(int) num].netNameRef );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-18 19:50:36 +00:00
|
|
|
int PCB::FindOutlinePoint( const VERTICES_ARRAY* aOutline, wxRealPoint aPoint ) const
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i = 0; i < (int) aOutline->GetCount(); i++ )
|
|
|
|
if( *((*aOutline)[i]) == aPoint )
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*int cmpFunc( wxRealPoint **first, wxRealPoint **second )
|
|
|
|
{
|
|
|
|
return sqrt( pow( (double) aPointA.x - (double) aPointB.x, 2 ) +
|
|
|
|
pow( (double) aPointA.y - (double) aPointB.y, 2 ) );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}*/
|
2020-11-18 19:50:36 +00:00
|
|
|
double PCB::GetDistance( const wxRealPoint* aPoint1, const wxRealPoint* aPoint2 ) const
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
return sqrt( ( aPoint1->x - aPoint2->x ) *
|
|
|
|
( aPoint1->x - aPoint2->x ) +
|
|
|
|
( aPoint1->y - aPoint2->y ) *
|
|
|
|
( aPoint1->y - aPoint2->y ) );
|
|
|
|
}
|
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
void PCB::GetBoardOutline( wxXmlDocument* aXmlDoc, const wxString& aActualConversion )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
XNODE* iNode, *lNode, *pNode;
|
|
|
|
long PCadLayer = 0;
|
|
|
|
int x, y, i, j, targetInd;
|
|
|
|
wxRealPoint* xchgPoint;
|
|
|
|
double minDistance, distance;
|
|
|
|
|
|
|
|
iNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
|
|
|
|
|
|
|
|
if( iNode )
|
|
|
|
{
|
|
|
|
// COMPONENTS AND OBJECTS
|
|
|
|
iNode = iNode->GetChildren();
|
|
|
|
|
|
|
|
while( iNode )
|
|
|
|
{
|
|
|
|
// objects
|
|
|
|
if( iNode->GetName() == wxT( "layerContents" ) )
|
|
|
|
{
|
|
|
|
if( FindNode( iNode, wxT( "layerNumRef" ) ) )
|
|
|
|
FindNode( iNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &PCadLayer );
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( GetKiCadLayer( PCadLayer ) == Edge_Cuts )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
lNode = iNode->GetChildren();
|
|
|
|
while( lNode )
|
|
|
|
{
|
|
|
|
if( lNode->GetName() == wxT( "line" ) )
|
|
|
|
{
|
|
|
|
pNode = FindNode( lNode, wxT( "pt" ) );
|
|
|
|
|
|
|
|
if( pNode )
|
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
SetPosition( pNode->GetNodeContent(), m_DefaultMeasurementUnit,
|
2012-12-29 09:54:25 +00:00
|
|
|
&x, &y, aActualConversion );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( FindOutlinePoint( &m_BoardOutline, wxRealPoint( x, y) ) == -1 )
|
|
|
|
m_BoardOutline.Add( new wxRealPoint( x, y ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 16:48:42 +00:00
|
|
|
if( pNode )
|
|
|
|
pNode = pNode->GetNext();
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
if( pNode )
|
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
SetPosition( pNode->GetNodeContent(), m_DefaultMeasurementUnit,
|
2012-12-29 09:54:25 +00:00
|
|
|
&x, &y, aActualConversion );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( FindOutlinePoint( &m_BoardOutline, wxRealPoint( x, y) ) == -1 )
|
|
|
|
m_BoardOutline.Add( new wxRealPoint( x, y ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lNode = lNode->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
//m_boardOutline.Sort( cmpFunc );
|
|
|
|
// sort vertices according to the distances between them
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_BoardOutline.GetCount() > 3 )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_BoardOutline.GetCount() - 1; i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
minDistance = GetDistance( m_BoardOutline[i], m_BoardOutline[ i + 1] );
|
2012-12-29 09:54:25 +00:00
|
|
|
targetInd = i + 1;
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( j = i + 2; j < (int) m_BoardOutline.GetCount(); j++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
distance = GetDistance( m_BoardOutline[i], m_BoardOutline[j] );
|
2012-12-29 09:54:25 +00:00
|
|
|
if( distance < minDistance )
|
|
|
|
{
|
|
|
|
minDistance = distance;
|
|
|
|
targetInd = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
xchgPoint = m_BoardOutline[ i + 1];
|
|
|
|
m_BoardOutline[ i + 1] = m_BoardOutline[targetInd];
|
|
|
|
m_BoardOutline[targetInd] = xchgPoint;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
iNode = iNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-23 09:20:10 +00:00
|
|
|
void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxString& aActualConversion )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
XNODE* aNode;//, *aaNode;
|
|
|
|
PCB_NET* net;
|
|
|
|
PCB_COMPONENT* comp;
|
2020-11-14 21:21:54 +00:00
|
|
|
PCB_FOOTPRINT* footprint;
|
2012-12-29 09:54:25 +00:00
|
|
|
wxString compRef, pinRef, layerName, layerType;
|
|
|
|
int i, j, netCode;
|
|
|
|
|
|
|
|
// Defaut measurement units
|
|
|
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "asciiHeader" ) );
|
|
|
|
|
|
|
|
if( aNode )
|
|
|
|
{
|
|
|
|
aNode = FindNode( aNode, wxT( "fileUnits" ) );
|
|
|
|
|
|
|
|
if( aNode )
|
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
m_DefaultMeasurementUnit = aNode->GetNodeContent().Lower();
|
|
|
|
m_DefaultMeasurementUnit.Trim( true );
|
|
|
|
m_DefaultMeasurementUnit.Trim( false );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine layers stackup
|
|
|
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
|
|
|
|
|
|
|
|
/*if( aNode )
|
|
|
|
{
|
|
|
|
aNode = FindNode( aNode, wxT( "layersStackup" ) );
|
|
|
|
|
|
|
|
if( aNode )
|
|
|
|
{
|
|
|
|
aNode = FindNode( aNode, wxT( "layerStackupData" ) );
|
|
|
|
|
|
|
|
while( aNode )
|
|
|
|
{
|
|
|
|
if( aNode->GetName() == wxT( "layerStackupData" ) )
|
|
|
|
{
|
|
|
|
aaNode = FindNode( aNode, wxT( "layerStackupName" ) );
|
|
|
|
|
|
|
|
if( aaNode ) {
|
|
|
|
aaNode->GetAttribute( wxT( "Name" ), &layerName );
|
|
|
|
layerName = layerName.MakeUpper();
|
|
|
|
m_layersStackup.Add( layerName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aNode = aNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
if( aNode )
|
|
|
|
{
|
|
|
|
aNode = FindNode( aNode, wxT( "layerDef" ) );
|
|
|
|
|
|
|
|
while( aNode )
|
|
|
|
{
|
|
|
|
if( aNode->GetName() == wxT( "layerDef" ) )
|
|
|
|
{
|
|
|
|
if( FindNode( aNode, wxT( "layerType" ) ) )
|
|
|
|
{
|
|
|
|
layerType = FindNode( aNode,
|
|
|
|
wxT( "layerType" ) )->GetNodeContent().Trim( false );
|
|
|
|
|
|
|
|
if( layerType == wxT( "Signal" ) || layerType == wxT( "Plane" ) )
|
|
|
|
{
|
|
|
|
aNode->GetAttribute( wxT( "Name" ), &layerName );
|
|
|
|
layerName = layerName.MakeUpper();
|
|
|
|
m_layersStackup.Add( layerName );
|
2020-02-28 19:43:37 +00:00
|
|
|
|
|
|
|
if( m_layersStackup.size() > 32 )
|
|
|
|
THROW_IO_ERROR( _( "KiCad only supports 32 signal layers" ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aNode = aNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Layers mapping
|
|
|
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
|
|
|
|
|
|
|
|
if( aNode )
|
|
|
|
{
|
|
|
|
aNode = FindNode( aNode, wxT( "layerDef" ) );
|
|
|
|
|
|
|
|
while( aNode )
|
|
|
|
{
|
|
|
|
if( aNode->GetName() == wxT( "layerDef" ) )
|
|
|
|
MapLayer( aNode );
|
|
|
|
|
|
|
|
aNode = aNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetBoardOutline( aXmlDoc, aActualConversion );
|
|
|
|
|
|
|
|
// NETLIST
|
|
|
|
// aStatusBar->SetStatusText( wxT( "Loading NETLIST " ) );
|
|
|
|
|
|
|
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "netlist" ) );
|
|
|
|
|
|
|
|
if( aNode )
|
|
|
|
{
|
|
|
|
aNode = FindNode( aNode, wxT( "net" ) );
|
|
|
|
|
|
|
|
netCode = 1;
|
|
|
|
|
|
|
|
while( aNode )
|
|
|
|
{
|
|
|
|
net = new PCB_NET( netCode++ );
|
|
|
|
net->Parse( aNode );
|
2020-11-14 21:21:54 +00:00
|
|
|
m_PcbNetlist.Add( net );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
aNode = aNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// BOARD FILE
|
|
|
|
// aStatusBar->SetStatusText( wxT( "Loading BOARD DEFINITION " ) );
|
|
|
|
|
|
|
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "pcbDesign" ) );
|
|
|
|
|
|
|
|
if( aNode )
|
|
|
|
{
|
|
|
|
// COMPONENTS AND OBJECTS
|
|
|
|
aNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
while( aNode )
|
|
|
|
{
|
2020-10-21 03:48:06 +00:00
|
|
|
// Components/footprints
|
2012-12-29 09:54:25 +00:00
|
|
|
if( aNode->GetName() == wxT( "multiLayer" ) )
|
|
|
|
DoPCBComponents( aNode, aXmlDoc, aActualConversion, aStatusBar );
|
|
|
|
|
|
|
|
// objects
|
|
|
|
if( aNode->GetName() == wxT( "layerContents" ) )
|
2020-11-14 21:21:54 +00:00
|
|
|
DoLayerContentsObjects( aNode, NULL, &m_PcbComponents, aStatusBar,
|
|
|
|
m_DefaultMeasurementUnit, aActualConversion );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
aNode = aNode->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
// POSTPROCESS -- SET NETLIST REFERENCES
|
|
|
|
// aStatusBar->SetStatusText( wxT( "Processing NETLIST " ) );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
net = m_PcbNetlist[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( j = 0; j < (int) net->m_NetNodes.GetCount(); j++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
compRef = net->m_NetNodes[j]->m_CompRef;
|
2012-12-29 09:54:25 +00:00
|
|
|
compRef.Trim( false );
|
|
|
|
compRef.Trim( true );
|
2020-11-14 21:21:54 +00:00
|
|
|
pinRef = net->m_NetNodes[j]->m_PinRef;
|
2012-12-29 09:54:25 +00:00
|
|
|
pinRef.Trim( false );
|
|
|
|
pinRef.Trim( true );
|
2020-11-14 21:21:54 +00:00
|
|
|
ConnectPinToNet( compRef, pinRef, net->m_Name );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// POSTPROCESS -- FLIP COMPONENTS
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_PcbComponents[i]->m_objType == wxT( 'M' ) )
|
|
|
|
( (PCB_FOOTPRINT*) m_PcbComponents[i] )->Flip();
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// POSTPROCESS -- SET/OPTIMIZE NEW PCB POSITION
|
|
|
|
// aStatusBar->SetStatusText( wxT( "Optimizing BOARD POSITION " ) );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_SizeX = 10000000;
|
|
|
|
m_SizeY = 0;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
comp = m_PcbComponents[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( comp->m_positionY < m_SizeY )
|
|
|
|
m_SizeY = comp->m_positionY; // max Y
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( comp->m_positionX < m_SizeX && comp->m_positionX > 0 )
|
|
|
|
m_SizeX = comp->m_positionX; // Min X
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_SizeY -= 10000;
|
|
|
|
m_SizeX -= 10000;
|
2012-12-29 09:54:25 +00:00
|
|
|
// aStatusBar->SetStatusText( wxT( " POSITIONING POSTPROCESS " ) );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
|
|
|
|
m_PcbComponents[i]->SetPosOffset( -m_SizeX, -m_SizeY );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_SizeX = 0;
|
|
|
|
m_SizeY = 0;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
comp = m_PcbComponents[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( comp->m_positionY < m_SizeY )
|
|
|
|
m_SizeY = comp->m_positionY; // max Y
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( comp->m_positionX > m_SizeX )
|
|
|
|
m_SizeX = comp->m_positionX; // Min X
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SHEET SIZE CALCULATION
|
2020-11-14 21:21:54 +00:00
|
|
|
m_SizeY = -m_SizeY; // it is in absolute units
|
|
|
|
m_SizeX += 10000;
|
|
|
|
m_SizeY += 10000;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
// A4 is minimum $Descr A4 11700 8267
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_SizeX < 11700 )
|
|
|
|
m_SizeX = 11700;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_SizeY < 8267 )
|
|
|
|
m_SizeY = 8267;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// LIBRARY FILE
|
|
|
|
// aStatusBar->SetStatusText( wxT( "Processing LIBRARY FILE " ) );
|
|
|
|
|
|
|
|
aNode = FindNode( (XNODE *)aXmlDoc->GetRoot(), wxT( "library" ) );
|
|
|
|
|
|
|
|
if( aNode )
|
|
|
|
{
|
|
|
|
aNode = FindNode( aNode, wxT( "compDef" ) );
|
|
|
|
|
|
|
|
while( aNode )
|
|
|
|
{
|
|
|
|
// aStatusBar->SetStatusText( wxT( "Processing COMPONENTS " ) );
|
|
|
|
|
|
|
|
if( aNode->GetName() == wxT( "compDef" ) )
|
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
footprint = new PCB_FOOTPRINT( this, m_board );
|
|
|
|
footprint->Parse( aNode, aStatusBar, m_DefaultMeasurementUnit,
|
|
|
|
aActualConversion );
|
|
|
|
m_PcbComponents.Add( footprint );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aNode = aNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB::AddToBoard()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
PCB_NET* net;
|
|
|
|
|
|
|
|
m_board->SetCopperLayerCount( m_layersStackup.GetCount() );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbNetlist.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
net = m_PcbNetlist[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
m_board->Add( new NETINFO_ITEM( m_board, net->m_Name, net->m_NetCode ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
Removed D_PAD::SetNetname() function and D_PAD::m_Netname, D_PAD::m_ShortNetname fields.
D_PAD::GetNetname() and D_PAD::GetShortNetname() were moved to BOARD_CONNECTED_ITEM. Now they use the net name stored in NETINFO_ITEM.
Moved some one-line functions from class_board_connected_item.cpp to class_board_connected_item.h.
Added a copyright notice, moved Doxygen comments from class_board_connected_item.cpp to class_board_connected_item.h.
I have some doubts if changes introduced pcbnew/dialogs/dialog_pad_properties.cpp do not break anything, but I could not find a test case that breaks the pcbnew.
Performed tests:
- changed pad's net name from empty to existent - ok, name was changed
- changed pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty
- changed pad's net name from existent to empty - ok, net name became empty
- changed pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed
- (re)reading netlists, including net changes - fine, changes are applied, but empty nets are still kept
- loaded pcbnew/pcad2kicadpcb_plugin/examples/CK1202_V1.pcb to test P-CAD import plugin - ok, net names are correct
- imported an Eagle 6.0 board (Arduino Uno; http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip) then saved in .kicad_pcb format and reloaded - ok, net names are correct
- saved demos/video/video.kicad_pcb in legacy format and then loaded it again - ok, net names are correct
2014-01-14 09:41:52 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_PcbComponents.GetCount(); i++ )
|
Removed D_PAD::SetNetname() function and D_PAD::m_Netname, D_PAD::m_ShortNetname fields.
D_PAD::GetNetname() and D_PAD::GetShortNetname() were moved to BOARD_CONNECTED_ITEM. Now they use the net name stored in NETINFO_ITEM.
Moved some one-line functions from class_board_connected_item.cpp to class_board_connected_item.h.
Added a copyright notice, moved Doxygen comments from class_board_connected_item.cpp to class_board_connected_item.h.
I have some doubts if changes introduced pcbnew/dialogs/dialog_pad_properties.cpp do not break anything, but I could not find a test case that breaks the pcbnew.
Performed tests:
- changed pad's net name from empty to existent - ok, name was changed
- changed pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty
- changed pad's net name from existent to empty - ok, net name became empty
- changed pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed
- (re)reading netlists, including net changes - fine, changes are applied, but empty nets are still kept
- loaded pcbnew/pcad2kicadpcb_plugin/examples/CK1202_V1.pcb to test P-CAD import plugin - ok, net names are correct
- imported an Eagle 6.0 board (Arduino Uno; http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip) then saved in .kicad_pcb format and reloaded - ok, net names are correct
- saved demos/video/video.kicad_pcb in legacy format and then loaded it again - ok, net names are correct
2014-01-14 09:41:52 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
m_PcbComponents[i]->AddToBoard();
|
Removed D_PAD::SetNetname() function and D_PAD::m_Netname, D_PAD::m_ShortNetname fields.
D_PAD::GetNetname() and D_PAD::GetShortNetname() were moved to BOARD_CONNECTED_ITEM. Now they use the net name stored in NETINFO_ITEM.
Moved some one-line functions from class_board_connected_item.cpp to class_board_connected_item.h.
Added a copyright notice, moved Doxygen comments from class_board_connected_item.cpp to class_board_connected_item.h.
I have some doubts if changes introduced pcbnew/dialogs/dialog_pad_properties.cpp do not break anything, but I could not find a test case that breaks the pcbnew.
Performed tests:
- changed pad's net name from empty to existent - ok, name was changed
- changed pad's net name from empty to nonexistent - ok, error message is displayed, net name stays empty
- changed pad's net name from existent to empty - ok, net name became empty
- changed pad's net name from existent to nonexistent - ok, error message is displayed, net name is not changed
- (re)reading netlists, including net changes - fine, changes are applied, but empty nets are still kept
- loaded pcbnew/pcad2kicadpcb_plugin/examples/CK1202_V1.pcb to test P-CAD import plugin - ok, net names are correct
- imported an Eagle 6.0 board (Arduino Uno; http://arduino.cc/en/uploads/Main/arduino_Uno_Rev3-02-TH.zip) then saved in .kicad_pcb format and reloaded - ok, net names are correct
- saved demos/video/video.kicad_pcb in legacy format and then loaded it again - ok, net names are correct
2014-01-14 09:41:52 +00:00
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace PCAD2KICAD
|