From 959b33c59be63bbe50906095233dea227bade32c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 14 May 2021 15:30:38 +0200 Subject: [PATCH] Footprint editor: fix incorrect "Zoom to Fit" when the F.Cu layer is not shown. Fixes #8420 --- pcbnew/pcb_draw_panel_gal.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index f3e4263cd5..4cd0486aca 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -37,6 +37,7 @@ #include #include #include +#include "footprint_edit_frame.h" #include #include @@ -439,6 +440,21 @@ BOX2I PCB_DRAW_PANEL_GAL::GetDefaultViewBBox() const if( m_worksheet && m_view->IsLayerVisible( LAYER_WORKSHEET ) ) return m_worksheet->ViewBBox(); + // The footprint editor frame has no worksheet, but the best default view box is the + // view box able to show the current footprint + FOOTPRINT_EDIT_FRAME* fp_frame; + + if( ( fp_frame = dynamic_cast( m_edaFrame ) ) ) + { + MODULE* footprint = fp_frame->GetBoard()->m_Modules; + + if( footprint ) + { + EDA_RECT bbox = footprint->GetBoundingBox(); + return bbox; + } + } + return BOX2I(); }