From a9f663d5efb0ce0971575a8b681fd48e398bb130 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 10 May 2019 20:28:16 +0100 Subject: [PATCH] Soften hit-testing in SchEdit and LibEdit a bit. Old threshold was 0; new is 5 pixels. --- eeschema/ee_collectors.cpp | 4 ++-- eeschema/ee_collectors.h | 3 +++ eeschema/tools/ee_selection_tool.cpp | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/eeschema/ee_collectors.cpp b/eeschema/ee_collectors.cpp index afce29cc54..6201ca868a 100644 --- a/eeschema/ee_collectors.cpp +++ b/eeschema/ee_collectors.cpp @@ -108,7 +108,7 @@ SEARCH_RESULT EE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* aTestData ) return SEARCH_CONTINUE; } - if( aItem->HitTest( m_RefPos ) ) + if( aItem->HitTest( m_RefPos, m_Threshold ) ) Append( aItem ); return SEARCH_CONTINUE; @@ -463,7 +463,7 @@ SEARCH_RESULT EE_TYPE_COLLECTOR::Inspect( EDA_ITEM* aItem, void* testData ) } -void EE_TYPE_COLLECTOR::Collect( SCH_ITEM* aItem, const KICAD_T aFilterList[] ) +void EE_TYPE_COLLECTOR::Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[] ) { Empty(); // empty the collection diff --git a/eeschema/ee_collectors.h b/eeschema/ee_collectors.h index e4bbd845f9..8061f792a3 100644 --- a/eeschema/ee_collectors.h +++ b/eeschema/ee_collectors.h @@ -46,6 +46,7 @@ public: static const KICAD_T SheetsAndSheetLabels[]; EE_COLLECTOR( const KICAD_T* aScanTypes = EE_COLLECTOR::AllItems ) : + m_Threshold( 0 ), m_MenuCancelled( false ) { SetScanTypes( aScanTypes ); @@ -107,6 +108,8 @@ public: int m_Unit; // Fixed symbol unit filter (for symbol editor) int m_Convert; // Fixed DeMorgan filter (for symbol editor) + int m_Threshold; // Hit-test threshold in internal units. + wxString m_MenuTitle; // The title of selection disambiguation menu (if needed) bool m_MenuCancelled; // Indicates selection disambiguation menu was cancelled }; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 52b9b0db9e..b11b77627e 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -149,6 +149,9 @@ SELECTION_CONDITION EE_CONDITIONS::SingleMultiUnitSymbol = [] ( const SELECTION& }; +#define HITTEST_THRESHOLD_PIXELS 5 + + EE_SELECTION_TOOL::EE_SELECTION_TOOL() : TOOL_INTERACTIVE( "eeschema.InteractiveSelection" ), m_frame( nullptr ), @@ -425,6 +428,7 @@ EDA_ITEM* EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* if( !start ) return nullptr; + collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) ); collector.Collect( start, aFilterList, (wxPoint) aWhere, m_unit, m_convert ); bool anyCollected = collector.GetCount() != 0;