Fixed a crash on Eagle PCB import with dimensions on unsupported layers
This commit is contained in:
parent
2ac8ab2a8f
commit
6cefb68c7d
|
@ -686,36 +686,40 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
||||||
else if( grName == "dimension" )
|
else if( grName == "dimension" )
|
||||||
{
|
{
|
||||||
EDIMENSION d( gr );
|
EDIMENSION d( gr );
|
||||||
|
PCB_LAYER_ID layer = kicad_layer( d.layer );
|
||||||
|
|
||||||
DIMENSION* dimension = new DIMENSION( m_board );
|
if( layer != UNDEFINED_LAYER )
|
||||||
m_board->Add( dimension, ADD_APPEND );
|
{
|
||||||
|
DIMENSION* dimension = new DIMENSION( m_board );
|
||||||
|
m_board->Add( dimension, ADD_APPEND );
|
||||||
|
|
||||||
dimension->SetLayer( kicad_layer( d.layer ) );
|
dimension->SetLayer( layer );
|
||||||
// The origin and end are assumed to always be in this order from eagle
|
// The origin and end are assumed to always be in this order from eagle
|
||||||
dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) );
|
dimension->SetOrigin( wxPoint( kicad_x( d.x1 ), kicad_y( d.y1 ) ) );
|
||||||
dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) );
|
dimension->SetEnd( wxPoint( kicad_x( d.x2 ), kicad_y( d.y2 ) ) );
|
||||||
dimension->Text().SetTextSize( m_board->GetDesignSettings().m_PcbTextSize );
|
dimension->Text().SetTextSize( m_board->GetDesignSettings().m_PcbTextSize );
|
||||||
|
|
||||||
int width = m_board->GetDesignSettings().m_PcbTextWidth;
|
int width = m_board->GetDesignSettings().m_PcbTextWidth;
|
||||||
int maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() );
|
int maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() );
|
||||||
|
|
||||||
if( width > maxThickness )
|
if( width > maxThickness )
|
||||||
width = maxThickness;
|
width = maxThickness;
|
||||||
|
|
||||||
dimension->Text().SetThickness( width );
|
dimension->Text().SetThickness( width );
|
||||||
dimension->SetWidth( width );
|
dimension->SetWidth( width );
|
||||||
|
|
||||||
// check which axis the dimension runs in
|
// check which axis the dimension runs in
|
||||||
// because the "height" of the dimension is perpendicular to that axis
|
// because the "height" of the dimension is perpendicular to that axis
|
||||||
// Note the check is just if two axes are close enough to each other
|
// Note the check is just if two axes are close enough to each other
|
||||||
// Eagle appears to have some rounding errors
|
// Eagle appears to have some rounding errors
|
||||||
if( fabs( d.x1 - d.x2 ) < 0.05 )
|
if( fabs( d.x1 - d.x2 ) < 0.05 )
|
||||||
dimension->SetHeight( kicad_x( d.x1 - d.x3 ) );
|
dimension->SetHeight( kicad_x( d.x1 - d.x3 ) );
|
||||||
else
|
else
|
||||||
dimension->SetHeight( kicad_y( d.y3 - d.y1 ) );
|
dimension->SetHeight( kicad_y( d.y3 - d.y1 ) );
|
||||||
|
|
||||||
dimension->AdjustDimensionDetails();
|
dimension->AdjustDimensionDetails();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get next graphic
|
// Get next graphic
|
||||||
gr = gr->GetNext();
|
gr = gr->GetNext();
|
||||||
|
@ -1928,8 +1932,7 @@ PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
|
||||||
case EAGLE_LAYER::USERLAYER2: kiLayer = Eco2_User; break;
|
case EAGLE_LAYER::USERLAYER2: kiLayer = Eco2_User; break;
|
||||||
default:
|
default:
|
||||||
// some layers do not map to KiCad
|
// some layers do not map to KiCad
|
||||||
// DBG( printf( "unsupported eagle layer: %d\n", aEagleLayer );)
|
wxASSERT_MSG( false, wxString::Format( "Unsupported Eagle layer %d", aEagleLayer ) );
|
||||||
//
|
|
||||||
kiLayer = UNDEFINED_LAYER; break;
|
kiLayer = UNDEFINED_LAYER; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue