From f685cfaf3d6d2cf777a67ffa2cfc21261a0d8636 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 6 Oct 2017 13:58:27 -0700 Subject: [PATCH] Eeschema: Add collision-based selection code to circles and text --- eeschema/lib_circle.cpp | 7 ++----- eeschema/lib_field.cpp | 6 +----- eeschema/lib_text.cpp | 6 +----- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 78a915325c..18ecfb000c 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -146,11 +146,8 @@ void LIB_CIRCLE::SetOffset( const wxPoint& aOffset ) bool LIB_CIRCLE::Inside( EDA_RECT& aRect ) const { - /* - * FIXME: This fails to take into account the radius around the center - * point. - */ - return aRect.Contains( m_Pos.x, -m_Pos.y ); + wxPoint center(m_Pos.x, -m_Pos.y); + return aRect.IntersectsCircle( center, m_Radius ); } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index cd7e524b68..26237bdf14 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -447,11 +447,7 @@ void LIB_FIELD::SetOffset( const wxPoint& aOffset ) bool LIB_FIELD::Inside( EDA_RECT& rect ) const { - /* - * FIXME: This fails to take into account the size and/or orientation of - * the text. - */ - return rect.Contains( GetTextPos().x, -GetTextPos().y ); + return rect.Intersects( GetBoundingBox() ); } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 428a28d0f4..d07f30533e 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -268,11 +268,7 @@ void LIB_TEXT::SetOffset( const wxPoint& aOffset ) bool LIB_TEXT::Inside( EDA_RECT& rect ) const { - /* - * FIXME: This should calculate the text size and justification and - * use rectangle intersect. - */ - return rect.Contains( GetTextPos().x, -GetTextPos().y ); + return rect.Intersects( GetBoundingBox() ); }