Promote pin selections to symbols when preference is set.

Also make additional line slop zoom-relative.

Fixes https://gitlab.com/kicad/code/kicad/issues/12034
This commit is contained in:
Jeff Young 2022-07-19 09:47:34 +01:00
parent e5a664c6b3
commit 45393f228a
2 changed files with 29 additions and 11 deletions

View File

@ -816,13 +816,7 @@ bool SCH_LINE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
else else
aAccuracy = abs( aAccuracy ); aAccuracy = abs( aAccuracy );
if( TestSegmentHit( aPosition, m_start, m_end, aAccuracy ) ) return TestSegmentHit( aPosition, m_start, m_end, aAccuracy );
return true;
aAccuracy += Mils2iu( DANGLING_SYMBOL_SIZE );
return ( EuclideanNorm( aPosition - m_start ) < aAccuracy
|| EuclideanNorm( aPosition - m_end ) < aAccuracy );
} }

View File

@ -801,6 +801,22 @@ bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& a
else else
{ {
aCollector.Collect( m_frame->GetScreen(), aFilterList, aWhere, m_unit, m_convert ); aCollector.Collect( m_frame->GetScreen(), aFilterList, aWhere, m_unit, m_convert );
if( m_frame->eeconfig()->m_Selection.select_pin_selects_symbol )
{
int originalCount = aCollector.GetCount();
for( int ii = 0; ii < originalCount; ++ii )
{
if( aCollector[ii]->Type() == SCH_PIN_T )
{
SCH_PIN* pin = static_cast<SCH_PIN*>( aCollector[ii] );
if( !aCollector.HasItem( pin->GetParentSymbol() ) )
aCollector.Append( pin->GetParentSymbol() );
}
}
}
} }
return aCollector.GetCount() > 0; return aCollector.GetCount() > 0;
@ -996,15 +1012,23 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
for( int i = collector.GetCount() - 1; i >= 0; --i ) for( int i = collector.GetCount() - 1; i >= 0; --i )
{ {
EDA_ITEM* item = collector[ i ]; EDA_ITEM* item = collector[ i ];
SCH_LINE* line = dynamic_cast<SCH_LINE*>( item ); SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
LIB_SHAPE* shape = dynamic_cast<LIB_SHAPE*>( item ); LIB_SHAPE* shape = dynamic_cast<LIB_SHAPE*>( item );
SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
// Lines are hard to hit. Give them a bit more slop to still be considered "exact". // Lines are hard to hit. Give them a bit more slop to still be considered "exact".
if( line || ( shape && shape->GetShape() == SHAPE_T::POLY ) ) if( line || ( shape && shape->GetShape() == SHAPE_T::POLY ) )
{ {
if( item->HitTest( aPos, Mils2iu( DANGLING_SYMBOL_SIZE ) ) ) int pixelThreshold = KiROUND( getView()->ToWorld( 1 ) );
if( item->HitTest( aPos, pixelThreshold ) )
exactHits.insert( item );
}
else if( symbol && m_frame->eeconfig()->m_Selection.select_pin_selects_symbol )
{
if( symbol->GetBodyAndPinsBoundingBox().Contains( aPos ) )
exactHits.insert( item ); exactHits.insert( item );
} }
else else