File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -209,8 +209,9 @@ int QgsMapToolCapture::addVertex( const QPoint &p )
209
209
{
210
210
mTempRubberBand = createRubberBand ( mCaptureMode == CapturePolygon ? QGis::Polygon : QGis::Line , true );
211
211
}
212
- else {
213
- mTempRubberBand ->reset (CapturePolygon ? true : false );
212
+ else
213
+ {
214
+ mTempRubberBand ->reset ( mCaptureMode == CapturePolygon ? true : false );
214
215
}
215
216
if ( mCaptureMode == CaptureLine )
216
217
{
@@ -234,14 +235,29 @@ void QgsMapToolCapture::undo()
234
235
if ( mRubberBand )
235
236
{
236
237
int rubberBandSize = mRubberBand ->numberOfVertices ();
238
+ int tempRubberBandSize = mTempRubberBand ->numberOfVertices ();
237
239
int captureListSize = mCaptureList .size ();
238
240
239
241
if ( rubberBandSize < 1 || captureListSize < 1 )
240
242
{
241
243
return ;
242
244
}
243
245
244
- mRubberBand ->removePoint ( -2 ); // remove the one before the last one
246
+ mRubberBand ->removePoint ( -1 );
247
+
248
+ if ( mRubberBand ->numberOfVertices () > 0 )
249
+ {
250
+ if ( mTempRubberBand ->numberOfVertices () > 1 )
251
+ {
252
+ const QgsPoint *point = mRubberBand ->getPoint ( 0 , mRubberBand ->numberOfVertices () - 1 );
253
+ mTempRubberBand ->movePoint ( mTempRubberBand ->numberOfVertices () - 2 , *point );
254
+ }
255
+ }
256
+ else
257
+ {
258
+ mTempRubberBand ->reset ( mCaptureMode == CapturePolygon ? true : false );
259
+ }
260
+
245
261
mCaptureList .removeLast ();
246
262
247
263
validateGeometry ();
Original file line number Diff line number Diff line change @@ -536,6 +536,12 @@ int QgsRubberBand::size() const
536
536
return mPoints .size ();
537
537
}
538
538
539
+ int QgsRubberBand::partSize ( int geometryIndex ) const
540
+ {
541
+ if ( geometryIndex < 0 || geometryIndex >= mPoints .size () ) return 0 ;
542
+ return mPoints [geometryIndex].size ();
543
+ }
544
+
539
545
int QgsRubberBand::numberOfVertices () const
540
546
{
541
547
int count = 0 ;
Original file line number Diff line number Diff line change @@ -163,6 +163,13 @@ class GUI_EXPORT QgsRubberBand: public QgsMapCanvasItem
163
163
*/
164
164
void movePoint ( int index, const QgsPoint& p, int geometryIndex = 0 );
165
165
166
+ /* *
167
+ * Returns number of vertices in feature part
168
+ * @param geometryIndex The index of the feature part (in case of multipart geometries)
169
+ * @return number of vertices
170
+ */
171
+ int partSize ( int geometryIndex ) const ;
172
+
166
173
/* *
167
174
* Sets this rubber band to the geometry of an existing feature.
168
175
* This is useful for feature highlighting.
You can’t perform that action at this time.
0 commit comments