From ca2252686ae788156148d3531755f951e074c6bb Mon Sep 17 00:00:00 2001 From: PJM Date: Sat, 19 Sep 2020 23:14:10 -0700 Subject: [PATCH] Eeschema: Make SCH_VIEW::GetItemsExtents() ignore invisible text CHANGED: SCH_VIEW::GetItemsExtents() returns a bbox of all visible items but ignores the page and border. It was taking invisible strings into account when calculating the bbox, and now it doesn't. Makes "Fit to Objects" work correctly with all components that have hidden text. Fixes https://gitlab.com/kicad/code/kicad/issues/5726 --- eeschema/sch_view.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/eeschema/sch_view.cpp b/eeschema/sch_view.cpp index 1e322a7a1c..319364c8a7 100644 --- a/eeschema/sch_view.cpp +++ b/eeschema/sch_view.cpp @@ -25,6 +25,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -87,8 +88,17 @@ const BOX2I SCH_VIEW::GetItemsExtents() const for( EDA_ITEM* item : m_frame->GetScreen()->Items() ) { - if( item != m_worksheet.get() ) - bBoxItems.Merge( item->GetBoundingBox() ); + if( item != m_worksheet.get() ) // Ignore the worksheet itself + { + if( item->Type() == SCH_COMPONENT_T ) + { + // For components we need to get the bounding box without invisible text + SCH_COMPONENT* comp = static_cast( item ); + bBoxItems.Merge( comp->GetBoundingBox( false ) ); + } + else + bBoxItems.Merge( item->GetBoundingBox() ); + } } return bBoxItems;