Quantum GIS API Documentation
1.7.4
|
00001 /*************************************************************************** 00002 qgsmaptool.h - base class for map canvas tools 00003 ---------------------- 00004 begin : January 2006 00005 copyright : (C) 2006 by Martin Dobias 00006 email : wonder.sk at gmail dot com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 /* $Id$ */ 00016 00017 #ifndef QGSMAPTOOL_H 00018 #define QGSMAPTOOL_H 00019 00020 #include <QCursor> 00021 #include <QString> 00022 #include <QObject> 00023 00024 class QgsMapLayer; 00025 class QgsMapCanvas; 00026 class QKeyEvent; 00027 class QMouseEvent; 00028 class QgsPoint; 00029 class QgsRectangle; 00030 class QPoint; 00031 class QAction; 00032 class QAbstractButton; 00033 00040 class GUI_EXPORT QgsMapTool : public QObject 00041 { 00042 public: 00043 00045 virtual ~QgsMapTool(); 00046 00048 virtual void canvasMoveEvent( QMouseEvent * e ); 00049 00051 virtual void canvasDoubleClickEvent( QMouseEvent * e ); 00052 00054 virtual void canvasPressEvent( QMouseEvent * e ); 00055 00057 virtual void canvasReleaseEvent( QMouseEvent * e ); 00058 00060 virtual void keyPressEvent( QKeyEvent* e ); 00061 00064 virtual void keyReleaseEvent( QKeyEvent* e ); 00065 00067 virtual void renderComplete(); 00068 00069 00074 void setAction( QAction* action ); 00075 00077 QAction* action(); 00078 00081 void setButton( QAbstractButton* button ); 00082 00084 QAbstractButton* button(); 00085 00086 00090 virtual bool isTransient(); 00091 00095 virtual bool isEditTool(); 00096 00098 virtual void activate(); 00099 00101 virtual void deactivate(); 00102 00104 QgsMapCanvas* canvas(); 00105 00106 protected: 00107 00109 QgsMapTool( QgsMapCanvas* canvas ); 00110 00112 QgsPoint toMapCoordinates( const QPoint& point ); 00113 00115 QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QPoint& point ); 00116 00118 QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QgsPoint& point ); 00119 00121 QgsPoint toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point ); 00122 00124 QgsRectangle toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect ); 00125 00127 QPoint toCanvasCoordinates( const QgsPoint& point ); 00128 00130 QgsMapCanvas* mCanvas; 00131 00133 QCursor mCursor; 00134 00137 QAction* mAction; 00138 00141 QAbstractButton* mButton; 00142 00143 }; 00144 00145 #endif