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
This commit is contained in:
PJM 2020-09-19 23:14:10 -07:00 committed by Jon Evans
parent 8f01771138
commit ca2252686a
1 changed files with 12 additions and 2 deletions

View File

@ -25,6 +25,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <core/typeinfo.h>
#include <memory>
#include <view/view.h>
#include <view/view_group.h>
@ -87,9 +88,18 @@ const BOX2I SCH_VIEW::GetItemsExtents() const
for( EDA_ITEM* item : m_frame->GetScreen()->Items() )
{
if( item != m_worksheet.get() )
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<SCH_COMPONENT*>( item );
bBoxItems.Merge( comp->GetBoundingBox( false ) );
}
else
bBoxItems.Merge( item->GetBoundingBox() );
}
}
return bBoxItems;
}