Skip to content

Commit

Permalink
Revert "[FEATURE] Allow using secondary zoom wheel on mouse to magnif…
Browse files Browse the repository at this point in the history
…y canvas"

This reverts commit ecc4925.

Works very badly for touchpads, where horizontal movement is interpreted
as a magnify request
  • Loading branch information
nyalldawson committed Mar 19, 2017
1 parent 6f430a6 commit 0d3cf57
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1404,35 +1404,25 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )
}

double zoomFactor = mWheelZoomFactor;
double delta = e->orientation() == Qt::Vertical ? e->angleDelta().y() : e->angleDelta().x();

// "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * qAbs( delta );
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * qAbs( e->angleDelta().y() );

if ( e->modifiers() & Qt::ControlModifier )
{
//holding ctrl while wheel zooming results in a finer zoom
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
}

double signedWheelFactor = delta > 0 ? 1 / zoomFactor : zoomFactor;
double signedWheelFactor = e->angleDelta().y() > 0 ? 1 / zoomFactor : zoomFactor;

// zoom map to mouse cursor by scaling
QgsPoint oldCenter = center();
QgsPoint mousePos( getCoordinateTransform()->toMapPoint( e->x(), e->y() ) );
QgsPoint newCenter( mousePos.x() + ( ( oldCenter.x() - mousePos.x() ) * signedWheelFactor ),
mousePos.y() + ( ( oldCenter.y() - mousePos.y() ) * signedWheelFactor ) );

switch ( e->orientation() )
{
case Qt::Vertical:
zoomByFactor( signedWheelFactor, &newCenter );
break;

case Qt::Horizontal:
setMagnificationFactor( mapSettings().magnificationFactor() / signedWheelFactor );
break;
}
zoomByFactor( signedWheelFactor, &newCenter );
}

void QgsMapCanvas::setWheelFactor( double factor )
Expand Down

0 comments on commit 0d3cf57

Please sign in to comment.