Skip to content
Permalink
Browse files

correctly delete last digitized point, fixes #8462

  • Loading branch information
blazek committed Aug 13, 2013
1 parent 441a46b commit db07f2f90c4872a5e42bebf13d40f37bcde41922
Showing with 32 additions and 3 deletions.
  1. +19 −3 src/app/qgsmaptoolcapture.cpp
  2. +6 −0 src/gui/qgsrubberband.cpp
  3. +7 −0 src/gui/qgsrubberband.h
@@ -209,8 +209,9 @@ int QgsMapToolCapture::addVertex( const QPoint &p )
{
mTempRubberBand = createRubberBand( mCaptureMode == CapturePolygon ? QGis::Polygon : QGis::Line , true );
}
else{
mTempRubberBand->reset(CapturePolygon ? true : false);
else
{
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? true : false );
}
if ( mCaptureMode == CaptureLine )
{
@@ -234,14 +235,29 @@ void QgsMapToolCapture::undo()
if ( mRubberBand )
{
int rubberBandSize = mRubberBand->numberOfVertices();
int tempRubberBandSize = mTempRubberBand->numberOfVertices();
int captureListSize = mCaptureList.size();

if ( rubberBandSize < 1 || captureListSize < 1 )
{
return;
}

mRubberBand->removePoint( -2 ); // remove the one before the last one
mRubberBand->removePoint( -1 );

if ( mRubberBand->numberOfVertices() > 0 )
{
if ( mTempRubberBand->numberOfVertices() > 1 )
{
const QgsPoint *point = mRubberBand->getPoint( 0, mRubberBand->numberOfVertices() - 1 );
mTempRubberBand->movePoint( mTempRubberBand->numberOfVertices() - 2, *point );
}
}
else
{
mTempRubberBand->reset( mCaptureMode == CapturePolygon ? true : false );
}

mCaptureList.removeLast();

validateGeometry();
@@ -536,6 +536,12 @@ int QgsRubberBand::size() const
return mPoints.size();
}

int QgsRubberBand::partSize( int geometryIndex ) const
{
if ( geometryIndex < 0 || geometryIndex >= mPoints.size() ) return 0;
return mPoints[geometryIndex].size();
}

int QgsRubberBand::numberOfVertices() const
{
int count = 0;
@@ -163,6 +163,13 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
*/
void movePoint( int index, const QgsPoint& p, int geometryIndex = 0 );

/**
* Returns number of vertices in feature part
* @param geometryIndex The index of the feature part (in case of multipart geometries)
* @return number of vertices
*/
int partSize( int geometryIndex ) const;

/**
* Sets this rubber band to the geometry of an existing feature.
* This is useful for feature highlighting.

0 comments on commit db07f2f

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