[QGIS Commit] r9480 - in trunk/qgis/src: app core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Thu Oct 16 14:26:22 EDT 2008
Author: mhugent
Date: 2008-10-16 14:26:21 -0400 (Thu, 16 Oct 2008)
New Revision: 9480
Modified:
trunk/qgis/src/app/qgsmaptoolsplitfeatures.cpp
trunk/qgis/src/core/qgsvectorlayer.cpp
trunk/qgis/src/core/qgsvectorlayer.h
Log:
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
Modified: trunk/qgis/src/app/qgsmaptoolsplitfeatures.cpp
===================================================================
--- trunk/qgis/src/app/qgsmaptoolsplitfeatures.cpp 2008-10-16 17:30:14 UTC (rev 9479)
+++ trunk/qgis/src/app/qgsmaptoolsplitfeatures.cpp 2008-10-16 18:26:21 UTC (rev 9480)
@@ -80,7 +80,11 @@
//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" ) );
Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp 2008-10-16 17:30:14 UTC (rev 9479)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp 2008-10-16 18:26:21 UTC (rev 9480)
@@ -1672,6 +1672,7 @@
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,6 +1750,7 @@
addTopologicalPoints( *topol_it );
}
}
+ ++numberOfSplitedFeatures;
}
else if ( splitFunctionReturn > 1 ) //1 means no split but also no error
{
@@ -1756,6 +1758,14 @@
}
}
+ 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 );
Modified: trunk/qgis/src/core/qgsvectorlayer.h
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.h 2008-10-16 17:30:14 UTC (rev 9479)
+++ trunk/qgis/src/core/qgsvectorlayer.h 2008-10-16 18:26:21 UTC (rev 9480)
@@ -287,7 +287,7 @@
/**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
More information about the QGIS-commit
mailing list