diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index c3fab972c9..53293ff121 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -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; diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 1d2b81acd2..ba177449f5 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -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 ) { diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index 4dd2233e30..53900dd52c 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -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" );