QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsmaptool.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaptool.h - base class for map canvas tools
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 QGSMAPTOOL_H
17 #define QGSMAPTOOL_H
18 
19 #include "qgsconfig.h"
20 
21 #include <QCursor>
22 #include <QString>
23 #include <QObject>
24 
25 #ifdef HAVE_TOUCH
26 #include <QGestureEvent>
27 #endif
28 
29 class QgsMapLayer;
30 class QgsMapCanvas;
31 class QKeyEvent;
32 class QMouseEvent;
33 class QWheelEvent;
34 class QgsPoint;
35 class QgsRectangle;
36 class QPoint;
37 class QAction;
38 class QAbstractButton;
39 
46 class GUI_EXPORT QgsMapTool : public QObject
47 {
48  public:
49 
51  virtual ~QgsMapTool();
52 
54  virtual void canvasMoveEvent( QMouseEvent * e );
55 
57  virtual void canvasDoubleClickEvent( QMouseEvent * e );
58 
60  virtual void canvasPressEvent( QMouseEvent * e );
61 
63  virtual void canvasReleaseEvent( QMouseEvent * e );
64 
67  virtual void wheelEvent( QWheelEvent* e );
68 
70  virtual void keyPressEvent( QKeyEvent* e );
71 
74  virtual void keyReleaseEvent( QKeyEvent* e );
75 
76 #ifdef HAVE_TOUCH
77 
78  virtual bool gestureEvent( QGestureEvent* e );
79 #endif
80 
82  virtual void renderComplete();
83 
84 
89  void setAction( QAction* action );
90 
92  QAction* action();
93 
96  void setButton( QAbstractButton* button );
97 
99  QAbstractButton* button();
100 
102  virtual void setCursor( QCursor cursor );
103 
107  virtual bool isTransient();
108 
112  virtual bool isEditTool();
113 
115  virtual void activate();
116 
118  virtual void deactivate();
119 
121  QgsMapCanvas* canvas();
122 
123  protected:
124 
126  QgsMapTool( QgsMapCanvas* canvas );
127 
129  QgsPoint toMapCoordinates( const QPoint& point );
130 
132  QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QPoint& point );
133 
135  QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QgsPoint& point );
136 
138  QgsPoint toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point );
139 
141  QgsRectangle toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect );
142 
144  QPoint toCanvasCoordinates( const QgsPoint& point );
145 
148 
150  QCursor mCursor;
151 
154  QAction* mAction;
155 
158  QAbstractButton* mButton;
159 
160 };
161 
162 #endif