Gerber: fix a minor issue in OBLONG standard aperture:

- incorrect (too big) bounding box.
- HitTest did not test the exact shape.
This commit is contained in:
jean-pierre charras 2020-03-27 16:15:39 +01:00
parent de7154e8e9
commit 873a633181
1 changed files with 32 additions and 1 deletions

View File

@ -348,7 +348,7 @@ const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
case GBR_SPOT_OVAL:
{
if( code )
bbox.Inflate( code->m_Size.x, code->m_Size.y );
bbox.Inflate( code->m_Size.x /2, code->m_Size.y / 2 );
break;
}
@ -808,6 +808,37 @@ bool GERBER_DRAW_ITEM::HitTest( const wxPoint& aRefPos, int aAccuracy ) const
case GBR_SPOT_RECT:
return GetBoundingBox().Contains( aRefPos );
case GBR_SPOT_OVAL:
{
EDA_RECT bbox = GetBoundingBox();
if( ! bbox.Contains( aRefPos ) )
return false;
// This is similar to a segment with thickness = min( m_Size.x, m_Size.y )
int radius = std::min( m_Size.x, m_Size.y )/2;
wxPoint start, end;
if( m_Size.x > m_Size.y ) // Horizontal oval
{
int len = m_Size.y - m_Size.x;
start.x = -len/2;
end.x = len/2;
}
else // Vertical oval
{
int len = m_Size.x - m_Size.y;
start.y = -len/2;
end.y = len/2;
}
start += bbox.Centre();
end += bbox.Centre();
if( radius < MIN_HIT_TEST_RADIUS )
radius = MIN_HIT_TEST_RADIUS;
return TestSegmentHit( aRefPos, start, end, radius );
}
case GBR_ARC:
{
double radius = GetLineLength( m_Start, m_ArcCentre );