From fc71fc6474c54aa888708cd2cb024d9f20b139fc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 31 May 2018 11:22:13 +0200 Subject: [PATCH] Gerbview: Fit to page: use the page size when nothing is loaded. Previously, due to a minor bug, a very small default size was used (therefore a high zoom value), that was not a good choice. --- gerbview/gbr_layout.cpp | 5 ++--- gerbview/gerbview_frame.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gerbview/gbr_layout.cpp b/gerbview/gbr_layout.cpp index 1bb9f21f56..5ae6ba1f0e 100644 --- a/gerbview/gbr_layout.cpp +++ b/gerbview/gbr_layout.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012-2014 Jean-Pierre Charras jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2012-2018 Jean-Pierre Charras jp.charras at wanadoo.fr + * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -89,7 +89,6 @@ EDA_RECT GBR_LAYOUT::ComputeBoundingBox() const } } - bbox.Inflate( ( bbox.GetWidth() / 10 ) + 100 ); bbox.Normalize(); m_BoundingBox = bbox; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index b0f233304d..26a147b734 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -360,22 +360,22 @@ bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector& aFileSet, in double GERBVIEW_FRAME::BestZoom() { - double defaultGerberZoom = 1.0; EDA_RECT bbox = GetGerberLayout()->ComputeBoundingBox(); + // Reserve a margin around the bounding box, for a better display. + double margin_scale_factor = 1.05; + + // If there is not item loaded, use the current page size if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 ) { - SetScrollCenterPosition( wxPoint( 0, 0 ) ); - return defaultGerberZoom; + bbox.SetSize( GetPageSizeIU() ); + bbox.SetOrigin( 0, 0 ); } double sizeX = (double) bbox.GetWidth(); double sizeY = (double) bbox.GetHeight(); wxPoint centre = bbox.Centre(); - // Reserve no margin because GetGerberLayout()->ComputeBoundingBox() builds one in. - double margin_scale_factor = 1.0; - return bestZoom( sizeX, sizeY, margin_scale_factor, centre ); }