Loading...
Searching...
No Matches
AbstractTool.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file terralib/qt/widgets/tools/AbstractTool.h
22
23 \brief Abstract tool concept.
24*/
25
26#ifndef __TERRALIB_QT_WIDGETS_INTERNAL_ABSTRACTTOOL_H
27#define __TERRALIB_QT_WIDGETS_INTERNAL_ABSTRACTTOOL_H
28
29// TerraLib
30#include "../Config.h"
31
32// Boost
33#include <boost/noncopyable.hpp>
34
35// Qt
36#include <QtCore/QObject>
37#include <QCursor>
38
39// Forward declarations
40class QKeyEvent;
41class QMouseEvent;
42
43namespace te
44{
45 namespace qt
46 {
47 namespace widgets
48 {
49// Forward declarations
50 class MapDisplay;
51
52 /*!
53 \class AbstractTool
54
55 \brief This class defines an interface for objects that can receive application events and respond to
56 them, according to specific tool behavior. Tools, in general, receives map display interaction events, like
57 MouseClick, MouseMove, etc. Tools are created to do some GIS operation using the user interactions.
58
59 \ingroup widgets
60
61 \sa CoordTracking, Info, Measure, Pan, RubberBand, Selection, Zoom, ZoomArea, ZoomClick, ZoomKeyboard, ZoomWheel
62 */
63 class TEQTWIDGETSEXPORT AbstractTool : public QObject, public boost::noncopyable
64 {
65 public:
66
67 /** @name Initializer Methods
68 * Methods related to instantiation and destruction.
69 */
70 //@{
71
72 /*!
73 \brief It constructs a tool associated with the given map display and with the specified cursor.
74
75 \param display The map display associated with the tool.
76 \param parent The tool's parent.
77
78 \note The tool will NOT take the ownership of the given pointers.
79 \note If the given cursor is different of Qt::BlankCursor, it will be setted on map display.
80 */
81 AbstractTool(MapDisplay* display, QObject* parent = 0);
82
83 /*! \brief Destructor. */
84 virtual ~AbstractTool();
85
86 //@}
87
88 virtual void init();
89
90 /** @name AbstractTool Methods
91 * Methods related with tool behavior.
92 */
93 //@{
94
95 /*!
96 \brief Filters events if this object has been installed as an event filter for the watched object.
97
98 \param watched The watched object.
99 \param event The last event sent to watched object.
100
101 \note In your reimplementation of this function, if you want to filter the event out,
102 i.e. stop it being handled further, return true; otherwise return false.
103
104 \note Here, the default implementation looks for QMouseEvents and call the pure virutal methods
105 defined on AbstractTool class, e.g. mousePressEvent().
106 */
107 virtual bool eventFilter(QObject* watched, QEvent* e);
108
109 /*!
110 \brief This event handler can be reimplemented in a concrete tool class
111 to receive mouse press events for the watched object.
112
113 \param e The mouse event.
114
115 \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
116 */
117 virtual bool mousePressEvent(QMouseEvent* e);
118
119 /*!
120 \brief This event handler can be reimplemented in a concrete tool class
121 to receive mouse move events for the watched object.
122
123 \param e The mouse event.
124
125 \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
126 */
127 virtual bool mouseMoveEvent(QMouseEvent* e);
128
129 /*!
130 \brief This event handler can be reimplemented in a concrete tool class
131 to receive mouse release events for the watched object.
132
133 \param e The mouse event.
134
135 \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
136 */
137 virtual bool mouseReleaseEvent(QMouseEvent* e);
138
139 /*!
140 \brief This event handler can be reimplemented in a concrete tool class
141 to receive mouse double click events for the watched object.
142
143 \param e The mouse event.
144
145 \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
146
147 \note The AbstractTool will also receive mouse press and mouse release events in addition to the double click event.
148 It is up to the developer to ensure that the application interprets these events correctly.
149 */
150 virtual bool mouseDoubleClickEvent(QMouseEvent* e);
151
152 /*!
153 \brief This event handler can be reimplemented in a concrete tool class
154 to receive key press events for the watched object.
155
156 \param e The key event.
157
158 \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
159 */
160 virtual bool keyPressEvent(QKeyEvent* e);
161
162 //@}
163
164 /*!
165 \brief It sets the tool cursor.
166
167 \param cursor The cursor that will be used during the tool operation.
168 */
169 virtual void setCursor(const QCursor& cursor);
170
171 protected:
172
173 MapDisplay* m_display; //!< The map display associated with the tool.
174 QCursor m_cursor; //!< The default tool cursor.
175 QCursor m_curCursor; //!< The current mapdisplay cursor.
176 };
177
178 } // end namespace widgets
179 } // end namespace qt
180} // end namespace te
181
182#endif // __TERRALIB_QT_WIDGETS_INTERNAL_ABSTRACTTOOL_H
This class defines an interface for objects that can receive application events and respond to them,...
Definition: AbstractTool.h:64
virtual bool mouseMoveEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse move events for the...
virtual ~AbstractTool()
Destructor.
virtual bool keyPressEvent(QKeyEvent *e)
This event handler can be reimplemented in a concrete tool class to receive key press events for the ...
virtual bool eventFilter(QObject *watched, QEvent *e)
Filters events if this object has been installed as an event filter for the watched object.
virtual bool mousePressEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse press events for th...
virtual void setCursor(const QCursor &cursor)
It sets the tool cursor.
AbstractTool(MapDisplay *display, QObject *parent=0)
It constructs a tool associated with the given map display and with the specified cursor.
QCursor m_curCursor
The current mapdisplay cursor.
Definition: AbstractTool.h:175
virtual bool mouseDoubleClickEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse double click events...
virtual bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...
MapDisplay * m_display
The map display associated with the tool.
Definition: AbstractTool.h:173
QCursor m_cursor
The default tool cursor.
Definition: AbstractTool.h:174
A widget to control the display of a set of layers.
Definition: MapDisplay.h:72
TerraLib.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63