Skip to content
Permalink
Browse files

digitizing: disable split parts on single part geometries and allow a…

…dding and removing only part of single part features (fixes #12886, refs #12799)
  • Loading branch information
jef-n committed Jun 14, 2015
1 parent c54013c commit df31fc0f43c8789f6d0d60c9db3982c569814d48
Showing with 17 additions and 14 deletions.
  1. +5 −10 src/app/qgisapp.cpp
  2. +3 −0 src/app/qgsmaptooldeletepart.cpp
  3. +9 −4 src/core/geometry/qgsgeometry.cpp
@@ -5531,14 +5531,7 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
}

//convert unionGeom to a multipart geometry in case it is necessary to match the layer type
QGis::WkbType t = vl->wkbType();
bool layerIsMultiType = ( t == QGis::WKBMultiPoint ||
t == QGis::WKBMultiPoint25D ||
t == QGis::WKBMultiLineString ||
t == QGis::WKBMultiLineString25D ||
t == QGis::WKBMultiPolygon ||
t == QGis::WKBMultiPolygon25D );
if ( layerIsMultiType && !unionGeom->isMultipart() )
if ( QGis::isMultiType( vl->wkbType() ) && !unionGeom->isMultipart() )
{
unionGeom->convertToMultiType();
}
@@ -9449,6 +9442,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionMergeFeatureAttributes->setEnabled( false );
}

bool isMultiPart = QGis::isMultiType( vlayer->wkbType() ) || !dprovider->doesStrictFeatureTypeCheck();

// moving enabled if geometry changes are supported
mActionAddPart->setEnabled( isEditable && canChangeGeometry );
mActionDeletePart->setEnabled( isEditable && canChangeGeometry );
@@ -9484,7 +9479,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )

mActionReshapeFeatures->setEnabled( isEditable && canAddFeatures );
mActionSplitFeatures->setEnabled( isEditable && canAddFeatures );
mActionSplitParts->setEnabled( isEditable && canAddFeatures );
mActionSplitParts->setEnabled( isEditable && canChangeGeometry && isMultiPart );
mActionSimplifyFeature->setEnabled( isEditable && canAddFeatures );
mActionOffsetCurve->setEnabled( isEditable && canAddFeatures && canChangeAttributes );

@@ -9500,7 +9495,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
mActionFillRing->setEnabled( isEditable && canChangeGeometry );
mActionReshapeFeatures->setEnabled( isEditable && canChangeGeometry );
mActionSplitFeatures->setEnabled( isEditable && canAddFeatures );
mActionSplitParts->setEnabled( isEditable && canChangeGeometry );
mActionSplitParts->setEnabled( isEditable && canChangeGeometry && isMultiPart );
mActionSimplifyFeature->setEnabled( isEditable && canChangeGeometry );
mActionDeleteRing->setEnabled( isEditable && canChangeGeometry );
mActionOffsetCurve->setEnabled( false );
@@ -170,7 +170,10 @@ QgsGeometry* QgsMapToolDeletePart::partUnderPoint( QPoint point, QgsFeatureId& f
if ( !g )
return geomPart;
if ( !g->isMultipart() )
{
fid = f.id();
return geomPart;
}
QgsMultiPolygon mpolygon = g->asMultiPolygon();
for ( int part = 0; part < mpolygon.count(); part++ ) // go through the polygons
{
@@ -578,10 +578,7 @@ int QgsGeometry::addPart( const QList<QgsPoint> &points, QGis::GeometryType geom
}
}

if ( !isMultipart() )
{
convertToMultiType();
}
convertToMultiType();

QgsAbstractGeometryV2* partGeom = 0;
if ( points.size() == 1 )
@@ -668,6 +665,8 @@ int QgsGeometry::splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeome
return 0;
}

convertToMultiType();

QList<QgsAbstractGeometryV2*> newGeoms;
QgsLineStringV2 splitLineString;
QList<QgsPointV2> splitLinePointsV2;
@@ -1456,6 +1455,12 @@ bool QgsGeometry::deletePart( int partNum )
return false;
}

if ( !isMultipart() && partNum < 1 )
{
setGeometry( 0 );
return true;
}

detach( true );
bool ok = QgsGeometryEditUtils::deletePart( d->geometry, partNum );
removeWkbGeos();

0 comments on commit df31fc0

Please sign in to comment.
You can’t perform that action at this time.