Skip to content
Permalink
Browse files
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
  • Loading branch information
mhugent committed Oct 16, 2008
1 parent 24452c8 commit 2ff1f918d70d6a4750b8eb67d20636c31c91a5bd
Showing with 16 additions and 2 deletions.
  1. +5 −1 src/app/qgsmaptoolsplitfeatures.cpp
  2. +10 −0 src/core/qgsvectorlayer.cpp
  3. +1 −1 src/core/qgsvectorlayer.h
@@ -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" ) );
@@ -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();
@@ -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 );

@@ -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

0 comments on commit 2ff1f91

Please sign in to comment.