Fixes: lp:1696204 3D STEP export doesn't handle B.Cu rename
https://bugs.launchpad.net/kicad/+bug/1696204
This commit is contained in:
parent
51bed4bae9
commit
33e0758636
|
@ -35,8 +35,9 @@
|
|||
#include "oce_utils.h"
|
||||
|
||||
|
||||
KICADMODULE::KICADMODULE()
|
||||
KICADMODULE::KICADMODULE( KICADPCB* aParent )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_side = LAYER_NONE;
|
||||
m_rotation = 0.0;
|
||||
m_virtual = false;
|
||||
|
@ -172,12 +173,12 @@ bool KICADMODULE::parseCurve( SEXPR::SEXPR* data, CURVE_TYPE aCurveType )
|
|||
bool KICADMODULE::parseLayer( SEXPR::SEXPR* data )
|
||||
{
|
||||
SEXPR::SEXPR* val = data->GetChild( 1 );
|
||||
std::string layer;
|
||||
std::string layername;
|
||||
|
||||
if( val->IsSymbol() )
|
||||
layer = val->GetSymbol();
|
||||
layername = val->GetSymbol();
|
||||
else if( val->IsString() )
|
||||
layer = val->GetString();
|
||||
layername = val->GetString();
|
||||
else
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
@ -187,10 +188,12 @@ bool KICADMODULE::parseLayer( SEXPR::SEXPR* data )
|
|||
return false;
|
||||
}
|
||||
|
||||
if( layer == "F.Cu" )
|
||||
m_side = LAYER_TOP;
|
||||
else if( layer == "B.Cu" )
|
||||
int layerId = m_parent->GetLayerId( layername );
|
||||
|
||||
if( layerId == 31 )
|
||||
m_side = LAYER_BOTTOM;
|
||||
else
|
||||
m_side = LAYER_TOP;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ private:
|
|||
bool parseText( SEXPR::SEXPR* data );
|
||||
bool parsePad( SEXPR::SEXPR* data );
|
||||
|
||||
KICADPCB* m_parent; // The parent KICADPCB, to know layer names
|
||||
|
||||
LAYERS m_side;
|
||||
std::string m_refdes;
|
||||
DOUBLET m_position;
|
||||
|
@ -66,7 +68,7 @@ private:
|
|||
std::vector< KICADMODEL* > m_models;
|
||||
|
||||
public:
|
||||
KICADMODULE();
|
||||
KICADMODULE( KICADPCB* aParent );
|
||||
virtual ~KICADMODULE();
|
||||
|
||||
bool Read( SEXPR::SEXPR* aEntry );
|
||||
|
|
|
@ -246,6 +246,8 @@ bool KICADPCB::parsePCB( SEXPR::SEXPR* data )
|
|||
result = result && parseGeneral( child );
|
||||
else if( symname == "setup" )
|
||||
result = result && parseSetup( child );
|
||||
else if( symname == "layers" )
|
||||
result = result && parseLayers( child );
|
||||
else if( symname == "module" )
|
||||
result = result && parseModule( child );
|
||||
else if( symname == "gr_arc" )
|
||||
|
@ -304,6 +306,44 @@ bool KICADPCB::parseGeneral( SEXPR::SEXPR* data )
|
|||
}
|
||||
|
||||
|
||||
bool KICADPCB::parseLayers( SEXPR::SEXPR* data )
|
||||
{
|
||||
size_t nc = data->GetNumberOfChildren();
|
||||
SEXPR::SEXPR* child = NULL;
|
||||
|
||||
// Read the layername and the correstponding layer id list:
|
||||
for( size_t i = 1; i < nc; ++i )
|
||||
{
|
||||
child = data->GetChild( i );
|
||||
|
||||
if( !child->IsList() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << "* corrupt PCB file (line " << child->GetLineNumber();
|
||||
ostr << "): '" << m_filename << "'\n";
|
||||
wxLogMessage( "%s\n", ostr.str().c_str() );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_layersNames[child->GetChild( 1 )->GetSymbol()] =
|
||||
child->GetChild( 0 )->GetInteger();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int KICADPCB::GetLayerId( std::string& aLayerName )
|
||||
{
|
||||
int lid = -1;
|
||||
auto item = m_layersNames.find( aLayerName );
|
||||
|
||||
if( item != m_layersNames.end() )
|
||||
lid = item->second;
|
||||
|
||||
return lid;
|
||||
}
|
||||
|
||||
|
||||
bool KICADPCB::parseSetup( SEXPR::SEXPR* data )
|
||||
{
|
||||
size_t nc = data->GetNumberOfChildren();
|
||||
|
@ -369,7 +409,7 @@ bool KICADPCB::parseSetup( SEXPR::SEXPR* data )
|
|||
|
||||
bool KICADPCB::parseModule( SEXPR::SEXPR* data )
|
||||
{
|
||||
KICADMODULE* mp = new KICADMODULE();
|
||||
KICADMODULE* mp = new KICADMODULE( this );
|
||||
|
||||
if( !mp->Read( data ) )
|
||||
{
|
||||
|
|
|
@ -62,6 +62,8 @@ private:
|
|||
// set to TRUE if the origin was actually parsed
|
||||
bool m_hasGridOrigin;
|
||||
bool m_hasDrillOrigin;
|
||||
// the names of layers in use, and the internal layer ID
|
||||
std::map<std::string, int> m_layersNames;
|
||||
|
||||
// PCB parameters/entities
|
||||
double m_thickness;
|
||||
|
@ -71,6 +73,7 @@ private:
|
|||
bool parsePCB( SEXPR::SEXPR* data );
|
||||
bool parseGeneral( SEXPR::SEXPR* data );
|
||||
bool parseSetup( SEXPR::SEXPR* data );
|
||||
bool parseLayers( SEXPR::SEXPR* data );
|
||||
bool parseModule( SEXPR::SEXPR* data );
|
||||
bool parseCurve( SEXPR::SEXPR* data, CURVE_TYPE aCurveType );
|
||||
|
||||
|
@ -78,6 +81,8 @@ public:
|
|||
KICADPCB();
|
||||
virtual ~KICADPCB();
|
||||
|
||||
int GetLayerId( std::string& aLayerName );
|
||||
|
||||
void SetOrigin( double aXOrigin, double aYOrigin )
|
||||
{
|
||||
m_origin.x = aXOrigin;
|
||||
|
|
Loading…
Reference in New Issue