[QGIS Commit] r10994 - in trunk/qgis/src: core gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jul 1 06:27:53 EDT 2009


Author: jef
Date: 2009-07-01 06:27:53 -0400 (Wed, 01 Jul 2009)
New Revision: 10994

Modified:
   trunk/qgis/src/core/qgsvectorlayer.cpp
   trunk/qgis/src/gui/qgsmapcanvas.cpp
Log:
fix #1311

Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp	2009-07-01 10:24:16 UTC (rev 10993)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp	2009-07-01 10:27:53 UTC (rev 10994)
@@ -583,26 +583,6 @@
       delete rings[i];
     }
 
-#ifdef QGISDEBUGVERBOSE
-    // this is only for verbose debug output -- no optimzation is
-    // needed :)
-    QgsDebugMsg( "Pixel points are:" );
-    for ( int i = 0; i < pa.size(); ++i )
-    {
-      QgsDebugMsgLevel( "i" + QString::number( i ), 2 );
-      QgsDebugMsgLevel( "pa[i].x()" + QString::number( pa[i].x() ), 2 );
-      QgsDebugMsgLevel( "pa[i].y()" + QString::number( pa[i].y() ), 2 );
-    }
-    QgsDebugMsg( "Ring positions are:" );
-    QgsDebugMsg( "Ring positions are:" );
-    for ( int i = 0; i < ringDetails.size(); ++i )
-    {
-      QgsDebugMsgLevel( "ringDetails[i].first" + QString::number( ringDetails[i].first ), 2 );
-      QgsDebugMsgLevel( "ringDetails[i].second" + QString::number( ringDetails[i].second ), 2 );
-    }
-    QgsDebugMsg( "Outer ring point is " + QString::number( outerRingPt.x() ) + ", " + QString::number( outerRingPt.y() ) );
-#endif
-
 #if 0
     // A bit of code to aid in working out what values of
     // QgsClipper::minX, etc cause the X11 zoom bug.
@@ -1063,17 +1043,6 @@
     {
       retval.set( -1.0, -1.0, 1.0, 1.0 );
     }
-    else
-    {
-      const double padFactor = 1e-8;
-      double widthPad = retval.xMinimum() * padFactor;
-      double heightPad = retval.yMinimum() * padFactor;
-      double xmin = retval.xMinimum() - widthPad;
-      double xmax = retval.xMaximum() + widthPad;
-      double ymin = retval.yMinimum() - heightPad;
-      double ymax = retval.yMaximum() + heightPad;
-      retval.set( xmin, ymin, xmax, ymax );
-    }
   }
 
   return retval;

Modified: trunk/qgis/src/gui/qgsmapcanvas.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.cpp	2009-07-01 10:24:16 UTC (rev 10993)
+++ trunk/qgis/src/gui/qgsmapcanvas.cpp	2009-07-01 10:27:53 UTC (rev 10994)
@@ -626,28 +626,33 @@
     layer = dynamic_cast < QgsVectorLayer * >( mCurrentLayer );
   }
 
-  if ( layer )
+  if ( layer == NULL )
   {
-    QgsRectangle rect = mMapRenderer->layerExtentToOutputExtent( layer, layer->boundingBoxOfSelected() );
+    return;
+  }
 
-    // no selected features, only one selected point feature
-    //or two point features with the same x- or y-coordinates
-    if ( rect.isEmpty() )
-    {
-      return;
-    }
-    //zoom to an area
-    else
-    {
-      // Expand rect to give a bit of space around the selected
-      // objects so as to keep them clear of the map boundaries
-      // The same 5% should apply to all margins.
-      rect.scale( 1.05 );
-      setExtent( rect );
-      refresh();
-      return;
-    }
+  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
+  if ( rect.isEmpty() )
+  {
+    // zoom in
+    QgsPoint c = rect.center();
+    rect = extent();
+    rect.expand( 0.25, &c );
   }
+  //zoom to an area
+  else
+  {
+    // Expand rect to give a bit of space around the selected
+    // objects so as to keep them clear of the map boundaries
+    // The same 5% should apply to all margins.
+    rect.scale( 1.05 );
+  }
+
+  setExtent( rect );
+  refresh();
 } // zoomToSelected
 
 void QgsMapCanvas::keyPressEvent( QKeyEvent * e )



More information about the QGIS-commit mailing list