Skip to content

Commit a9289b6

Browse files
committedJul 25, 2014
can re-center when scaling mapCanvas extent
1 parent 6f23cb6 commit a9289b6

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed
 

‎python/gui/qgsmapcanvas.sip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ class QgsMapCanvas : QGraphicsView
238238
void zoomScale( double scale );
239239

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

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

‎src/gui/qgsmapcanvas.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,10 +1815,10 @@ void QgsMapCanvas::getDatumTransformInfo( const QgsMapLayer* ml, const QString&
18151815
}
18161816
}
18171817

1818-
void QgsMapCanvas::zoomByFactor( double scaleFactor )
1818+
void QgsMapCanvas::zoomByFactor( double scaleFactor , const QgsPoint* center )
18191819
{
18201820
QgsRectangle r = mapSettings().visibleExtent();
1821-
r.scale( scaleFactor );
1821+
r.scale( scaleFactor, center );
18221822
setExtent( r );
18231823
refresh();
18241824
}

‎src/gui/qgsmapcanvas.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
307307
void zoomScale( double scale );
308308

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.