Commit 3e46f223 authored by Maciej Suminski's avatar Maciej Suminski

Corrected "Zoom Auto" in GAL with empty board.

parent 6379d806
......@@ -100,18 +100,17 @@ int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
BOARD* board = getModel<BOARD>();
board->ComputeBoundingBox();
BOX2I boardBBox = board->ViewBBox();
VECTOR2I screenSize = gal->GetScreenPixelSize();
if( boardBBox.GetSize().x == 0 || boardBBox.GetSize().y == 0 )
{
// Empty view
view->SetScale( 100000.0 );
view->SetCenter( VECTOR2D( 0, 0 ) );
view->SetCenter( view->ToWorld( VECTOR2D( screenSize.x / 2, screenSize.y / 2 ) ) );
view->SetScale( 17.0 );
}
else
{
// Autozoom to board
VECTOR2I screenSize = gal->GetScreenPixelSize();
double iuPerX = screenSize.x ? boardBBox.GetWidth() / screenSize.x : 1.0;
double iuPerY = screenSize.y ? boardBBox.GetHeight() / screenSize.y : 1.0;
......@@ -119,8 +118,8 @@ int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double zoom = 1.0 / ( zoomFactor * bestZoom );
view->SetScale( zoom );
view->SetCenter( boardBBox.Centre() );
view->SetScale( zoom );
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment