Fix for Arc HitTest

compureArcBBox does not account for line width
This commit is contained in:
Oliver Walters 2017-05-09 17:28:01 +10:00 committed by Maciej Suminski
parent a2fda9bd39
commit 2ae47d31cc
1 changed files with 6 additions and 7 deletions

View File

@ -431,7 +431,7 @@ const EDA_RECT DRAWSEGMENT::GetBoundingBox() const
break;
default:
;
break;
}
bbox.Inflate( ((m_Width+1) / 2) + 1 );
@ -521,17 +521,18 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
arect.Inflate( aAccuracy );
EDA_RECT arcRect;
EDA_RECT bb = GetBoundingBox();
switch( m_Shape )
{
case S_CIRCLE:
// Test if area intersects or contains the circle:
if( aContained )
return arect.Contains( GetBoundingBox() );
return arect.Contains( bb );
else
{
// If the rectangle does not intersect the bounding box, this is a much quicker test
if( !aRect.Intersects( GetBoundingBox() ) )
if( !aRect.Intersects( bb ) )
{
return false;
}
@ -545,17 +546,15 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
case S_ARC:
computeArcBBox( arcRect );
// Test for full containment of this arc in the rect
if( aContained )
{
return arect.Contains( arcRect );
return arect.Contains( bb );
}
// Test if the rect crosses the arc
else
{
arcRect = arcRect.Common( arect );
arcRect = bb.Common( arect );
/* All following tests must pass:
* 1. Rectangle must intersect arc BoundingBox