From 80d6b9e76d181e058d9fd729ff1de86f81f91b84 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 28 Nov 2021 18:59:55 +0000 Subject: [PATCH] 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 --- eeschema/sch_symbol.cpp | 6 +++--- eeschema/tools/ee_selection_tool.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 0d2c3277d2..4627074c55 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1783,8 +1783,8 @@ SCH_SYMBOL& SCH_SYMBOL::operator=( const SCH_ITEM& aItem ) bool SCH_SYMBOL::HitTest( const wxPoint& aPosition, int aAccuracy ) const { - EDA_RECT bBox = GetBoundingBox(); - bBox.Inflate( aAccuracy ); + EDA_RECT bBox = GetBodyBoundingBox(); + bBox.Inflate( aAccuracy / 2 ); if( bBox.Contains( aPosition ) ) return true; @@ -1800,7 +1800,7 @@ bool SCH_SYMBOL::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy EDA_RECT rect = aRect; - rect.Inflate( aAccuracy ); + rect.Inflate( aAccuracy / 2 ); if( aContained ) return rect.Contains( GetBodyBoundingBox() ); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 1ec5ef756d..cc1f5c2736 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -785,7 +785,7 @@ bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& a const KICAD_T* aFilterList ) { 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 ); if( m_isSymbolEditor )