From 2036012b8b5bd7d68867f688ec5cffffed1d0574 Mon Sep 17 00:00:00 2001 From: g_j_m Date: Sun, 16 Apr 2006 01:25:22 +0000 Subject: [PATCH] The remainder of the fix for ticket #80. git-svn-id: http://svn.osgeo.org/qgis/trunk@5285 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/gui/qgsvectorlayer.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/gui/qgsvectorlayer.cpp b/src/gui/qgsvectorlayer.cpp index 272f22fa691..b05cc05a524 100644 --- a/src/gui/qgsvectorlayer.cpp +++ b/src/gui/qgsvectorlayer.cpp @@ -1332,6 +1332,31 @@ QgsRect QgsVectorLayer::bBoxOfSelected() retval.combineExtentWith(&r); } } + + if (retval.width() == 0.0 || retval.height() == 0.0) + { + // If all of the features are at the one point, buffer the + // rectangle a bit. If they are all at zero, do something a bit + // more crude. + + if (retval.xMin() == 0.0 && retval.xMax() == 0.0 && + retval.yMin() == 0.0 && retval.yMax() == 0.0) + { + retval.set(-1.0, -1.0, 1.0, 1.0); + } + else + { + const double padFactor = 0.05; + double widthPad = retval.xMin() * padFactor; + double heightPad = retval.yMin() * padFactor; + double xmin = retval.xMin() - widthPad; + double xmax = retval.xMax() + widthPad; + double ymin = retval.yMin() - heightPad; + double ymax = retval.yMax() + heightPad; + retval.set(xmin, ymin, xmax, ymax); + } + } + return retval; }