Skip to content

Commit

Permalink
first part of advanced editing branch merge
Browse files Browse the repository at this point in the history
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 9eba4b0
Show file tree
Hide file tree
Showing 51 changed files with 3,206 additions and 1,512 deletions.
Binary file added images/themes/default/mActionMoveFeature.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion python/core/core.sip
Expand Up @@ -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
Expand Down
40 changes: 16 additions & 24 deletions python/core/qgsgeometry.sip
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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),
Expand All @@ -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
Expand All @@ -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();
Expand Down
57 changes: 0 additions & 57 deletions python/core/qgsgeometryvertexindex.sip

This file was deleted.

51 changes: 12 additions & 39 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 3 additions & 6 deletions python/gui/qgsrubberband.sip
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion src/app/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -51,6 +56,7 @@ SET(QGIS_APP_SRCS
qgssearchquerybuilder.cpp
qgsserversourceselect.cpp
qgssinglesymboldialog.cpp
qgssnappingdialog.cpp
qgsuniquevaluedialog.cpp
qgsvectorlayerproperties.cpp

Expand Down Expand Up @@ -79,7 +85,6 @@ SET(QGIS_APP_SRCS


SET (QGIS_APP_MOC_HDRS

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

Expand Down
28 changes: 25 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 9eba4b0

Please sign in to comment.