Improve hit-test logic by gradually increasing threshold.

Fixes: lp:1828222
* https://bugs.launchpad.net/kicad/+bug/1828222
This commit is contained in:
Jeff Young 2019-05-15 18:00:49 +01:00
parent ddc6079ceb
commit eba892009d
1 changed files with 20 additions and 3 deletions

View File

@ -449,9 +449,17 @@ 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 ) );
int thresholdMax = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
for( int threshold : { 0, thresholdMax/2, thresholdMax } )
{
collector.m_Threshold = threshold;
collector.Collect( start, aFilterList, (wxPoint) aWhere, m_unit, m_convert );
if( collector.GetCount() > 0 )
break;
}
bool anyCollected = collector.GetCount() != 0;
// Remove unselectable items
@ -673,8 +681,17 @@ EDA_ITEM* EE_SELECTION_TOOL::GetNode( VECTOR2I aPosition )
{
EE_COLLECTOR collector;
int thresholdMax = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
for( int threshold : { 0, thresholdMax/2, thresholdMax } )
{
collector.m_Threshold = threshold;
collector.Collect( m_frame->GetScreen()->GetDrawItems(), nodeTypes, (wxPoint) aPosition );
if( collector.GetCount() > 0 )
break;
}
return collector.GetCount() ? collector[ 0 ] : nullptr;
}