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

This commit is contained in:
Dick Hollenbeck 2013-11-03 20:09:28 -06:00
parent fe54ceacab
commit 96912e6b8c
2 changed files with 52 additions and 35 deletions

View File

@ -116,7 +116,12 @@ public:
* is virtual because some items (in fact: class DIMENSION)
* 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

View File

@ -1321,6 +1321,7 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers )
{
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->SetLayerType( layer, LT_SIGNAL );
@ -1339,6 +1340,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
if( gr->first == "wire" )
{
m_xpath->push( "wire" );
EWIRE w( gr->second );
LAYER_NUM layer = kicad_layer( w.layer );
@ -1366,10 +1368,11 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
}
#endif
m_xpath->push( "text" );
ETEXT t( gr->second );
LAYER_NUM layer = kicad_layer( t.layer );
if( layer != -1 ) // supported layer
if( layer != UNDEFINED_LAYER )
{
TEXTE_PCB* pcbtxt = new TEXTE_PCB( m_board );
m_board->Add( pcbtxt, ADD_APPEND );
@ -1456,6 +1459,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
else if( gr->first == "circle" )
{
m_xpath->push( "circle" );
ECIRCLE c( gr->second );
LAYER_NUM layer = kicad_layer( c.layer );
@ -1479,6 +1483,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
else if( gr->first == "rectangle" )
{
m_xpath->push( "rectangle" );
ERECT r( gr->second );
LAYER_NUM layer = kicad_layer( r.layer );
@ -1501,9 +1506,8 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
zone->Outline()->CloseLastContour();
// this is not my fault:
zone->Outline()->SetHatch( outline_hatch,
Mils2iu( zone->Outline()->GetDefaultHatchPitchMils() ),
true );
zone->Outline()->SetHatch(
outline_hatch, Mils2iu( zone->Outline()->GetDefaultHatchPitchMils() ), true );
}
m_xpath->pop();
@ -1917,7 +1921,7 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, CPTREE& aTree ) const
EWIRE w( aTree );
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 end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
@ -2024,6 +2028,11 @@ void EAGLE_PLUGIN::packageText( MODULE* aModule, CPTREE& aTree ) const
ETEXT t( aTree );
LAYER_NUM layer = kicad_layer( t.layer );
if( layer == UNDEFINED_LAYER )
{
layer = COMMENT_N;
}
TEXTE_MODULE* txt;
if( t.text == ">NAME" || t.text == ">name" )
@ -2208,19 +2217,20 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, CPTREE& aTree ) const
{
ECIRCLE e( aTree );
LAYER_NUM layer = kicad_layer( e.layer );
EDGE_MODULE* gr = new EDGE_MODULE( aModule, S_CIRCLE );
aModule->GraphicalItems().PushBack( gr );
gr->SetWidth( kicad( e.width ) );
/*
switch( layer )
{
case UNDEFINED_LAYER: layer = COMMENT_N; break;
/*
case ECO1_N: layer = SILKSCREEN_N_FRONT; break;
case ECO2_N: layer = SILKSCREEN_N_BACK; break;
}
*/
}
gr->SetLayer( layer );
gr->SetTimeStamp( timeStamp( aTree ) );
@ -2468,6 +2478,7 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals )
else if( it->first == "polygon" )
{
m_xpath->push( "polygon" );
EPOLYGON p( it->second );
LAYER_NUM layer = kicad_layer( p.layer );
@ -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:
@ -2681,8 +2692,9 @@ LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
case 95: kiLayer = ECO1_N; break;
case 96: kiLayer = ECO2_N; break;
default:
// D( printf( "unsupported eagle layer: %d\n", aEagleLayer );)
kiLayer = -1; break; // some layers do not map to KiCad
// some layers do not map to KiCad
// DBG( printf( "unsupported eagle layer: %d\n", aEagleLayer );)
kiLayer = UNDEFINED_LAYER; break;
}
}