Tighten up hittesting for symbols and other items.

Grid-based accuracy doesn't need to be any larger than 1/2 the
diagonal as we'll snap to one side or the other.  And symbols don't
need as much slop as other items since there's plenty of "meat" on
them.

Fixes https://gitlab.com/kicad/code/kicad/issues/9805
This commit is contained in:
Jeff Young 2021-11-28 18:59:55 +00:00
parent 71bfbfaa70
commit 80d6b9e76d
2 changed files with 4 additions and 4 deletions

View File

@ -1783,8 +1783,8 @@ SCH_SYMBOL& SCH_SYMBOL::operator=( const SCH_ITEM& aItem )
bool SCH_SYMBOL::HitTest( const wxPoint& aPosition, int aAccuracy ) const bool SCH_SYMBOL::HitTest( const wxPoint& aPosition, int aAccuracy ) const
{ {
EDA_RECT bBox = GetBoundingBox(); EDA_RECT bBox = GetBodyBoundingBox();
bBox.Inflate( aAccuracy ); bBox.Inflate( aAccuracy / 2 );
if( bBox.Contains( aPosition ) ) if( bBox.Contains( aPosition ) )
return true; return true;
@ -1800,7 +1800,7 @@ bool SCH_SYMBOL::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
EDA_RECT rect = aRect; EDA_RECT rect = aRect;
rect.Inflate( aAccuracy ); rect.Inflate( aAccuracy / 2 );
if( aContained ) if( aContained )
return rect.Contains( GetBodyBoundingBox() ); return rect.Contains( GetBodyBoundingBox() );

View File

@ -785,7 +785,7 @@ bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& a
const KICAD_T* aFilterList ) const KICAD_T* aFilterList )
{ {
int pixelThreshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) ); int pixelThreshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
int gridThreshold = KiROUND( getView()->GetGAL()->GetGridSize().EuclideanNorm() ); int gridThreshold = KiROUND( getView()->GetGAL()->GetGridSize().EuclideanNorm() / 2 );
aCollector.m_Threshold = std::max( pixelThreshold, gridThreshold ); aCollector.m_Threshold = std::max( pixelThreshold, gridThreshold );
if( m_isSymbolEditor ) if( m_isSymbolEditor )