From 375e8a2f978270c6da1b98693859a6b75d4ba21e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 20 Aug 2019 12:58:14 +0100 Subject: [PATCH] Only add ref & value to boundingBox if they're visible. Fixes: lp:1746911 * https://bugs.launchpad.net/kicad/+bug/1746911 --- pcbnew/class_board.cpp | 7 ++++--- pcbnew/class_module.cpp | 21 +++++++++++++++++++++ pcbnew/class_module.h | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 57cabf01e2..14fe280ab2 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -51,7 +51,7 @@ #include #include #include - +#include /** * A singleton item of this class is returned for a weak reference that no longer exists. @@ -779,7 +779,8 @@ unsigned BOARD::GetUnconnectedNetCount() const EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const { EDA_RECT area; - LSET visible = GetVisibleLayers(); + LSET visible = GetVisibleLayers(); + bool showInvisibleText = IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) && !Pgm().m_Printing; // Check segments, dimensions, texts, and fiducials for( auto item : m_drawings ) @@ -807,7 +808,7 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const } else { - area.Merge( module->GetBoundingBox() ); + area.Merge( module->GetBoundingBox( showInvisibleText ) ); } } diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 84326ef649..ae70663167 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -407,6 +407,27 @@ const EDA_RECT MODULE::GetBoundingBox() const } +const EDA_RECT MODULE::GetBoundingBox( bool aIncludeInvisibleText ) const +{ + EDA_RECT area = GetFootprintRect(); + + // Add in items not collected by GetFootprintRect(): + for( auto item : m_drawings ) + { + if( item->Type() != PCB_MODULE_EDGE_T ) + area.Merge( item->GetBoundingBox() ); + } + + if( m_Value->IsVisible() || aIncludeInvisibleText ) + area.Merge( m_Value->GetBoundingBox() ); + + if( m_Reference->IsVisible() || aIncludeInvisibleText ) + area.Merge( m_Reference->GetBoundingBox() ); + + return area; +} + + /** * This is a bit hacky right now for performance reasons. * diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 28b87407b1..2635846fb5 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -160,6 +160,8 @@ public: // Virtual function const EDA_RECT GetBoundingBox() const override; + const EDA_RECT GetBoundingBox( bool aIncludeInvisibleText ) const; + PADS& Pads() { return m_pads;