Skip to content

Commit b4f7a61

Browse files
committed
fix #4858
1 parent 32f3690 commit b4f7a61

File tree

4 files changed

+18
-32
lines changed

4 files changed

+18
-32
lines changed

src/app/nodetool/qgsmaptoolnodetool.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,8 @@ void QgsMapToolNodeTool::canvasMoveEvent( QMouseEvent * e )
289289
double x = mapCoords.x() + posMapCoord.x() - firstCoords.x();
290290
double y = mapCoords.y() + posMapCoord.y() - firstCoords.y();
291291

292-
mRubberBands[vertexMap[i]->rubberBandNr()]->movePoint( vertexMap[i]->index(), QgsPoint( x, y ) );
293-
if ( vertexMap[i]->index() == 0 )
292+
mRubberBands[vertexMap[i]->rubberBandNr()]->movePoint( vertexMap[i]->rubberBandIndex(), QgsPoint( x, y ) );
293+
if ( vertexMap[i]->rubberBandIndex() == 0 )
294294
{
295295
mRubberBands[vertexMap[i]->rubberBandNr()]->movePoint( 0, QgsPoint( x, y ) );
296296
}
@@ -374,18 +374,12 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
374374
dist = sqrt( dist );
375375

376376
mSnapper.snapToCurrentLayer( e->pos(), snapResults, QgsSnapper::SnapToVertex, tol );
377-
// if (snapResults.size() < 1)
378377
if ( dist > tol )
379378
{
380379
// for points only selecting another feature
381380
// no vertexes found (selecting or inverting selection) if move
382381
// or select another feature if clicked there
383-
QgsSnapper::SnappingType snapType = QgsSnapper::SnapToSegment;
384-
if ( mIsPoint )
385-
{
386-
snapType = QgsSnapper::SnapToVertex;
387-
}
388-
mSnapper.snapToCurrentLayer( e->pos(), snapResults, snapType, tol );
382+
mSnapper.snapToCurrentLayer( e->pos(), snapResults, mIsPoint ? QgsSnapper::SnapToVertex : QgsSnapper::SnapToSegment, tol );
389383
if ( snapResults.size() > 0 )
390384
{
391385
// need to check all if there is a point in my selected feature
@@ -646,7 +640,6 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
646640
}
647641

648642
vlayer->beginEditCommand( tr( "Inserted vertex" ) );
649-
mSelectedFeature->beginGeometryChange();
650643

651644
// add vertex
652645
vlayer->insertVertex( layerCoords.x(), layerCoords.y(), mSelectedFeature->featureId(), snapResults.first().afterVertexNr );
@@ -667,8 +660,6 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
667660

668661
// make sure that new node gets its vertex marker
669662
mCanvas->refresh();
670-
671-
mSelectedFeature->endGeometryChange();
672663
}
673664

674665
QgsPoint QgsMapToolNodeTool::closestVertex( QgsPoint point )

src/app/nodetool/qgsselectedfeature.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,12 @@ void QgsSelectedFeature::createVertexMapPolygon()
374374
for ( int i2 = 0; i2 < polygon.size(); i2++ )
375375
{
376376
const QgsPolyline& poly = polygon[i2];
377-
int i;
378-
for ( i = 0; i < poly.size(); i++ )
377+
for ( int i = 0; i < poly.size(); i++ )
379378
{
380379
mVertexMap.insert( y + i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], i, tr( "ring %1, vertex %2" ).arg( i2 ).arg( i ) ) );
381380
}
382-
mVertexMap[y + i - 1 ]->setEqual( y );
383-
mVertexMap[y]->setEqual( y + i - 1 );
381+
mVertexMap[y + poly.size() - 1 ]->setEqual( y );
382+
mVertexMap[y]->setEqual( y + poly.size() - 1 );
384383
y += poly.size();
385384
}
386385
}
@@ -395,13 +394,12 @@ void QgsSelectedFeature::createVertexMapPolygon()
395394
{
396395
// iterating through polygon rings
397396
const QgsPolyline& poly = poly2[i3];
398-
int i;
399-
for ( i = 0; i < poly.size(); i++ )
397+
for ( int i = 0; i < poly.size(); i++ )
400398
{
401399
mVertexMap.insert( y + i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], y + i - 1, tr( "polygon %1, ring %2, vertex %3" ).arg( i2 ).arg( i3 ).arg( i ) ) );
402400
}
403-
mVertexMap[y + i - 1]->setEqual( y );
404-
mVertexMap[y]->setEqual( y + i - 1 );
401+
mVertexMap[y + poly.size() - 1]->setEqual( y );
402+
mVertexMap[y]->setEqual( y + poly.size() - 1 );
405403
y += poly.size();
406404
}
407405
}
@@ -420,8 +418,7 @@ void QgsSelectedFeature::createVertexMapLine()
420418
{
421419
// iterating through polylines
422420
QgsPolyline poly = mLine[i2];
423-
int i;
424-
for ( i = 0; i < poly.size(); i++ )
421+
for ( int i = 0; i < poly.size(); i++ )
425422
{
426423
mVertexMap.insert( y + i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], i, tr( "polyline %1, vertex %2" ).arg( i2 ).arg( i ) ) );
427424
}
@@ -431,8 +428,7 @@ void QgsSelectedFeature::createVertexMapLine()
431428
else
432429
{
433430
QgsPolyline poly = mGeometry->asPolyline();
434-
int i;
435-
for ( i = 0; i < poly.size(); i++ )
431+
for ( int i = 0; i < poly.size(); i++ )
436432
{
437433
mVertexMap.insert( i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], i, tr( "vertex %1" ).arg( i ) ) );
438434
}
@@ -447,10 +443,9 @@ void QgsSelectedFeature::createVertexMapPoint()
447443
{
448444
// multipoint
449445
QgsMultiPoint poly = mGeometry->asMultiPoint();
450-
int i;
451-
for ( i = 0; i < poly.size(); i++ )
446+
for ( int i = 0; i < poly.size(); i++ )
452447
{
453-
mVertexMap.insert( i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], 1, tr( "point %1" ).arg( i ) ) );
448+
mVertexMap.insert( i, new QgsVertexEntry( mCanvas, mVlayer, poly[i], 1, tr( "point %1" ).arg( i ) ) );
454449
}
455450
}
456451
else

src/app/nodetool/qgsvertexentry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ void QgsVertexEntry::setSelected( bool selected )
8686

8787
void QgsVertexEntry::setRubberBandValues( bool inRubberBand, int rubberBandNr, int indexInRubberBand )
8888
{
89-
mIndex = indexInRubberBand;
90-
mInRubberBand = inRubberBand;
91-
mRubberBandNr = rubberBandNr;
89+
mRubberBandIndex = indexInRubberBand;
90+
mInRubberBand = inRubberBand;
91+
mRubberBandNr = rubberBandNr;
9292
}
9393

9494
void QgsVertexEntry::update()

src/app/nodetool/qgsvertexentry.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class QgsVertexEntry
2828
int mEquals;
2929
bool mInRubberBand;
3030
int mRubberBandNr;
31-
int mIndex;
31+
int mRubberBandIndex;
3232
int mOriginalIndex;
3333
int mPenWidth;
3434
QString mToolTip;
@@ -58,7 +58,7 @@ class QgsVertexEntry
5858
void setSelected( bool selected = true );
5959
void setInRubberBand( bool inRubberBand = true ) { mInRubberBand = inRubberBand; }
6060
int rubberBandNr() const { return mRubberBandNr; }
61-
int index() { return mIndex; }
61+
int rubberBandIndex() { return mRubberBandIndex; }
6262

6363
void setRubberBandValues( bool inRubberBand, int rubberBandNr, int indexInRubberBand );
6464
void update();

0 commit comments

Comments
 (0)