Better-encapsulate collector sources in the selection tool.

Fixes https://gitlab.com/kicad/code/kicad/issues/7191
This commit is contained in:
Jeff Young 2021-01-19 21:10:04 +00:00
parent ef2aa8a730
commit 351074cc48
3 changed files with 7 additions and 9 deletions

View File

@ -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 );

View File

@ -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.

View File

@ -354,9 +354,7 @@ int SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
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 )