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>
|
2022-01-13 17:27:36 +00:00
|
|
|
* Copyright (C) 2012-2022 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
|
|
|
|
*/
|
|
|
|
|
2021-06-04 00:28:40 +00:00
|
|
|
#include <pcad/pcb_arc.h>
|
|
|
|
#include <pcad/pcb_copper_pour.h>
|
|
|
|
#include <pcad/pcb_cutout.h>
|
|
|
|
#include <pcad/pcb_plane.h>
|
|
|
|
#include <pcad/pcb_line.h>
|
|
|
|
#include <pcad/pcb_footprint.h>
|
|
|
|
#include <pcad/pcb_pad.h>
|
|
|
|
#include <pcad/pcb_polygon.h>
|
|
|
|
#include <pcad/pcb_text.h>
|
|
|
|
#include <pcad/pcb_via.h>
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2021-06-04 00:28:40 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
2016-02-24 11:56:40 +00:00
|
|
|
#include <trigo.h>
|
2021-06-04 00:28:40 +00:00
|
|
|
#include <xnode.h>
|
|
|
|
|
|
|
|
#include <wx/string.h>
|
2016-02-24 11:56:40 +00:00
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
namespace PCAD2KICAD {
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
PCB_FOOTPRINT::PCB_FOOTPRINT( PCB_CALLBACKS* aCallbacks, BOARD* aBoard ) :
|
2020-11-13 21:07:01 +00:00
|
|
|
PCB_COMPONENT( aCallbacks, aBoard )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
InitTTextValue( &m_Value );
|
|
|
|
m_Mirror = 0;
|
2020-11-13 21:07:01 +00:00
|
|
|
m_objType = wxT( 'M' ); // FOOTPRINT
|
2014-06-24 16:17:18 +00:00
|
|
|
m_KiCadLayer = F_SilkS; // default
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
PCB_FOOTPRINT::~PCB_FOOTPRINT()
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
delete m_FootprintItems[i];
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
XNODE* PCB_FOOTPRINT::FindModulePatternDefName( XNODE* aNode, const wxString& aName )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
XNODE* result, * lNode;
|
|
|
|
wxString propValue1, propValue2;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
result = nullptr;
|
2012-12-29 09:54:25 +00:00
|
|
|
lNode = FindNode( aNode, wxT( "patternDef" ) );
|
|
|
|
|
|
|
|
while( lNode )
|
|
|
|
{
|
|
|
|
if( lNode->GetName() == wxT( "patternDef" ) )
|
|
|
|
{
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue1 );
|
|
|
|
FindNode( lNode,
|
|
|
|
wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), &propValue2 );
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( ValidateName( propValue1 ) == aName || ValidateName( propValue2 ) == aName )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
result = lNode;
|
2021-07-19 23:56:05 +00:00
|
|
|
lNode = nullptr;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
lNode = lNode->GetNext();
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
if( result == nullptr )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
lNode = FindNode( aNode, wxT( "patternDefExtended" ) ); // New file format
|
|
|
|
|
|
|
|
while( lNode )
|
|
|
|
{
|
|
|
|
if( lNode->GetName() == wxT( "patternDefExtended" ) )
|
|
|
|
{
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue1 );
|
|
|
|
|
|
|
|
if( ValidateName( propValue1 ) == aName )
|
|
|
|
{
|
|
|
|
result = lNode;
|
2021-07-19 23:56:05 +00:00
|
|
|
lNode = nullptr;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
lNode = lNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
XNODE* PCB_FOOTPRINT::FindPatternMultilayerSection( XNODE* aNode, wxString* aPatGraphRefName )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
XNODE* result, * pNode, * lNode;
|
|
|
|
wxString propValue, patName;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
result = nullptr;
|
2012-12-29 09:54:25 +00:00
|
|
|
pNode = aNode; // pattern;
|
|
|
|
lNode = aNode;
|
|
|
|
|
|
|
|
// calling from library conversion we need to find pattern
|
|
|
|
if( lNode->GetName() == wxT( "compDef" ) )
|
|
|
|
{
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
propValue.Trim( false );
|
|
|
|
patName = ValidateName( propValue );
|
|
|
|
|
|
|
|
if( FindNode( lNode, wxT( "attachedPattern" ) ) )
|
|
|
|
{
|
|
|
|
FindNode( FindNode( lNode, wxT( "attachedPattern" ) ),
|
|
|
|
wxT( "patternName" ) )->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
propValue.Trim( false );
|
|
|
|
propValue.Trim( true );
|
|
|
|
patName = ValidateName( propValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
lNode = FindModulePatternDefName( lNode->GetParent(), patName );
|
|
|
|
pNode = lNode; // pattern;
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
lNode = nullptr;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
if( pNode )
|
|
|
|
lNode = FindNode( pNode, wxT( "multiLayer" ) ); // Old file format
|
|
|
|
|
|
|
|
if( lNode )
|
2013-03-09 19:36:31 +00:00
|
|
|
{
|
|
|
|
*aPatGraphRefName = wxEmptyString; // default
|
2012-12-29 09:54:25 +00:00
|
|
|
result = lNode;
|
2013-03-09 19:36:31 +00:00
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// New file format
|
2013-03-09 19:36:31 +00:00
|
|
|
|
|
|
|
if( *aPatGraphRefName == wxEmptyString ) // default
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2013-03-09 19:36:31 +00:00
|
|
|
if( FindNode( aNode, wxT( "patternGraphicsNameRef" ) ) )
|
|
|
|
{
|
|
|
|
FindNode( aNode,
|
|
|
|
wxT( "patternGraphicsNameRef" ) )->GetAttribute( wxT( "Name" ),
|
|
|
|
aPatGraphRefName );
|
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( FindNode( aNode, wxT( "patternGraphicsDef" ) ) )
|
|
|
|
lNode = FindNode( aNode, wxT( "patternGraphicsDef" ) );
|
2017-03-11 21:18:45 +00:00
|
|
|
else if( pNode )
|
2012-12-29 09:54:25 +00:00
|
|
|
lNode = FindNode( pNode, wxT( "patternGraphicsDef" ) );
|
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
if( *aPatGraphRefName == wxEmptyString ) // no pattern detection, the first is actual...
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
if( lNode )
|
|
|
|
{
|
|
|
|
result = FindNode( lNode, wxT( "multiLayer" ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
lNode = nullptr;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while( lNode ) // selected by name
|
|
|
|
{
|
|
|
|
if( lNode->GetName() == wxT( "patternGraphicsDef" ) )
|
|
|
|
{
|
|
|
|
FindNode( lNode,
|
|
|
|
wxT( "patternGraphicsNameDef" ) )->GetAttribute( wxT( "Name" ),
|
|
|
|
&propValue );
|
|
|
|
|
|
|
|
if( propValue == *aPatGraphRefName )
|
|
|
|
{
|
|
|
|
result = FindNode( lNode, wxT( "multiLayer" ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
lNode = nullptr;
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2012-12-29 09:54:25 +00:00
|
|
|
lNode = lNode->GetNext();
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
else
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2012-12-29 09:54:25 +00:00
|
|
|
lNode = lNode->GetNext();
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void PCB_FOOTPRINT::DoLayerContentsObjects( XNODE* aNode, PCB_FOOTPRINT* aFootprint,
|
|
|
|
PCB_COMPONENTS_ARRAY* aList, wxStatusBar* aStatusBar,
|
|
|
|
const wxString& aDefaultMeasurementUnit,
|
|
|
|
const wxString& aActualConversion )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
PCB_ARC* arc;
|
|
|
|
PCB_POLYGON* polygon;
|
2021-07-19 23:56:05 +00:00
|
|
|
PCB_POLYGON *plane_layer = nullptr;
|
2012-12-29 09:54:25 +00:00
|
|
|
PCB_COPPER_POUR* copperPour;
|
|
|
|
PCB_CUTOUT* cutout;
|
|
|
|
PCB_PLANE* plane;
|
|
|
|
VERTICES_ARRAY* plane_layer_polygon;
|
|
|
|
PCB_LINE* line;
|
|
|
|
PCB_TEXT* text;
|
|
|
|
XNODE* lNode, * tNode;
|
|
|
|
wxString propValue;
|
|
|
|
long long i;
|
|
|
|
int PCadLayer;
|
|
|
|
long num = 0;
|
|
|
|
|
|
|
|
i = 0;
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
// aStatusBar->SetStatusText( wxT( "Processing LAYER CONTENT OBJECTS " ) );
|
|
|
|
if( FindNode( aNode, wxT( "layerNumRef" ) ) )
|
|
|
|
FindNode( aNode, wxT( "layerNumRef" ) )->GetNodeContent().ToLong( &num );
|
|
|
|
|
|
|
|
PCadLayer = (int) num;
|
|
|
|
|
|
|
|
if( m_callbacks->GetLayerType( PCadLayer ) == LAYER_TYPE_PLANE )
|
|
|
|
{
|
|
|
|
plane_layer = new PCB_POLYGON( m_callbacks, m_board, PCadLayer );
|
|
|
|
plane_layer->AssignNet( m_callbacks->GetLayerNetNameRef( PCadLayer ) );
|
2020-11-14 21:21:54 +00:00
|
|
|
plane_layer->SetOutline( &m_BoardOutline );
|
2012-12-29 09:54:25 +00:00
|
|
|
aList->Add( plane_layer );
|
|
|
|
|
|
|
|
// fill the polygon with the same contour as its outline is
|
|
|
|
//plane_layer->AddIsland( &m_boardOutline );
|
|
|
|
}
|
|
|
|
|
|
|
|
lNode = aNode->GetChildren();
|
|
|
|
|
|
|
|
while( lNode )
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
// aStatusBar->SetStatusText( wxString::Format( "Processing LAYER CONTENT OBJECTS :%lld",
|
|
|
|
// i ) );
|
|
|
|
|
|
|
|
if( lNode->GetName() == wxT( "line" ) )
|
|
|
|
{
|
|
|
|
line = new PCB_LINE( m_callbacks, m_board );
|
|
|
|
line->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
|
|
|
|
aList->Add( line );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lNode->GetName() == wxT( "text" ) )
|
|
|
|
{
|
|
|
|
text = new PCB_TEXT( m_callbacks, m_board );
|
|
|
|
text->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
|
|
|
|
aList->Add( text );
|
|
|
|
}
|
|
|
|
|
|
|
|
// added as Sergeys request 02/2008
|
|
|
|
if( lNode->GetName() == wxT( "attr" ) )
|
|
|
|
{
|
|
|
|
// assign fonts to Module Name,Value,Type,....s
|
|
|
|
lNode->GetAttribute( wxT( "Name" ), &propValue );
|
|
|
|
propValue.Trim( false );
|
|
|
|
propValue.Trim( true );
|
|
|
|
|
2016-02-24 11:56:40 +00:00
|
|
|
if( propValue == wxT( "RefDes" ) )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
tNode = FindNode( lNode, wxT( "textStyleRef" ) );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( tNode && aFootprint )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
// TODO: to understand and may be repair
|
|
|
|
// Alexander Lunev: originally in Delphi version of the project there was
|
|
|
|
// a strange access to pcbModule->m_name (it was global variable). This access
|
|
|
|
// is necessary when the function DoLayerContentsObjects() is called from
|
|
|
|
// function CreatePCBModule(). However it is not clear whether the access is
|
|
|
|
// required when the function DoLayerContentsObjects() is called from
|
|
|
|
// function ProcessXMLtoPCBLib().
|
2021-07-19 23:56:05 +00:00
|
|
|
SetFontProperty( tNode, &aFootprint->m_name, aDefaultMeasurementUnit,
|
2012-12-29 09:54:25 +00:00
|
|
|
aActualConversion );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// added as Sergeys request 02/2008
|
|
|
|
if( lNode->GetName() == wxT( "arc" ) || lNode->GetName() == wxT( "triplePointArc" ) )
|
|
|
|
{
|
|
|
|
arc = new PCB_ARC( m_callbacks, m_board );
|
|
|
|
arc->Parse( lNode, PCadLayer, aDefaultMeasurementUnit, aActualConversion );
|
|
|
|
aList->Add( arc );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lNode->GetName() == wxT( "pcbPoly" ) )
|
|
|
|
{
|
|
|
|
if( m_callbacks->GetLayerType( PCadLayer ) == LAYER_TYPE_PLANE )
|
|
|
|
{
|
|
|
|
plane_layer_polygon = new VERTICES_ARRAY;
|
|
|
|
wxASSERT( plane_layer );
|
2021-07-19 23:56:05 +00:00
|
|
|
plane_layer->FormPolygon( lNode, plane_layer_polygon, aDefaultMeasurementUnit,
|
|
|
|
aActualConversion );
|
2012-12-29 09:54:25 +00:00
|
|
|
plane_layer->m_cutouts.Add( plane_layer_polygon );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
polygon = new PCB_POLYGON( m_callbacks, m_board, PCadLayer );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
|
|
|
if( polygon->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
|
2012-12-29 09:54:25 +00:00
|
|
|
aList->Add( polygon );
|
|
|
|
else
|
|
|
|
delete polygon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lNode->GetName() == wxT( "copperPour95" ) )
|
|
|
|
{
|
|
|
|
copperPour = new PCB_COPPER_POUR( m_callbacks, m_board, PCadLayer );
|
|
|
|
|
2017-12-14 15:09:04 +00:00
|
|
|
if( copperPour->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
|
2012-12-29 09:54:25 +00:00
|
|
|
aList->Add( copperPour );
|
|
|
|
else
|
|
|
|
delete copperPour;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lNode->GetName() == wxT( "polyCutOut" ) )
|
|
|
|
{
|
|
|
|
cutout = new PCB_CUTOUT( m_callbacks, m_board, PCadLayer );
|
|
|
|
|
|
|
|
if( cutout->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
|
|
|
|
aList->Add( cutout );
|
|
|
|
else
|
|
|
|
delete cutout;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( lNode->GetName() == wxT( "planeObj" ) )
|
|
|
|
{
|
|
|
|
plane = new PCB_PLANE( m_callbacks, m_board, PCadLayer );
|
|
|
|
|
2017-12-14 15:09:04 +00:00
|
|
|
if( plane->Parse( lNode, aDefaultMeasurementUnit, aActualConversion ) )
|
2012-12-29 09:54:25 +00:00
|
|
|
aList->Add( plane );
|
|
|
|
else
|
|
|
|
delete plane;
|
|
|
|
}
|
|
|
|
|
|
|
|
lNode = lNode->GetNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
void PCB_FOOTPRINT::SetName( const wxString& aPin, const wxString& aName )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
long num;
|
|
|
|
|
|
|
|
aPin.ToLong( &num );
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_FootprintItems[i]->m_objType == wxT( 'P' ) )
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
|
|
|
if( ( (PCB_PAD*) m_FootprintItems[i] )->m_Number == num )
|
2020-11-14 21:21:54 +00:00
|
|
|
( (PCB_PAD*) m_FootprintItems[i] )->m_name.text = aName;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
void PCB_FOOTPRINT::Parse( XNODE* aNode, wxStatusBar* aStatusBar,
|
2020-11-14 21:21:54 +00:00
|
|
|
const wxString& aDefaultMeasurementUnit,
|
|
|
|
const wxString& aActualConversion )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
XNODE* lNode, * tNode, * mNode;
|
|
|
|
PCB_PAD* pad;
|
|
|
|
PCB_VIA* via;
|
|
|
|
wxString propValue, str;
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
FindNode( aNode, wxT( "originalName" ) )->GetAttribute( wxT( "Name" ), &propValue );
|
2012-12-29 09:54:25 +00:00
|
|
|
propValue.Trim( false );
|
|
|
|
m_name.text = propValue;
|
|
|
|
|
|
|
|
// aStatusBar->SetStatusText( wxT( "Creating Component : " ) + m_name.text );
|
|
|
|
lNode = aNode;
|
|
|
|
lNode = FindPatternMultilayerSection( lNode, &m_patGraphRefName );
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
{
|
|
|
|
tNode = lNode;
|
|
|
|
tNode = tNode->GetChildren();
|
|
|
|
|
|
|
|
while( tNode )
|
|
|
|
{
|
|
|
|
if( tNode->GetName() == wxT( "pad" ) )
|
|
|
|
{
|
|
|
|
pad = new PCB_PAD( m_callbacks, m_board );
|
|
|
|
pad->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
|
2020-11-14 21:21:54 +00:00
|
|
|
m_FootprintItems.Add( pad );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( tNode->GetName() == wxT( "via" ) )
|
|
|
|
{
|
|
|
|
via = new PCB_VIA( m_callbacks, m_board );
|
|
|
|
via->Parse( tNode, aDefaultMeasurementUnit, aActualConversion );
|
2020-11-14 21:21:54 +00:00
|
|
|
m_FootprintItems.Add( via );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tNode = tNode->GetNext();
|
|
|
|
}
|
|
|
|
|
2020-10-30 19:31:23 +00:00
|
|
|
lNode = lNode->GetParent();
|
|
|
|
}
|
2015-03-28 16:16:40 +00:00
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
lNode = FindNode( lNode, wxT( "layerContents" ) );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
while( lNode )
|
|
|
|
{
|
|
|
|
if( lNode->GetName() == wxT( "layerContents" ) )
|
2020-11-14 21:21:54 +00:00
|
|
|
DoLayerContentsObjects( lNode, this, &m_FootprintItems, aStatusBar,
|
2012-12-29 09:54:25 +00:00
|
|
|
aDefaultMeasurementUnit, aActualConversion );
|
|
|
|
|
|
|
|
lNode = lNode->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
// map pins
|
|
|
|
lNode = FindPinMap( aNode );
|
|
|
|
|
|
|
|
if( lNode )
|
|
|
|
{
|
|
|
|
mNode = lNode->GetChildren();
|
|
|
|
|
|
|
|
while( mNode )
|
|
|
|
{
|
|
|
|
if( mNode->GetName() == wxT( "padNum" ) )
|
|
|
|
{
|
|
|
|
str = mNode->GetNodeContent();
|
|
|
|
mNode = mNode->GetNext();
|
|
|
|
|
|
|
|
if( !mNode )
|
|
|
|
break;
|
|
|
|
|
|
|
|
mNode->GetAttribute( wxT( "Name" ), &propValue );
|
2017-08-11 09:22:13 +00:00
|
|
|
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
|
|
|
wxString PCB_FOOTPRINT::ModuleLayer( int aMirror )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
wxString result;
|
|
|
|
|
|
|
|
// ///NOT ! {IntToStr(KiCadLayer)} NOT !
|
2020-11-13 15:15:52 +00:00
|
|
|
// / FOOTPRINTs ARE HARD PLACED ON COMPONENT OR COPPER LAYER.
|
2012-12-29 09:54:25 +00:00
|
|
|
// / IsFLIPPED--> MIRROR attribute is decision Point!!!
|
|
|
|
|
|
|
|
if( aMirror == 0 )
|
|
|
|
result = wxT( "15" ); // Components side
|
|
|
|
else
|
|
|
|
result = wxT( "0" ); // Copper side
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
void PCB_FOOTPRINT::AddToBoard()
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
|
|
|
int i;
|
2022-01-18 02:05:59 +00:00
|
|
|
EDA_ANGLE r;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
// transform text positions
|
2016-02-24 11:56:40 +00:00
|
|
|
CorrectTextPosition( &m_name );
|
2022-01-18 02:05:59 +00:00
|
|
|
RotatePoint( &m_name.correctedPositionX, &m_name.correctedPositionY, -m_rotation );
|
2016-02-24 11:56:40 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
CorrectTextPosition( &m_Value );
|
2022-01-18 02:05:59 +00:00
|
|
|
RotatePoint( &m_Value.correctedPositionX, &m_Value.correctedPositionY, -m_rotation );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
FOOTPRINT* footprint = new FOOTPRINT( m_board );
|
|
|
|
m_board->Add( footprint, ADD_MODE::APPEND );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2022-01-01 18:57:44 +00:00
|
|
|
footprint->SetPosition( VECTOR2I( m_positionX, m_positionY ) );
|
2020-11-14 21:21:54 +00:00
|
|
|
footprint->SetLayer( m_Mirror ? B_Cu : F_Cu );
|
2022-01-18 02:05:59 +00:00
|
|
|
footprint->SetOrientation( m_rotation );
|
2020-11-14 21:21:54 +00:00
|
|
|
footprint->SetLastEditTime( 0 );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2018-07-26 14:38:30 +00:00
|
|
|
LIB_ID fpID;
|
2020-12-17 23:32:23 +00:00
|
|
|
fpID.Parse( m_compRef, true );
|
2020-11-14 21:21:54 +00:00
|
|
|
footprint->SetFPID( fpID );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
// reference text
|
2020-11-14 21:21:54 +00:00
|
|
|
FP_TEXT* ref_text = &footprint->Reference();
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2017-12-10 08:12:10 +00:00
|
|
|
ref_text->SetText( ValidateReference( m_name.text ) );
|
2020-10-04 23:34:59 +00:00
|
|
|
ref_text->SetType( FP_TEXT::TEXT_is_REFERENCE );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2022-01-01 18:57:44 +00:00
|
|
|
ref_text->SetPos0( VECTOR2I( m_name.correctedPositionX, m_name.correctedPositionY ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2017-12-12 18:21:44 +00:00
|
|
|
if( m_name.isTrueType )
|
|
|
|
SetTextSizeFromTrueTypeFontHeight( ref_text, m_name.textHeight );
|
|
|
|
else
|
|
|
|
SetTextSizeFromStrokeFontHeight( ref_text, m_name.textHeight );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2016-02-24 11:56:40 +00:00
|
|
|
r = m_name.textRotation - m_rotation;
|
2022-01-18 02:05:59 +00:00
|
|
|
ref_text->SetTextAngle( r );
|
2018-04-28 15:22:25 +00:00
|
|
|
ref_text->SetKeepUpright( false );
|
2016-02-24 11:56:40 +00:00
|
|
|
|
2017-12-10 09:21:43 +00:00
|
|
|
ref_text->SetItalic( m_name.isItalic );
|
2020-04-14 12:25:00 +00:00
|
|
|
ref_text->SetTextThickness( m_name.textstrokeWidth );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
ref_text->SetMirrored( m_name.mirror );
|
|
|
|
ref_text->SetVisible( m_name.textIsVisible );
|
|
|
|
|
2017-12-11 18:35:14 +00:00
|
|
|
ref_text->SetLayer( m_name.mirror ? FlipLayer( m_KiCadLayer ) : m_KiCadLayer );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
// Calculate the actual position.
|
|
|
|
ref_text->SetDrawCoord();
|
|
|
|
|
|
|
|
// value text
|
2020-11-14 21:21:54 +00:00
|
|
|
FP_TEXT* val_text = &footprint->Value();
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
val_text->SetText( m_Value.text );
|
2020-10-04 23:34:59 +00:00
|
|
|
val_text->SetType( FP_TEXT::TEXT_is_VALUE );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2022-01-01 18:57:44 +00:00
|
|
|
val_text->SetPos0( VECTOR2I( m_Value.correctedPositionX, m_Value.correctedPositionY ) );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_Value.isTrueType )
|
|
|
|
SetTextSizeFromTrueTypeFontHeight( val_text, m_Value.textHeight );
|
2017-12-12 18:21:44 +00:00
|
|
|
else
|
2020-11-14 21:21:54 +00:00
|
|
|
SetTextSizeFromStrokeFontHeight( val_text, m_Value.textHeight );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
r = m_Value.textRotation - m_rotation;
|
2022-01-18 02:05:59 +00:00
|
|
|
val_text->SetTextAngle( r );
|
2018-04-28 15:22:25 +00:00
|
|
|
val_text->SetKeepUpright( false );
|
2016-02-24 11:56:40 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
val_text->SetItalic( m_Value.isItalic );
|
|
|
|
val_text->SetTextThickness( m_Value.textstrokeWidth );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
val_text->SetMirrored( m_Value.mirror );
|
|
|
|
val_text->SetVisible( m_Value.textIsVisible );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
val_text->SetLayer( m_Value.mirror ? FlipLayer( m_KiCadLayer ) : m_KiCadLayer );
|
2012-12-29 09:54:25 +00:00
|
|
|
|
|
|
|
// Calculate the actual position.
|
|
|
|
val_text->SetDrawCoord();
|
|
|
|
|
|
|
|
// TEXTS
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_FootprintItems[i]->m_objType == wxT( 'T' ) )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
( (PCB_TEXT*) m_FootprintItems[i] )->m_tag = i + 2;
|
|
|
|
m_FootprintItems[ i ]->AddToFootprint( footprint );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-13 21:07:01 +00:00
|
|
|
// FOOTPRINT LINES
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_FootprintItems[i]->m_objType == wxT( 'L' ) )
|
|
|
|
m_FootprintItems[ i ]->AddToFootprint( footprint );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 21:07:01 +00:00
|
|
|
// FOOTPRINT ARCS
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_FootprintItems[i]->m_objType == wxT( 'A' ) )
|
|
|
|
m_FootprintItems[ i ]->AddToFootprint( footprint );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 21:07:01 +00:00
|
|
|
// FOOTPRINT POLYGONS
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2017-12-13 19:14:23 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_FootprintItems[i]->m_objType == wxT( 'Z' ) )
|
|
|
|
m_FootprintItems[ i ]->AddToFootprint( footprint );
|
2017-12-13 19:14:23 +00:00
|
|
|
}
|
|
|
|
|
2012-12-29 09:54:25 +00:00
|
|
|
// PADS
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_FootprintItems[i]->m_objType == wxT( 'P' ) )
|
|
|
|
((PCB_PAD*) m_FootprintItems[ i ] )->AddToFootprint( footprint, m_rotation, false );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// VIAS
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_FootprintItems[i]->m_objType == wxT( 'V' ) )
|
|
|
|
((PCB_VIA*) m_FootprintItems[ i ] )->AddToFootprint( footprint, m_rotation, false );
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
void PCB_FOOTPRINT::Flip()
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2013-03-09 19:36:31 +00:00
|
|
|
int i;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_Mirror == 1 )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2017-12-11 18:35:14 +00:00
|
|
|
m_rotation = -m_rotation;
|
2012-12-29 09:54:25 +00:00
|
|
|
|
2020-11-14 21:21:54 +00:00
|
|
|
for( i = 0; i < (int) m_FootprintItems.GetCount(); i++ )
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
if( m_FootprintItems[i]->m_objType == wxT( 'L' ) || // lines
|
|
|
|
m_FootprintItems[i]->m_objType == wxT( 'A' ) || // arcs
|
|
|
|
m_FootprintItems[i]->m_objType == wxT( 'Z' ) || // polygons
|
|
|
|
m_FootprintItems[i]->m_objType == wxT( 'P' ) || // pads
|
|
|
|
m_FootprintItems[i]->m_objType == wxT( 'V' ) ) // vias
|
2012-12-29 09:54:25 +00:00
|
|
|
{
|
2020-11-14 21:21:54 +00:00
|
|
|
m_FootprintItems[i]->Flip();
|
2012-12-29 09:54:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace PCAD2KICAD
|