Skip to content

Commit

Permalink
If there are selected features, the split tool is only applies to the…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
mhugent committed Oct 16, 2008
1 parent 24452c8 commit 2ff1f91
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/qgsmaptoolsplitfeatures.cpp
Expand Up @@ -80,7 +80,11 @@ void QgsMapToolSplitFeatures::canvasReleaseEvent( QMouseEvent * e )
//bring up dialog if a split was not possible (polygon) or only done once (line)
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
int returnCode = vlayer->splitFeatures( mCaptureList, topologicalEditing );
if ( returnCode != 0 )
if(returnCode == 4)
{
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"));
}
else if ( returnCode != 0 )
{
//several intersections but only one split (most likely line)
QMessageBox::warning( 0, tr( "Split error" ), tr( "An error occured during feature splitting" ) );
Expand Down
10 changes: 10 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -1672,6 +1672,7 @@ int QgsVectorLayer::splitFeatures( const QList<QgsPoint>& splitLine, bool topolo
QgsRect bBox; //bounding box of the split line
int returnCode = 0;
int splitFunctionReturn; //return code of QgsGeometry::splitGeometry
int numberOfSplitedFeatures = 0;

QgsFeatureList featureList;
const QgsFeatureIds selectedIds = selectedFeaturesIds();
Expand Down Expand Up @@ -1749,13 +1750,22 @@ int QgsVectorLayer::splitFeatures( const QList<QgsPoint>& splitLine, bool topolo
addTopologicalPoints( *topol_it );
}
}
++numberOfSplitedFeatures;
}
else if ( splitFunctionReturn > 1 ) //1 means no split but also no error
{
returnCode = 3;
}
}

if(numberOfSplitedFeatures == 0 && selectedIds.size() > 0)
{
//There is a selection but no feature has been split.
//Maybe user forgot that only the selected features are split
returnCode = 4;
}


//now add the new features to this vectorlayer
addFeatures( newFeatures, false );

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.h
Expand Up @@ -287,7 +287,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
/**Splits features cut by the given line
@param splitLine line that splits the layer features
@param topologicalEditing true if topological editing is enabled
@return 0 in case of success*/
@return 0 in case of success, 4 if there is a selection but no feature split*/
int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );

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

0 comments on commit 2ff1f91

Please sign in to comment.