QGIS API Documentation  2.5.0-Master
 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 QgsMapSettings;
30 class QgsVectorLayer;
31 class QPoint;
32 
36 struct CORE_EXPORT QgsSnappingResult
37 {
57 };
58 
59 
60 
62 class CORE_EXPORT QgsSnapper
63 {
64  public:
67  {
70  //snap to vertex and also to segment if no vertex is within the search tolerance
71  SnapToVertexAndSegment
72  };
73 
75  {
82  SnapWithResultsWithinTolerances
83  };
84 
85  struct SnapLayer
86  {
90  double mTolerance;
95  };
96 
98  Q_DECL_DEPRECATED QgsSnapper( QgsMapRenderer* mapRender );
99 
100  explicit QgsSnapper( const QgsMapSettings& mapSettings );
101 
102  ~QgsSnapper();
109  int snapPoint( const QPoint& startPoint, QList<QgsSnappingResult>& snappingResult, const QList<QgsPoint>& excludePoints = QList<QgsPoint>() );
110 
111  //setters
112  void setSnapLayers( const QList<QgsSnapper::SnapLayer>& snapLayers );
113  void setSnapMode( QgsSnapper::SnappingMode snapMode );
114 
115  private:
116 
118  void cleanResultList( QMultiMap<double, QgsSnappingResult>& list, const QList<QgsPoint>& excludeList ) const;
119 
122  const QgsMapSettings& mMapSettings;
124  QgsSnapper::SnappingMode mSnapMode;
126  QList<QgsSnapper::SnapLayer> mSnapLayers;
127 };
128 
129 #endif