Skip to content

Commit 2ff1f91

Browse files
author
mhugent
committed
If there are selected features, the split tool is only applies to the selection. Added a warning for users in case they may have forgotten that a selection exists (or for users that don't know this feature
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9480 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 24452c8 commit 2ff1f91

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/app/qgsmaptoolsplitfeatures.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ void QgsMapToolSplitFeatures::canvasReleaseEvent( QMouseEvent * e )
8080
//bring up dialog if a split was not possible (polygon) or only done once (line)
8181
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
8282
int returnCode = vlayer->splitFeatures( mCaptureList, topologicalEditing );
83-
if ( returnCode != 0 )
83+
if(returnCode == 4)
84+
{
85+
QMessageBox::warning(0, tr("No feature split done"), tr("If there are selected features, the split tool only applies to the selected ones. If you like to split all features under the split line, clear the selection"));
86+
}
87+
else if ( returnCode != 0 )
8488
{
8589
//several intersections but only one split (most likely line)
8690
QMessageBox::warning( 0, tr( "Split error" ), tr( "An error occured during feature splitting" ) );

src/core/qgsvectorlayer.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,7 @@ int QgsVectorLayer::splitFeatures( const QList<QgsPoint>& splitLine, bool topolo
16721672
QgsRect bBox; //bounding box of the split line
16731673
int returnCode = 0;
16741674
int splitFunctionReturn; //return code of QgsGeometry::splitGeometry
1675+
int numberOfSplitedFeatures = 0;
16751676

16761677
QgsFeatureList featureList;
16771678
const QgsFeatureIds selectedIds = selectedFeaturesIds();
@@ -1749,13 +1750,22 @@ int QgsVectorLayer::splitFeatures( const QList<QgsPoint>& splitLine, bool topolo
17491750
addTopologicalPoints( *topol_it );
17501751
}
17511752
}
1753+
++numberOfSplitedFeatures;
17521754
}
17531755
else if ( splitFunctionReturn > 1 ) //1 means no split but also no error
17541756
{
17551757
returnCode = 3;
17561758
}
17571759
}
17581760

1761+
if(numberOfSplitedFeatures == 0 && selectedIds.size() > 0)
1762+
{
1763+
//There is a selection but no feature has been split.
1764+
//Maybe user forgot that only the selected features are split
1765+
returnCode = 4;
1766+
}
1767+
1768+
17591769
//now add the new features to this vectorlayer
17601770
addFeatures( newFeatures, false );
17611771

src/core/qgsvectorlayer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
287287
/**Splits features cut by the given line
288288
@param splitLine line that splits the layer features
289289
@param topologicalEditing true if topological editing is enabled
290-
@return 0 in case of success*/
290+
@return 0 in case of success, 4 if there is a selection but no feature split*/
291291
int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
292292

293293
/**Changes the specified geometry such that it has no intersections with other

0 commit comments

Comments
 (0)