From 9544c58bd7ed4527f0d6706a6da1afd1cd5dc835 Mon Sep 17 00:00:00 2001 From: PJM Date: Sun, 27 Sep 2020 00:09:23 -0700 Subject: [PATCH] Pcbnew: Cross-probe - Get correct zoom direction when view flipped CHANGED: When Pcbnew has the view flipped, it causes cross-probe zooming to go the wrong direction. Instead of zooming in to the selected part, it zooms very wide. The problem is the x dimension of the screen size becomes a negative value when the view is flipped, so "fabs()" is used to correct it. Fixes https://gitlab.com/kicad/code/kicad/issues/5157 --- pcbnew/cross-probing.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pcbnew/cross-probing.cpp b/pcbnew/cross-probing.cpp index 2dbf7b4481..bc8a13e0ee 100644 --- a/pcbnew/cross-probing.cpp +++ b/pcbnew/cross-probing.cpp @@ -269,7 +269,8 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) { auto bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize(); auto screenSize = view->ToWorld( GetCanvas()->GetClientSize(), false ); - screenSize.x = std::max( 10.0, screenSize.x ); + // The "fabs" on x ensures the right answer when the view is flipped + screenSize.x = std::max( 10.0, fabs( screenSize.x ) ); screenSize.y = std::max( 10.0, screenSize.y ); double ratio = std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );