Skip to content

Commit

Permalink
Renamed ambiguous functions QgsMapCanvas::zoom to zoomIn, zoomOut and…
Browse files Browse the repository at this point in the history
… zoomByFactor.

git-svn-id: http://svn.osgeo.org/qgis/trunk@9691 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 24, 2008
1 parent 8b6cbc2 commit 9456716
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
10 changes: 8 additions & 2 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -155,8 +155,14 @@ class QgsMapCanvas : QGraphicsView
//! set wheel action and zoom factor (should be greater than 1)
void setWheelAction(WheelAction action, double factor = 2);

//! Zooms in/out preserving
void zoom(bool zoomIn);
//! Zoom in with fixed factor
void zoomIn( );

//! Zoom out with fixed factor
void zoomOut( );

//! Zoom with the factor supplied. Factor > 1 zooms in
void zoomByFactor( double scaleFactor );

//! Zooms in/out with a given center
void zoomWithCenter(int x, int y, bool zoomIn);
Expand Down
2 changes: 1 addition & 1 deletion src/app/legend/qgslegend.cpp
Expand Up @@ -1821,7 +1821,7 @@ void QgsLegend::legendLayerZoomNative()
QgsDebugMsg( "Raster units per pixel : " + QString::number( layer->rasterUnitsPerPixel() ) );
QgsDebugMsg( "MapUnitsPerPixel before : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );

mMapCanvas->zoom( fabs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel() ) );
mMapCanvas->zoomByFactor( fabs( layer->rasterUnitsPerPixel() / mMapCanvas->mapUnitsPerPixel() ) );
mMapCanvas->refresh();

QgsDebugMsg( "MapUnitsPerPixel after : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -3980,7 +3980,7 @@ void QgisApp::userScale()
if ( leftSide > 0.0 && leftOk && rightOk )
{
double wantedScale = rightSide / leftSide;
mMapCanvas->zoom( wantedScale / currentScale );
mMapCanvas->zoomByFactor( wantedScale / currentScale );
}
}
}
Expand Down
23 changes: 13 additions & 10 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -658,12 +658,12 @@ void QgsMapCanvas::keyPressEvent( QKeyEvent * e )

case Qt::Key_PageUp:
QgsDebugMsg( "Zoom in" );
zoom( true );
zoomIn();
break;

case Qt::Key_PageDown:
QgsDebugMsg( "Zoom out" );
zoom( false );
zoomOut();
break;

default:
Expand Down Expand Up @@ -860,7 +860,10 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )
{
case WheelZoom:
// zoom without changing extent
zoom( e->delta() > 0 );
if (e->delta() > 0)
zoomIn();
else
zoomOut();
break;

case WheelZoomAndRecenter:
Expand Down Expand Up @@ -898,14 +901,14 @@ void QgsMapCanvas::setWheelAction( WheelAction action, double factor )
mWheelZoomFactor = factor;
}

void QgsMapCanvas::zoom( bool zoomIn )
void QgsMapCanvas::zoomIn()
{
double scaleFactor = ( zoomIn ? 1 / mWheelZoomFactor : mWheelZoomFactor );
zoomByFactor( 1 / mWheelZoomFactor );
}

QgsRectangle r = mMapRenderer->extent();
r.scale( scaleFactor );
setExtent( r );
refresh();
void QgsMapCanvas::zoomOut()
{
zoomByFactor( mWheelZoomFactor );
}

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

}

void QgsMapCanvas::zoom( double scaleFactor )
void QgsMapCanvas::zoomByFactor( double scaleFactor )
{
if ( mDrawing )
{
Expand Down
13 changes: 8 additions & 5 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -210,8 +210,14 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! set wheel action and zoom factor (should be greater than 1)
void setWheelAction( WheelAction action, double factor = 2 );

//! Zooms in/out preserving
void zoom( bool zoomIn );
//! Zoom in with fixed factor
void zoomIn( );

//! Zoom out with fixed factor
void zoomOut( );

//! Zoom with the factor supplied. Factor > 1 zooms in
void zoomByFactor( double scaleFactor );

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

//! zooms with the factor supplied. Factor > 1 zooms in
void zoom( double scaleFactor );

public slots:

/**Repaints the canvas map*/
Expand Down

0 comments on commit 9456716

Please sign in to comment.