Oh, that is much better. Thanks for the suggestion. Attached is the updated patch using EDA_RECT calls.
-S On Tue, Oct 10, 2017 at 11:16 AM, jp charras <[email protected]> wrote: > Le 10/10/2017 à 18:41, Seth Hillbrand a écrit : > > Thank you for testing, JP. I've corrected the issue. I had missed the > inverted Y-axis in lib > > editor. The attached patch functions correctly on all circles, in all > quadrants. > > > > Thanks. > It works fine now. > > However, in order to simplify this code (and avoid duplicate code) could > you consider using > bool EDA_RECT::Intersects( const EDA_RECT& aRect ) const; > to calculate if two rectangles intersect, both for text and circle. > > Again, thanks. > > > -- > Jean-Pierre CHARRAS >
From 3a023b12a3ce7792b704b59b094efc1b3ed32eff Mon Sep 17 00:00:00 2001 From: Seth Hillbrand <[email protected]> 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 78a915325..18ecfb000 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 cd7e524b6..26237bdf1 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 428a28d0f..d07f30533 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() ); } -- 2.11.0
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

