QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "qgspoint.h"
22 #include "qgstolerance.h"
23 #include "qgsfeature.h"
24 
25 #include <QList>
26 #include <QMultiMap>
27 
28 class QgsMapRenderer;
29 class QgsVectorLayer;
30 class QPoint;
31 
35 struct CORE_EXPORT QgsSnappingResult
36 {
56 };
57 
58 
59 
61 class CORE_EXPORT QgsSnapper
62 {
63  public:
66  {
69  //snap to vertex and also to segment if no vertex is within the search tolerance
70  SnapToVertexAndSegment
71  };
72 
74  {
81  SnapWithResultsWithinTolerances
82  };
83 
84  struct SnapLayer
85  {
89  double mTolerance;
94  };
95 
96  QgsSnapper( QgsMapRenderer* mapRender );
97  ~QgsSnapper();
103  int snapPoint( const QPoint& startPoint, QList<QgsSnappingResult>& snappingResult, const QList<QgsPoint>& excludePoints = QList<QgsPoint>() );
104 
105  //setters
106  void setSnapLayers( const QList<QgsSnapper::SnapLayer>& snapLayers );
107  void setSnapMode( QgsSnapper::SnappingMode snapMode );
108 
109  private:
111  QgsSnapper();
112 
114  void cleanResultList( QMultiMap<double, QgsSnappingResult>& list, const QList<QgsPoint>& excludeList ) const;
115 
122  QList<QgsSnapper::SnapLayer> mSnapLayers;
123 };
124 
125 #endif
double mTolerance
The snapping tolerances for the layers, always in source coordinate systems of the layer...
Definition: qgssnapper.h:89
UnitType
Type of unit of tolerance value from settings.
Definition: qgstolerance.h:33
A non GUI class for rendering a map layer set onto a QPainter.
QgsTolerance::UnitType mUnitType
What unit is used for tolerance.
Definition: qgssnapper.h:93
QgsSnapper::SnappingType mSnapTo
What snapping type to use (snap to segment or to vertex)
Definition: qgssnapper.h:91
SnappingType
Snap to vertex, to segment or both.
Definition: qgssnapper.h:65
Represents the result of a snapping operation.
Definition: qgssnapper.h:35
A class that allows advanced snapping operations on a set of vector layers.
Definition: qgssnapper.h:61
QgsMapRenderer * mMapRenderer
The maprender object contains information about the output coordinate system of the map and about the...
Definition: qgssnapper.h:118
int afterVertexNr
The index of the vertex after snappedVertex or -1 if no such vertex.
Definition: qgssnapper.h:51
Several snapping results which have the same position are returned.
Definition: qgssnapper.h:79
QgsFeatureId snappedAtGeometry
Index of the snapped geometry.
Definition: qgssnapper.h:53
A class to represent a point geometry.
Definition: qgspoint.h:63
QgsPoint beforeVertex
The layer coordinates of the vertex before snappedVertex.
Definition: qgssnapper.h:43
QgsPoint afterVertex
The layer coordinates of the vertex after snappedVertex.
Definition: qgssnapper.h:48
int snappedVertexNr
The vertex index of snappedVertex or -1 if no such vertex number (e.g.
Definition: qgssnapper.h:41
Only one snapping result is returned.
Definition: qgssnapper.h:76
QgsSnapper::SnappingMode mSnapMode
Snap mode to apply.
Definition: qgssnapper.h:120
QList< QgsSnapper::SnapLayer > mSnapLayers
List of layers to which snapping is applied.
Definition: qgssnapper.h:122
QgsPoint snappedVertex
The coordinates of the snapping result.
Definition: qgssnapper.h:38
QgsVectorLayer * mLayer
The layer to which snapping is applied.
Definition: qgssnapper.h:87
qint64 QgsFeatureId
Definition: qgsfeature.h:30
Represents a vector layer which manages a vector based data sets.
const QgsVectorLayer * layer
Layer where the snap occured.
Definition: qgssnapper.h:55
int beforeVertexNr
The index of the vertex before snappedVertex or -1 if no such vertex.
Definition: qgssnapper.h:46