From 725834b5544b98476bb030ef300981dcd174beb2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 13 Mar 2023 22:44:31 +0000 Subject: [PATCH] Don't use ViewBBox for zoom-to-fit. The ViewBBox can include the largest document clearance so that pad clearance lines get included. But the largest clearance can be, well, large. Fixes https://gitlab.com/kicad/code/kicad/issues/14276 --- pcbnew/footprint.cpp | 7 ++----- pcbnew/footprint_preview_panel.cpp | 4 +--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index ad9c57c50f..1eba7e46d2 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -1513,11 +1513,8 @@ const BOX2I FOOTPRINT::ViewBBox() const { BOX2I area = GetBoundingBox( true, true ); - // Add the Clearance shape size: (shape around the pads when the clearance is shown. Not - // optimized, but the draw cost is small (perhaps smaller than optimization). - const BOARD* board = GetBoard(); - - if( board ) + // Inflate in case clearance lines are drawn around pads, etc. + if( const BOARD* board = GetBoard() ) { int biggest_clearance = board->GetDesignSettings().GetBiggestClearanceValue(); area.Inflate( biggest_clearance ); diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 4b3639fe74..12d6333e8c 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -129,9 +129,7 @@ void FOOTPRINT_PREVIEW_PANEL::renderFootprint( std::shared_ptr aFootp void FOOTPRINT_PREVIEW_PANEL::fitToCurrentFootprint() { - BOX2I bbox = m_currentFootprint->ViewBBox(); - bbox.Merge( m_currentFootprint->Value().ViewBBox() ); - bbox.Merge( m_currentFootprint->Reference().ViewBBox() ); + BOX2I bbox = m_currentFootprint->GetBoundingBox( true, false ); if( bbox.GetSize().x > 0 && bbox.GetSize().y > 0 ) {