Bug fixes for paste margins on custom-shaped pads.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15125

(cherry picked from commit 60419f542a)
This commit is contained in:
Jeff Young 2023-09-03 20:43:20 +01:00
parent ec53ed6a37
commit 5cd88dbd20
2 changed files with 22 additions and 6 deletions

View File

@ -1250,7 +1250,7 @@ bool DIALOG_PAD_PROPERTIES::padValuesOK()
if( m_dummyPad->GetShape() == PAD_SHAPE::CUSTOM ) if( m_dummyPad->GetShape() == PAD_SHAPE::CUSTOM )
{ {
// allow 0-sized anchor pads pad_size = m_dummyPad->GetBoundingBox().GetSize();
} }
else if( m_dummyPad->GetShape() == PAD_SHAPE::CIRCLE ) else if( m_dummyPad->GetShape() == PAD_SHAPE::CIRCLE )
{ {

View File

@ -942,11 +942,14 @@ VECTOR2I PAD::GetSolderPasteMargin() const
pad_margin.y = margin + KiROUND( m_size.y * mratio ); pad_margin.y = margin + KiROUND( m_size.y * mratio );
// ensure mask have a size always >= 0 // ensure mask have a size always >= 0
if( pad_margin.x < -m_size.x / 2 ) if( m_padShape != PAD_SHAPE::CUSTOM )
pad_margin.x = -m_size.x / 2; {
if( pad_margin.x < -m_size.x / 2 )
pad_margin.x = -m_size.x / 2;
if( pad_margin.y < -m_size.y / 2 ) if( pad_margin.y < -m_size.y / 2 )
pad_margin.y = -m_size.y / 2; pad_margin.y = -m_size.y / 2;
}
return pad_margin; return pad_margin;
} }
@ -1683,7 +1686,7 @@ void PAD::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
outline.Rotate( m_orient ); outline.Rotate( m_orient );
outline.Move( VECTOR2I( padShapePos ) ); outline.Move( VECTOR2I( padShapePos ) );
if( aClearance ) if( aClearance > 0 )
{ {
int numSegs = std::max( GetArcToSegmentCount( aClearance, aError, FULL_CIRCLE ), int numSegs = std::max( GetArcToSegmentCount( aClearance, aError, FULL_CIRCLE ),
pad_min_seg_per_circle_count ); pad_min_seg_per_circle_count );
@ -1699,6 +1702,19 @@ void PAD::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
outline.Simplify( SHAPE_POLY_SET::PM_FAST ); outline.Simplify( SHAPE_POLY_SET::PM_FAST );
outline.Fracture( SHAPE_POLY_SET::PM_FAST ); outline.Fracture( SHAPE_POLY_SET::PM_FAST );
} }
else if( aClearance < 0 )
{
// Negative clearances are primarily for drawing solder paste layer, so we don't
// worry ourselves overly about which side the error is on.
int numSegs = std::max( GetArcToSegmentCount( aClearance, aError, FULL_CIRCLE ),
pad_min_seg_per_circle_count );
// aClearance is negative so this is actually a deflate
outline.Inflate( aClearance, numSegs );
outline.Simplify( SHAPE_POLY_SET::PM_FAST );
outline.Fracture( SHAPE_POLY_SET::PM_FAST );
}
aBuffer.Append( outline ); aBuffer.Append( outline );
break; break;