Skip to content
Permalink
Browse files
first part of advanced editing branch merge
git-svn-id: http://svn.osgeo.org/qgis/trunk@7880 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 9, 2008
1 parent 06e65ca commit 9eba4b0c31dbdc53afd3af3c247dd011357bc680
Showing with 3,206 additions and 1,512 deletions.
  1. BIN images/themes/default/mActionMoveFeature.png
  2. +0 −1 python/core/core.sip
  3. +16 −24 python/core/qgsgeometry.sip
  4. +0 −57 python/core/qgsgeometryvertexindex.sip
  5. +12 −39 python/core/qgsvectorlayer.sip
  6. +3 −6 python/gui/qgsrubberband.sip
  7. +8 −1 src/app/CMakeLists.txt
  8. +25 −3 src/app/qgisapp.cpp
  9. +4 −0 src/app/qgisapp.h
  10. +19 −17 src/app/qgsmaptooladdfeature.cpp
  11. +2 −1 src/app/qgsmaptooladdisland.h
  12. +1 −1 src/app/qgsmaptooladdring.h
  13. +109 −0 src/app/qgsmaptooladdvertex.cpp
  14. +45 −0 src/app/qgsmaptooladdvertex.h
  15. +49 −34 src/app/qgsmaptoolcapture.cpp
  16. +6 −2 src/app/qgsmaptoolcapture.h
  17. +91 −0 src/app/qgsmaptooldeletevertex.cpp
  18. +46 −0 src/app/qgsmaptooldeletevertex.h
  19. +126 −0 src/app/qgsmaptooledit.cpp
  20. +69 −0 src/app/qgsmaptooledit.h
  21. +11 −0 src/app/qgsmaptoolidentify.cpp
  22. +129 −0 src/app/qgsmaptoolmovefeature.cpp
  23. +49 −0 src/app/qgsmaptoolmovefeature.h
  24. +176 −0 src/app/qgsmaptoolmovevertex.cpp
  25. +54 −0 src/app/qgsmaptoolmovevertex.h
  26. +3 −443 src/app/qgsmaptoolvertexedit.cpp
  27. +13 −94 src/app/qgsmaptoolvertexedit.h
  28. +29 −1 src/app/qgsoptions.cpp
  29. +6 −0 src/app/qgsoptions.h
  30. +117 −43 src/app/qgsprojectproperties.cpp
  31. +10 −5 src/app/qgsprojectproperties.h
  32. +165 −0 src/app/qgssnappingdialog.cpp
  33. +59 −0 src/app/qgssnappingdialog.h
  34. +2 −2 src/core/CMakeLists.txt
  35. +295 −42 src/core/qgsgeometry.cpp
  36. +33 −19 src/core/qgsgeometry.h
  37. +0 −106 src/core/qgsgeometryvertexindex.cpp
  38. +0 −88 src/core/qgsgeometryvertexindex.h
  39. +138 −0 src/core/qgssnapper.cpp
  40. +110 −0 src/core/qgssnapper.h
  41. +184 −233 src/core/qgsvectorlayer.cpp
  42. +40 −42 src/core/qgsvectorlayer.h
  43. +2 −0 src/gui/CMakeLists.txt
  44. +240 −0 src/gui/qgsmapcanvassnapper.cpp
  45. +70 −0 src/gui/qgsmapcanvassnapper.h
  46. +236 −76 src/gui/qgsrubberband.cpp
  47. +22 −9 src/gui/qgsrubberband.h
  48. +1 −0 src/ui/CMakeLists.txt
  49. +223 −21 src/ui/qgsoptionsbase.ui
  50. +70 −102 src/ui/qgsprojectpropertiesbase.ui
  51. +88 −0 src/ui/qgssnappingdialogbase.ui
Binary file not shown.
@@ -19,7 +19,6 @@
%Include qgsfeature.sip
%Include qgsfield.sip
%Include qgsgeometry.sip
%Include qgsgeometryvertexindex.sip
%Include qgsgraduatedsymbolrenderer.sip
%Include qgslabel.sip
%Include qgslabelattributes.sip
@@ -242,8 +242,7 @@ class QgsGeometry
Returns the vertex closest to the given point
(and also vertex index, squared distance and indexes of the vertices before/after)
*/
QgsPoint closestVertex(const QgsPoint& point, QgsGeometryVertexIndex& atVertex, int& beforeVertex, int& afterVertex, double& sqrDist);

QgsPoint closestVertex(const QgsPoint& point, int& atVertex /Out/, int& beforeVertex /Out/, int& afterVertex /Out/, double& sqrDist /Out/);

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

void adjacentVerticies(int atVertex, int& beforeVertex /Out/, int& afterVertex /Out/);

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

/** Moves the vertex at the given position number,
* ring and item (first number is index 0)
* to the given coordinates.
* Returns FALSE if atVertex does not correspond to a valid vertex
* on this geometry
*/
bool moveVertexAt(double x, double y, QgsGeometryVertexIndex atVertex);

/** Deletes the vertex at the given position number,
bool moveVertexAt(double x, double y, int atVertex);
/** Deletes the vertex at the given position number,
* ring and item (first number is index 0)
* Returns FALSE if atVertex does not correspond to a valid vertex
* on this geometry (including if this geometry is a Point),
@@ -291,32 +289,28 @@ class QgsGeometry
* these error conditions. (Or maybe we add another method to this
* object to help make the distinction?)
*/
bool deleteVertexAt(QgsGeometryVertexIndex atVertex);

/**
Returns the squared cartesian distance between the given point
to the given vertex index (vertex at the given position number,
ring and item (first number is index 0))

*/
double sqrDistToVertexAt(QgsPoint& point,
QgsGeometryVertexIndex& atVertex /Out/);
bool deleteVertexAt(int atVertex);

/**
* Returns coordinates of a vertex.
* @param atVertex index of the vertex
* @return Coordinates of the vertex or QgsPoint(0,0) on error
*/
QgsPoint vertexAt(const QgsGeometryVertexIndex& atVertex);
QgsPoint vertexAt(int atVertex);

/**
Returns the squared cartesian distance between the given point
to the given vertex index*/
//double sqrDistToVertexAt(QgsPoint& point /In, int atVertex);


/**
* Searches for the the closest vertex in this geometry to the given point.
* @param point Specifiest the point for search
* @param atVertex Receives index of the closest vertex
* @return The squared cartesian distance is also returned in sqrDist, negative number on error
*/
double closestVertexWithContext(const QgsPoint& point,
QgsGeometryVertexIndex& atVertex /Out/);
double closestVertexWithContext(const QgsPoint& point, int& atVertex /Out/);

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

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

This file was deleted.

@@ -141,21 +141,18 @@ public:
* in the given ring, item (first number is index 0), and feature
* Not meaningful for Point geometries
*/
bool insertVertexBefore(double x, double y, int atFeatureId,
QgsGeometryVertexIndex beforeVertex);
bool insertVertexBefore(double x, double y, int atFeatureId, int beforeVertex);

/** Moves the vertex at the given position number,
* ring and item (first number is index 0), and feature
* to the given coordinates
*/
bool moveVertexAt(double x, double y, int atFeatureId,
QgsGeometryVertexIndex atVertex);
bool moveVertexAt(double x, double y, int atFeatureId, int atVertex);

/** Deletes the vertex at the given position number,
* ring and item (first number is index 0), and feature
*/
bool deleteVertexAt(int atFeatureId,
QgsGeometryVertexIndex atVertex);
bool deleteVertexAt(int atFeatureId, int atVertex);

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

/**Snaps a point to the closest vertex if there is one within the snapping tolerance
@param atVertex Set to a vertex index of the snapped-to vertex
@param beforeVertexIndex Returns the index of the vertex before atVertex (for rubber band purposes). -1 if no vertex is before
@param afterVertexIndex Returns the index of the vertex after atVertex (for rubber band purposes). -1 if no vertex is after
@param snappedFeatureId Set to the feature ID that where the snapped-to vertex belongs to.
@param snappedGeometry Set to the geometry that the snapped-to vertex belongs to.
@param tolerance The snapping tolerance
@return true if the position of the points have been changed, and false otherwise (or not implemented by the provider)

TODO: Handle returning multiple verticies if they are coincident
*/
bool snapVertexWithContext(QgsPoint& point,
QgsGeometryVertexIndex& atVertex /Out/,
int& beforeVertexIndex /Out/,
int& afterVertexIndex /Out/,
int& snappedFeatureId /Out/,
QgsGeometry& snappedGeometry /Out/,
double tolerance);

/**Snaps a point to the closest line segment if there is one within the snapping tolerance
@param beforeVertex Set to a value where the snapped-to segment is before this vertex index
@param snappedFeatureId Set to the feature ID that where the snapped-to segment belongs to.
@param snappedGeometry Set to the geometry that the snapped-to segment belongs to.
@param tolerance The snapping tolerance
@return true if the position of the points have been changed, and false otherwise (or not implemented by the provider)

TODO: Handle returning multiple lineFeatures if they are coincident
*/
bool snapSegmentWithContext(QgsPoint& point /In, Out/,
QgsGeometryVertexIndex& beforeVertex /Out/,
int& snappedFeatureId /Out/,
QgsGeometry& snappedGeometry /Out/,
double tolerance);
/**Snaps to segment or vertex within given tolerance
@param startPoint point to snap (in layer coordinates)
@param snappingTolerance distance tolerance for snapping
@param snappingResults snapping results. Key is the distance between startPoint and snapping target
@param snap_to to segment / to vertex
@return 0 in case of success
*/
//int snapWithContext(const QgsPoint& startPoint, double snappingTolerance, QMultiMap<double, QgsSnappingResult>& snappingResults, \
// QgsSnapper::SNAP_TO snap_to);

/**
Commits edited attributes. Depending on the feature id,
@@ -13,13 +13,10 @@ class QgsRubberBand: QgsMapCanvasItem
void setWidth(int width);

void reset(bool isPolygon = false);
void addPoint(const QgsPoint & p);

// ! Remove last point
void removePoint(bool update = true);

void movePoint(const QgsPoint & p);
void movePoint(int index, const QgsPoint& p);
void addPoint(const QgsPoint & p, int geometryIndex);
void movePoint(const QgsPoint & p, int geometryIndex);
void movePoint(int index, const QgsPoint& p, int geometryIndex);

int size() const;
const QList<QgsPoint>& getPoints() const;
@@ -27,10 +27,15 @@ SET(QGIS_APP_SRCS
qgslinestylewidget.cpp
qgsludialog.cpp
qgsmaptooladdfeature.cpp
qgsmaptooladdvertex.cpp
qgsmaptooladdisland.cpp
qgsmaptooladdring.cpp
qgsmaptoolcapture.cpp
qgsmaptooldeletevertex.cpp
qgsmaptooledit.cpp
qgsmaptoolidentify.cpp
qgsmaptoolmovefeature.cpp
qgsmaptoolmovevertex.cpp
qgsmaptoolselect.cpp
qgsmaptoolvertexedit.cpp
qgsmarkerdialog.cpp
@@ -51,6 +56,7 @@ SET(QGIS_APP_SRCS
qgssearchquerybuilder.cpp
qgsserversourceselect.cpp
qgssinglesymboldialog.cpp
qgssnappingdialog.cpp
qgsuniquevaluedialog.cpp
qgsvectorlayerproperties.cpp

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


SET (QGIS_APP_MOC_HDRS

qgisapp.h
qgisappinterface.h
qgsabout.h
@@ -102,6 +107,7 @@ SET (QGIS_APP_MOC_HDRS
qgslinestylewidget.h
qgsludialog.h
qgsmaplayerinterface.h
qgsmaptooledit.h
qgsmaptoolidentify.h
qgsmarkerdialog.h
qgsmeasuredialog.h
@@ -116,6 +122,7 @@ SET (QGIS_APP_MOC_HDRS
qgssearchquerybuilder.h
qgsserversourceselect.h
qgssinglesymboldialog.h
qgssnappingdialog.h
qgsuniquevaluedialog.h
qgsvectorlayerproperties.h

@@ -146,7 +146,11 @@
#include "qgsmaptooladdfeature.h"
#include "qgsmaptooladdisland.h"
#include "qgsmaptooladdring.h"
#include "qgsmaptooladdvertex.h"
#include "qgsmaptooldeletevertex.h"
#include "qgsmaptoolidentify.h"
#include "qgsmaptoolmovefeature.h"
#include "qgsmaptoolmovevertex.h"
#include "qgsmaptoolpan.h"
#include "qgsmaptoolselect.h"
#include "qgsmaptoolvertexedit.h"
@@ -409,10 +413,13 @@ QgisApp::~QgisApp()
delete mMapTools.mCapturePoint;
delete mMapTools.mCaptureLine;
delete mMapTools.mCapturePolygon;
delete mMapTools.mMoveFeature;
delete mMapTools.mSelect;
delete mMapTools.mVertexAdd;
delete mMapTools.mVertexMove;
delete mMapTools.mVertexDelete;
delete mMapTools.mAddRing;
delete mMapTools.mAddIsland;

#ifdef HAVE_PYTHON
delete mPythonConsole;
@@ -731,6 +738,11 @@ void QgisApp::createActions()
connect(mActionDeleteSelected, SIGNAL(triggered()), this, SLOT(deleteSelected()));
mActionDeleteSelected->setEnabled(false);
//
mActionMoveFeature = new QAction(QIcon(myIconPath+"/mActionMoveFeature.png"), tr("Move Feature"), this);
mActionMoveFeature->setStatusTip(tr("Move Feature"));
connect(mActionMoveFeature, SIGNAL(triggered()), this, SLOT(moveFeature()));
mActionMoveFeature->setEnabled(true);
//
mActionAddVertex = new QAction(QIcon(myIconPath+"/mActionAddVertex.png"), tr("Add Vertex"), this);
mActionAddVertex->setStatusTip(tr("Add Vertex"));
connect(mActionAddVertex, SIGNAL(triggered()), this, SLOT(addVertex()));
@@ -812,6 +824,8 @@ void QgisApp::createActionGroups()
mMapToolGroup->addAction(mActionCapturePoint);
mActionCapturePolygon->setCheckable(true);
mMapToolGroup->addAction(mActionCapturePolygon);
mActionMoveFeature->setCheckable(true);
mMapToolGroup->addAction(mActionMoveFeature);
mMapToolGroup->addAction(mActionDeleteSelected);
mActionAddVertex->setCheckable(true);
mMapToolGroup->addAction(mActionAddVertex);
@@ -971,6 +985,7 @@ void QgisApp::createToolBars()
mDigitizeToolBar->addAction(mActionCapturePoint);
mDigitizeToolBar->addAction(mActionCaptureLine);
mDigitizeToolBar->addAction(mActionCapturePolygon);
mDigitizeToolBar->addAction(mActionMoveFeature);
mDigitizeToolBar->addAction(mActionDeleteSelected);
mDigitizeToolBar->addAction(mActionAddVertex);
mDigitizeToolBar->addAction(mActionDeleteVertex);
@@ -1235,13 +1250,15 @@ void QgisApp::createCanvas()
mMapTools.mCaptureLine->setAction(mActionCaptureLine);
mMapTools.mCapturePolygon = new QgsMapToolAddFeature(mMapCanvas, QgsMapToolCapture::CapturePolygon);
mMapTools.mCapturePolygon->setAction(mActionCapturePolygon);
mMapTools.mMoveFeature = new QgsMapToolMoveFeature(mMapCanvas);
mMapTools.mMoveFeature->setAction(mActionMoveFeature);
mMapTools.mSelect = new QgsMapToolSelect(mMapCanvas);
mMapTools.mSelect->setAction(mActionSelect);
mMapTools.mVertexAdd = new QgsMapToolVertexEdit(mMapCanvas, QgsMapToolVertexEdit::AddVertex);
mMapTools.mVertexAdd = new QgsMapToolAddVertex(mMapCanvas);
mMapTools.mVertexAdd->setAction(mActionAddVertex);
mMapTools.mVertexMove = new QgsMapToolVertexEdit(mMapCanvas, QgsMapToolVertexEdit::MoveVertex);
mMapTools.mVertexMove = new QgsMapToolMoveVertex(mMapCanvas);
mMapTools.mVertexMove->setAction(mActionMoveVertex);
mMapTools.mVertexDelete = new QgsMapToolVertexEdit(mMapCanvas, QgsMapToolVertexEdit::DeleteVertex);
mMapTools.mVertexDelete = new QgsMapToolDeleteVertex(mMapCanvas);
mMapTools.mVertexDelete->setAction(mActionDeleteVertex);
mMapTools.mAddRing = new QgsMapToolAddRing(mMapCanvas);
mMapTools.mAddRing->setAction(mActionAddRing);
@@ -3396,6 +3413,11 @@ void QgisApp::deleteSelected()
QgsProject::instance()->dirty(true);
}

void QgisApp::moveFeature()
{
mMapCanvas->setMapTool(mMapTools.mMoveFeature);
}

void QgisApp::capturePoint()
{
if(mMapCanvas && mMapCanvas->isDrawing())
Loading

0 comments on commit 9eba4b0

Please sign in to comment.