2016-09-02 10:08:40 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
2022-07-05 12:58:59 +00:00
|
|
|
* Copyright 2018-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-09-02 10:08:40 +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
|
|
|
|
*/
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
#include "kicadfootprint.h"
|
2016-09-02 10:08:40 +00:00
|
|
|
|
|
|
|
#include "3d_resolver.h"
|
2019-04-15 17:09:27 +00:00
|
|
|
#include "kicadcurve.h"
|
2016-09-02 10:08:40 +00:00
|
|
|
#include "kicadmodel.h"
|
|
|
|
#include "kicadpad.h"
|
|
|
|
#include "oce_utils.h"
|
|
|
|
|
2019-04-15 17:09:27 +00:00
|
|
|
#include <sexpr/sexpr.h>
|
|
|
|
|
|
|
|
#include <wx/log.h>
|
2021-09-08 14:28:22 +00:00
|
|
|
#include <wx/filename.h>
|
2019-04-15 17:09:27 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <limits>
|
2022-01-21 14:52:32 +00:00
|
|
|
#include <memory>
|
2019-04-15 17:09:27 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2020-02-15 09:58:44 +00:00
|
|
|
#include <Standard_Failure.hxx>
|
2016-09-02 10:08:40 +00:00
|
|
|
|
2020-11-17 13:49:24 +00:00
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
KICADFOOTPRINT::KICADFOOTPRINT( KICADPCB* aParent )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
2017-06-08 06:33:14 +00:00
|
|
|
m_parent = aParent;
|
2016-09-02 10:08:40 +00:00
|
|
|
m_side = LAYER_NONE;
|
|
|
|
m_rotation = 0.0;
|
2021-08-28 14:43:06 +00:00
|
|
|
m_smd = false;
|
|
|
|
m_tht = false;
|
2016-09-18 00:25:10 +00:00
|
|
|
m_virtual = false;
|
2016-09-02 10:08:40 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
KICADFOOTPRINT::~KICADFOOTPRINT()
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
2021-09-04 17:05:30 +00:00
|
|
|
for( KICADPAD* i : m_pads )
|
2016-09-02 10:08:40 +00:00
|
|
|
delete i;
|
|
|
|
|
2021-09-04 17:05:30 +00:00
|
|
|
for( KICADCURVE* i : m_curves )
|
2016-09-02 10:08:40 +00:00
|
|
|
delete i;
|
|
|
|
|
2021-09-04 17:05:30 +00:00
|
|
|
for( KICADMODEL* i : m_models )
|
2016-09-02 10:08:40 +00:00
|
|
|
delete i;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::Read( SEXPR::SEXPR* aEntry )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
2021-09-04 17:05:30 +00:00
|
|
|
if( !aEntry )
|
2016-09-02 10:08:40 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if( aEntry->IsList() )
|
|
|
|
{
|
|
|
|
size_t nc = aEntry->GetNumberOfChildren();
|
|
|
|
SEXPR::SEXPR* child = aEntry->GetChild( 0 );
|
|
|
|
std::string name = child->GetSymbol();
|
|
|
|
|
2020-11-17 13:49:24 +00:00
|
|
|
if( name != "module" && name != "footprint" )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << "* BUG: module parser invoked for type '" << name << "'\n";
|
2022-02-08 21:47:43 +00:00
|
|
|
wxLogMessage( wxT( "%s\n" ), ostr.str().c_str() );
|
2016-09-02 10:08:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool result = true;
|
|
|
|
|
2017-02-01 22:53:01 +00:00
|
|
|
for( size_t i = 2; i < nc && result; ++i )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
child = aEntry->GetChild( i );
|
2018-01-15 09:53:25 +00:00
|
|
|
std::string symname;
|
2016-09-02 10:08:40 +00:00
|
|
|
|
2018-01-15 09:53:25 +00:00
|
|
|
// skip the optional locked and/or placed attributes; due to the vagaries of the
|
2020-11-17 13:49:24 +00:00
|
|
|
// KiCad version of sexpr, the attribute may be a Symbol or a String
|
2018-01-15 09:53:25 +00:00
|
|
|
if( child->IsSymbol() || child->IsString() )
|
|
|
|
{
|
|
|
|
if( child->IsSymbol() )
|
|
|
|
symname = child->GetSymbol();
|
|
|
|
else if( child->IsString() )
|
|
|
|
symname = child->GetString();
|
|
|
|
|
|
|
|
if( symname == "locked" || symname == "placed" )
|
|
|
|
continue;
|
|
|
|
|
2022-02-08 21:47:43 +00:00
|
|
|
wxLogMessage( wxT( "* module descr in PCB file at line %d: unexpected keyword "
|
|
|
|
"'%s'\n" ),
|
|
|
|
child->GetLineNumber(),
|
|
|
|
symname.c_str() );
|
2018-01-15 09:53:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
2016-09-02 10:08:40 +00:00
|
|
|
|
|
|
|
if( !child->IsList() )
|
|
|
|
{
|
2022-02-08 21:47:43 +00:00
|
|
|
wxLogMessage( wxT( "* corrupt module in PCB file at line %d\n" ),
|
2018-01-15 09:53:25 +00:00
|
|
|
child->GetLineNumber() );
|
2016-09-02 10:08:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-01-15 09:53:25 +00:00
|
|
|
symname = child->GetChild( 0 )->GetSymbol();
|
2016-09-02 10:08:40 +00:00
|
|
|
|
|
|
|
if( symname == "layer" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseLayer( child );
|
2016-09-02 10:08:40 +00:00
|
|
|
else if( symname == "at" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parsePosition( child );
|
2016-09-18 00:25:10 +00:00
|
|
|
else if( symname == "attr" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseAttribute( child );
|
2016-09-02 10:08:40 +00:00
|
|
|
else if( symname == "fp_text" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseText( child );
|
2016-09-02 10:08:40 +00:00
|
|
|
else if( symname == "fp_arc" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseCurve( child, CURVE_ARC );
|
2016-09-02 10:08:40 +00:00
|
|
|
else if( symname == "fp_line" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseCurve( child, CURVE_LINE );
|
2016-09-02 10:08:40 +00:00
|
|
|
else if( symname == "fp_circle" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseCurve( child, CURVE_CIRCLE );
|
2021-01-03 20:07:15 +00:00
|
|
|
else if( symname == "fp_rect" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseRect( child );
|
2021-01-03 20:07:15 +00:00
|
|
|
else if( symname == "fp_curve" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseCurve( child, CURVE_BEZIER );
|
2016-09-02 10:08:40 +00:00
|
|
|
else if( symname == "pad" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parsePad( child );
|
2016-09-02 10:08:40 +00:00
|
|
|
else if( symname == "model" )
|
2021-09-04 17:05:30 +00:00
|
|
|
result = parseModel( child );
|
2016-09-02 10:08:40 +00:00
|
|
|
}
|
|
|
|
|
2021-08-28 14:43:06 +00:00
|
|
|
if( !m_smd && !m_tht )
|
|
|
|
m_virtual = true;
|
|
|
|
|
2016-09-02 10:08:40 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ostringstream ostr;
|
|
|
|
ostr << "* data is not a valid PCB module\n";
|
2022-02-08 21:47:43 +00:00
|
|
|
wxLogMessage( wxT( "%s\n" ), ostr.str().c_str() );
|
2016-09-02 10:08:40 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-03 20:07:15 +00:00
|
|
|
bool KICADFOOTPRINT::parseRect( SEXPR::SEXPR* data )
|
|
|
|
{
|
2021-01-07 08:24:30 +00:00
|
|
|
std::unique_ptr<KICADCURVE> rect = std::make_unique<KICADCURVE>();
|
2021-01-03 20:07:15 +00:00
|
|
|
|
|
|
|
if( !rect->Read( data, CURVE_LINE ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// reject any curves not on the Edge.Cuts layer
|
|
|
|
if( rect->GetLayer() != LAYER_EDGE )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
KICADCURVE* top = new KICADCURVE( *rect );
|
|
|
|
KICADCURVE* right = new KICADCURVE( *rect );
|
|
|
|
KICADCURVE* bottom = new KICADCURVE( *rect );
|
|
|
|
KICADCURVE* left = new KICADCURVE( *rect );
|
|
|
|
|
|
|
|
top->m_end.y = right->m_start.y;
|
|
|
|
m_curves.push_back( top );
|
|
|
|
|
|
|
|
right->m_start.x = bottom->m_end.x;
|
|
|
|
m_curves.push_back( right );
|
|
|
|
|
|
|
|
bottom->m_start.y = left->m_end.y;
|
|
|
|
m_curves.push_back( bottom );
|
|
|
|
|
|
|
|
left->m_end.x = top->m_start.x;
|
|
|
|
m_curves.push_back( left );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::parseModel( SEXPR::SEXPR* data )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
KICADMODEL* mp = new KICADMODEL();
|
|
|
|
|
|
|
|
if( !mp->Read( data ) )
|
|
|
|
{
|
|
|
|
delete mp;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-03 21:59:03 +00:00
|
|
|
if( mp->Hide() )
|
|
|
|
delete mp;
|
|
|
|
else
|
|
|
|
m_models.push_back( mp );
|
|
|
|
|
2016-09-02 10:08:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::parseCurve( SEXPR::SEXPR* data, CURVE_TYPE aCurveType )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
KICADCURVE* mp = new KICADCURVE();
|
|
|
|
|
|
|
|
if( !mp->Read( data, aCurveType ) )
|
|
|
|
{
|
|
|
|
delete mp;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: for now we are only interested in glyphs on the outline layer
|
|
|
|
if( LAYER_EDGE != mp->GetLayer() )
|
|
|
|
{
|
|
|
|
delete mp;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_curves.push_back( mp );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::parseLayer( SEXPR::SEXPR* data )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
SEXPR::SEXPR* val = data->GetChild( 1 );
|
2017-06-08 06:33:14 +00:00
|
|
|
std::string layername;
|
2016-09-02 10:08:40 +00:00
|
|
|
|
|
|
|
if( val->IsSymbol() )
|
2017-06-08 06:33:14 +00:00
|
|
|
layername = val->GetSymbol();
|
2016-09-02 10:08:40 +00:00
|
|
|
else if( val->IsString() )
|
2017-06-08 06:33:14 +00:00
|
|
|
layername = val->GetString();
|
2016-09-02 10:08:40 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
2017-02-01 03:49:48 +00:00
|
|
|
ostr << "* corrupt module in PCB file (line ";
|
|
|
|
ostr << val->GetLineNumber() << "); layer cannot be parsed\n";
|
2022-02-08 21:47:43 +00:00
|
|
|
wxLogMessage( wxT( "%s\n" ), ostr.str().c_str() );
|
2016-09-02 10:08:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-06-08 06:33:14 +00:00
|
|
|
int layerId = m_parent->GetLayerId( layername );
|
|
|
|
|
|
|
|
if( layerId == 31 )
|
2016-09-02 10:08:40 +00:00
|
|
|
m_side = LAYER_BOTTOM;
|
2017-06-08 06:33:14 +00:00
|
|
|
else
|
|
|
|
m_side = LAYER_TOP;
|
2016-09-02 10:08:40 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::parsePosition( SEXPR::SEXPR* data )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
return Get2DPositionAndRotation( data, m_position, m_rotation );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::parseAttribute( SEXPR::SEXPR* data )
|
2016-09-18 00:25:10 +00:00
|
|
|
{
|
|
|
|
if( data->GetNumberOfChildren() < 2 )
|
|
|
|
{
|
|
|
|
std::ostringstream ostr;
|
2017-02-01 03:49:48 +00:00
|
|
|
ostr << "* corrupt module in PCB file (line ";
|
|
|
|
ostr << data->GetLineNumber() << "); attribute cannot be parsed\n";
|
2022-02-08 21:47:43 +00:00
|
|
|
wxLogMessage( wxT( "%s\n" ), ostr.str().c_str() );
|
2016-09-18 00:25:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SEXPR::SEXPR* child = data->GetChild( 1 );
|
|
|
|
std::string text;
|
|
|
|
|
|
|
|
if( child->IsSymbol() )
|
|
|
|
text = child->GetSymbol();
|
|
|
|
else if( child->IsString() )
|
|
|
|
text = child->GetString();
|
|
|
|
|
2022-07-05 12:58:59 +00:00
|
|
|
// The "virtual" attribute token is obsolete but kicad2step can still be run against older
|
|
|
|
// board files. It has been replaced with "exclude_from_bom" so any footprint with this
|
|
|
|
// attribute will behave the same as the "virtual" attribute.
|
2021-08-28 14:43:06 +00:00
|
|
|
if( text == "smd" )
|
|
|
|
m_smd = true;
|
|
|
|
else if( text == "through_hole" )
|
|
|
|
m_tht = true;
|
|
|
|
else if( text == "virtual" )
|
2016-09-18 00:25:10 +00:00
|
|
|
m_virtual = true;
|
2022-07-05 12:58:59 +00:00
|
|
|
else if( text == "exclude_from_bom" )
|
|
|
|
m_virtual = true;
|
2016-09-18 00:25:10 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::parseText( SEXPR::SEXPR* data )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
// we're only interested in the Reference Designator
|
|
|
|
if( data->GetNumberOfChildren() < 3 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
SEXPR::SEXPR* child = data->GetChild( 1 );
|
|
|
|
std::string text;
|
|
|
|
|
|
|
|
if( child->IsSymbol() )
|
|
|
|
text = child->GetSymbol();
|
|
|
|
else if( child->IsString() )
|
|
|
|
text = child->GetString();
|
|
|
|
|
|
|
|
if( text != "reference" )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
child = data->GetChild( 2 );
|
|
|
|
|
|
|
|
if( child->IsSymbol() )
|
|
|
|
text = child->GetSymbol();
|
|
|
|
else if( child->IsString() )
|
|
|
|
text = child->GetString();
|
|
|
|
|
|
|
|
m_refdes = text;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::parsePad( SEXPR::SEXPR* data )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
KICADPAD* mp = new KICADPAD();
|
|
|
|
|
|
|
|
if( !mp->Read( data ) )
|
|
|
|
{
|
|
|
|
delete mp;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: for now we only accept thru-hole pads
|
|
|
|
// for the MCAD description
|
|
|
|
if( !mp->IsThruHole() )
|
|
|
|
{
|
|
|
|
delete mp;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pads.push_back( mp );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-14 19:16:42 +00:00
|
|
|
bool KICADFOOTPRINT::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver,
|
2021-06-08 22:46:37 +00:00
|
|
|
DOUBLET aOrigin, bool aComposeVirtual, bool aSubstituteModels )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
// translate pads and curves to final position and append to PCB.
|
|
|
|
double dlim = (double)std::numeric_limits< float >::epsilon();
|
|
|
|
|
|
|
|
double vsin = sin( m_rotation );
|
|
|
|
double vcos = cos( m_rotation );
|
|
|
|
bool hasdata = false;
|
|
|
|
|
|
|
|
double posX = m_position.x - aOrigin.x;
|
|
|
|
double posY = m_position.y - aOrigin.y;
|
|
|
|
|
2020-04-22 08:43:28 +00:00
|
|
|
for( KICADCURVE* i : m_curves )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
if( i->m_layer != LAYER_EDGE || CURVE_NONE == i->m_form )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
KICADCURVE lcurve = *i;
|
|
|
|
|
2019-05-22 23:51:11 +00:00
|
|
|
lcurve.m_start.y = -lcurve.m_start.y;
|
|
|
|
lcurve.m_end.y = -lcurve.m_end.y;
|
|
|
|
lcurve.m_angle = -lcurve.m_angle;
|
2016-09-02 10:08:40 +00:00
|
|
|
|
|
|
|
if( m_rotation < -dlim || m_rotation > dlim )
|
|
|
|
{
|
|
|
|
double x = lcurve.m_start.x * vcos - lcurve.m_start.y * vsin;
|
|
|
|
double y = lcurve.m_start.x * vsin + lcurve.m_start.y * vcos;
|
|
|
|
lcurve.m_start.x = x;
|
|
|
|
lcurve.m_start.y = y;
|
|
|
|
x = lcurve.m_end.x * vcos - lcurve.m_end.y * vsin;
|
|
|
|
y = lcurve.m_end.x * vsin + lcurve.m_end.y * vcos;
|
|
|
|
lcurve.m_end.x = x;
|
|
|
|
lcurve.m_end.y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
lcurve.m_start.x += posX;
|
|
|
|
lcurve.m_start.y -= posY;
|
|
|
|
lcurve.m_end.x += posX;
|
|
|
|
lcurve.m_end.y -= posY;
|
|
|
|
|
|
|
|
if( aPCB->AddOutlineSegment( &lcurve ) )
|
|
|
|
hasdata = true;
|
|
|
|
}
|
|
|
|
|
2021-09-04 17:05:30 +00:00
|
|
|
for( KICADPAD* i : m_pads )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
|
|
|
if( !i->IsThruHole() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
KICADPAD lpad = *i;
|
|
|
|
lpad.m_position.y = -lpad.m_position.y;
|
|
|
|
|
|
|
|
if( m_rotation < -dlim || m_rotation > dlim )
|
|
|
|
{
|
|
|
|
double x = lpad.m_position.x * vcos - lpad.m_position.y * vsin;
|
|
|
|
double y = lpad.m_position.x * vsin + lpad.m_position.y * vcos;
|
|
|
|
lpad.m_position.x = x;
|
|
|
|
lpad.m_position.y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpad.m_position.x += posX;
|
|
|
|
lpad.m_position.y -= posY;
|
|
|
|
|
|
|
|
if( aPCB->AddPadHole( &lpad ) )
|
|
|
|
hasdata = true;
|
|
|
|
}
|
|
|
|
|
2016-09-18 00:25:10 +00:00
|
|
|
if( m_virtual && !aComposeVirtual )
|
|
|
|
return hasdata;
|
|
|
|
|
2016-09-02 10:08:40 +00:00
|
|
|
DOUBLET newpos( posX, posY );
|
|
|
|
|
2021-09-04 17:05:30 +00:00
|
|
|
for( KICADMODEL* i : m_models )
|
2016-09-02 10:08:40 +00:00
|
|
|
{
|
2021-09-04 17:05:30 +00:00
|
|
|
wxString mname = wxString::FromUTF8Unchecked( i->m_modelname.c_str() );
|
2021-09-08 14:28:22 +00:00
|
|
|
|
|
|
|
if( mname.empty() )
|
2021-09-14 12:03:38 +00:00
|
|
|
continue;
|
2021-09-08 14:28:22 +00:00
|
|
|
|
2021-09-21 16:51:59 +00:00
|
|
|
std::vector<wxString> searchedPaths;
|
|
|
|
mname = resolver->ResolvePath( mname, searchedPaths );
|
2021-09-08 14:28:22 +00:00
|
|
|
|
|
|
|
if( !wxFileName::FileExists( mname ) )
|
|
|
|
{
|
2021-09-21 16:51:59 +00:00
|
|
|
wxString paths;
|
|
|
|
|
|
|
|
for( const wxString& path : searchedPaths )
|
|
|
|
paths += " " + path + "\n";
|
|
|
|
|
2022-02-08 21:47:43 +00:00
|
|
|
ReportMessage( wxString::Format( wxT( "Could not add 3D model to %s.\n"
|
|
|
|
"File not found: %s\n"
|
|
|
|
"Searched paths:\n"
|
|
|
|
"%s" ),
|
2021-09-08 14:28:22 +00:00
|
|
|
m_refdes,
|
2021-09-21 16:51:59 +00:00
|
|
|
mname,
|
|
|
|
paths) );
|
2021-09-15 20:52:49 +00:00
|
|
|
continue;
|
2021-09-08 14:28:22 +00:00
|
|
|
}
|
|
|
|
|
2021-09-14 11:20:35 +00:00
|
|
|
std::string fname( mname.ToUTF8() );
|
2016-09-02 10:08:40 +00:00
|
|
|
|
2020-02-15 09:58:44 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if( aPCB->AddComponent( fname, m_refdes, LAYER_BOTTOM == m_side ? true : false,
|
2021-09-08 14:28:22 +00:00
|
|
|
newpos, m_rotation, i->m_offset, i->m_rotation, i->m_scale,
|
|
|
|
aSubstituteModels ) )
|
2021-09-04 17:05:30 +00:00
|
|
|
{
|
2020-02-15 09:58:44 +00:00
|
|
|
hasdata = true;
|
2021-09-04 17:05:30 +00:00
|
|
|
}
|
2020-02-15 09:58:44 +00:00
|
|
|
}
|
|
|
|
catch( const Standard_Failure& e)
|
|
|
|
{
|
2022-02-08 21:47:43 +00:00
|
|
|
ReportMessage( wxString::Format( wxT( "Could not add 3D model to %s.\n"
|
|
|
|
"OpenCASCADE error: %s\n" ),
|
2022-07-05 12:58:59 +00:00
|
|
|
m_refdes,
|
2021-09-04 17:05:30 +00:00
|
|
|
e.GetMessageString() ) );
|
2020-02-15 09:58:44 +00:00
|
|
|
}
|
2016-09-02 10:08:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return hasdata;
|
|
|
|
}
|