Skip to content
Permalink
Browse files

[fix #18892] avoid high jumps by setting a minimum pixel size for rec…

…t in map tool zoom
  • Loading branch information
3nids committed Oct 19, 2018
1 parent f00e43d commit b3e526338b8924f0beb81ca611cb4e2d3637c258
Showing with 7 additions and 8 deletions.
  1. +5 −8 src/gui/qgsmaptoolzoom.cpp
  2. +2 −0 src/gui/qgsmaptoolzoom.h
@@ -91,14 +91,16 @@ void QgsMapToolZoom::canvasReleaseEvent( QgsMapMouseEvent *e )
// We are not really dragging in this case. This is sometimes caused by
// a pen based computer reporting a press, move, and release, all the
// one point.
if ( mDragging && ( mZoomRect.topLeft() == mZoomRect.bottomRight() ) )
if ( !mDragging || ( mZoomRect.topLeft() - mZoomRect.bottomRight() ).manhattanLength() < mMinPixelZoom )
{
mDragging = false;
delete mRubberBand;
mRubberBand = nullptr;
}

if ( mDragging )
// change to zoom in/out by the default multiple
mCanvas->zoomWithCenter( e->x(), e->y(), !zoomOut );
}
else
{
mDragging = false;
delete mRubberBand;
@@ -126,11 +128,6 @@ void QgsMapToolZoom::canvasReleaseEvent( QgsMapMouseEvent *e )

mCanvas->refresh();
}
else // not dragging
{
// change to zoom in/out by the default multiple
mCanvas->zoomWithCenter( e->x(), e->y(), !zoomOut );
}
}

void QgsMapToolZoom::deactivate()
@@ -45,6 +45,8 @@ class GUI_EXPORT QgsMapToolZoom : public QgsMapTool
protected:
//! stores actual zoom rect
QRect mZoomRect;
// minimum pixel size of diagonal of the zoom rectangle
int mMinPixelZoom = 20;

//! indicates whether we're zooming in or out
bool mZoomOut;

0 comments on commit b3e5263

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