Expand autoplace collision search to include potential field locations

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9762
This commit is contained in:
Jon Evans 2021-11-25 07:47:53 -05:00
parent bba00fa74c
commit 9f6910f1e6
1 changed files with 19 additions and 10 deletions

View File

@ -275,21 +275,30 @@ protected:
{
wxCHECK_RET( m_screen, "getPossibleCollisions() with null m_screen" );
for( SCH_ITEM* item : m_screen->Items().Overlapping( m_symbol->GetBodyAndPinsBoundingBox() ) )
EDA_RECT symbolBox = m_symbol->GetBodyAndPinsBoundingBox();
std::vector<SIDE_AND_NPINS> sides = getPreferredSides();
for( SIDE_AND_NPINS& side : sides )
{
if( SCH_SYMBOL* candidate = dynamic_cast<SCH_SYMBOL*>( item ) )
EDA_RECT box( fieldBoxPlacement( side ), m_fbox_size );
box.Merge( symbolBox );
for( SCH_ITEM* item : m_screen->Items().Overlapping( box ) )
{
if( candidate == m_symbol )
continue;
if( SCH_SYMBOL* candidate = dynamic_cast<SCH_SYMBOL*>( item ) )
{
if( candidate == m_symbol )
continue;
std::vector<SCH_FIELD*> fields;
candidate->GetFields( fields, /* aVisibleOnly */ true );
std::vector<SCH_FIELD*> fields;
candidate->GetFields( fields, /* aVisibleOnly */ true );
for( SCH_FIELD* field : fields )
aItems.push_back( field );
for( SCH_FIELD* field : fields )
aItems.push_back( field );
}
aItems.push_back( item );
}
aItems.push_back( item );
}
}