Skip to content

Commit

Permalink
The remainder of the fix for ticket #80.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@5285 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Apr 16, 2006
1 parent ca7c535 commit 2036012
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/gui/qgsvectorlayer.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 2036012

Please sign in to comment.