Skip to content

Commit

Permalink
apply #2712 and #2716 with slight modification. Thanks to Charles Timko.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13517 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 17, 2010
1 parent 5edec9d commit e5cbbfd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -170,6 +170,10 @@ class QgsMapCanvas : QGraphicsView

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

//! Zoom to a specific scale
// added in 1.5
void zoomScale( double scale );

//! Zoom with the factor supplied. Factor > 1 zooms in
void zoomByFactor( double scaleFactor );
Expand Down
14 changes: 8 additions & 6 deletions src/app/qgisapp.cpp
Expand Up @@ -1220,6 +1220,12 @@ void QgisApp::showPythonDialog()
mPythonUtils->getError( className, text );
QMessageBox::critical( this, tr( "Error" ), tr( "Failed to open Python console:" ) + "\n" + className + ": " + text );
}
#ifdef Q_WS_MAC
else
{
addWindow( mActionShowPythonDialog );
}
#endif
}

void QgisApp::createActionGroups()
Expand Down Expand Up @@ -4779,8 +4785,6 @@ void QgisApp::showScale( double theScale )

void QgisApp::userScale()
{
double currentScale = mMapCanvas->scale();

QStringList parts = mScaleEdit->text().split( ':' );
if ( parts.size() == 2 )
{
Expand All @@ -4789,8 +4793,7 @@ void QgisApp::userScale()
double rightSide = parts.at( 1 ).toDouble( &rightOk );
if ( leftSide > 0.0 && leftOk && rightOk )
{
double wantedScale = rightSide / leftSide;
mMapCanvas->zoomByFactor( wantedScale / currentScale );
mMapCanvas->zoomScale( rightSide / leftSide );
}
}
}
Expand Down Expand Up @@ -4998,7 +5001,6 @@ void QgisApp::loadPythonSupport()
mActionPluginSeparator2 = mPluginMenu->addSeparator();
mPluginMenu->addAction( mActionShowPythonDialog );
std::cout << "Python support ENABLED :-) " << std::endl; // OK

}
}

Expand Down Expand Up @@ -5255,7 +5257,7 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
else
{
QMessageBox::critical( this, tr( "Layer is not valid" ),
tr( "The layer is not a valid layer and can not be added to the map" ) );
tr( "The layer %1 is not a valid layer and can not be added to the map" ).arg( vectorLayerPath ) );

delete layer;
mMapCanvas->freeze( false );
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -1057,6 +1057,11 @@ void QgsMapCanvas::zoomOut()
zoomByFactor( mWheelZoomFactor );
}

void QgsMapCanvas::zoomScale( double newScale )
{
zoomByFactor( newScale / scale() );
}

void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn )
{
if ( mDrawing )
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -228,6 +228,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! Zoom out with fixed factor
void zoomOut( );

//! Zoom to a specific scale
// added in 1.5
void zoomScale( double scale );

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

Expand Down

0 comments on commit e5cbbfd

Please sign in to comment.