Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 b3e5263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/gui/qgsmaptoolzoom.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgsmaptoolzoom.h
Expand Up @@ -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;
Expand Down

0 comments on commit b3e5263

Please sign in to comment.