~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to src/gui/qgsmeasure.h

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-05-06 13:42:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134232-pyli6t388w5asd8x
Tags: 0.8.0-3ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules, debian/qgis.install, debian/qgis.dirs debian/qgis.desktop:
    Add and install .desktop.
* debian/qgis.desktop: Remove Applications category; it's not real.
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                                qgsmeasure.h 
 
3
                               ------------------
 
4
        begin                : March 2005
 
5
        copyright            : (C) 2005 by Radim Blazek
 
6
        email                : blazek@itc.it 
 
7
 ***************************************************************************/
 
8
/***************************************************************************
 
9
 *                                                                         *
 
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.                                   *
 
14
 *                                                                         *
 
15
 ***************************************************************************/
 
16
#ifndef QGSMEASURE_H
 
17
#define QGSMEASURE_H
 
18
 
 
19
#include "ui_qgsmeasurebase.h"
 
20
#include <QWidget>
 
21
#include "qgsmaptool.h"
 
22
#include "qgspoint.h"
 
23
#include <vector>
 
24
 
 
25
class QgsDistanceArea;
 
26
class QgsMapCanvas;
 
27
class QgsRubberBand;
 
28
 
 
29
class QCloseEvent;
 
30
 
 
31
 
 
32
class QgsMeasure:public QDialog, public QgsMapTool, private Ui::QgsMeasureBase
 
33
{
 
34
  Q_OBJECT;
 
35
  public:
 
36
 
 
37
  //! Constructor
 
38
  QgsMeasure(bool measureArea, QgsMapCanvas *mc, Qt::WFlags f = 0);
 
39
 
 
40
  ~QgsMeasure();
 
41
 
 
42
  //! Save position
 
43
  void saveWindowLocation(void);
 
44
 
 
45
  //! Restore last window position/size and show the window
 
46
  void restorePosition(void);
 
47
 
 
48
  //! Add new point
 
49
  void addPoint(QgsPoint &point);
 
50
  
 
51
  //! Mose move
 
52
  void mouseMove(QgsPoint &point);
 
53
  
 
54
  //! Mouse press
 
55
  void mousePress(QgsPoint &point);
 
56
  
 
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);
 
61
 
 
62
public:
 
63
  
 
64
  // Inherited from QgsMapTool
 
65
  
 
66
  //! Mouse move event for overriding
 
67
  virtual void canvasMoveEvent(QMouseEvent * e);
 
68
 
 
69
  //! Mouse press event for overriding
 
70
  virtual void canvasPressEvent(QMouseEvent * e);
 
71
 
 
72
  //! Mouse release event for overriding
 
73
  virtual void canvasReleaseEvent(QMouseEvent * e);
 
74
 
 
75
  //! called when set as currently active map tool
 
76
  virtual void activate();
 
77
    
 
78
  //! called when map tool is being deactivated
 
79
  virtual void deactivate();
 
80
  
 
81
public slots:
 
82
  //! Close
 
83
  void close ( void);
 
84
 
 
85
  //! Reset and start new
 
86
  void restart ( void);
 
87
 
 
88
  //! Close event
 
89
  void closeEvent(QCloseEvent *e);
 
90
 
 
91
  //! Redraw lines to match current state of canvas
 
92
  void mapCanvasChanged(); 
 
93
 
 
94
  //! Show the help for the dialog 
 
95
  void on_btnHelp_clicked();
 
96
  
 
97
private:
 
98
  
 
99
  //! formats distance to most appropriate units
 
100
  QString formatDistance(double distance);
 
101
  
 
102
  //! formats area to most appropriate units
 
103
  QString formatArea(double area);
 
104
  
 
105
  //! shows/hides table, shows correct units
 
106
  void updateUi();
 
107
  
 
108
  QgsMapCanvas *mMapCanvas;
 
109
  
 
110
  //! distance/area calculator
 
111
  QgsDistanceArea* mCalc;
 
112
  
 
113
  std::vector<QgsPoint> mPoints;
 
114
 
 
115
  double mTotal;
 
116
 
 
117
  //! Rubberband widget tracking the lines being drawn
 
118
  QgsRubberBand *mRubberBand;
 
119
 
 
120
  //! Help context id
 
121
  static const int context_id = 687883780;
 
122
  
 
123
  //! indicates whether we're measuring distances or areas
 
124
  bool mMeasureArea;
 
125
 
 
126
  //! indicates whether we've just done a right mouse click
 
127
  bool mRightMouseClicked;
 
128
};
 
129
 
 
130
#endif