1
/***************************************************************************
5
copyright : (C) 2005 by Radim Blazek
7
***************************************************************************/
8
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
***************************************************************************/
19
#include "ui_qgsmeasurebase.h"
21
#include "qgsmaptool.h"
25
class QgsDistanceArea;
32
class QgsMeasure:public QDialog, public QgsMapTool, private Ui::QgsMeasureBase
38
QgsMeasure(bool measureArea, QgsMapCanvas *mc, Qt::WFlags f = 0);
43
void saveWindowLocation(void);
45
//! Restore last window position/size and show the window
46
void restorePosition(void);
49
void addPoint(QgsPoint &point);
52
void mouseMove(QgsPoint &point);
55
void mousePress(QgsPoint &point);
57
//! returns whether measuring distance or area
58
bool measureArea() { return mMeasureArea; }
59
//! sets whether we're measuring area (and restarts)
60
void setMeasureArea(bool measureArea);
64
// Inherited from QgsMapTool
66
//! Mouse move event for overriding
67
virtual void canvasMoveEvent(QMouseEvent * e);
69
//! Mouse press event for overriding
70
virtual void canvasPressEvent(QMouseEvent * e);
72
//! Mouse release event for overriding
73
virtual void canvasReleaseEvent(QMouseEvent * e);
75
//! called when set as currently active map tool
76
virtual void activate();
78
//! called when map tool is being deactivated
79
virtual void deactivate();
85
//! Reset and start new
89
void closeEvent(QCloseEvent *e);
91
//! Redraw lines to match current state of canvas
92
void mapCanvasChanged();
94
//! Show the help for the dialog
95
void on_btnHelp_clicked();
99
//! formats distance to most appropriate units
100
QString formatDistance(double distance);
102
//! formats area to most appropriate units
103
QString formatArea(double area);
105
//! shows/hides table, shows correct units
108
QgsMapCanvas *mMapCanvas;
110
//! distance/area calculator
111
QgsDistanceArea* mCalc;
113
std::vector<QgsPoint> mPoints;
117
//! Rubberband widget tracking the lines being drawn
118
QgsRubberBand *mRubberBand;
121
static const int context_id = 687883780;
123
//! indicates whether we're measuring distances or areas
126
//! indicates whether we've just done a right mouse click
127
bool mRightMouseClicked;