Skip to content

Commit d6c1a74

Browse files
author
wonder
committed
Fixes compilation of bindings, added wrapper for QgsSnapper.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7893 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b8b154c commit d6c1a74

File tree

4 files changed

+79
-3
lines changed

4 files changed

+79
-3
lines changed

python/core/core.sip

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
%Include qgsrenderer.sip
4343
%Include qgsscalecalculator.sip
4444
%Include qgssinglesymbolrenderer.sip
45+
%Include qgssnapper.sip
4546
%Include qgsspatialindex.sip
4647
%Include qgsspatialrefsys.sip
4748
%Include qgssymbol.sip

python/core/qgsgeometry.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ class QgsGeometry
301301
/**
302302
Returns the squared cartesian distance between the given point
303303
to the given vertex index*/
304-
double sqrDistToVertexAt(QgsPoint& point /In, int atVertex);
304+
double sqrDistToVertexAt(QgsPoint& point /In/, int atVertex);
305305

306306

307307
/**

python/core/qgssnapper.sip

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
/**Describes the result of a snapping operation*/
3+
struct QgsSnappingResult
4+
{
5+
%TypeHeaderCode
6+
#include <qgssnapper.h>
7+
%End
8+
9+
/**The coordinates of the snapping result*/
10+
QgsPoint snappedVertex;
11+
/**The vertex index of snappedVertex
12+
or -1 if no such vertex number (e.g. snap to segment)*/
13+
int snappedVertexNr;
14+
/**The layer coordinates of the vertex before snappedVertex*/
15+
QgsPoint beforeVertex;
16+
/**The index of the vertex before snappedVertex
17+
or -1 if no such vertex*/
18+
int beforeVertexNr;
19+
/**The layer coordinates of the vertex after snappedVertex*/
20+
QgsPoint afterVertex;
21+
/**The index of the vertex after snappedVertex
22+
or -1 if no such vertex*/
23+
int afterVertexNr;
24+
/**Index of the snapped geometry*/
25+
int snappedAtGeometry;
26+
/**Layer where the snap occured*/
27+
const QgsVectorLayer* layer;
28+
};
29+
30+
31+
32+
/**A class that allows advanced snapping operations on a set of vector layers*/
33+
class QgsSnapper
34+
{
35+
%TypeHeaderCode
36+
#include <qgssnapper.h>
37+
%End
38+
39+
public:
40+
/**Snap to vertex, to segment or both*/
41+
enum SNAP_TO
42+
{
43+
SNAP_TO_VERTEX,
44+
SNAP_TO_SEGMENT,
45+
//snap to vertex and also to segment if no vertex is within the search tolerance
46+
SNAP_TO_VERTEX_AND_SEGMENT
47+
};
48+
49+
enum SNAP_MODE
50+
{
51+
/**Only one snapping result is retured*/
52+
ONE_RESULT,
53+
/**Several snapping results which have the same position are returned. This is usefull for topological
54+
editing*/
55+
SEVERAL_RESULTS_SAME_POSITION,
56+
/**All results within the given layer tolerances are returned*/
57+
ALL_RESULTS_WITHIN_GIVEN_TOLERANCES
58+
};
59+
60+
QgsSnapper(QgsMapRender* mapRender);
61+
~QgsSnapper();
62+
/**Does the snapping operation
63+
@param startPoint the start point for snapping (in pixel coordinates)
64+
@param snappingResult the list where the results are inserted (everything in map coordinate system)
65+
@return 0 in case of success*/
66+
int snapPoint(const QPoint& startPoint, QList<QgsSnappingResult>& snappingResult);
67+
68+
//setters
69+
void setLayersToSnap(const QList<QgsVectorLayer*>& layerList);
70+
void setTolerances(const QList<double>& toleranceList);
71+
// TODO wrap void setSnapToList(const QList<QgsSnapper::SNAP_TO>& snapToList);
72+
void setSnapMode(QgsSnapper::SNAP_MODE snapMode);
73+
74+
};

python/core/qgsvectorlayer.sip

+3-2
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ existing rings, 5 no feature found where ring can be inserted*/
245245
@param snap_to to segment / to vertex
246246
@return 0 in case of success
247247
*/
248-
int snapWithContext(const QgsPoint& startPoint, double snappingTolerance, QMultiMap<double, QgsSnappingResult>& snappingResults, \
249-
QgsSnapper::SNAP_TO snap_to);
248+
// TODO: wrap QMultiMap
249+
//int snapWithContext(const QgsPoint& startPoint, double snappingTolerance, QMultiMap<double, QgsSnappingResult>& snappingResults,
250+
// QgsSnapper::SNAP_TO snap_to);
250251

251252
/**
252253
Commits edited attributes. Depending on the feature id,

0 commit comments

Comments
 (0)