QGIS API Documentation  2.12.0-Lyon
qgsmaptoolcapture.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaptoolcapture.h - map tool for capturing points, lines, polygons
3  ---------------------
4  begin : January 2006
5  copyright : (C) 2006 by Martin Dobias
6  email : wonder.sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMAPTOOLCAPTURE_H
17 #define QGSMAPTOOLCAPTURE_H
18 
19 
21 #include "qgscompoundcurvev2.h"
22 #include "qgspoint.h"
23 #include "qgsgeometry.h"
24 #include "qgslayertreeview.h"
25 
26 #include <QPoint>
27 #include <QList>
28 
29 class QgsRubberBand;
30 class QgsVertexMarker;
31 class QgsMapLayer;
33 
35 {
36  Q_OBJECT
37 
38  public:
40  QgsMapToolCapture( QgsMapCanvas* canvas, QgsAdvancedDigitizingDockWidget* cadDockWidget, CaptureMode mode = CaptureNone );
41 
43  virtual ~QgsMapToolCapture();
44 
46  virtual void deactivate() override;
47 
49  int addCurve( QgsCurveV2* c );
50 
56  const QgsCompoundCurveV2* captureCurve() const { return &mCaptureCurve; }
57 
58 
64  virtual void cadCanvasMoveEvent( QgsMapMouseEvent * e ) override;
65 
70  virtual void keyPressEvent( QKeyEvent* e ) override;
71 
72 #ifdef Q_OS_WIN
73  virtual bool eventFilter( QObject *obj, QEvent *e ) override;
74 #endif
75 
79  void deleteTempRubberBand();
80 
81  private slots:
82  void validationFinished();
83  void currentLayerChanged( QgsMapLayer *layer );
84  void addError( QgsGeometry::Error );
85 
86 
87  protected:
88  int nextPoint( const QgsPoint& mapPoint, QgsPoint& layerPoint );
89  int nextPoint( const QPoint &p, QgsPoint &layerPoint, QgsPoint &mapPoint );
90 
93  int addVertex( const QgsPoint& point );
94 
96  void undo();
97 
101  void startCapturing();
102 
108  bool isCapturing() const;
109 
113  void stopCapturing();
114 
120  int size();
121 
126  QList<QgsPoint> points();
127 
133  void setPoints( const QList<QgsPoint>& pointList );
134 
138  void closePolygon();
139 
140  private:
142  bool mCapturing;
143 
145  QgsRubberBand* mRubberBand;
146 
148  QgsRubberBand* mTempRubberBand;
149 
151  QgsCompoundCurveV2 mCaptureCurve;
152 
153  void validateGeometry();
154  QStringList mValidationWarnings;
155  QgsGeometryValidator *mValidator;
156  QList< QgsGeometry::Error > mGeomErrors;
157  QList< QgsVertexMarker * > mGeomErrorMarkers;
158 
159  bool mCaptureModeFromLayer;
160 
161  QgsVertexMarker* mSnappingMarker;
162 
163 #ifdef Q_OS_WIN
164  int mSkipNextContextMenuEvent;
165 #endif
166 };
167 
168 #endif
Base class for all map layer types.
Definition: qgsmaplayer.h:49
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
The QgsMapToolAdvancedDigitizing class is a QgsMapTool whcih gives event directly in map coordinates ...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:107
A class for drawing transient features (e.g.
Definition: qgsrubberband.h:32
A class for marking vertices of features using e.g.
virtual bool eventFilter(QObject *watched, QEvent *event)
A class to represent a point.
Definition: qgspoint.h:63
Compound curve geometry type.
virtual void keyPressEvent(QKeyEvent *e)
Key event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:170
virtual void cadCanvasMoveEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
Abstract base class for curved geometry type.
Definition: qgscurvev2.h:32
The QgsAdvancedDigitizingDock class is a dockable widget used to handle the CAD tools on top of a sel...
const QgsCompoundCurveV2 * captureCurve() const
Get the capture curve.
virtual void deactivate() override
Unregisters this maptool from the cad dock widget.