From 24e54178db2a19360d96e56d56beef018ec30db5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 1 Jul 2021 14:28:01 +0100 Subject: [PATCH] Make sure pin hittest regions don't get too hard to hit. Fixes https://gitlab.com/kicad/code/kicad/issues/8616 --- eeschema/sch_pin.cpp | 4 ++++ pcbnew/zone.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 19f044395b..505da44878 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -317,6 +317,10 @@ const EDA_RECT SCH_PIN::GetBoundingBox() const bool SCH_PIN::HitTest( const wxPoint& aPosition, int aAccuracy ) const { + // When looking for an "exact" hit aAccuracy will be 0 which works poorly if the pin has + // no pin number or name. Give it a floor. + aAccuracy = std::max( aAccuracy, GetPenWidth() ); + EDA_RECT rect = GetBoundingBox(); return rect.Inflate( aAccuracy ).Contains( aPosition ); } diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 26fcaff94b..3a1918bf4b 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -399,8 +399,8 @@ void ZONE::BuildHashValue( PCB_LAYER_ID aLayer ) bool ZONE::HitTest( const wxPoint& aPosition, int aAccuracy ) const { - // Normally accuracy is zoom-relative, but at high zooms zones can be too hard to select - // so we provide a minimum. + // When looking for an "exact" hit aAccuracy will be 0 which works poorly for very thin + // lines. Give it a floor. int accuracy = std::max( aAccuracy, Millimeter2iu( 0.1 ) ); return HitTestForCorner( aPosition, accuracy * 2 ) || HitTestForEdge( aPosition, accuracy );