From 9f6910f1e6e830c644765848819a5896a4ba006f Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 25 Nov 2021 07:47:53 -0500 Subject: [PATCH] Expand autoplace collision search to include potential field locations Fixes https://gitlab.com/kicad/code/kicad/-/issues/9762 --- eeschema/autoplace_fields.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/eeschema/autoplace_fields.cpp b/eeschema/autoplace_fields.cpp index a6729d1275..7be39e4330 100644 --- a/eeschema/autoplace_fields.cpp +++ b/eeschema/autoplace_fields.cpp @@ -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 sides = getPreferredSides(); + + for( SIDE_AND_NPINS& side : sides ) { - if( SCH_SYMBOL* candidate = dynamic_cast( 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( item ) ) + { + if( candidate == m_symbol ) + continue; - std::vector fields; - candidate->GetFields( fields, /* aVisibleOnly */ true ); + std::vector 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 ); } }