[QGIS Commit] r12318 - trunk/qgis/src/app/legend

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Dec 3 04:52:32 EST 2009


Author: mhugent
Date: 2009-12-03 04:52:29 -0500 (Thu, 03 Dec 2009)
New Revision: 12318

Modified:
   trunk/qgis/src/app/legend/qgslegend.cpp
Log:
Fix zoom to layer if otf-reprojection is enabled (ticket #2148)

Modified: trunk/qgis/src/app/legend/qgslegend.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.cpp	2009-12-03 09:13:55 UTC (rev 12317)
+++ trunk/qgis/src/app/legend/qgslegend.cpp	2009-12-03 09:52:29 UTC (rev 12318)
@@ -1581,6 +1581,11 @@
 
 void QgsLegend::legendLayerZoom()
 {
+  if(!mMapCanvas)
+  {
+    return;
+  }
+
   //find current Layer
   QgsLegendLayer* currentLayer = dynamic_cast<QgsLegendLayer *>( currentItem() );
   if ( !currentLayer )
@@ -1589,6 +1594,16 @@
   QgsMapLayer* theLayer = currentLayer->layer();
   QgsRectangle extent = theLayer->extent();
 
+  //transform extent if otf-projection is on
+  if(mMapCanvas->hasCrsTransformEnabled())
+  {
+    QgsMapRenderer* renderer = mMapCanvas->mapRenderer();
+    if(renderer)
+    {
+      extent = renderer->layerExtentToOutputExtent(theLayer, extent);
+    }
+  }
+
   // Increase bounding box with 5%, so that layer is a bit inside the borders
   extent.scale( 1.05 );
 



More information about the QGIS-commit mailing list