QGIS API Documentation  2.99.0-Master (0a63d1f)
qgssnapper.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssnapper.h
3  ------------
4  begin : June 7, 2007
5  copyright : (C) 2007 by Marco Hugentobler
6  email : marco dot hugentobler at karto dot baug dot ethz dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSSNAPPER_H
19 #define QGSSNAPPER_H
20 
21 #include "qgis_core.h"
22 #include "qgspoint.h"
23 #include "qgstolerance.h"
24 #include "qgsfeature.h"
25 
26 #include <QList>
27 #include <QMultiMap>
28 
29 class QgsMapSettings;
30 class QgsVectorLayer;
31 class QPoint;
32 
36 // ### QGIS 3: remove from API
37 struct CORE_EXPORT QgsSnappingResult
38 {
41 
47 
53 
61 };
62 
63 
64 
67 // ### QGIS 3: remove from API
68 class CORE_EXPORT QgsSnapper
69 {
70  public:
73  {
76  //snap to vertex and also to segment if no vertex is within the search tolerance
77  SnapToVertexAndSegment
78  };
79 
81  {
84 
89  SnapWithResultsWithinTolerances
90  };
91 
92  struct SnapLayer
93  {
97  double mTolerance;
102  };
103 
104  explicit QgsSnapper( const QgsMapSettings& mapSettings );
105 
112  int snapMapPoint( const QgsPoint &mapCoordPoint, QList<QgsSnappingResult> &snappingResult, const QList<QgsPoint> &excludePoints = QList<QgsPoint>() );
113 
114  //setters
115  void setSnapLayers( const QList<QgsSnapper::SnapLayer>& snapLayers );
116  void setSnapMode( QgsSnapper::SnappingMode snapMode );
117 
118  private:
119 
121  void cleanResultList( QMultiMap<double, QgsSnappingResult>& list, const QList<QgsPoint>& excludeList ) const;
122 
126  const QgsMapSettings& mMapSettings;
128  QgsSnapper::SnappingMode mSnapMode;
130  QList<QgsSnapper::SnapLayer> mSnapLayers;
131 };
132 
133 #endif
double mTolerance
The snapping tolerances for the layers, always in source coordinate systems of the layer...
Definition: qgssnapper.h:97
UnitType
Type of unit of tolerance value from settings.
Definition: qgstolerance.h:36
QgsTolerance::UnitType mUnitType
What unit is used for tolerance.
Definition: qgssnapper.h:101
QgsSnapper::SnappingType mSnapTo
What snapping type to use (snap to segment or to vertex)
Definition: qgssnapper.h:99
The QgsMapSettings class contains configuration for rendering of the map.
SnappingType
Snap to vertex, to segment or both.
Definition: qgssnapper.h:72
Represents the result of a snapping operation.
Definition: qgssnapper.h:37
A class that allows advanced snapping operations on a set of vector layers.
Definition: qgssnapper.h:68
int afterVertexNr
The index of the vertex after snappedVertex or -1 if no such vertex.
Definition: qgssnapper.h:56
Several snapping results which have the same position are returned.
Definition: qgssnapper.h:87
QgsFeatureId snappedAtGeometry
Index of the snapped geometry.
Definition: qgssnapper.h:58
A class to represent a point.
Definition: qgspoint.h:143
QgsPoint beforeVertex
The layer coordinates of the vertex before snappedVertex.
Definition: qgssnapper.h:46
QgsPoint afterVertex
The layer coordinates of the vertex after snappedVertex.
Definition: qgssnapper.h:52
int snappedVertexNr
The vertex index of snappedVertex or -1 if no such vertex number (e.g.
Definition: qgssnapper.h:44
Only one snapping result is returned.
Definition: qgssnapper.h:83
QgsPoint snappedVertex
The coordinates of the snapping result.
Definition: qgssnapper.h:40
QgsVectorLayer * mLayer
The layer to which snapping is applied.
Definition: qgssnapper.h:95
qint64 QgsFeatureId
Definition: qgsfeature.h:33
Represents a vector layer which manages a vector based data sets.
const QgsVectorLayer * layer
Layer where the snap occurred.
Definition: qgssnapper.h:60
int beforeVertexNr
The index of the vertex before snappedVertex or -1 if no such vertex.
Definition: qgssnapper.h:50