mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Handle corner radius in Create from selection
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21601
This commit is contained in:
parent
aeafbe48fe
commit
0f1b514964
@ -2301,23 +2301,44 @@ void EDA_SHAPE::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance
|
|||||||
|
|
||||||
case SHAPE_T::RECTANGLE:
|
case SHAPE_T::RECTANGLE:
|
||||||
{
|
{
|
||||||
std::vector<VECTOR2I> pts = GetRectCorners();
|
if( GetCornerRadius() > 0 )
|
||||||
|
|
||||||
if( solidFill )
|
|
||||||
{
|
{
|
||||||
aBuffer.NewOutline();
|
// Use specialized function for rounded rectangles
|
||||||
|
VECTOR2I size( GetRectangleWidth(), GetRectangleHeight() );
|
||||||
|
VECTOR2I position = GetStart() + size / 2; // Center position
|
||||||
|
|
||||||
for( const VECTOR2I& pt : pts )
|
TransformRoundChamferedRectToPolygon( aBuffer, position, size, ANGLE_0,
|
||||||
aBuffer.Append( pt );
|
GetCornerRadius(), 0.0, 0,
|
||||||
|
solidFill ? 0 : width / 2, aError, aErrorLoc );
|
||||||
|
|
||||||
|
if( solidFill && width > 0 )
|
||||||
|
{
|
||||||
|
// Add outline for filled shapes with border
|
||||||
|
TransformRoundChamferedRectToPolygon( aBuffer, position, size, ANGLE_0,
|
||||||
|
GetCornerRadius(), 0.0, 0,
|
||||||
|
width / 2, aError, aErrorLoc );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( width > 0 || !solidFill )
|
|
||||||
{
|
{
|
||||||
// Add in segments
|
std::vector<VECTOR2I> pts = GetRectCorners();
|
||||||
TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aError, aErrorLoc );
|
|
||||||
TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aError, aErrorLoc );
|
if( solidFill )
|
||||||
TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aError, aErrorLoc );
|
{
|
||||||
TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aError, aErrorLoc );
|
aBuffer.NewOutline();
|
||||||
|
|
||||||
|
for( const VECTOR2I& pt : pts )
|
||||||
|
aBuffer.Append( pt );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( width > 0 || !solidFill )
|
||||||
|
{
|
||||||
|
// Add in segments
|
||||||
|
TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aError, aErrorLoc );
|
||||||
|
TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aError, aErrorLoc );
|
||||||
|
TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aError, aErrorLoc );
|
||||||
|
TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aError, aErrorLoc );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -978,24 +978,14 @@ int CONVERT_TOOL::CreateLines( const TOOL_EVENT& aEvent )
|
|||||||
{
|
{
|
||||||
PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
|
PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
|
||||||
|
|
||||||
if( graphic->GetShape() == SHAPE_T::POLY )
|
if( graphic->GetShape() == SHAPE_T::RECTANGLE )
|
||||||
|
{
|
||||||
|
graphic->TransformShapeToPolygon( set, graphic->GetLayer(), 0, graphic->GetMaxError(), ERROR_INSIDE );
|
||||||
|
}
|
||||||
|
else if( graphic->GetShape() == SHAPE_T::POLY )
|
||||||
{
|
{
|
||||||
set = graphic->GetPolyShape();
|
set = graphic->GetPolyShape();
|
||||||
}
|
}
|
||||||
else if( graphic->GetShape() == SHAPE_T::RECTANGLE )
|
|
||||||
{
|
|
||||||
SHAPE_LINE_CHAIN outline;
|
|
||||||
VECTOR2I start( graphic->GetStart() );
|
|
||||||
VECTOR2I end( graphic->GetEnd() );
|
|
||||||
|
|
||||||
outline.Append( start );
|
|
||||||
outline.Append( VECTOR2I( end.x, start.y ) );
|
|
||||||
outline.Append( end );
|
|
||||||
outline.Append( VECTOR2I( start.x, end.y ) );
|
|
||||||
outline.SetClosed( true );
|
|
||||||
|
|
||||||
set.AddOutline( outline );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( wxT( "Unhandled graphic shape type in PolyToLines - getPolySet" ) );
|
wxFAIL_MSG( wxT( "Unhandled graphic shape type in PolyToLines - getPolySet" ) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user