@@ -34,21 +34,20 @@ QgsMapToolNodeTool::QgsMapToolNodeTool( QgsMapCanvas* canvas )
34
34
: QgsMapToolEdit( canvas )
35
35
, mSelectedFeature( 0 )
36
36
, mNodeEditor( 0 )
37
- , mMoving( true )
38
- , mSelectAnother( false )
39
37
, mRect( 0 )
40
38
, mIsPoint( false )
41
- , mDeselectOnRelease( -1 )
42
39
{
43
40
mSnapper .setMapCanvas ( canvas );
41
+ mCadAllowed = true ;
42
+ mSnapOnPress = true ;
44
43
}
45
44
46
45
QgsMapToolNodeTool::~QgsMapToolNodeTool ()
47
46
{
48
47
cleanTool ();
49
48
}
50
49
51
- void QgsMapToolNodeTool::canvasPressEvent ( QMouseEvent * e )
50
+ void QgsMapToolNodeTool::canvasMapPressEvent ( QgsMapMouseEvent * e )
52
51
{
53
52
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mCanvas ->currentLayer () );
54
53
if ( !vlayer )
@@ -66,6 +65,7 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
66
65
}
67
66
68
67
bool hasVertexSelection = mSelectedFeature && mSelectedFeature ->hasSelection ();
68
+
69
69
if ( !mSelectedFeature || !hasVertexSelection )
70
70
{
71
71
// try to select feature
@@ -101,22 +101,17 @@ void QgsMapToolNodeTool::canvasPressEvent( QMouseEvent * e )
101
101
{
102
102
if ( mSelectedFeature ->hasSelection () && !ctrlModifier ) // move vertices
103
103
{
104
- // move selected nodes and deselect all //where does 'mClosestMapVertex' come from?
105
- QList<QgsSnappingResult> snapResults;
106
- mSnapper .snapToBackgroundLayers ( e->pos (), snapResults, QList<QgsPoint>() << mClosestMapVertex );
107
- QgsPoint targetCoords = toLayerCoordinates ( vlayer, snapPointFromResults ( snapResults, e->pos () ) );
104
+ QgsPoint targetCoords = e->mapPoint ();
108
105
mSelectedFeature ->moveSelectedVertexes ( targetCoords - mClosestMapVertex );
109
106
mCanvas ->refresh ();
110
107
mSelectedFeature ->deselectAllVertexes ();
111
108
}
112
109
else // add vertex selection
113
110
{
114
- // snap and add to selection
115
- QgsPoint layerCoordPoint = toLayerCoordinates ( vlayer, e->pos () );
116
111
int atVertex, beforeVertex, afterVertex;
117
112
double dist;
118
113
119
- QgsPoint closestLayerVertex = mSelectedFeature ->geometry ()->closestVertex ( layerCoordPoint , atVertex, beforeVertex, afterVertex, dist );
114
+ QgsPoint closestLayerVertex = mSelectedFeature ->geometry ()->closestVertex ( e-> mapPoint () , atVertex, beforeVertex, afterVertex, dist );
120
115
mSelectedFeature ->selectVertex ( atVertex );
121
116
mClosestMapVertex = toMapCoordinates ( vlayer, closestLayerVertex );
122
117
}
@@ -145,9 +140,6 @@ void QgsMapToolNodeTool::editingToggled()
145
140
void QgsMapToolNodeTool::deactivate ()
146
141
{
147
142
cleanTool ();
148
- mSelectAnother = false ;
149
- mMoving = true ;
150
-
151
143
QgsMapTool::deactivate ();
152
144
}
153
145
@@ -184,7 +176,6 @@ void QgsMapToolNodeTool::canvasDoubleClickEvent( QMouseEvent * e )
184
176
QMultiMap<double , QgsSnappingResult> currentResultList;
185
177
186
178
QList<QgsSnappingResult> snapResults;
187
- mMoving = false ;
188
179
double tol = QgsTolerance::vertexSearchRadius ( vlayer, mCanvas ->mapSettings () );
189
180
mSnapper .snapToCurrentLayer ( e->pos (), snapResults, QgsSnapper::SnapToSegment, tol );
190
181
if ( snapResults.size () < 1 ||
0 commit comments