From db394286c727278516c72924e66bce0f13bee288 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 6 Jan 2021 10:02:01 -0800 Subject: [PATCH] Add missing rect hittest --- eeschema/lib_rectangle.cpp | 17 +++++++++++++++++ eeschema/lib_rectangle.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index be626f6da2..7e067e159d 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -254,6 +254,23 @@ bool LIB_RECTANGLE::HitTest( const wxPoint& aPosition, int aAccuracy ) const } +bool LIB_RECTANGLE::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const +{ + if( m_flags & (STRUCT_DELETED | SKIP_STRUCT ) ) + return false; + + EDA_RECT sel = aRect; + + if ( aAccuracy ) + sel.Inflate( aAccuracy ); + + if( aContained ) + return sel.Contains( GetBoundingBox() ); + + return sel.Intersects( GetBoundingBox() ); +} + + wxString LIB_RECTANGLE::GetSelectMenuText( EDA_UNITS aUnits ) const { return wxString::Format( _( "Rectangle, width %s height %s" ), diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index fbe57f8917..9362d045ab 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -58,6 +58,8 @@ public: bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override; + bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; + int GetPenWidth() const override; const EDA_RECT GetBoundingBox() const override;