7 changes: 5 additions & 2 deletions src/app/nodetool/qgsmaptoolnodetool.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class QgsMapToolNodeTool: public QgsMapToolVertexEdit
QgsFeatureId mAnother;

/** stored position of last press down action to count how much vertexes should be moved */
QgsPoint* mLastCoordinates;
QPoint mPressCoordinates;

/** closest vertex to click */
QgsPoint mClosestVertex;
Expand All @@ -141,13 +141,16 @@ class QgsMapToolNodeTool: public QgsMapToolVertexEdit
QgsPoint mPosMapCoordBackup;

/** active rubberband for selecting vertexes */
QRubberBand *mRubberBand;
QRubberBand *mSelectionRubberBand;

/** rectangle defining area for selecting vertexes */
QRect* mRect;

/** flag to tell if edition points */
bool mIsPoint;

/** vertex to deselect on release */
int mDeselectOnRelease;
};

#endif
69 changes: 38 additions & 31 deletions src/app/nodetool/qgsselectedfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,48 +283,55 @@ void QgsSelectedFeature::deleteSelectedVertexes()
}
}

void QgsSelectedFeature::moveSelectedVertexes( double changeX, double changeY )
void QgsSelectedFeature::moveSelectedVertexes( const QgsVector &v )
{
int nUpdates = 0;
foreach( QgsVertexEntry *entry, mVertexMap )
{
if ( entry->isSelected() )
nUpdates++;
}

if ( nUpdates == 0 )
return;

mVlayer->beginEditCommand( QObject::tr( "Moved vertices" ) );
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );

beginGeometryChange();

QMultiMap<double, QgsSnappingResult> currentResultList;
for ( int i = mVertexMap.size() - 1; i > -1; i-- )
for ( int i = mVertexMap.size() - 1; i > -1 && nUpdates > 0; i-- )
{
if ( mVertexMap[i]->isSelected() )
{
if ( topologicalEditing )
{
// snap from current vertex
currentResultList.clear();
mVlayer->snapWithContext( mVertexMap[i]->point(), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
}
QgsVertexEntry *entry = mVertexMap.value( i, 0 );
if ( !entry || !entry->isSelected() )
continue;

mVlayer->moveVertex( mVertexMap[i]->point().x() + changeX, mVertexMap[i]->point().y() + changeY, mFeatureId, i );
if ( topologicalEditing )
{
// snap from current vertex
currentResultList.clear();
mVlayer->snapWithContext( entry->point(), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
}

mVertexMap[i]->moveCenter( changeX, changeY );
// only last update should trigger the geometry update
// as vertex selection gets lost on the update
if ( --nUpdates == 0 )
endGeometryChange();

if ( topologicalEditing )
{
QMultiMap<double, QgsSnappingResult>::iterator resultIt = currentResultList.begin();
QgsPoint p = entry->point() + v;
mVlayer->moveVertex( p.x(), p.y(), mFeatureId, i );

for ( ; resultIt != currentResultList.end(); ++resultIt )
{
// move all other
if ( mFeatureId != resultIt.value().snappedAtGeometry )
mVlayer->moveVertex( mVertexMap[i]->point().x(), mVertexMap[i]->point().y(),
resultIt.value().snappedAtGeometry, resultIt.value().snappedVertexNr );
}
}

QgsVertexEntry *entry = mVertexMap[i];
entry->setCenter( entry->point() );
entry->update();
if ( topologicalEditing )
{
QMultiMap<double, QgsSnappingResult>::iterator resultIt = currentResultList.begin();

if ( entry->equals() != -1 && !mVertexMap[ entry->equals()]->isSelected() )
for ( ; resultIt != currentResultList.end(); ++resultIt )
{
mVertexMap[ entry->equals()]->moveCenter( changeX, changeY );
mVertexMap[ entry->equals()]->update();
// for polygon delete both
// move all other
if ( mFeatureId != resultIt.value().snappedAtGeometry )
mVlayer->moveVertex( p.x(), p.y(),
resultIt.value().snappedAtGeometry, resultIt.value().snappedVertexNr );
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/app/nodetool/qgsselectedfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ class QgsSelectedFeature: public QObject

/**
* Moves selected vertex
* @param changeX change in X coordinate
* @param changeY change in Y coordinate
* @param v translation vector
*/
void moveSelectedVertexes( double changeX, double changeY );
void moveSelectedVertexes( const QgsVector &v );

/**
* Inverts selection of vertex with number
Expand Down
6 changes: 0 additions & 6 deletions src/app/nodetool/qgsvertexentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ void QgsVertexEntry::setCenter( QgsPoint p )
}
}

void QgsVertexEntry::moveCenter( double x, double y )
{
mPoint += QgsVector( x, y );
setCenter( mPoint );
}

void QgsVertexEntry::setSelected( bool selected )
{
mSelected = selected;
Expand Down
1 change: 0 additions & 1 deletion src/app/nodetool/qgsvertexentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class QgsVertexEntry
bool isInRubberBand() const { return mInRubberBand; }

void setCenter( QgsPoint p );
void moveCenter( double x, double y );

void setEqual( int index ) { mEquals = index; }
void setSelected( bool selected = true );
Expand Down