Skip to content

Commit e88a80a

Browse files
author
jef
committedMay 17, 2010
apply #2712 and #2716 with slight modification. Thanks to Charles Timko.
git-svn-id: http://svn.osgeo.org/qgis/trunk@13517 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e2455a0 commit e88a80a

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed
 

‎python/gui/qgsmapcanvas.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ class QgsMapCanvas : QGraphicsView
170170

171171
//! Zoom out with fixed factor
172172
void zoomOut( );
173+
174+
//! Zoom to a specific scale
175+
// added in 1.5
176+
void zoomScale( double scale );
173177

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

‎src/app/qgisapp.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,12 @@ void QgisApp::showPythonDialog()
12201220
mPythonUtils->getError( className, text );
12211221
QMessageBox::critical( this, tr( "Error" ), tr( "Failed to open Python console:" ) + "\n" + className + ": " + text );
12221222
}
1223+
#ifdef Q_WS_MAC
1224+
else
1225+
{
1226+
addWindow( mActionShowPythonDialog );
1227+
}
1228+
#endif
12231229
}
12241230

12251231
void QgisApp::createActionGroups()
@@ -4779,8 +4785,6 @@ void QgisApp::showScale( double theScale )
47794785

47804786
void QgisApp::userScale()
47814787
{
4782-
double currentScale = mMapCanvas->scale();
4783-
47844788
QStringList parts = mScaleEdit->text().split( ':' );
47854789
if ( parts.size() == 2 )
47864790
{
@@ -4789,8 +4793,7 @@ void QgisApp::userScale()
47894793
double rightSide = parts.at( 1 ).toDouble( &rightOk );
47904794
if ( leftSide > 0.0 && leftOk && rightOk )
47914795
{
4792-
double wantedScale = rightSide / leftSide;
4793-
mMapCanvas->zoomByFactor( wantedScale / currentScale );
4796+
mMapCanvas->zoomScale( rightSide / leftSide );
47944797
}
47954798
}
47964799
}
@@ -4998,7 +5001,6 @@ void QgisApp::loadPythonSupport()
49985001
mActionPluginSeparator2 = mPluginMenu->addSeparator();
49995002
mPluginMenu->addAction( mActionShowPythonDialog );
50005003
std::cout << "Python support ENABLED :-) " << std::endl; // OK
5001-
50025004
}
50035005
}
50045006

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

52605262
delete layer;
52615263
mMapCanvas->freeze( false );

‎src/gui/qgsmapcanvas.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,11 @@ void QgsMapCanvas::zoomOut()
10571057
zoomByFactor( mWheelZoomFactor );
10581058
}
10591059

1060+
void QgsMapCanvas::zoomScale( double newScale )
1061+
{
1062+
zoomByFactor( newScale / scale() );
1063+
}
1064+
10601065
void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn )
10611066
{
10621067
if ( mDrawing )

‎src/gui/qgsmapcanvas.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
228228
//! Zoom out with fixed factor
229229
void zoomOut( );
230230

231+
//! Zoom to a specific scale
232+
// added in 1.5
233+
void zoomScale( double scale );
234+
231235
//! Zoom with the factor supplied. Factor > 1 zooms out, interval (0,1) zooms in
232236
void zoomByFactor( double scaleFactor );
233237

0 commit comments

Comments
 (0)