HitTest for pads

- Circular pads
This commit is contained in:
Oliver Walters 2017-04-22 16:49:15 +10:00 committed by Maciej Suminski
parent 2b4c2efc85
commit a0afcd5a62
3 changed files with 33 additions and 0 deletions

View File

@ -517,6 +517,7 @@ bool DRAWSEGMENT::HitTest( const wxPoint& aPosition ) const
bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT arect = aRect;
arect.Normalize();
arect.Inflate( aAccuracy );
EDA_RECT arcRect;

View File

@ -776,6 +776,36 @@ bool D_PAD::HitTest( const wxPoint& aPosition ) const
return false;
}
bool D_PAD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
EDA_RECT arect = aRect;
arect.Normalize();
arect.Inflate( aAccuracy );
if( !arect.Intersects( GetBoundingBox() ) )
return false;
if( aContained )
return arect.Contains( GetBoundingBox() );
switch( GetShape() )
{
case PAD_SHAPE_CIRCLE:
return arect.IntersectsCircle( GetPosition(), GetBoundingRadius() );
case PAD_SHAPE_RECT:
break;
case PAD_SHAPE_OVAL:
break;
case PAD_SHAPE_TRAPEZOID:
break;
case PAD_SHAPE_ROUNDRECT:
break;
default:
break;
}
return false;
}
int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
{

View File

@ -483,6 +483,8 @@ public:
bool HitTest( const wxPoint& aPosition ) const override;
bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
wxString GetClass() const override
{
return wxT( "PAD" );