QGIS/python/core/qgssnapper.sip

97 lines
3.5 KiB
Plaintext
Raw Normal View History

2016-02-14 03:50:23 +01:00
/** \ingroup core
* Represents the result of a snapping operation.
* */
struct QgsSnappingResult
{
%TypeHeaderCode
#include <qgssnapper.h>
%End
2015-07-29 11:52:14 +02:00
/** The coordinates of the snapping result*/
QgsPoint snappedVertex;
2015-07-29 11:52:14 +02:00
/** The vertex index of snappedVertex
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*/
QgsPoint beforeVertex;
2015-07-29 11:52:14 +02:00
/** The index of the vertex before snappedVertex
or -1 if no such vertex*/
int beforeVertexNr;
2015-07-29 11:52:14 +02:00
/** The layer coordinates of the vertex after snappedVertex*/
QgsPoint afterVertex;
2015-07-29 11:52:14 +02:00
/** The index of the vertex after snappedVertex
or -1 if no such vertex*/
int afterVertexNr;
2015-07-29 11:52:14 +02:00
/** Index of the snapped geometry*/
qint64 snappedAtGeometry;
2016-01-24 20:16:19 +01:00
/** Layer where the snap occurred*/
const QgsVectorLayer* layer;
};
2015-07-29 11:52:14 +02:00
/** A class that allows advanced snapping operations on a set of vector layers*/
class QgsSnapper
{
%TypeHeaderCode
#include <qgssnapper.h>
%End
public:
2015-07-29 11:52:14 +02:00
/** Snap to vertex, to segment or both*/
enum SnappingType
{
SnapToVertex,
SnapToSegment,
//snap to vertex and also to segment if no vertex is within the search tolerance
SnapToVertexAndSegment
};
enum SnappingMode
{
2015-07-29 11:52:14 +02:00
/** Only one snapping result is returned*/
SnapWithOneResult,
2015-07-29 11:52:14 +02:00
/** Several snapping results which have the same position are returned.
This is useful for topological editing*/
SnapWithResultsForSamePosition,
2015-07-29 11:52:14 +02:00
/** All results within the given layer tolerances are returned*/
SnapWithResultsWithinTolerances
};
struct SnapLayer
{
2015-07-29 11:52:14 +02:00
/** The layer to which snapping is applied*/
QgsVectorLayer* mLayer;
2015-07-29 11:52:14 +02:00
/** The snapping tolerances for the layers, always in source coordinate systems of the layer*/
double mTolerance;
2015-07-29 11:52:14 +02:00
/** What snapping type to use (snap to segment or to vertex)*/
QgsSnapper::SnappingType mSnapTo;
2015-07-29 11:52:14 +02:00
/** What unit is used for tolerance*/
QgsTolerance::UnitType mUnitType;
};
explicit QgsSnapper( const QgsMapSettings& mapSettings );
2015-02-03 02:21:52 +01:00
/** Does the snapping operation
2016-02-14 03:50:23 +01:00
* @param startPoint the start point for snapping (in pixel 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
* @deprecated
2014-05-27 23:22:50 +02:00
*/
int snapPoint( 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
2016-02-14 03:50:23 +01:00
* @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
*/
int snapMapPoint( const QgsPoint &mapCoordPoint, QList<QgsSnappingResult> &snappingResult /Out/, const QList<QgsPoint> &excludePoints = QList<QgsPoint>() );
//setters
void setSnapLayers( const QList<QgsSnapper::SnapLayer>& snapLayers );
void setSnapMode( QgsSnapper::SnappingMode snapMode );
2012-09-26 17:56:27 +02:00
};