[QGIS Commit] r13517 - in trunk/qgis: python/gui src/app src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon May 17 12:35:56 EDT 2010


Author: jef
Date: 2010-05-17 12:35:55 -0400 (Mon, 17 May 2010)
New Revision: 13517

Modified:
   trunk/qgis/python/gui/qgsmapcanvas.sip
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/gui/qgsmapcanvas.cpp
   trunk/qgis/src/gui/qgsmapcanvas.h
Log:
apply #2712 and #2716 with slight modification.  Thanks to Charles Timko.

Modified: trunk/qgis/python/gui/qgsmapcanvas.sip
===================================================================
--- trunk/qgis/python/gui/qgsmapcanvas.sip	2010-05-17 15:06:24 UTC (rev 13516)
+++ trunk/qgis/python/gui/qgsmapcanvas.sip	2010-05-17 16:35:55 UTC (rev 13517)
@@ -170,6 +170,10 @@
 
     //! 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 );

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-05-17 15:06:24 UTC (rev 13516)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-05-17 16:35:55 UTC (rev 13517)
@@ -1220,6 +1220,12 @@
     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()
@@ -4779,8 +4785,6 @@
 
 void QgisApp::userScale()
 {
-  double currentScale = mMapCanvas->scale();
-
   QStringList parts = mScaleEdit->text().split( ':' );
   if ( parts.size() == 2 )
   {
@@ -4789,8 +4793,7 @@
     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 );
     }
   }
 }
@@ -4998,7 +5001,6 @@
     mActionPluginSeparator2 = mPluginMenu->addSeparator();
     mPluginMenu->addAction( mActionShowPythonDialog );
     std::cout << "Python support ENABLED :-) " << std::endl; // OK
-
   }
 }
 
@@ -5255,7 +5257,7 @@
   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 );

Modified: trunk/qgis/src/gui/qgsmapcanvas.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.cpp	2010-05-17 15:06:24 UTC (rev 13516)
+++ trunk/qgis/src/gui/qgsmapcanvas.cpp	2010-05-17 16:35:55 UTC (rev 13517)
@@ -1057,6 +1057,11 @@
   zoomByFactor( mWheelZoomFactor );
 }
 
+void QgsMapCanvas::zoomScale( double newScale )
+{
+  zoomByFactor( newScale / scale() );
+}
+
 void QgsMapCanvas::zoomWithCenter( int x, int y, bool zoomIn )
 {
   if ( mDrawing )

Modified: trunk/qgis/src/gui/qgsmapcanvas.h
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.h	2010-05-17 15:06:24 UTC (rev 13516)
+++ trunk/qgis/src/gui/qgsmapcanvas.h	2010-05-17 16:35:55 UTC (rev 13517)
@@ -228,6 +228,10 @@
     //! 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 );
 



More information about the QGIS-commit mailing list