Index: src/gui/qgsmapcanvas.cpp
===================================================================
--- src/gui/qgsmapcanvas.cpp (revisión: 8248)
+++ src/gui/qgsmapcanvas.cpp (copia de trabajo)
@@ -819,12 +819,30 @@
// zoom without changing extent
zoom(e->delta() > 0);
break;
-
+
case WheelZoomAndRecenter:
// zoom and don't change extent
zoomWithCenter(e->x(), e->y(), e->delta() > 0);
break;
-
+
+ case WheelZoomToMouseCursor:
+ {
+ // zoom map to mouse cursor
+ double scaleFactor = e->delta() > 0 ? 1 / mWheelZoomFactor : mWheelZoomFactor;
+
+ QgsPoint oldCenter(mMapRender->extent().center());
+ QgsPoint mousePos(getCoordinateTransform()->toMapPoint(e->x(), e->y()));
+ QgsPoint newCenter(mousePos.x() + ((oldCenter.x() - mousePos.x()) * scaleFactor),
+ mousePos.y() + ((oldCenter.y() - mousePos.y()) * scaleFactor));
+
+ // same as zoomWithCenter (no coordinate transformations are needed)
+ QgsRect extent = mMapRender->extent();
+ extent.scale(scaleFactor, &newCenter);
+ setExtent(extent);
+ refresh();
+ break;
+ }
+
case WheelNothing:
// well, nothing!
break;
Index: src/gui/qgsmapcanvas.h
===================================================================
--- src/gui/qgsmapcanvas.h (revisión: 8248)
+++ src/gui/qgsmapcanvas.h (copia de trabajo)
@@ -95,7 +95,7 @@
public:
- enum WheelAction { WheelZoom, WheelZoomAndRecenter, WheelNothing };
+ enum WheelAction { WheelZoom, WheelZoomAndRecenter, WheelZoomToMouseCursor, WheelNothing };
//! Constructor
QgsMapCanvas(QWidget * parent = 0, const char *name = 0);
Index: src/ui/qgsoptionsbase.ui
===================================================================
--- src/ui/qgsoptionsbase.ui (revisión: 8248)
+++ src/ui/qgsoptionsbase.ui (copia de trabajo)
@@ -489,6 +489,11 @@
-
+ Zoom to mouse cursor
+
+
+ -
+
Nothing