Commit 96912e6b authored by Dick Hollenbeck's avatar Dick Hollenbeck

filter better the unsupported layers coming into EAGLE_PLUGIN::Load()

parent fe54ceac
...@@ -116,7 +116,12 @@ public: ...@@ -116,7 +116,12 @@ public:
* is virtual because some items (in fact: class DIMENSION) * is virtual because some items (in fact: class DIMENSION)
* have a slightly different initialization * have a slightly different initialization
*/ */
virtual void SetLayer( LAYER_NUM aLayer ) { m_Layer = aLayer; } virtual void SetLayer( LAYER_NUM aLayer )
{
// trap any invalid layers, then go find the caller and fix it.
// wxASSERT( unsigned( aLayer ) < unsigned( NB_PCB_LAYERS ) );
m_Layer = aLayer;
}
/** /**
* Function Draw * Function Draw
......
...@@ -1321,6 +1321,7 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers ) ...@@ -1321,6 +1321,7 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers )
{ {
LAYER_NUM layer = kicad_layer( it->number ); LAYER_NUM layer = kicad_layer( it->number );
// these function provide their own protection against UNDEFINED_LAYER:
m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) ); m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) );
m_board->SetLayerType( layer, LT_SIGNAL ); m_board->SetLayerType( layer, LT_SIGNAL );
...@@ -1339,6 +1340,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) ...@@ -1339,6 +1340,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
if( gr->first == "wire" ) if( gr->first == "wire" )
{ {
m_xpath->push( "wire" ); m_xpath->push( "wire" );
EWIRE w( gr->second ); EWIRE w( gr->second );
LAYER_NUM layer = kicad_layer( w.layer ); LAYER_NUM layer = kicad_layer( w.layer );
...@@ -1366,10 +1368,11 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) ...@@ -1366,10 +1368,11 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
} }
#endif #endif
m_xpath->push( "text" ); m_xpath->push( "text" );
ETEXT t( gr->second ); ETEXT t( gr->second );
LAYER_NUM layer = kicad_layer( t.layer ); LAYER_NUM layer = kicad_layer( t.layer );
if( layer != -1 ) // supported layer if( layer != UNDEFINED_LAYER )
{ {
TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board ); TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board );
m_board->Add( pcbtxt, ADD_APPEND ); m_board->Add( pcbtxt, ADD_APPEND );
...@@ -1456,6 +1459,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) ...@@ -1456,6 +1459,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
else if( gr->first == "circle" ) else if( gr->first == "circle" )
{ {
m_xpath->push( "circle" ); m_xpath->push( "circle" );
ECIRCLE c( gr->second ); ECIRCLE c( gr->second );
LAYER_NUM layer = kicad_layer( c.layer ); LAYER_NUM layer = kicad_layer( c.layer );
...@@ -1479,6 +1483,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) ...@@ -1479,6 +1483,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
else if( gr->first == "rectangle" ) else if( gr->first == "rectangle" )
{ {
m_xpath->push( "rectangle" ); m_xpath->push( "rectangle" );
ERECT r( gr->second ); ERECT r( gr->second );
LAYER_NUM layer = kicad_layer( r.layer ); LAYER_NUM layer = kicad_layer( r.layer );
...@@ -1501,9 +1506,8 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) ...@@ -1501,9 +1506,8 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
zone->Outline()->CloseLastContour(); zone->Outline()->CloseLastContour();
// this is not my fault: // this is not my fault:
zone->Outline()->SetHatch( outline_hatch, zone->Outline()->SetHatch(
Mils2iu( zone->Outline()->GetDefaultHatchPitchMils() ), outline_hatch, Mils2iu( zone->Outline()->GetDefaultHatchPitchMils() ), true );
true );
} }
m_xpath->pop(); m_xpath->pop();
...@@ -1917,7 +1921,7 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, CPTREE& aTree ) const ...@@ -1917,7 +1921,7 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, CPTREE& aTree ) const
EWIRE w( aTree ); EWIRE w( aTree );
LAYER_NUM layer = kicad_layer( w.layer ); LAYER_NUM layer = kicad_layer( w.layer );
if( IsNonCopperLayer( layer ) ) // skip copper package wires if( IsNonCopperLayer( layer ) ) // only valid non-copper wires, skip copper package wires
{ {
wxPoint start( kicad_x( w.x1 ), kicad_y( w.y1 ) ); wxPoint start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) ); wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
...@@ -2024,6 +2028,11 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const ...@@ -2024,6 +2028,11 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const
ETEXT t( aTree ); ETEXT t( aTree );
LAYER_NUM layer = kicad_layer( t.layer ); LAYER_NUM layer = kicad_layer( t.layer );
if( layer == UNDEFINED_LAYER )
{
layer = COMMENT_N;
}
TEXTE_MODULE* txt; TEXTE_MODULE* txt;
if( t.text == ">NAME" || t.text == ">name" ) if( t.text == ">NAME" || t.text == ">name" )
...@@ -2208,19 +2217,20 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, CPTREE& aTree ) const ...@@ -2208,19 +2217,20 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, CPTREE& aTree ) const
{ {
ECIRCLE e( aTree ); ECIRCLE e( aTree );
LAYER_NUM layer = kicad_layer( e.layer ); LAYER_NUM layer = kicad_layer( e.layer );
EDGE_MODULE* gr = new EDGE_MODULE( aModule, S_CIRCLE ); EDGE_MODULE* gr = new EDGE_MODULE( aModule, S_CIRCLE );
aModule->GraphicalItems().PushBack( gr ); aModule->GraphicalItems().PushBack( gr );
gr->SetWidth( kicad( e.width ) ); gr->SetWidth( kicad( e.width ) );
/*
switch( layer ) switch( layer )
{ {
case UNDEFINED_LAYER: layer = COMMENT_N; break;
/*
case ECO1_N: layer = SILKSCREEN_N_FRONT; break; case ECO1_N: layer = SILKSCREEN_N_FRONT; break;
case ECO2_N: layer = SILKSCREEN_N_BACK; break; case ECO2_N: layer = SILKSCREEN_N_BACK; break;
}
*/ */
}
gr->SetLayer( layer ); gr->SetLayer( layer );
gr->SetTimeStamp( timeStamp( aTree ) ); gr->SetTimeStamp( timeStamp( aTree ) );
...@@ -2468,6 +2478,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals ) ...@@ -2468,6 +2478,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
else if( it->first == "polygon" ) else if( it->first == "polygon" )
{ {
m_xpath->push( "polygon" ); m_xpath->push( "polygon" );
EPOLYGON p( it->second ); EPOLYGON p( it->second );
LAYER_NUM layer = kicad_layer( p.layer ); LAYER_NUM layer = kicad_layer( p.layer );
...@@ -2552,7 +2563,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals ) ...@@ -2552,7 +2563,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
} }
LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const int EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
{ {
/* will assume this is a valid mapping for all eagle boards until I get paid more: /* will assume this is a valid mapping for all eagle boards until I get paid more:
...@@ -2681,8 +2692,9 @@ LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const ...@@ -2681,8 +2692,9 @@ LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
case 95: kiLayer = ECO1_N; break; case 95: kiLayer = ECO1_N; break;
case 96: kiLayer = ECO2_N; break; case 96: kiLayer = ECO2_N; break;
default: default:
// D( printf( "unsupported eagle layer: %d\n", aEagleLayer );) // some layers do not map to KiCad
kiLayer = -1; break; // some layers do not map to KiCad // DBG( printf( "unsupported eagle layer: %d\n", aEagleLayer );)
kiLayer = UNDEFINED_LAYER; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment