Use a sloppier hittest for the collector as well as the actual hittest.

Fixes https://gitlab.com/kicad/code/kicad/issues/7079
This commit is contained in:
Jeff Young 2021-01-13 21:02:21 +00:00
parent f45c6b4166
commit ffdff21f45
3 changed files with 15 additions and 12 deletions

View File

@ -457,7 +457,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
}
else if( dimension )
{
// Dimensions feels particularly hard to select, probably due to their
// Dimensions feel particularly hard to select, probably due to their
// noisy shape making it feel like they should have a larger bounary.
if( dimension->HitTest( m_refPos, KiROUND( accuracy * 1.5 ) ) )
{
@ -467,7 +467,7 @@ SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
}
else
{
if( item->HitTest( m_refPos, 0 ) )
if( item->HitTest( m_refPos, accuracy ) )
{
Append( item );
goto exit;

View File

@ -601,6 +601,7 @@ public:
void SetIgnoreZoneFills( bool ignore ) { m_ignoreZoneFills = ignore; }
double OnePixelInIU() const override { return m_onePixelInIU; }
void SetOnePixelInIU( double aValue ) { m_onePixelInIU = aValue; }
};

View File

@ -2234,12 +2234,14 @@ void PCB_SELECTION_TOOL::unhighlightInternal( BOARD_ITEM* aItem, int aMode, bool
bool PCB_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
{
const unsigned GRIP_MARGIN = 20;
VECTOR2I margin = getView()->ToWorld( VECTOR2I( GRIP_MARGIN, GRIP_MARGIN ), false );
GENERAL_COLLECTORS_GUIDE guide = getCollectorsGuide();
GENERAL_COLLECTOR collector;
// Since we're just double-checking, we want something considerably sloppier than the initial
// selection (most tools use a 5 pixel slop value). We increase this to an effective 20 pixels
// by inflating the value of a pixel by 4x.
guide.SetOnePixelInIU( guide.OnePixelInIU() * 4 );
collector.Collect( board(), m_isFootprintEditor ? GENERAL_COLLECTOR::FootprintItems
: GENERAL_COLLECTOR::AllBoardItems,
(wxPoint) aPoint, guide );
@ -2248,7 +2250,7 @@ bool PCB_SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const
{
BOARD_ITEM* item = collector[i];
if( item->IsSelected() && item->HitTest( (wxPoint) aPoint, margin.x ) )
if( item->IsSelected() && item->HitTest( (wxPoint) aPoint, 5 * guide.OnePixelInIU() ) )
return true;
}