2008-01-09 21:54:36 +00:00
2015-07-29 11:52:14 +02:00
/** Describes the result of a snapping operation*/
2008-01-09 21:54:36 +00:00
struct QgsSnappingResult
{
%TypeHeaderCode
#include <qgssnapper.h>
%End
2012-09-24 02:28:15 +02:00
2015-07-29 11:52:14 +02:00
/** The coordinates of the snapping result*/
2008-01-09 21:54:36 +00:00
QgsPoint snappedVertex;
2015-07-29 11:52:14 +02:00
/** The vertex index of snappedVertex
2008-01-09 21:54:36 +00:00
or -1 if no such vertex number (e.g. snap to segment)*/
int snappedVertexNr;
2015-07-29 11:52:14 +02:00
/** The layer coordinates of the vertex before snappedVertex*/
2008-01-09 21:54:36 +00:00
QgsPoint beforeVertex;
2015-07-29 11:52:14 +02:00
/** The index of the vertex before snappedVertex
2008-01-09 21:54:36 +00:00
or -1 if no such vertex*/
int beforeVertexNr;
2015-07-29 11:52:14 +02:00
/** The layer coordinates of the vertex after snappedVertex*/
2008-01-09 21:54:36 +00:00
QgsPoint afterVertex;
2015-07-29 11:52:14 +02:00
/** The index of the vertex after snappedVertex
2008-01-09 21:54:36 +00:00
or -1 if no such vertex*/
int afterVertexNr;
2015-07-29 11:52:14 +02:00
/** Index of the snapped geometry*/
2012-09-24 02:28:15 +02:00
qint64 snappedAtGeometry;
2015-07-29 11:52:14 +02:00
/** Layer where the snap occured*/
2008-01-09 21:54:36 +00:00
const QgsVectorLayer* layer;
};
2015-07-29 11:52:14 +02:00
/** A class that allows advanced snapping operations on a set of vector layers*/
2008-01-09 21:54:36 +00:00
class QgsSnapper
{
%TypeHeaderCode
#include <qgssnapper.h>
%End
2012-09-24 02:28:15 +02:00
public:
2015-07-29 11:52:14 +02:00
/** Snap to vertex, to segment or both*/
2012-09-24 02:28:15 +02:00
enum SnappingType
2008-01-09 21:54:36 +00:00
{
2008-10-24 23:22:44 +00:00
SnapToVertex,
SnapToSegment,
2008-01-09 21:54:36 +00:00
//snap to vertex and also to segment if no vertex is within the search tolerance
2008-10-24 23:22:44 +00:00
SnapToVertexAndSegment
2008-01-09 21:54:36 +00:00
};
2012-09-24 02:28:15 +02:00
enum SnappingMode
2008-01-09 21:54:36 +00:00
{
2015-07-29 11:52:14 +02:00
/** Only one snapping result is returned*/
2008-10-24 23:22:44 +00:00
SnapWithOneResult,
2015-07-29 11:52:14 +02:00
/** Several snapping results which have the same position are returned.
2012-09-24 02:28:15 +02:00
This is useful for topological editing*/
2008-10-24 23:22:44 +00:00
SnapWithResultsForSamePosition,
2015-07-29 11:52:14 +02:00
/** All results within the given layer tolerances are returned*/
2008-10-24 23:22:44 +00:00
SnapWithResultsWithinTolerances
2008-01-09 21:54:36 +00:00
};
2008-11-17 17:20:21 +00:00
struct SnapLayer
{
2015-07-29 11:52:14 +02:00
/** The layer to which snapping is applied*/
2008-11-17 17:20:21 +00:00
QgsVectorLayer* mLayer;
2015-07-29 11:52:14 +02:00
/** The snapping tolerances for the layers, always in source coordinate systems of the layer*/
2008-11-17 17:20:21 +00:00
double mTolerance;
2015-07-29 11:52:14 +02:00
/** What snapping type to use (snap to segment or to vertex)*/
2008-11-17 17:20:21 +00:00
QgsSnapper::SnappingType mSnapTo;
2015-07-29 11:52:14 +02:00
/** What unit is used for tolerance*/
2009-04-05 16:46:13 +00:00
QgsTolerance::UnitType mUnitType;
2012-09-24 02:28:15 +02:00
};
2008-01-09 21:54:36 +00:00
2015-12-07 21:54:40 +11:00
//!@deprecated since 2.4 - use constructor with QgsMapSettings
2015-02-08 22:03:33 +01:00
QgsSnapper( QgsMapRenderer *mapRender ) /Deprecated/;
2013-12-05 18:27:45 +07:00
explicit QgsSnapper( const QgsMapSettings& mapSettings );
2012-09-24 02:28:15 +02:00
~QgsSnapper();
2015-02-08 22:03:33 +01:00
2015-02-03 02:21:52 +01:00
/** Does the snapping operation
2012-09-24 02:28:15 +02:00
@param startPoint the start point for snapping (in pixel coordinates)
2014-05-27 23:22:50 +02:00
@param snappingResult the list where the results are inserted (everything in map coordinate system)
@param excludePoints a list with (map coordinate) points that should be excluded in the snapping result. Useful e.g. for vertex moves where a vertex should not be snapped to its original position
@return 0 in case of success
2015-02-03 02:21:52 +01:00
@deprecated
2014-05-27 23:22:50 +02:00
*/
2015-02-08 22:03:33 +01:00
int snapPoint( const QPoint &startPoint, QList<QgsSnappingResult> &snappingResult /Out/, const QList<QgsPoint> &excludePoints = QList<QgsPoint>() ) /Deprecated/;
2015-02-03 02:21:52 +01:00
/** Does the snapping operation
@param mapCoordPoint the start point for snapping (in map coordinates)
@param snappingResult the list where the results are inserted (everything in map coordinate system)
@param excludePoints a list with (map coordinate) points that should be excluded in the snapping result. Useful e.g. for vertex moves where a vertex should not be snapped to its original position
@return 0 in case of success
*/
2015-02-08 22:03:33 +01:00
int snapMapPoint( const QgsPoint &mapCoordPoint, QList<QgsSnappingResult> &snappingResult /Out/, const QList<QgsPoint> &excludePoints = QList<QgsPoint>() );
2008-01-09 21:54:36 +00:00
2012-09-24 02:28:15 +02:00
//setters
void setSnapLayers( const QList<QgsSnapper::SnapLayer>& snapLayers );
void setSnapMode( QgsSnapper::SnappingMode snapMode );
2012-09-26 17:56:27 +02:00
};