From 351074cc48e13e3785dfddbb0c68492250b3d444 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 19 Jan 2021 21:10:04 +0000 Subject: [PATCH] Better-encapsulate collector sources in the selection tool. Fixes https://gitlab.com/kicad/code/kicad/issues/7191 --- eeschema/tools/ee_selection_tool.cpp | 8 ++++---- eeschema/tools/ee_selection_tool.h | 4 ++-- eeschema/tools/symbol_editor_edit_tool.cpp | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index f46ae17255..28f332f788 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -343,7 +343,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) bool continueSelect = true; // Collect items at the clicked location (doesn't select them yet) - if( collectHits( collector, evt->Position() ) ) + if( CollectHits( collector, evt->Position()) ) { narrowSelection( collector, evt->Position(), false ); @@ -514,7 +514,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) // We are checking if we should display a pencil when hovering over anchors // for "auto starting" wires when clicked - if( collectHits( collector, evt->Position() ) ) + if( CollectHits( collector, evt->Position()) ) { narrowSelection( collector, evt->Position(), false ); @@ -635,7 +635,7 @@ EE_SELECTION& EE_SELECTION_TOOL::GetSelection() } -bool EE_SELECTION_TOOL::collectHits( EE_COLLECTOR& aCollector, const VECTOR2I& aWhere, +bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& aWhere, const KICAD_T* aFilterList ) { aCollector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) ); @@ -770,7 +770,7 @@ bool EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* aFil { EE_COLLECTOR collector; - if( !collectHits( collector, aWhere, aFilterList ) ) + if( !CollectHits( collector, aWhere, aFilterList ) ) return false; narrowSelection( collector, aWhere, aCheckLocked ); diff --git a/eeschema/tools/ee_selection_tool.h b/eeschema/tools/ee_selection_tool.h index d126442883..22d2316491 100644 --- a/eeschema/tools/ee_selection_tool.h +++ b/eeschema/tools/ee_selection_tool.h @@ -170,7 +170,6 @@ public: */ void RebuildSelection(); -private: /** * Function CollectHits() * Selects one or more items at the location given by parameter aWhere. @@ -182,9 +181,10 @@ private: * @param aFilterList is a list of items that are acceptable for collection * @param aCheckLocked indicates if locked items should be excluded. */ - bool collectHits( EE_COLLECTOR& aCollector, const VECTOR2I& aWhere, + bool CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& aWhere, const KICAD_T* aFilterList = EE_COLLECTOR::AllItems ); +private: /** * Applies rules to narrow the collection down to selectable objects, and then heuristics * to try and narrow it to a single object. diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index 272ec75c24..bc203c4968 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -354,9 +354,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool(); EE_COLLECTOR collector; - collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) ); - collector.Collect( m_frame->GetScreen(), nonFields, (wxPoint) aPos, - m_frame->GetUnit(), m_frame->GetConvert() ); + selectionTool->CollectHits( collector, aPos, nonFields ); // Remove unselectable items for( int i = collector.GetCount() - 1; i >= 0; --i )