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.
This commit is contained in:
jean-pierre charras 2018-05-31 11:22:13 +02:00
parent 7c49bcd3a6
commit fc71fc6474
2 changed files with 8 additions and 9 deletions

View File

@ -1,8 +1,8 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2012-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2014 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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(); bbox.Normalize();
m_BoundingBox = bbox; m_BoundingBox = bbox;

View File

@ -360,22 +360,22 @@ bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
double GERBVIEW_FRAME::BestZoom() double GERBVIEW_FRAME::BestZoom()
{ {
double defaultGerberZoom = 1.0;
EDA_RECT bbox = GetGerberLayout()->ComputeBoundingBox(); 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 ) if( bbox.GetWidth() == 0 || bbox.GetHeight() == 0 )
{ {
SetScrollCenterPosition( wxPoint( 0, 0 ) ); bbox.SetSize( GetPageSizeIU() );
return defaultGerberZoom; bbox.SetOrigin( 0, 0 );
} }
double sizeX = (double) bbox.GetWidth(); double sizeX = (double) bbox.GetWidth();
double sizeY = (double) bbox.GetHeight(); double sizeY = (double) bbox.GetHeight();
wxPoint centre = bbox.Centre(); 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 ); return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
} }