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>
|
2023-03-30 11:49:23 +00:00
|
|
|
* Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.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
|
|
|
|
*/
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
#include <pcad/pcad_pad.h>
|
|
|
|
#include <pcad/pcad_pad_shape.h>
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2021-06-04 00:28:40 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
|
|
|
#include <pad.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2012-12-29 09:54:25 +00:00
|
|
|
#include <trigo.h>
|
2021-06-04 00:28:40 +00:00
|
|
|
#include <xnode.h>
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2021-06-04 00:28:40 +00:00
|
|
|
#include <wx/string.h>
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
namespace PCAD2KICAD {
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2023-04-01 20:05:58 +00:00
|
|
|
PCAD_PAD::PCAD_PAD( PCAD_CALLBACKS* aCallbacks, BOARD* aBoard ) :
|
2023-03-30 11:49:23 +00:00
|
|
|
PCAD_PCB_COMPONENT( aCallbacks, aBoard )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2023-04-01 20:05:58 +00:00
|
|
|
m_ObjType = wxT( 'P' );
|
2020-11-14 21:21:54 +00:00
|
|
|
m_Number = 0;
|
|
|
|
m_Hole = 0;
|
|
|
|
m_IsHolePlated = true;
|
2013-03-09 19:36:31 +00:00
|
|
|
m_defaultPinDes = wxEmptyString;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
PCAD_PAD::~PCAD_PAD()
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_Shapes.GetCount(); i++ )
|
|
|
|
delete m_Shapes[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
void PCAD_PAD::Parse( XNODE* aNode, const wxString& aDefaultUnits,
|
2023-04-01 20:05:58 +00:00
|
|
|
const wxString& aActualConversion )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-13 01:33:30 +00:00
|
|
|
XNODE* lNode;
|
|
|
|
XNODE* cNode;
|
2012-12-29 09:54:25 +00:00
|
|
|
long num;
|
|
|
|
wxString propValue, str, emsg;
|
2023-04-01 20:05:58 +00:00
|
|
|
PCAD_PAD_SHAPE* padShape;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2023-04-01 20:05:58 +00:00
|
|
|
m_Rotation = ANGLE_0;
|
2012-12-29 09:54:25 +00:00
|
|
|
lNode = FindNode( aNode, wxT( "padNum" ) );
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
{
|
|
|
|
lNode->GetNodeContent().ToLong( &num );
|
2020-11-14 21:21:54 +00:00
|
|
|
m_Number = (int) num;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lNode = FindNode( aNode, wxT( "padStyleRef" ) );
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
{
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
propValue.Trim( false );
|
2023-04-01 20:05:58 +00:00
|
|
|
m_Name.text = propValue;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lNode = FindNode( aNode, wxT( "pt" ) );
|
|
|
|
|
|
|
|
if( lNode )
|
2020-11-13 01:33:30 +00:00
|
|
|
{
|
2023-04-01 20:05:58 +00:00
|
|
|
SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_PositionX, &m_PositionY,
|
2020-11-13 01:33:30 +00:00
|
|
|
aActualConversion );
|
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
lNode = FindNode( aNode, wxT( "rotation" ) );
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
{
|
|
|
|
str = lNode->GetNodeContent();
|
|
|
|
str.Trim( false );
|
2023-04-01 20:05:58 +00:00
|
|
|
m_Rotation = EDA_ANGLE( StrToInt1Units( str ), TENTHS_OF_A_DEGREE_T );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2013-03-09 19:36:31 +00:00
|
|
|
lNode = FindNode( aNode, wxT( "netNameRef" ) );
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
{
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
propValue.Trim( false );
|
|
|
|
propValue.Trim( true );
|
2023-04-01 20:05:58 +00:00
|
|
|
m_Net = propValue;
|
|
|
|
m_NetCode = GetNetCode( m_Net );
|
2013-03-09 19:36:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lNode = FindNode( aNode, wxT( "defaultPinDes" ) );
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
{
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2013-03-09 19:36:31 +00:00
|
|
|
//propValue.Trim( false );
|
|
|
|
m_defaultPinDes = propValue;
|
|
|
|
}
|
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
lNode = aNode;
|
|
|
|
|
|
|
|
while( lNode && lNode->GetName() != wxT( "www.lura.sk" ) )
|
|
|
|
lNode = lNode->GetParent();
|
|
|
|
|
|
|
|
lNode = FindNode( lNode, wxT( "library" ) );
|
2020-11-13 01:33:30 +00:00
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
if ( !lNode )
|
|
|
|
THROW_IO_ERROR( wxT( "Unable to find library section" ) );
|
|
|
|
|
|
|
|
lNode = FindNode( lNode, wxT( "padStyleDef" ) );
|
|
|
|
|
|
|
|
while( lNode )
|
|
|
|
{
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
|
2023-04-01 20:05:58 +00:00
|
|
|
if( propValue.IsSameAs( m_Name.text, false) )
|
2012-12-29 09:54:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
lNode = lNode->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !lNode )
|
2023-04-01 20:05:58 +00:00
|
|
|
THROW_IO_ERROR( wxString::Format( wxT( "Unable to find padStyleDef " ) + m_Name.text ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
cNode = FindNode( lNode, wxT( "holeDiam" ) );
|
|
|
|
|
|
|
|
if( cNode )
|
2021-07-18 12:31:56 +00:00
|
|
|
SetWidth( cNode->GetNodeContent(), aDefaultUnits, &m_Hole, aActualConversion );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2022-05-27 17:08:27 +00:00
|
|
|
if( FindNodeGetContent( lNode, wxT( "isHolePlated" ) ).IsSameAs( wxT( "False" ), false ) )
|
2020-11-14 21:21:54 +00:00
|
|
|
m_IsHolePlated = false;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
cNode = FindNode( lNode, wxT( "padShape" ) );
|
|
|
|
|
|
|
|
while( cNode )
|
|
|
|
{
|
2022-05-27 17:08:27 +00:00
|
|
|
if( cNode->GetName().IsSameAs( wxT( "padShape" ), false ) )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
// we support only Pads on specific layers......
|
|
|
|
// we do not support pads on "Plane", "NonSignal" , "Signal" ... layerr
|
|
|
|
if( FindNode( cNode, wxT( "layerNumRef" ) ) )
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
padShape = new PCAD_PAD_SHAPE( m_callbacks, m_board );
|
2021-07-18 12:31:56 +00:00
|
|
|
padShape->Parse( cNode, aDefaultUnits, aActualConversion );
|
2020-11-14 21:21:54 +00:00
|
|
|
m_Shapes.Add( padShape );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cNode = cNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
void PCAD_PAD::Flip()
|
2013-03-09 19:36:31 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
PCAD_PCB_COMPONENT::Flip();
|
2013-03-09 19:36:31 +00:00
|
|
|
|
2023-04-01 20:05:58 +00:00
|
|
|
if( m_ObjType == wxT( 'P' ) )
|
|
|
|
m_Rotation = -m_Rotation;
|
2013-03-09 19:36:31 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int)m_Shapes.GetCount(); i++ )
|
|
|
|
m_Shapes[i]->m_KiCadLayer = FlipLayer( m_Shapes[i]->m_KiCadLayer );
|
2013-03-09 19:36:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
void PCAD_PAD::AddToFootprint( FOOTPRINT* aFootprint, const EDA_ANGLE& aRotation,
|
2022-01-18 02:05:59 +00:00
|
|
|
bool aEncapsulatedPad )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCAD_PAD_SHAPE* padShape;
|
2012-12-29 09:54:25 +00:00
|
|
|
wxString padShapeName = wxT( "Ellipse" );
|
2021-05-01 14:46:50 +00:00
|
|
|
PAD_ATTRIB padType;
|
2012-12-29 09:54:25 +00:00
|
|
|
int i;
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
|
2020-11-13 01:33:30 +00:00
|
|
|
PAD* pad = new PAD( aFootprint );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( !m_IsHolePlated && m_Hole )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
// mechanical hole
|
2021-05-01 12:22:35 +00:00
|
|
|
pad->SetShape( PAD_SHAPE::CIRCLE );
|
2021-05-01 14:46:50 +00:00
|
|
|
pad->SetAttribute( PAD_ATTRIB::NPTH );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
pad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
|
2023-02-19 03:40:07 +00:00
|
|
|
pad->SetDrillSize( VECTOR2I( m_Hole, m_Hole ) );
|
|
|
|
pad->SetSize( VECTOR2I( m_Hole, m_Hole ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2017-11-05 10:13:09 +00:00
|
|
|
// Mounting Hole: Solder Mask Margin from Top Layer Width size.
|
|
|
|
// Used the default zone clearance (simplify)
|
2022-05-27 17:08:27 +00:00
|
|
|
if( m_Shapes.GetCount() && m_Shapes[0]->m_Shape.IsSameAs( wxT( "MtHole" ), false ) )
|
2017-11-05 10:13:09 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
int sm_margin = ( m_Shapes[0]->m_Width - m_Hole ) / 2;
|
2017-11-05 10:13:09 +00:00
|
|
|
pad->SetLocalSolderMaskMargin( sm_margin );
|
2022-09-16 11:33:56 +00:00
|
|
|
pad->SetLocalClearance( sm_margin + pcbIUScale.mmToIU( 0.254 ) );
|
2017-11-05 10:13:09 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 08:28:49 +00:00
|
|
|
pad->SetLayerSet( LSET::AllCuMask() | LSET( 2, B_Mask, F_Mask ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
( m_Hole ) ? padType = PAD_ATTRIB::PTH : padType = PAD_ATTRIB::SMD;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
// form layer mask
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_Shapes.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
padShape = m_Shapes[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( padShape->m_Width > 0 && padShape->m_Height > 0 )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( padShape->m_KiCadLayer == F_Cu ||
|
|
|
|
padShape->m_KiCadLayer == B_Cu )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
padShapeName = padShape->m_Shape;
|
|
|
|
width = padShape->m_Width;
|
|
|
|
height = padShape->m_Height;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
// assume this is SMD pad
|
2014-06-24 16:17:18 +00:00
|
|
|
if( padShape->m_KiCadLayer == F_Cu )
|
|
|
|
pad->SetLayerSet( LSET( 3, F_Cu, F_Paste, F_Mask ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
else
|
2014-06-24 16:17:18 +00:00
|
|
|
pad->SetLayerSet( LSET( 3, B_Cu, B_Paste, B_Mask ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-13 10:41:14 +00:00
|
|
|
if( width == 0 || height == 0 )
|
|
|
|
{
|
|
|
|
delete pad;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-01 14:46:50 +00:00
|
|
|
if( padType == PAD_ATTRIB::PTH )
|
2012-12-29 09:54:25 +00:00
|
|
|
// actually this is a thru-hole pad
|
2014-06-24 16:17:18 +00:00
|
|
|
pad->SetLayerSet( LSET::AllCuMask() | LSET( 2, B_Mask, F_Mask ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2023-04-01 20:05:58 +00:00
|
|
|
pad->SetNumber( m_Name.text );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2022-05-27 17:08:27 +00:00
|
|
|
if( padShapeName.IsSameAs( wxT( "Oval" ), false )
|
|
|
|
|| padShapeName.IsSameAs( wxT( "Ellipse" ), false )
|
|
|
|
|| padShapeName.IsSameAs( wxT( "MtHole" ), false ) )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
if( width != height )
|
2021-05-01 12:22:35 +00:00
|
|
|
pad->SetShape( PAD_SHAPE::OVAL );
|
2012-12-29 09:54:25 +00:00
|
|
|
else
|
2021-05-01 12:22:35 +00:00
|
|
|
pad->SetShape( PAD_SHAPE::CIRCLE );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
2022-05-27 17:08:27 +00:00
|
|
|
else if( padShapeName.IsSameAs( wxT( "Rect" ), false ) )
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
pad->SetShape( PAD_SHAPE::RECT );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2022-05-27 17:08:27 +00:00
|
|
|
else if( padShapeName.IsSameAs( wxT( "RndRect" ), false ) )
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
pad->SetShape( PAD_SHAPE::ROUNDRECT );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2022-05-27 17:08:27 +00:00
|
|
|
else if( padShapeName.IsSameAs( wxT( "Polygon" ), false ) )
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2021-05-01 12:22:35 +00:00
|
|
|
pad->SetShape( PAD_SHAPE::RECT ); // approximation
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2022-01-05 01:42:27 +00:00
|
|
|
pad->SetSize( VECTOR2I( width, height ) );
|
|
|
|
pad->SetDelta( VECTOR2I( 0, 0 ) );
|
2023-04-01 20:05:58 +00:00
|
|
|
pad->SetOrientation( m_Rotation + aRotation );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2015-08-23 19:40:33 +00:00
|
|
|
pad->SetDrillShape( PAD_DRILL_SHAPE_CIRCLE );
|
2022-01-05 01:42:27 +00:00
|
|
|
pad->SetOffset( VECTOR2I( 0, 0 ) );
|
|
|
|
pad->SetDrillSize( VECTOR2I( m_Hole, m_Hole ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
pad->SetAttribute( padType );
|
|
|
|
|
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
|
|
|
// Set the proper net code
|
2023-04-01 20:05:58 +00:00
|
|
|
NETINFO_ITEM* netinfo = m_board->FindNet( m_Net );
|
2021-07-18 12:31:56 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( netinfo == nullptr ) // I believe this should not happen, but just in case
|
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
|
|
|
{
|
|
|
|
// It is a new net
|
2023-04-01 20:05:58 +00:00
|
|
|
netinfo = new NETINFO_ITEM( m_board, m_Net );
|
2016-09-05 10:22:24 +00:00
|
|
|
m_board->Add( netinfo );
|
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-12-08 13:02:08 +00:00
|
|
|
pad->SetNetCode( netinfo->GetNetCode() );
|
2013-03-09 19:36:31 +00:00
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2013-03-09 19:36:31 +00:00
|
|
|
if( !aEncapsulatedPad )
|
|
|
|
{
|
2023-04-01 20:05:58 +00:00
|
|
|
VECTOR2I padpos( m_PositionX, m_PositionY );
|
2022-01-01 06:04:08 +00:00
|
|
|
RotatePoint( padpos, aFootprint->GetOrientation() );
|
2020-11-13 01:33:30 +00:00
|
|
|
pad->SetPosition( padpos + aFootprint->GetPosition() );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
2016-03-13 10:41:14 +00:00
|
|
|
|
2020-11-13 01:33:30 +00:00
|
|
|
aFootprint->Add( pad );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
void PCAD_PAD::AddToBoard( FOOTPRINT* aFootprint )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
PCAD_PAD_SHAPE* padShape;
|
2012-12-29 09:54:25 +00:00
|
|
|
int i;
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
|
2023-04-01 20:05:58 +00:00
|
|
|
if( m_ObjType == wxT( 'V' ) ) // via
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2013-03-09 19:36:31 +00:00
|
|
|
// choose one of the shapes
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_Shapes.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
padShape = m_Shapes[i];
|
2013-03-09 19:36:31 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( padShape->m_Width > 0 && padShape->m_Height > 0 )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( padShape->m_KiCadLayer == F_Cu
|
|
|
|
|| padShape->m_KiCadLayer == B_Cu )
|
2013-03-09 19:36:31 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
width = padShape->m_Width;
|
|
|
|
height = padShape->m_Height;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2013-03-09 19:36:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-09 19:36:31 +00:00
|
|
|
if( width == 0 || height == 0 )
|
2016-03-13 10:41:14 +00:00
|
|
|
return;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2013-04-09 16:00:46 +00:00
|
|
|
if( IsCopperLayer( m_KiCadLayer ) )
|
2013-03-09 19:36:31 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
PCB_VIA* via = new PCB_VIA( m_board );
|
2019-05-31 02:30:28 +00:00
|
|
|
m_board->Add( via );
|
2013-03-09 19:36:31 +00:00
|
|
|
|
2023-04-01 20:05:58 +00:00
|
|
|
via->SetPosition( VECTOR2I( m_PositionX, m_PositionY ) );
|
|
|
|
via->SetEnd( VECTOR2I( m_PositionX, m_PositionY ) );
|
2013-03-09 19:36:31 +00:00
|
|
|
|
|
|
|
via->SetWidth( height );
|
2019-12-28 00:55:11 +00:00
|
|
|
via->SetViaType( VIATYPE::THROUGH );
|
2014-06-24 16:17:18 +00:00
|
|
|
via->SetLayerPair( F_Cu, B_Cu );
|
2020-11-14 21:21:54 +00:00
|
|
|
via->SetDrill( m_Hole );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2013-03-09 19:36:31 +00:00
|
|
|
via->SetLayer( m_KiCadLayer );
|
2023-04-01 20:05:58 +00:00
|
|
|
via->SetNetCode( m_NetCode );
|
2013-03-09 19:36:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else // pad
|
|
|
|
{
|
2023-03-30 11:49:23 +00:00
|
|
|
if( !aFootprint )
|
|
|
|
{
|
|
|
|
aFootprint = new FOOTPRINT( m_board );
|
|
|
|
m_board->Add( aFootprint, ADD_MODE::APPEND );
|
2023-04-01 20:05:58 +00:00
|
|
|
aFootprint->SetPosition( VECTOR2I( m_PositionX, m_PositionY ) );
|
2023-03-30 11:49:23 +00:00
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2023-04-01 20:05:58 +00:00
|
|
|
m_Name.text = m_defaultPinDes;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2023-03-30 11:49:23 +00:00
|
|
|
AddToFootprint( aFootprint, ANGLE_0, true );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace PCAD2KICAD
|