Quantum GIS API Documentation  1.8
src/gui/qgsmaptool.h
Go to the documentation of this file.
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 <QCursor>
00020 #include <QString>
00021 #include <QObject>
00022 
00023 #ifdef HAVE_TOUCH
00024 #include <QGestureEvent>
00025 #endif
00026 
00027 class QgsMapLayer;
00028 class QgsMapCanvas;
00029 class QKeyEvent;
00030 class QMouseEvent;
00031 class QgsPoint;
00032 class QgsRectangle;
00033 class QPoint;
00034 class QAction;
00035 class QAbstractButton;
00036 
00043 class GUI_EXPORT QgsMapTool : public QObject
00044 {
00045   public:
00046 
00048     virtual ~QgsMapTool();
00049 
00051     virtual void canvasMoveEvent( QMouseEvent * e );
00052 
00054     virtual void canvasDoubleClickEvent( QMouseEvent * e );
00055 
00057     virtual void canvasPressEvent( QMouseEvent * e );
00058 
00060     virtual void canvasReleaseEvent( QMouseEvent * e );
00061 
00063     virtual void keyPressEvent( QKeyEvent* e );
00064 
00067     virtual void keyReleaseEvent( QKeyEvent* e );
00068 
00069 #ifdef HAVE_TOUCH
00070 
00071     virtual bool gestureEvent( QGestureEvent* e );
00072 #endif
00073 
00075     virtual void renderComplete();
00076 
00077 
00082     void setAction( QAction* action );
00083 
00085     QAction* action();
00086 
00089     void setButton( QAbstractButton* button );
00090 
00092     QAbstractButton* button();
00093 
00094 
00098     virtual bool isTransient();
00099 
00103     virtual bool isEditTool();
00104 
00106     virtual void activate();
00107 
00109     virtual void deactivate();
00110 
00112     QgsMapCanvas* canvas();
00113 
00114   protected:
00115 
00117     QgsMapTool( QgsMapCanvas* canvas );
00118 
00120     QgsPoint toMapCoordinates( const QPoint& point );
00121 
00123     QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QPoint& point );
00124 
00126     QgsPoint toLayerCoordinates( QgsMapLayer* layer, const QgsPoint& point );
00127 
00129     QgsPoint toMapCoordinates( QgsMapLayer* layer, const QgsPoint& point );
00130 
00132     QgsRectangle toLayerCoordinates( QgsMapLayer* layer, const QgsRectangle& rect );
00133 
00135     QPoint toCanvasCoordinates( const QgsPoint& point );
00136 
00138     QgsMapCanvas* mCanvas;
00139 
00141     QCursor mCursor;
00142 
00145     QAction* mAction;
00146 
00149     QAbstractButton* mButton;
00150 
00151 };
00152 
00153 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines