Skip to content

Commit

Permalink
can re-center when scaling mapCanvas extent
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jul 25, 2014
1 parent 6f23cb6 commit a9289b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion python/gui/qgsmapcanvas.sip
Expand Up @@ -238,7 +238,8 @@ class QgsMapCanvas : QGraphicsView
void zoomScale( double scale );

//! Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in
void zoomByFactor( double scaleFactor );
//! If point is given, re-center on it
void zoomByFactor( double scaleFactor, const QgsPoint *center = 0 );

//! Zooms in/out with a given center
void zoomWithCenter( int x, int y, bool zoomIn );
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1815,10 +1815,10 @@ void QgsMapCanvas::getDatumTransformInfo( const QgsMapLayer* ml, const QString&
}
}

void QgsMapCanvas::zoomByFactor( double scaleFactor )
void QgsMapCanvas::zoomByFactor( double scaleFactor , const QgsPoint* center )
{
QgsRectangle r = mapSettings().visibleExtent();
r.scale( scaleFactor );
r.scale( scaleFactor, center );
setExtent( r );
refresh();
}
Expand Down
3 changes: 2 additions & 1 deletion src/gui/qgsmapcanvas.h
Expand Up @@ -307,7 +307,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
void zoomScale( double scale );

//! Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in
void zoomByFactor( double scaleFactor );
//! If point is given, re-center on it
void zoomByFactor( double scaleFactor, const QgsPoint *center = 0 );

//! Zooms in/out with a given center
void zoomWithCenter( int x, int y, bool zoomIn );
Expand Down

0 comments on commit a9289b6

Please sign in to comment.