|
QGIS API Documentation
master-3f58142
|
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 00016 #ifndef QGSMAPTOOL_H 00017 #define QGSMAPTOOL_H 00018 00019 #include "qgsconfig.h" 00020 00021 #include <QCursor> 00022 #include <QString> 00023 #include <QObject> 00024 00025 #ifdef HAVE_TOUCH 00026 #include <QGestureEvent> 00027 #endif 00028 00029 class QgsMapLayer; 00030 class QgsMapCanvas; 00031 class QKeyEvent; 00032 class QMouseEvent; 00033 class QWheelEvent; 00034 class QgsPoint; 00035 class QgsRectangle; 00036 class QPoint; 00037 class QAction; 00038 class QAbstractButton; 00039 00046 class GUI_EXPORT QgsMapTool : public QObject 00047 { 00048 public: 00049 00051 virtual ~QgsMapTool(); 00052 00054 virtual void canvasMoveEvent( QMouseEvent * e ); 00055 00057 virtual void canvasDoubleClickEvent( QMouseEvent * e ); 00058 00060 virtual void canvasPressEvent( QMouseEvent * e ); 00061 00063 virtual void canvasReleaseEvent( QMouseEvent * e ); 00064 00067 virtual void wheelEvent( QWheelEvent* e ); 00068 00070 virtual void keyPressEvent( QKeyEvent* e ); 00071 00074 virtual void keyReleaseEvent( QKeyEvent* e ); 00075 00076 #ifdef HAVE_TOUCH 00077 00078 virtual bool gestureEvent( QGestureEvent* e ); 00079 #endif 00080 00082 virtual void renderComplete(); 00083 00084 00089 void setAction( QAction* action ); 00090 00092 QAction* action(); 00093 00096 void setButton( QAbstractButton* button ); 00097 00099 QAbstractButton* button(); 00100 00104 virtual bool isTransient(); 00105 00109 virtual bool isEditTool(); 00110 00112 virtual void activate(); 00113 00115 virtual void deactivate(); 00116 00118 QgsMapCanvas* canvas(); 00119 00120 protected: 00121 00123 QgsMapTool( QgsMapCanvas* canvas ); 00124 00126 QgsPoint toMapCoordinates( const QPoint& point ); 00127 00129 QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QPoint& point ); 00130 00132 QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QgsPoint& point ); 00133 00135 QgsPoint toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point ); 00136 00138 QgsRectangle toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect ); 00139 00141 QPoint toCanvasCoordinates( const QgsPoint& point ); 00142 00144 QgsMapCanvas* mCanvas; 00145 00147 QCursor mCursor; 00148 00151 QAction* mAction; 00152 00155 QAbstractButton* mButton; 00156 00157 }; 00158 00159 #endif