Skip to content
Permalink
Browse files

Don't zoom when panning with the keyboard on a rotated QgsMapCanvas

Fixes #14243

Signed-off-by: Sandro Santilli <strk@keybit.net>
  • Loading branch information
SebDieBln authored and Sandro Santilli committed Feb 20, 2016
1 parent 81a1f63 commit 138be4a359ebb093736cdf878718d0e7743e3f2c
Showing with 6 additions and 18 deletions.
  1. +6 −18 src/gui/qgsmapcanvas.cpp
@@ -1154,44 +1154,32 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e )
// Don't want to interfer with mouse events

QgsRectangle currentExtent = mapSettings().visibleExtent();
double dx = qAbs(( currentExtent.xMaximum() - currentExtent.xMinimum() ) / 4 );
double dy = qAbs(( currentExtent.yMaximum() - currentExtent.yMinimum() ) / 4 );
double dx = qAbs( currentExtent.width() / 4 );
double dy = qAbs( currentExtent.height() / 4 );

switch ( e->key() )
{
case Qt::Key_Left:
QgsDebugMsg( "Pan left" );

currentExtent.setXMinimum( currentExtent.xMinimum() - dx );
currentExtent.setXMaximum( currentExtent.xMaximum() - dx );
setExtent( currentExtent );
setCenter( center() - QgsVector( dx, 0 ).rotateBy( rotation() * M_PI / 180.0 ) );
refresh();
break;

case Qt::Key_Right:
QgsDebugMsg( "Pan right" );

currentExtent.setXMinimum( currentExtent.xMinimum() + dx );
currentExtent.setXMaximum( currentExtent.xMaximum() + dx );
setExtent( currentExtent );
setCenter( center() + QgsVector( dx, 0 ).rotateBy( rotation() * M_PI / 180.0 ) );
refresh();
break;

case Qt::Key_Up:
QgsDebugMsg( "Pan up" );

currentExtent.setYMaximum( currentExtent.yMaximum() + dy );
currentExtent.setYMinimum( currentExtent.yMinimum() + dy );
setExtent( currentExtent );
setCenter( center() + QgsVector( 0, dy ).rotateBy( rotation() * M_PI / 180.0 ) );
refresh();
break;

case Qt::Key_Down:
QgsDebugMsg( "Pan down" );

currentExtent.setYMaximum( currentExtent.yMaximum() - dy );
currentExtent.setYMinimum( currentExtent.yMinimum() - dy );
setExtent( currentExtent );
setCenter( center() - QgsVector( 0, dy ).rotateBy( rotation() * M_PI / 180.0 ) );
refresh();
break;

0 comments on commit 138be4a

Please sign in to comment.
You can’t perform that action at this time.