Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 /* $Id$ */
16 
17 #ifndef QGSMAPTOOL_H
18 #define QGSMAPTOOL_H
19 
20 #include <QCursor>
21 #include <QString>
22 #include <QObject>
23 
24 class QgsMapLayer;
25 class QgsMapCanvas;
26 class QKeyEvent;
27 class QMouseEvent;
28 class QgsPoint;
29 class QgsRectangle;
30 class QPoint;
31 class QAction;
32 class QAbstractButton;
33 
40 class GUI_EXPORT QgsMapTool : public QObject
41 {
42  public:
43 
45  virtual ~QgsMapTool();
46 
48  virtual void canvasMoveEvent( QMouseEvent * e );
49 
51  virtual void canvasDoubleClickEvent( QMouseEvent * e );
52 
54  virtual void canvasPressEvent( QMouseEvent * e );
55 
57  virtual void canvasReleaseEvent( QMouseEvent * e );
58 
60  virtual void keyPressEvent( QKeyEvent* e );
61 
64  virtual void keyReleaseEvent( QKeyEvent* e );
65 
67  virtual void renderComplete();
68 
69 
74  void setAction( QAction* action );
75 
77  QAction* action();
78 
81  void setButton( QAbstractButton* button );
82 
84  QAbstractButton* button();
85 
86 
90  virtual bool isTransient();
91 
95  virtual bool isEditTool();
96 
98  virtual void activate();
99 
101  virtual void deactivate();
102 
104  QgsMapCanvas* canvas();
105 
106  protected:
107 
109  QgsMapTool( QgsMapCanvas* canvas );
110 
112  QgsPoint toMapCoordinates( const QPoint& point );
113 
115  QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QPoint& point );
116 
118  QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QgsPoint& point );
119 
121  QgsPoint toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point );
122 
124  QgsRectangle toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect );
125 
127  QPoint toCanvasCoordinates( const QgsPoint& point );
128 
131 
133  QCursor mCursor;
134 
137  QAction* mAction;
138 
141  QAbstractButton* mButton;
142 
143 };
144 
145 #endif