Use the boundary of the object and not just the boundary of the text in SCH_TEXT hit testing.

This commit is contained in:
Marco Mattila 2013-04-07 21:49:13 +03:00
parent b739b2b075
commit e04b6a04a6
2 changed files with 10 additions and 24 deletions

View File

@ -643,13 +643,21 @@ void SCH_TEXT::GetNetListItem( vector<NETLIST_OBJECT*>& 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 );
}

View File

@ -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: