Don't construct an arc if we won't need it in pcbnew gfx importer.

This commit is contained in:
Alex Shvartzkop 2024-06-04 07:19:00 +03:00
parent 044a2305e3
commit d34df3e951
1 changed files with 5 additions and 6 deletions

View File

@ -111,10 +111,6 @@ void GRAPHICS_IMPORTER_PCBNEW::AddCircle( const VECTOR2D& aCenter, double aRadiu
void GRAPHICS_IMPORTER_PCBNEW::AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart,
const EDA_ANGLE& aAngle, const IMPORTED_STROKE& aStroke )
{
std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( m_parent );
arc->SetShape( SHAPE_T::ARC );
arc->SetLayer( GetLayer() );
/**
* We need to perform the rotation/conversion here while still using floating point values
* to avoid rounding errors when operating in integer space in pcbnew
@ -125,8 +121,6 @@ void GRAPHICS_IMPORTER_PCBNEW::AddArc( const VECTOR2D& aCenter, const VECTOR2D&
RotatePoint( end, aCenter, -aAngle );
RotatePoint( mid, aCenter, -aAngle / 2.0 );
arc->SetArcGeometry( MapCoordinate( aStart ), MapCoordinate( mid ), MapCoordinate( end ) );
// Ensure the arc can be handled by Pcbnew. Arcs with a too big radius cannot.
// The criteria used here is radius < MAX_INT / 2.
// this is not perfect, but we do not know the exact final position of the arc, so
@ -142,6 +136,11 @@ void GRAPHICS_IMPORTER_PCBNEW::AddArc( const VECTOR2D& aCenter, const VECTOR2D&
return;
}
std::unique_ptr<PCB_SHAPE> arc = std::make_unique<PCB_SHAPE>( m_parent );
arc->SetShape( SHAPE_T::ARC );
arc->SetLayer( GetLayer() );
arc->SetArcGeometry( MapCoordinate( aStart ), MapCoordinate( mid ), MapCoordinate( end ) );
arc->SetStroke( MapStrokeParams( aStroke ) );
addItem( std::move( arc ) );