Skip to content
Permalink
Browse files
always delete regardless of mouse position; use default rubberband color
  • Loading branch information
leyan committed May 15, 2014
1 parent 609b692 commit c0fdfcf3716faa22b37f1fae52b2d713c8d593a8
Showing with 12 additions and 28 deletions.
  1. +3 −11 src/app/qgsmaptooldeletepart.cpp
  2. +9 −17 src/app/qgsmaptooldeletering.cpp
@@ -73,15 +73,14 @@ void QgsMapToolDeletePart::canvasPressEvent( QMouseEvent *e )
mRubberBand = createRubberBand( vlayer->geometryType() );

mRubberBand->setToGeometry( geomPart, vlayer );
mRubberBand->setColor( QColor( 255, 0, 0, 65 ) );
mRubberBand->setWidth( 2 );
mRubberBand->show();
}

}

void QgsMapToolDeletePart::canvasReleaseEvent( QMouseEvent *e )
{
Q_UNUSED( e );

delete mRubberBand;
mRubberBand = 0;
@@ -94,18 +93,11 @@ void QgsMapToolDeletePart::canvasReleaseEvent( QMouseEvent *e )
if ( mPressedFid == -1 )
return;

int fid;
int partNum;
partUnderPoint( e->pos(), fid, partNum );

if ( fid != mPressedFid || partNum != mPressedPartNum )
return;

QgsFeature f;
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( fid ) ).nextFeature( f );
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( mPressedFid ) ).nextFeature( f );
QgsGeometry* g = f.geometry();

if ( g->deletePart( partNum ) )
if ( g->deletePart( mPressedPartNum ) )
{
vlayer->beginEditCommand( tr( "Part of multipart feature deleted" ) );
vlayer->changeGeometry( f.id(), g );
@@ -82,40 +82,32 @@ void QgsMapToolDeleteRing::canvasPressEvent( QMouseEvent *e )
mRubberBand = createRubberBand( vlayer->geometryType() );

mRubberBand->setToGeometry( ringGeom, vlayer );
mRubberBand->setColor( QColor( 255, 0, 0, 65 ) );
mRubberBand->setWidth( 2 );
mRubberBand->show();
}
}

void QgsMapToolDeleteRing::canvasReleaseEvent( QMouseEvent *e )
{
Q_UNUSED( e );

delete mRubberBand;
mRubberBand = 0;

if ( mPressedFid == -1 )
return;

QgsPoint p = toLayerCoordinates( vlayer, e->pos() );

int fid, partNum, ringNum;
QgsFeature f;
QgsGeometry* g;
ringUnderPoint( p, fid, partNum, ringNum );

if ( fid == mPressedFid && partNum == mPressedPartNum && ringNum == mPressedRingNum )
{
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( mPressedFid ) ).nextFeature( f );
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( mPressedFid ) ).nextFeature( f );

g = f.geometry();
if ( g->deleteRing( ringNum, partNum ) )
{
vlayer->beginEditCommand( tr( "Ring deleted" ) );
vlayer->changeGeometry( fid, g );
vlayer->endEditCommand();
mCanvas->refresh();
}
g = f.geometry();
if ( g->deleteRing( mPressedRingNum, mPressedPartNum ) )
{
vlayer->beginEditCommand( tr( "Ring deleted" ) );
vlayer->changeGeometry( mPressedFid, g );
vlayer->endEditCommand();
mCanvas->refresh();
}
}

0 comments on commit c0fdfcf

Please sign in to comment.