Skip to content

Commit f3e30c3

Browse files
author
mhugent
committedJan 28, 2008
Improvement to feature splitting: if there is a selection, the split tool only considers the selected features. If not, all the features intersecting the bounding box of the split line are considered
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8063 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed
 

‎src/core/qgsvectorlayer.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,24 +1704,32 @@ int QgsVectorLayer::splitFeatures(const QList<QgsPoint>& splitLine, bool topolog
17041704
int returnCode = 0;
17051705
int splitFunctionReturn; //return code of QgsGeometry::splitGeometry
17061706

1707-
if(boundingBoxFromPointList(splitLine, xMin, yMin, xMax, yMax) == 0)
1707+
QgsFeatureList featureList;
1708+
const QgsFeatureIds selectedIds = selectedFeaturesIds();
1709+
1710+
if(selectedIds.size() > 0)//consider only the selected features if there is a selection
17081711
{
1709-
bBox.setXmin(xMin); bBox.setYmin(yMin); bBox.setXmax(xMax); bBox.setYmax(yMax);
1712+
featureList = selectedFeatures();
17101713
}
1711-
else
1714+
else //else consider all the feature that intersect the bounding box of the split line
17121715
{
1713-
return 1;
1716+
if(boundingBoxFromPointList(splitLine, xMin, yMin, xMax, yMax) == 0)
1717+
{
1718+
bBox.setXmin(xMin); bBox.setYmin(yMin); bBox.setXmax(xMax); bBox.setYmax(yMax);
1719+
}
1720+
else
1721+
{
1722+
return 1;
1723+
}
1724+
1725+
if(bBox.isEmpty())
1726+
{
1727+
return 2;
1728+
}
1729+
featuresInRectangle(bBox, featureList);
17141730
}
17151731

1716-
if(bBox.isEmpty())
1717-
{
1718-
return 2;
1719-
}
1720-
1721-
QList<QgsFeature> featureList;
1722-
featuresInRectangle(bBox, featureList);
1723-
QList<QgsFeature>::iterator select_it = featureList.begin();
1724-
1732+
QgsFeatureList::iterator select_it = featureList.begin();
17251733
for(; select_it != featureList.end(); ++select_it)
17261734
{
17271735
QList<QgsGeometry*> newGeometries;

0 commit comments

Comments
 (0)
Please sign in to comment.