From 04c0ba65d2904f527831daab052f9131ef956b06 Mon Sep 17 00:00:00 2001 From: Marco Mattila Date: Sun, 7 Apr 2013 21:49:13 +0300 Subject: [PATCH] Use the boundary of the object and not just the boundary of the text in SCH_TEXT hit testing. --- eeschema/sch_text.cpp | 28 ++++++++++------------------ eeschema/sch_text.h | 6 ------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 9802fcd708..6eb22f2574 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -643,13 +643,21 @@ void SCH_TEXT::GetNetListItem( vector& aNetListItems, bool SCH_TEXT::HitTest( const wxPoint& aPosition, int aAccuracy ) const { - return TextHitTest( aPosition, aAccuracy ); + EDA_RECT bBox = GetBoundingBox(); + bBox.Inflate( aAccuracy ); + return bBox.Contains( aPosition ); } bool SCH_TEXT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const { - return TextHitTest( aRect, aContained, aAccuracy ); + EDA_RECT bBox = GetBoundingBox(); + bBox.Inflate( aAccuracy ); + + if( aContained ) + return aRect.Contains( bBox ); + + return aRect.Intersects( bBox ); } @@ -1019,11 +1027,6 @@ wxString SCH_LABEL::GetSelectMenuText() const } -bool SCH_LABEL::HitTest( const wxPoint& aPosition, int aAccuracy ) const -{ - return TextHitTest( aPosition, aAccuracy ); -} - SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : SCH_TEXT( pos, text, SCH_GLOBAL_LABEL_T ) @@ -1454,11 +1457,6 @@ wxString SCH_GLOBALLABEL::GetSelectMenuText() const } -bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosition, int aAccuracy ) const -{ - return TextHitTest( aPosition, aAccuracy ); -} - SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text, KICAD_T aType ) : SCH_TEXT( pos, text, aType ) @@ -1802,9 +1800,3 @@ wxString SCH_HIERLABEL::GetSelectMenuText() const msg.Printf( _( "Hierarchical Label %s" ), GetChars( tmp ) ); return msg; } - - -bool SCH_HIERLABEL::HitTest( const wxPoint& aPosition, int aAccuracy ) const -{ - return TextHitTest( aPosition, aAccuracy ); -} diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 2d2bc481f6..dff401acc6 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -262,8 +262,6 @@ public: bool IsReplaceable() const { return true; } - bool HitTest( const wxPoint& aPosition, int aAccuracy ) const; - EDA_ITEM* Clone() const; private: @@ -315,8 +313,6 @@ public: BITMAP_DEF GetMenuImage() const { return add_glabel_xpm; } - bool HitTest( const wxPoint& aPosition, int aAccuracy ) const; - EDA_ITEM* Clone() const; private: @@ -370,8 +366,6 @@ public: BITMAP_DEF GetMenuImage() const { return add_hierarchical_label_xpm; } - bool HitTest( const wxPoint& aPosition, int aAccuracy ) const; - EDA_ITEM* Clone() const; private: