Eagle PCB import plugin: handle correctly non-consecutive layer numbers
This commit is contained in:
parent
59394fedbf
commit
0f532c3e8d
|
@ -145,15 +145,6 @@ EAGLE_PLUGIN::EAGLE_PLUGIN() :
|
||||||
m_mod_time( wxDateTime::Now() )
|
m_mod_time( wxDateTime::Now() )
|
||||||
{
|
{
|
||||||
init( NULL );
|
init( NULL );
|
||||||
|
|
||||||
// add a dummy layer, so the layers numbers match the vector index
|
|
||||||
// (in Eagle layers are enumerated from 1)
|
|
||||||
wxXmlNode dummy( wxXML_ELEMENT_NODE, "dummyLayer" );
|
|
||||||
dummy.AddAttribute( "number", "0" );
|
|
||||||
dummy.AddAttribute( "name", "invalid" );
|
|
||||||
dummy.AddAttribute( "color", "black" );
|
|
||||||
m_eagleLayers.push_back( ELAYER( &dummy ) );
|
|
||||||
|
|
||||||
clear_cu_map();
|
clear_cu_map();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,18 +358,20 @@ void EAGLE_PLUGIN::loadLayerDefs( wxXmlNode* aLayers )
|
||||||
// Get the first layer and iterate
|
// Get the first layer and iterate
|
||||||
wxXmlNode* layerNode = aLayers->GetChildren();
|
wxXmlNode* layerNode = aLayers->GetChildren();
|
||||||
|
|
||||||
// find the subset of layers that are copper, and active
|
m_eagleLayers.clear();
|
||||||
|
|
||||||
while( layerNode )
|
while( layerNode )
|
||||||
{
|
{
|
||||||
ELAYER elayer( layerNode );
|
ELAYER elayer( layerNode );
|
||||||
|
m_eagleLayers.insert( std::make_pair( elayer.number, elayer ) );
|
||||||
|
|
||||||
|
// find the subset of layers that are copper and active
|
||||||
if( elayer.number >= 1 && elayer.number <= 16 && ( !elayer.active || *elayer.active ) )
|
if( elayer.number >= 1 && elayer.number <= 16 && ( !elayer.active || *elayer.active ) )
|
||||||
{
|
{
|
||||||
cu.push_back( elayer );
|
cu.push_back( elayer );
|
||||||
}
|
}
|
||||||
|
|
||||||
layerNode = layerNode->GetNext();
|
layerNode = layerNode->GetNext();
|
||||||
m_eagleLayers.push_back( elayer );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// establish cu layer map:
|
// establish cu layer map:
|
||||||
|
@ -1244,7 +1237,7 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, wxXmlNode* aTree ) const
|
||||||
if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
|
if( IsCopperLayer( layer ) ) // skip copper "package.circle"s
|
||||||
{
|
{
|
||||||
wxLogMessage( wxString::Format(
|
wxLogMessage( wxString::Format(
|
||||||
"Line on copper layer in package %s (%d mm, %d mm) (%d mm, %d mm)."
|
"Line on copper layer in package %s (%f mm, %f mm) (%f mm, %f mm)."
|
||||||
"\nMoving to Dwgs.User layer",
|
"\nMoving to Dwgs.User layer",
|
||||||
aModule->GetFPID().GetLibItemName().c_str(), w.x1.ToMm(), w.y1.ToMm(),
|
aModule->GetFPID().GetLibItemName().c_str(), w.x1.ToMm(), w.y1.ToMm(),
|
||||||
w.x2.ToMm(), w.y2.ToMm() ) );
|
w.x2.ToMm(), w.y2.ToMm() ) );
|
||||||
|
@ -1493,7 +1486,7 @@ void EAGLE_PLUGIN::packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const
|
||||||
wxLogMessage( wxString::Format( "Unsupported rectangle in package %s"
|
wxLogMessage( wxString::Format( "Unsupported rectangle in package %s"
|
||||||
" (%f mm, %f mm) (%f mm, %f mm), layer: %s",
|
" (%f mm, %f mm) (%f mm, %f mm), layer: %s",
|
||||||
aModule->GetFPID().GetLibItemName().c_str(), r.x1.ToMm(), r.y1.ToMm(),
|
aModule->GetFPID().GetLibItemName().c_str(), r.x1.ToMm(), r.y1.ToMm(),
|
||||||
r.x2.ToMm(), r.y2.ToMm(), m_eagleLayers[r.layer].name ) );
|
r.x2.ToMm(), r.y2.ToMm(), eagle_layer_name( r.layer ) ) );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2034,7 +2027,7 @@ PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
|
||||||
default:
|
default:
|
||||||
// some layers do not map to KiCad
|
// some layers do not map to KiCad
|
||||||
wxLogMessage( wxString::Format( "Unsupported Eagle layer '%s' (%d), converted to Dwgs.User layer",
|
wxLogMessage( wxString::Format( "Unsupported Eagle layer '%s' (%d), converted to Dwgs.User layer",
|
||||||
m_eagleLayers[aEagleLayer].name, aEagleLayer ) );
|
eagle_layer_name( aEagleLayer ), aEagleLayer ) );
|
||||||
kiLayer = Dwgs_User; break;
|
kiLayer = Dwgs_User; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2043,6 +2036,14 @@ PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const string& EAGLE_PLUGIN::eagle_layer_name( int aLayer ) const
|
||||||
|
{
|
||||||
|
static const string unknown( "unknown" );
|
||||||
|
auto it = m_eagleLayers.find( aLayer );
|
||||||
|
return it == m_eagleLayers.end() ? unknown : it->second.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EAGLE_PLUGIN::centerBoard()
|
void EAGLE_PLUGIN::centerBoard()
|
||||||
{
|
{
|
||||||
if( m_props )
|
if( m_props )
|
||||||
|
|
|
@ -129,7 +129,7 @@ private:
|
||||||
typedef ELAYERS::const_iterator EITER;
|
typedef ELAYERS::const_iterator EITER;
|
||||||
|
|
||||||
int m_cu_map[17]; ///< map eagle to kicad, cu layers only.
|
int m_cu_map[17]; ///< map eagle to kicad, cu layers only.
|
||||||
ELAYERS m_eagleLayers; ///< Eagle layers data
|
std::map<int, ELAYER> m_eagleLayers; ///< Eagle layers data stored by the layer number
|
||||||
|
|
||||||
ERULES* m_rules; ///< Eagle design rules.
|
ERULES* m_rules; ///< Eagle design rules.
|
||||||
XPATH* m_xpath; ///< keeps track of what we are working on within
|
XPATH* m_xpath; ///< keeps track of what we are working on within
|
||||||
|
@ -169,6 +169,9 @@ private:
|
||||||
/// Convert an Eagle layer to a KiCad layer.
|
/// Convert an Eagle layer to a KiCad layer.
|
||||||
PCB_LAYER_ID kicad_layer( int aLayer ) const;
|
PCB_LAYER_ID kicad_layer( int aLayer ) const;
|
||||||
|
|
||||||
|
/// Get Eagle layer name by its number
|
||||||
|
const std::string& eagle_layer_name( int aLayer ) const;
|
||||||
|
|
||||||
/// This PLUGIN only caches one footprint library, this determines which one.
|
/// This PLUGIN only caches one footprint library, this determines which one.
|
||||||
void cacheLib( const wxString& aLibraryPath );
|
void cacheLib( const wxString& aLibraryPath );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue