Don't export hidden models to STEP.

Fixes https://gitlab.com/kicad/code/kicad/issues/5451
This commit is contained in:
Jeff Young 2020-09-03 22:59:03 +01:00
parent a4d23fff12
commit 904d186f6d
3 changed files with 53 additions and 39 deletions

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com> * Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,17 +32,16 @@
KICADMODEL::KICADMODEL() : KICADMODEL::KICADMODEL() :
m_hide( false ),
m_scale( 1.0, 1.0, 1.0 ), m_scale( 1.0, 1.0, 1.0 ),
m_offset( 0.0, 0.0, 0.0 ), m_offset( 0.0, 0.0, 0.0 ),
m_rotation( 0.0, 0.0, 0.0 ) m_rotation( 0.0, 0.0, 0.0 )
{ {
return;
} }
KICADMODEL::~KICADMODEL() KICADMODEL::~KICADMODEL()
{ {
return;
} }
@ -61,9 +61,13 @@ bool KICADMODEL::Read( SEXPR::SEXPR* aEntry )
SEXPR::SEXPR* child = aEntry->GetChild( 1 ); SEXPR::SEXPR* child = aEntry->GetChild( 1 );
if( child->IsSymbol() ) if( child->IsSymbol() )
{
m_modelname = child->GetSymbol(); m_modelname = child->GetSymbol();
}
else if( child->IsString() ) else if( child->IsString() )
{
m_modelname = child->GetString(); m_modelname = child->GetString();
}
else else
{ {
std::ostringstream ostr; std::ostringstream ostr;
@ -76,46 +80,50 @@ bool KICADMODEL::Read( SEXPR::SEXPR* aEntry )
{ {
child = aEntry->GetChild( i ); child = aEntry->GetChild( i );
if( !child->IsList() ) if( child->IsSymbol() && child->GetSymbol() == "hide" )
continue;
std::string name = child->GetChild( 0 )->GetSymbol();
bool ret = true;
/*
* Version 4.x and prior used 'at' parameter,
* which was specified in inches.
*/
if( name == "at" )
{ {
ret = Get3DCoordinate( child->GetChild( 1 ), m_offset ); m_hide = true;
}
else if( child->IsList() )
{
std::string name = child->GetChild( 0 )->GetSymbol();
bool ret = true;
if( ret ) /*
* Version 4.x and prior used 'at' parameter,
* which was specified in inches.
*/
if( name == "at" )
{ {
m_offset.x *= 25.4f; ret = Get3DCoordinate( child->GetChild( 1 ), m_offset );
m_offset.y *= 25.4f;
m_offset.z *= 25.4f;
}
}
/*
* From 5.x onwards, 3D model is provided in 'offset',
* which is in millimetres
*/
else if( name == "offset" )
{
ret = Get3DCoordinate( child->GetChild( 1 ), m_offset );
}
else if( name == "scale" )
{
ret = Get3DCoordinate( child->GetChild( 1 ), m_scale );
}
else if( name == "rotate" )
{
ret = GetXYZRotation( child->GetChild( 1 ), m_rotation );
}
if( !ret ) if( ret )
return false; {
m_offset.x *= 25.4f;
m_offset.y *= 25.4f;
m_offset.z *= 25.4f;
}
}
/*
* From 5.x onwards, 3D model is provided in 'offset',
* which is in millimetres
*/
else if( name == "offset" )
{
ret = Get3DCoordinate( child->GetChild( 1 ), m_offset );
}
else if( name == "scale" )
{
ret = Get3DCoordinate( child->GetChild( 1 ), m_scale );
}
else if( name == "rotate" )
{
ret = GetXYZRotation( child->GetChild( 1 ), m_rotation );
}
if( !ret )
return false;
}
} }
return true; return true;

View File

@ -38,8 +38,10 @@ public:
virtual ~KICADMODEL(); virtual ~KICADMODEL();
bool Read( SEXPR::SEXPR* aEntry ); bool Read( SEXPR::SEXPR* aEntry );
bool Hide() const { return m_hide; }
std::string m_modelname; std::string m_modelname;
bool m_hide;
TRIPLET m_scale; TRIPLET m_scale;
TRIPLET m_offset; TRIPLET m_offset;
TRIPLET m_rotation; TRIPLET m_rotation;

View File

@ -159,7 +159,11 @@ bool KICADMODULE::parseModel( SEXPR::SEXPR* data )
return false; return false;
} }
m_models.push_back( mp ); if( mp->Hide() )
delete mp;
else
m_models.push_back( mp );
return true; return true;
} }