Skip to content

Commit 9eba4b0

Browse files
author
mhugent
committed
first part of advanced editing branch merge
git-svn-id: http://svn.osgeo.org/qgis/trunk@7880 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 06e65ca commit 9eba4b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3206
-1512
lines changed
235 Bytes
Loading

python/core/core.sip

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
%Include qgsfeature.sip
2020
%Include qgsfield.sip
2121
%Include qgsgeometry.sip
22-
%Include qgsgeometryvertexindex.sip
2322
%Include qgsgraduatedsymbolrenderer.sip
2423
%Include qgslabel.sip
2524
%Include qgslabelattributes.sip

python/core/qgsgeometry.sip

+16-24
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@ class QgsGeometry
242242
Returns the vertex closest to the given point
243243
(and also vertex index, squared distance and indexes of the vertices before/after)
244244
*/
245-
QgsPoint closestVertex(const QgsPoint& point, QgsGeometryVertexIndex& atVertex, int& beforeVertex, int& afterVertex, double& sqrDist);
246-
245+
QgsPoint closestVertex(const QgsPoint& point, int& atVertex /Out/, int& beforeVertex /Out/, int& afterVertex /Out/, double& sqrDist /Out/);
247246

248247
/**
249248
Returns the indexes of the vertices before and after the given vertex index.
@@ -257,8 +256,7 @@ class QgsGeometry
257256
account the first vertex is equal to the last vertex (and will
258257
skip equal vertex positions).
259258
*/
260-
void adjacentVerticies(const QgsGeometryVertexIndex& atVertex, int& beforeVertex, int& afterVertex);
261-
259+
void adjacentVerticies(int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/);
262260

263261
/** Insert a new vertex before the given vertex index,
264262
* ring and item (first number is index 0)
@@ -271,17 +269,17 @@ class QgsGeometry
271269
* these error conditions. (Or maybe we add another method to this
272270
* object to help make the distinction?)
273271
*/
274-
bool insertVertexBefore(double x, double y, QgsGeometryVertexIndex beforeVertex);
272+
bool insertVertexBefore(double x, double y, int beforeVertex);
275273

276274
/** Moves the vertex at the given position number,
277275
* ring and item (first number is index 0)
278276
* to the given coordinates.
279277
* Returns FALSE if atVertex does not correspond to a valid vertex
280278
* on this geometry
281279
*/
282-
bool moveVertexAt(double x, double y, QgsGeometryVertexIndex atVertex);
283-
284-
/** Deletes the vertex at the given position number,
280+
bool moveVertexAt(double x, double y, int atVertex);
281+
282+
/** Deletes the vertex at the given position number,
285283
* ring and item (first number is index 0)
286284
* Returns FALSE if atVertex does not correspond to a valid vertex
287285
* on this geometry (including if this geometry is a Point),
@@ -291,32 +289,28 @@ class QgsGeometry
291289
* these error conditions. (Or maybe we add another method to this
292290
* object to help make the distinction?)
293291
*/
294-
bool deleteVertexAt(QgsGeometryVertexIndex atVertex);
295-
296-
/**
297-
Returns the squared cartesian distance between the given point
298-
to the given vertex index (vertex at the given position number,
299-
ring and item (first number is index 0))
300-
301-
*/
302-
double sqrDistToVertexAt(QgsPoint& point,
303-
QgsGeometryVertexIndex& atVertex /Out/);
292+
bool deleteVertexAt(int atVertex);
304293

305294
/**
306295
* Returns coordinates of a vertex.
307296
* @param atVertex index of the vertex
308297
* @return Coordinates of the vertex or QgsPoint(0,0) on error
309298
*/
310-
QgsPoint vertexAt(const QgsGeometryVertexIndex& atVertex);
299+
QgsPoint vertexAt(int atVertex);
311300

312301
/**
302+
Returns the squared cartesian distance between the given point
303+
to the given vertex index*/
304+
//double sqrDistToVertexAt(QgsPoint& point /In, int atVertex);
305+
306+
307+
/**
313308
* Searches for the the closest vertex in this geometry to the given point.
314309
* @param point Specifiest the point for search
315310
* @param atVertex Receives index of the closest vertex
316311
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
317312
*/
318-
double closestVertexWithContext(const QgsPoint& point,
319-
QgsGeometryVertexIndex& atVertex /Out/);
313+
double closestVertexWithContext(const QgsPoint& point, int& atVertex /Out/);
320314

321315
/**
322316
* Searches for the closest segment of geometry to the given point
@@ -325,9 +319,7 @@ class QgsGeometry
325319
* @param beforeVertex Receives index of the vertex before the closest segment
326320
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
327321
*/
328-
double closestSegmentWithContext(const QgsPoint& point,
329-
QgsPoint& minDistPoint /Out/,
330-
QgsGeometryVertexIndex& beforeVertex /Out/);
322+
double closestSegmentWithContext(const QgsPoint& point, QgsPoint& minDistPoint /Out/, int& beforeVertex /Out/);
331323

332324
/**Returns the bounding box of this feature*/
333325
QgsRect boundingBox();

python/core/qgsgeometryvertexindex.sip

-57
This file was deleted.

python/core/qgsvectorlayer.sip

+12-39
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,18 @@ public:
141141
* in the given ring, item (first number is index 0), and feature
142142
* Not meaningful for Point geometries
143143
*/
144-
bool insertVertexBefore(double x, double y, int atFeatureId,
145-
QgsGeometryVertexIndex beforeVertex);
144+
bool insertVertexBefore(double x, double y, int atFeatureId, int beforeVertex);
146145

147146
/** Moves the vertex at the given position number,
148147
* ring and item (first number is index 0), and feature
149148
* to the given coordinates
150149
*/
151-
bool moveVertexAt(double x, double y, int atFeatureId,
152-
QgsGeometryVertexIndex atVertex);
150+
bool moveVertexAt(double x, double y, int atFeatureId, int atVertex);
153151

154152
/** Deletes the vertex at the given position number,
155153
* ring and item (first number is index 0), and feature
156154
*/
157-
bool deleteVertexAt(int atFeatureId,
158-
QgsGeometryVertexIndex atVertex);
155+
bool deleteVertexAt(int atFeatureId, int atVertex);
159156

160157
/** Deletes the selected features
161158
* @return true in case of success and false otherwise
@@ -192,39 +189,15 @@ existing rings, 5 no feature found where ring can be inserted*/
192189
@return true if the position of point has been changed, and false otherwise */
193190
bool snapPoint(QgsPoint& point /In, Out/, double tolerance);
194191

195-
/**Snaps a point to the closest vertex if there is one within the snapping tolerance
196-
@param atVertex Set to a vertex index of the snapped-to vertex
197-
@param beforeVertexIndex Returns the index of the vertex before atVertex (for rubber band purposes). -1 if no vertex is before
198-
@param afterVertexIndex Returns the index of the vertex after atVertex (for rubber band purposes). -1 if no vertex is after
199-
@param snappedFeatureId Set to the feature ID that where the snapped-to vertex belongs to.
200-
@param snappedGeometry Set to the geometry that the snapped-to vertex belongs to.
201-
@param tolerance The snapping tolerance
202-
@return true if the position of the points have been changed, and false otherwise (or not implemented by the provider)
203-
204-
TODO: Handle returning multiple verticies if they are coincident
205-
*/
206-
bool snapVertexWithContext(QgsPoint& point,
207-
QgsGeometryVertexIndex& atVertex /Out/,
208-
int& beforeVertexIndex /Out/,
209-
int& afterVertexIndex /Out/,
210-
int& snappedFeatureId /Out/,
211-
QgsGeometry& snappedGeometry /Out/,
212-
double tolerance);
213-
214-
/**Snaps a point to the closest line segment if there is one within the snapping tolerance
215-
@param beforeVertex Set to a value where the snapped-to segment is before this vertex index
216-
@param snappedFeatureId Set to the feature ID that where the snapped-to segment belongs to.
217-
@param snappedGeometry Set to the geometry that the snapped-to segment belongs to.
218-
@param tolerance The snapping tolerance
219-
@return true if the position of the points have been changed, and false otherwise (or not implemented by the provider)
220-
221-
TODO: Handle returning multiple lineFeatures if they are coincident
222-
*/
223-
bool snapSegmentWithContext(QgsPoint& point /In, Out/,
224-
QgsGeometryVertexIndex& beforeVertex /Out/,
225-
int& snappedFeatureId /Out/,
226-
QgsGeometry& snappedGeometry /Out/,
227-
double tolerance);
192+
/**Snaps to segment or vertex within given tolerance
193+
@param startPoint point to snap (in layer coordinates)
194+
@param snappingTolerance distance tolerance for snapping
195+
@param snappingResults snapping results. Key is the distance between startPoint and snapping target
196+
@param snap_to to segment / to vertex
197+
@return 0 in case of success
198+
*/
199+
//int snapWithContext(const QgsPoint& startPoint, double snappingTolerance, QMultiMap<double, QgsSnappingResult>& snappingResults, \
200+
// QgsSnapper::SNAP_TO snap_to);
228201

229202
/**
230203
Commits edited attributes. Depending on the feature id,

python/gui/qgsrubberband.sip

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ class QgsRubberBand: QgsMapCanvasItem
1313
void setWidth(int width);
1414

1515
void reset(bool isPolygon = false);
16-
void addPoint(const QgsPoint & p);
1716

18-
// ! Remove last point
19-
void removePoint(bool update = true);
20-
21-
void movePoint(const QgsPoint & p);
22-
void movePoint(int index, const QgsPoint& p);
17+
void addPoint(const QgsPoint & p, int geometryIndex);
18+
void movePoint(const QgsPoint & p, int geometryIndex);
19+
void movePoint(int index, const QgsPoint& p, int geometryIndex);
2320

2421
int size() const;
2522
const QList<QgsPoint>& getPoints() const;

src/app/CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ SET(QGIS_APP_SRCS
2727
qgslinestylewidget.cpp
2828
qgsludialog.cpp
2929
qgsmaptooladdfeature.cpp
30+
qgsmaptooladdvertex.cpp
3031
qgsmaptooladdisland.cpp
3132
qgsmaptooladdring.cpp
3233
qgsmaptoolcapture.cpp
34+
qgsmaptooldeletevertex.cpp
35+
qgsmaptooledit.cpp
3336
qgsmaptoolidentify.cpp
37+
qgsmaptoolmovefeature.cpp
38+
qgsmaptoolmovevertex.cpp
3439
qgsmaptoolselect.cpp
3540
qgsmaptoolvertexedit.cpp
3641
qgsmarkerdialog.cpp
@@ -51,6 +56,7 @@ SET(QGIS_APP_SRCS
5156
qgssearchquerybuilder.cpp
5257
qgsserversourceselect.cpp
5358
qgssinglesymboldialog.cpp
59+
qgssnappingdialog.cpp
5460
qgsuniquevaluedialog.cpp
5561
qgsvectorlayerproperties.cpp
5662

@@ -79,7 +85,6 @@ SET(QGIS_APP_SRCS
7985

8086

8187
SET (QGIS_APP_MOC_HDRS
82-
8388
qgisapp.h
8489
qgisappinterface.h
8590
qgsabout.h
@@ -102,6 +107,7 @@ SET (QGIS_APP_MOC_HDRS
102107
qgslinestylewidget.h
103108
qgsludialog.h
104109
qgsmaplayerinterface.h
110+
qgsmaptooledit.h
105111
qgsmaptoolidentify.h
106112
qgsmarkerdialog.h
107113
qgsmeasuredialog.h
@@ -116,6 +122,7 @@ SET (QGIS_APP_MOC_HDRS
116122
qgssearchquerybuilder.h
117123
qgsserversourceselect.h
118124
qgssinglesymboldialog.h
125+
qgssnappingdialog.h
119126
qgsuniquevaluedialog.h
120127
qgsvectorlayerproperties.h
121128

src/app/qgisapp.cpp

+25-3
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@
146146
#include "qgsmaptooladdfeature.h"
147147
#include "qgsmaptooladdisland.h"
148148
#include "qgsmaptooladdring.h"
149+
#include "qgsmaptooladdvertex.h"
150+
#include "qgsmaptooldeletevertex.h"
149151
#include "qgsmaptoolidentify.h"
152+
#include "qgsmaptoolmovefeature.h"
153+
#include "qgsmaptoolmovevertex.h"
150154
#include "qgsmaptoolpan.h"
151155
#include "qgsmaptoolselect.h"
152156
#include "qgsmaptoolvertexedit.h"
@@ -409,10 +413,13 @@ QgisApp::~QgisApp()
409413
delete mMapTools.mCapturePoint;
410414
delete mMapTools.mCaptureLine;
411415
delete mMapTools.mCapturePolygon;
416+
delete mMapTools.mMoveFeature;
412417
delete mMapTools.mSelect;
413418
delete mMapTools.mVertexAdd;
414419
delete mMapTools.mVertexMove;
415420
delete mMapTools.mVertexDelete;
421+
delete mMapTools.mAddRing;
422+
delete mMapTools.mAddIsland;
416423

417424
#ifdef HAVE_PYTHON
418425
delete mPythonConsole;
@@ -731,6 +738,11 @@ void QgisApp::createActions()
731738
connect(mActionDeleteSelected, SIGNAL(triggered()), this, SLOT(deleteSelected()));
732739
mActionDeleteSelected->setEnabled(false);
733740
//
741+
mActionMoveFeature = new QAction(QIcon(myIconPath+"/mActionMoveFeature.png"), tr("Move Feature"), this);
742+
mActionMoveFeature->setStatusTip(tr("Move Feature"));
743+
connect(mActionMoveFeature, SIGNAL(triggered()), this, SLOT(moveFeature()));
744+
mActionMoveFeature->setEnabled(true);
745+
//
734746
mActionAddVertex = new QAction(QIcon(myIconPath+"/mActionAddVertex.png"), tr("Add Vertex"), this);
735747
mActionAddVertex->setStatusTip(tr("Add Vertex"));
736748
connect(mActionAddVertex, SIGNAL(triggered()), this, SLOT(addVertex()));
@@ -812,6 +824,8 @@ void QgisApp::createActionGroups()
812824
mMapToolGroup->addAction(mActionCapturePoint);
813825
mActionCapturePolygon->setCheckable(true);
814826
mMapToolGroup->addAction(mActionCapturePolygon);
827+
mActionMoveFeature->setCheckable(true);
828+
mMapToolGroup->addAction(mActionMoveFeature);
815829
mMapToolGroup->addAction(mActionDeleteSelected);
816830
mActionAddVertex->setCheckable(true);
817831
mMapToolGroup->addAction(mActionAddVertex);
@@ -971,6 +985,7 @@ void QgisApp::createToolBars()
971985
mDigitizeToolBar->addAction(mActionCapturePoint);
972986
mDigitizeToolBar->addAction(mActionCaptureLine);
973987
mDigitizeToolBar->addAction(mActionCapturePolygon);
988+
mDigitizeToolBar->addAction(mActionMoveFeature);
974989
mDigitizeToolBar->addAction(mActionDeleteSelected);
975990
mDigitizeToolBar->addAction(mActionAddVertex);
976991
mDigitizeToolBar->addAction(mActionDeleteVertex);
@@ -1235,13 +1250,15 @@ void QgisApp::createCanvas()
12351250
mMapTools.mCaptureLine->setAction(mActionCaptureLine);
12361251
mMapTools.mCapturePolygon = new QgsMapToolAddFeature(mMapCanvas, QgsMapToolCapture::CapturePolygon);
12371252
mMapTools.mCapturePolygon->setAction(mActionCapturePolygon);
1253+
mMapTools.mMoveFeature = new QgsMapToolMoveFeature(mMapCanvas);
1254+
mMapTools.mMoveFeature->setAction(mActionMoveFeature);
12381255
mMapTools.mSelect = new QgsMapToolSelect(mMapCanvas);
12391256
mMapTools.mSelect->setAction(mActionSelect);
1240-
mMapTools.mVertexAdd = new QgsMapToolVertexEdit(mMapCanvas, QgsMapToolVertexEdit::AddVertex);
1257+
mMapTools.mVertexAdd = new QgsMapToolAddVertex(mMapCanvas);
12411258
mMapTools.mVertexAdd->setAction(mActionAddVertex);
1242-
mMapTools.mVertexMove = new QgsMapToolVertexEdit(mMapCanvas, QgsMapToolVertexEdit::MoveVertex);
1259+
mMapTools.mVertexMove = new QgsMapToolMoveVertex(mMapCanvas);
12431260
mMapTools.mVertexMove->setAction(mActionMoveVertex);
1244-
mMapTools.mVertexDelete = new QgsMapToolVertexEdit(mMapCanvas, QgsMapToolVertexEdit::DeleteVertex);
1261+
mMapTools.mVertexDelete = new QgsMapToolDeleteVertex(mMapCanvas);
12451262
mMapTools.mVertexDelete->setAction(mActionDeleteVertex);
12461263
mMapTools.mAddRing = new QgsMapToolAddRing(mMapCanvas);
12471264
mMapTools.mAddRing->setAction(mActionAddRing);
@@ -3396,6 +3413,11 @@ void QgisApp::deleteSelected()
33963413
QgsProject::instance()->dirty(true);
33973414
}
33983415

3416+
void QgisApp::moveFeature()
3417+
{
3418+
mMapCanvas->setMapTool(mMapTools.mMoveFeature);
3419+
}
3420+
33993421
void QgisApp::capturePoint()
34003422
{
34013423
if(mMapCanvas && mMapCanvas->isDrawing())

0 commit comments

Comments
 (0)