Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 <QList>
24 #include <QMultiMap>
25 
26 class QgsMapRenderer;
27 class QgsVectorLayer;
28 class QPoint;
29 
33 struct CORE_EXPORT QgsSnappingResult
34 {
54 };
55 
56 
57 
59 class CORE_EXPORT QgsSnapper
60 {
61  public:
64  {
67  //snap to vertex and also to segment if no vertex is within the search tolerance
68  SnapToVertexAndSegment
69  };
70 
72  {
79  SnapWithResultsWithinTolerances
80  };
81 
82  struct SnapLayer
83  {
87  double mTolerance;
92  };
93 
94  QgsSnapper( QgsMapRenderer* mapRender );
95  ~QgsSnapper();
101  int snapPoint( const QPoint& startPoint, QList<QgsSnappingResult>& snappingResult, const QList<QgsPoint>& excludePoints = QList<QgsPoint>() );
102 
103  //setters
104  void setSnapLayers( const QList<QgsSnapper::SnapLayer>& snapLayers );
105  void setSnapMode( QgsSnapper::SnappingMode snapMode );
106 
107  private:
109  QgsSnapper();
110 
112  void cleanResultList( QMultiMap<double, QgsSnappingResult>& list, const QList<QgsPoint>& excludeList ) const;
113 
120  QList<QgsSnapper::SnapLayer> mSnapLayers;
121 };
122 
123 #endif