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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Jun 9 19:25:10 EDT 2009


Author: wonder
Date: 2009-06-09 19:25:10 -0400 (Tue, 09 Jun 2009)
New Revision: 10896

Modified:
   trunk/qgis/python/gui/qgsmapcanvas.sip
   trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
   trunk/qgis/src/gui/qgsmapcanvas.cpp
   trunk/qgis/src/gui/qgsmapcanvas.h
Log:
Fixed #1706.


Modified: trunk/qgis/python/gui/qgsmapcanvas.sip
===================================================================
--- trunk/qgis/python/gui/qgsmapcanvas.sip	2009-06-09 22:28:08 UTC (rev 10895)
+++ trunk/qgis/python/gui/qgsmapcanvas.sip	2009-06-09 23:25:10 UTC (rev 10896)
@@ -93,8 +93,9 @@
     //! Zoom to the next extent (view)
     void zoomToNextExtent();
 
-    /**Zooms to the extend of the selected features*/
-    void zoomToSelected();
+    /** Zoom to the extent of the selected features of current (vector) layer.
+      Added in version 1.2: optionally specify different than current layer */
+    void zoomToSelected(QgsVectorLayer* layer = NULL);
 
     /** \brief Sets the map tool currently being used on the canvas */
     void setMapTool(QgsMapTool* mapTool);

Modified: trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp
===================================================================
--- trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2009-06-09 22:28:08 UTC (rev 10895)
+++ trunk/qgis/src/app/attributetable/qgsattributetabledialog.cpp	2009-06-09 23:25:10 UTC (rev 10896)
@@ -30,6 +30,7 @@
 #include "qgisapp.h"
 #include "qgssearchquerybuilder.h"
 #include "qgslogger.h"
+#include "qgsmapcanvas.h"
 
 
 class QgsAttributeTableTableDock : public QDockWidget
@@ -201,7 +202,7 @@
 
 void QgsAttributeTableDialog::on_mZoomMapToSelectedRowsButton_clicked()
 {
-  QgisApp::instance()->zoomToSelected();
+  QgisApp::instance()->mapCanvas()->zoomToSelected(mLayer);
 }
 
 void QgsAttributeTableDialog::on_mInvertSelectionButton_clicked()

Modified: trunk/qgis/src/gui/qgsmapcanvas.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.cpp	2009-06-09 22:28:08 UTC (rev 10895)
+++ trunk/qgis/src/gui/qgsmapcanvas.cpp	2009-06-09 23:25:10 UTC (rev 10896)
@@ -613,18 +613,22 @@
   refresh();
 }
 
-void QgsMapCanvas::zoomToSelected()
+void QgsMapCanvas::zoomToSelected(QgsVectorLayer* layer)
 {
   if ( mDrawing )
   {
     return;
   }
 
-  QgsVectorLayer *lyr = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
+  if (layer == NULL)
+  {
+    // use current layer by default
+    layer = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
+  }
 
-  if ( lyr )
+  if ( layer )
   {
-    QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( lyr, lyr->boundingBoxOfSelected() );
+    QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( layer, layer->boundingBoxOfSelected() );
 
     // no selected features, only one selected point feature
     //or two point features with the same x- or y-coordinates

Modified: trunk/qgis/src/gui/qgsmapcanvas.h
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.h	2009-06-09 22:28:08 UTC (rev 10895)
+++ trunk/qgis/src/gui/qgsmapcanvas.h	2009-06-09 23:25:10 UTC (rev 10896)
@@ -49,6 +49,7 @@
 class QgsLegend;
 class QgsLegendView;
 class QgsRubberBand;
+class QgsVectorLayer;
 
 class QgsMapRenderer;
 class QgsMapCanvasMap;
@@ -146,8 +147,9 @@
     //! Zoom to the Next extent (view)
     void zoomToNextExtent();
 
-    /**Zooms to the extend of the selected features*/
-    void zoomToSelected();
+    /** Zoom to the extent of the selected features of current (vector) layer.
+      Added in version 1.2: optionally specify different than current layer */
+    void zoomToSelected(QgsVectorLayer* layer = NULL);
 
     /** \brief Sets the map tool currently being used on the canvas */
     void setMapTool( QgsMapTool* mapTool );



More information about the QGIS-commit mailing list