Skip to content

Commit 32ed67a

Browse files
author
wonder
committedJun 18, 2009
A bunch of fixes for node tool from Richard:
- fixed update of node tool vertex markers after undo #1736 - fixed a crash when trying to edit non-existent feature - vertex markers are now QgsVertexMarker instances (i.e. don't scale when zooming) - fixed moving of points in point layer - original node is excluded when snapping Fixed double map canvas refresh when doing edits. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@10947 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

5 files changed

+334
-124
lines changed

5 files changed

+334
-124
lines changed
 

‎src/app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ SET (QGIS_APP_MOC_HDRS
127127
qgsmaptooladdisland.h
128128
qgsmaptooladdring.h
129129
qgsmaptoolmovefeature.h
130+
qgsmaptoolnodetool.h
130131
qgsmaptoolselect.h
131132
qgsmaptoolsimplify.h
132133

‎src/app/qgsmaptoolnodetool.cpp

Lines changed: 260 additions & 117 deletions
Large diffs are not rendered by default.

‎src/app/qgsmaptoolnodetool.h

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "qgsmaptoolvertexedit.h"
2020
#include "qgsfeature.h"
21+
#include "qgsvertexmarker.h"
2122
#include <QRect>
2223
#include <QRubberBand>
2324

@@ -31,7 +32,8 @@ struct VertexEntry
3132
bool selected;
3233
QgsPoint point;
3334
int equals;
34-
QgsRubberBand *vertexMarker;;
35+
//QgsRubberBand *vertexMarker;
36+
QgsVertexMarker* vertexMarker;
3537
bool inRubberBand;
3638
int rubberBandNr;
3739
int index;
@@ -143,10 +145,18 @@ class SelectionFeature
143145
*/
144146
void cleanRubberBandsData();
145147

146-
void setMarkerCenter(QgsRubberBand* marker, QgsPoint center);
147-
148-
QgsRubberBand* createRubberBandMarker(QgsPoint center);
148+
/**
149+
* Function connecting all necessary thing to create vertex marker
150+
* @param center center of marker
151+
* @return created vertex marker
152+
*/
153+
QgsVertexMarker* createVertexMarker(QgsPoint center);
149154

155+
/**
156+
* Getter for getting vector layer which selection is working
157+
* @return used vector layer
158+
*/
159+
QgsVectorLayer* vlayer();
150160

151161

152162
private:
@@ -183,6 +193,7 @@ class SelectionFeature
183193

184194
QgsFeature* mFeature;
185195
int mFeatureId;
196+
bool mFeatureSelected;
186197
QgsVectorLayer* mVlayer;
187198
QgsRubberBand* mRubberBand;
188199
QList<VertexEntry> mVertexMap;
@@ -192,6 +203,7 @@ class SelectionFeature
192203
/**A maptool to move/deletes/adds vertices of line or polygon fetures*/
193204
class QgsMapToolNodeTool: public QgsMapToolVertexEdit
194205
{
206+
Q_OBJECT
195207
public:
196208
QgsMapToolNodeTool( QgsMapCanvas* canvas );
197209
virtual ~QgsMapToolNodeTool();
@@ -215,14 +227,51 @@ class QgsMapToolNodeTool: public QgsMapToolVertexEdit
215227
* Returns closest vertex to given point from selected feature
216228
*/
217229
QgsPoint getClosestVertex(QgsPoint point);
218-
230+
231+
protected slots:
232+
/**
233+
* Processing incomming signal of deleted feature (for deletion of selected feature)
234+
* @param featureId id of deleted feature
235+
*/
236+
void featureDeleted( int featureId );
237+
238+
/**
239+
* Processing incomming signal of deleted feature (for deletion of selected feature)
240+
* @param featureId id of deleted feature
241+
*/
242+
void layerModified( bool onlyGeometry );
243+
244+
/**
245+
* Processing when layers are changed problem when layer is closed
246+
*/
247+
void layersChanged();
219248

220249
private:
221250

251+
void connectSignals(QgsVectorLayer* vlayer);
252+
222253
/** Deletes the rubber band pointers
223254
and clears mRubberBands*/
224255
void removeRubberBands();
225256

257+
/**
258+
* Creating rubber band marker for movin of point
259+
* @param center coordinates of point to be moved
260+
* @param vlayer vector layer on which we are working
261+
*/
262+
QgsRubberBand* createRubberBandMarker(QgsPoint center, QgsVectorLayer* vlayer);
263+
264+
/**
265+
* Function to check if selected feature exists and is same with original one
266+
* @param vlayer vector layer for checking
267+
*/
268+
bool checkCorrectnessOfFeature(QgsVectorLayer* vlayer);
269+
270+
/**
271+
* Creates rubberbands for moving points
272+
*/
273+
void createMovingRubberBands();
274+
226275
/** The position of the vertex to move (in map coordinates) to exclude later from snapping*/
227276
QList<QgsPoint> mExcludePoint;
228277

@@ -244,7 +293,7 @@ class QgsMapToolNodeTool: public QgsMapToolVertexEdit
244293
/** flag if crtl is pressed */
245294
bool mCtrl;
246295

247-
/** flag if selection of another frature can occur */
296+
/** flag if selection of another feature can occur */
248297
bool mSelectAnother;
249298

250299
/** feature id of another feature where user clicked */
@@ -262,6 +311,12 @@ class QgsMapToolNodeTool: public QgsMapToolVertexEdit
262311
/** rectangle defining area for selecting vertexes */
263312
QRect* mRect;
264313

314+
/** flag that tells that tool is currently updating feature to do not act on change signal */
315+
bool mChangingGeometry;
316+
317+
/** flag to tell if edition points */
318+
bool mIsPoint;
319+
265320
};
266321

267322

‎src/app/qgsundowidget.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ void QgsUndoWidget::setUndoStack(QUndoStack* undoStack)
101101
setWidget(dockWidgetContents);
102102
connect(this->mUndoStack, SIGNAL(canUndoChanged(bool)), this, SLOT(undoChanged(bool)));
103103
connect(this->mUndoStack, SIGNAL(canRedoChanged(bool)), this, SLOT(redoChanged(bool)));
104-
connect(this->mUndoStack, SIGNAL(indexChanged(int)), this, SLOT(indexChanged(int)));
104+
105+
// indexChanged() triggers a refresh. but it gets triggered also when a new action
106+
// is done, resulting in two refreshes. For now let's trigger the refresh from
107+
// vector layer: it causes potentially multiple refreshes when moving more commands
108+
// back, but avoids double refresh in common case when adding commands to the stack
109+
//connect(this->mUndoStack, SIGNAL(indexChanged(int)), this, SLOT(indexChanged(int)));
105110

106111
this->undoButton->setDisabled( !mUndoStack->canUndo() );
107112
this->redoButton->setDisabled( !mUndoStack->canRedo() );

‎src/core/qgsvectorlayer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3943,7 +3943,10 @@ void QgsVectorLayer::redoEditCommand(QgsUndoCommand* cmd)
39433943
mDeletedAttributeIds.insert(attrIndex);
39443944
mUpdatedFields.remove(attrIndex);
39453945
}
3946+
setModified( true );
39463947

3948+
// it's not ideal to trigger refresh from here
3949+
triggerRepaint();
39473950
}
39483951

39493952
void QgsVectorLayer::undoEditCommand(QgsUndoCommand* cmd)
@@ -4044,5 +4047,8 @@ void QgsVectorLayer::undoEditCommand(QgsUndoCommand* cmd)
40444047
emit attributeValueChanged( fid, attrChIt.key(), attrChIt.value().original );
40454048
}
40464049
}
4050+
setModified( true );
40474051

4052+
// it's not ideal to trigger refresh from here
4053+
triggerRepaint();
40484054
}

0 commit comments

Comments
 (0)
Please sign in to comment.