Skip to content

Commit 9456716

Browse files
author
wonder
committed
Renamed ambiguous functions QgsMapCanvas::zoom to zoomIn, zoomOut and zoomByFactor.
git-svn-id: http://svn.osgeo.org/qgis/trunk@9691 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 8b6cbc2 commit 9456716

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

python/gui/qgsmapcanvas.sip

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ class QgsMapCanvas : QGraphicsView
155155
//! set wheel action and zoom factor (should be greater than 1)
156156
void setWheelAction(WheelAction action, double factor = 2);
157157

158-
//! Zooms in/out preserving
159-
void zoom(bool zoomIn);
158+
//! Zoom in with fixed factor
159+
void zoomIn( );
160+
161+
//! Zoom out with fixed factor
162+
void zoomOut( );
163+
164+
//! Zoom with the factor supplied. Factor > 1 zooms in
165+
void zoomByFactor( double scaleFactor );
160166

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

src/app/legend/qgslegend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ void QgsLegend::legendLayerZoomNative()
18211821
QgsDebugMsg( "Raster units per pixel : " + QString::number( layer->rasterUnitsPerPixel() ) );
18221822
QgsDebugMsg( "MapUnitsPerPixel before : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );
18231823

1824-
mMapCanvas->zoom( fabs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel() ) );
1824+
mMapCanvas->zoomByFactor( fabs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel() ) );
18251825
mMapCanvas->refresh();
18261826

18271827
QgsDebugMsg( "MapUnitsPerPixel after : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );

src/app/qgisapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3980,7 +3980,7 @@ void QgisApp::userScale()
39803980
if ( leftSide > 0.0 && leftOk && rightOk )
39813981
{
39823982
double wantedScale = rightSide / leftSide;
3983-
mMapCanvas->zoom( wantedScale / currentScale );
3983+
mMapCanvas->zoomByFactor( wantedScale / currentScale );
39843984
}
39853985
}
39863986
}

src/gui/qgsmapcanvas.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,12 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e )
658658

659659
case Qt::Key_PageUp:
660660
QgsDebugMsg( "Zoom in" );
661-
zoom( true );
661+
zoomIn();
662662
break;
663663

664664
case Qt::Key_PageDown:
665665
QgsDebugMsg( "Zoom out" );
666-
zoom( false );
666+
zoomOut();
667667
break;
668668

669669
default:
@@ -860,7 +860,10 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )
860860
{
861861
case WheelZoom:
862862
// zoom without changing extent
863-
zoom( e->delta() > 0 );
863+
if (e->delta() > 0)
864+
zoomIn();
865+
else
866+
zoomOut();
864867
break;
865868

866869
case WheelZoomAndRecenter:
@@ -898,14 +901,14 @@ void QgsMapCanvas::setWheelAction( WheelAction action, double factor )
898901
mWheelZoomFactor = factor;
899902
}
900903

901-
void QgsMapCanvas::zoom( bool zoomIn )
904+
void QgsMapCanvas::zoomIn()
902905
{
903-
double scaleFactor = ( zoomIn ? 1 / mWheelZoomFactor : mWheelZoomFactor );
906+
zoomByFactor( 1 / mWheelZoomFactor );
907+
}
904908

905-
QgsRectangle r = mMapRenderer->extent();
906-
r.scale( scaleFactor );
907-
setExtent( r );
908-
refresh();
909+
void QgsMapCanvas::zoomOut()
910+
{
911+
zoomByFactor( mWheelZoomFactor );
909912
}
910913

911914
void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn )
@@ -1265,7 +1268,7 @@ void QgsMapCanvas::writeProject( QDomDocument & doc )
12651268

12661269
}
12671270

1268-
void QgsMapCanvas::zoom( double scaleFactor )
1271+
void QgsMapCanvas::zoomByFactor( double scaleFactor )
12691272
{
12701273
if ( mDrawing )
12711274
{

src/gui/qgsmapcanvas.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,14 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
210210
//! set wheel action and zoom factor (should be greater than 1)
211211
void setWheelAction( WheelAction action, double factor = 2 );
212212

213-
//! Zooms in/out preserving
214-
void zoom( bool zoomIn );
213+
//! Zoom in with fixed factor
214+
void zoomIn( );
215+
216+
//! Zoom out with fixed factor
217+
void zoomOut( );
218+
219+
//! Zoom with the factor supplied. Factor > 1 zooms in
220+
void zoomByFactor( double scaleFactor );
215221

216222
//! Zooms in/out with a given center
217223
void zoomWithCenter( int x, int y, bool zoomIn );
@@ -233,9 +239,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
233239
//! returns last position of mouse cursor
234240
QPoint mouseLastXY();
235241

236-
//! zooms with the factor supplied. Factor > 1 zooms in
237-
void zoom( double scaleFactor );
238-
239242
public slots:
240243

241244
/**Repaints the canvas map*/

0 commit comments

Comments
 (0)