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
This commit is contained in:
PJM 2020-09-27 00:09:23 -07:00 committed by Jon Evans
parent e4bc1eb3bf
commit 9544c58bd7
1 changed files with 2 additions and 1 deletions

View File

@ -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 ) );