/
qgsmeasuretool.h
107 lines (73 loc) · 2.96 KB
/
qgsmeasuretool.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/***************************************************************************
qgsmeasuretool.h - map tool for measuring distances and areas
---------------------
begin : April 2007
copyright : (C) 2007 by Martin Dobias
email : wonder.sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMEASURETOOL_H
#define QGSMEASURETOOL_H
#include "qgsmaptool.h"
#include "qgsmapcanvassnapper.h"
class QgsDistanceArea;
class QgsMapCanvas;
class QgsMeasureDialog;
class QgsRubberBand;
class APP_EXPORT QgsMeasureTool : public QgsMapTool
{
Q_OBJECT
public:
QgsMeasureTool( QgsMapCanvas* canvas, bool measureArea );
~QgsMeasureTool();
//! returns whether measuring distance or area
bool measureArea() { return mMeasureArea; }
//! When we have added our last point, and not following
// Added in 2.0
bool done() { return mDone; }
//! Reset and start new
void restart();
//! Add new point
void addPoint( QgsPoint &point );
//! Returns reference to array of the points
const QList<QgsPoint>& points();
// Inherited from QgsMapTool
//! Mouse move event for overriding
virtual void canvasMoveEvent( QMouseEvent * e );
//! Mouse press event for overriding
virtual void canvasPressEvent( QMouseEvent * e );
//! Mouse release event for overriding
virtual void canvasReleaseEvent( QMouseEvent * e );
//! called when set as currently active map tool
virtual void activate();
//! called when map tool is being deactivated
virtual void deactivate();
public slots:
//! updates the projections we're using
void updateSettings();
protected:
QList<QgsPoint> mPoints;
QgsMeasureDialog* mDialog;
//! Rubberband widget tracking the lines being drawn
QgsRubberBand *mRubberBand;
//! Rubberband widget tracking the added nodes to line
QgsRubberBand *mRubberBandPoints;
//! indicates whether we're measuring distances or areas
bool mMeasureArea;
//! indicates whether we've just done a right mouse click
bool mDone;
//! indicates whether we've recently warned the user about having the wrong
// project projection
bool mWrongProjectProjection;
QgsMapCanvasSnapper mSnapper;
//! Returns the snapped (map) coordinate
//@param p (pixel) coordinate
QgsPoint snapPoint( const QPoint& p );
};
#endif