All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AbstractViewTool.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 #ifndef __TERRALIB_LAYOUT_INTERNAL_ABSTRACTTOOL_H
21 #define __TERRALIB_LAYOUT_INTERNAL_ABSTRACTTOOL_H
22 
23 // TerraLib
24 #include "../../core/Config.h"
25 
26 // Boost
27 #include <boost/noncopyable.hpp>
28 
29 // Qt
30 #include <QtCore/QObject>
31 #include <QtGui/QCursor>
32 
33 // Forward declarations
34 class QMouseEvent;
35 
36 namespace te
37 {
38  namespace layout
39  {
40  class View;
41 
42  class TELAYOUTEXPORT AbstractViewTool : public QObject, public boost::noncopyable
43  {
44  public:
45 
46  /** @name Initializer Methods
47  * Methods related to instantiation and destruction.
48  */
49  //@{
50 
51  /*!
52  \brief It constructs a tool associated with the given map display and with the specified cursor.
53 
54  \param display The map display associated with the tool.
55  \param parent The tool's parent.
56 
57  \note The tool will NOT take the ownership of the given pointers.
58  \note If the given cursor is different of Qt::BlankCursor, it will be setted on map display.
59  */
60  AbstractViewTool(View* view, QObject* parent = 0);
61 
62  /*! \brief Destructor. */
63  virtual ~AbstractViewTool();
64 
65  //@}
66 
67  /** @name AbstractTool Methods
68  * Methods related with tool behavior.
69  */
70  //@{
71 
72  /*!
73  \brief Filters events if this object has been installed as an event filter for the watched object.
74 
75  \param watched The watched object.
76  \param event The last event sent to watched object.
77 
78  \note In your reimplementation of this function, if you want to filter the event out,
79  i.e. stop it being handled further, return true; otherwise return false.
80 
81  \note Here, the default implementation looks for QMouseEvents and call the pure virutal methods
82  defined on AbstractTool class, e.g. mousePressEvent().
83  */
84  virtual bool eventFilter(QObject* watched, QEvent* e);
85 
86  /*!
87  \brief This event handler can be reimplemented in a concrete tool class
88  to receive mouse press events for the watched object.
89 
90  \param e The mouse event.
91 
92  \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
93  */
94  virtual bool mousePressEvent(QMouseEvent* e);
95 
96  /*!
97  \brief This event handler can be reimplemented in a concrete tool class
98  to receive mouse move events for the watched object.
99 
100  \param e The mouse event.
101 
102  \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
103  */
104  virtual bool mouseMoveEvent(QMouseEvent* e);
105 
106  /*!
107  \brief This event handler can be reimplemented in a concrete tool class
108  to receive mouse release events for the watched object.
109 
110  \param e The mouse event.
111 
112  \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
113  */
114  virtual bool mouseReleaseEvent(QMouseEvent* e);
115 
116  /*!
117  \brief This event handler can be reimplemented in a concrete tool class
118  to receive mouse double click events for the watched object.
119 
120  \param e The mouse event.
121 
122  \return If you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.
123 
124  \note The AbstractTool will also receive mouse press and mouse release events in addition to the double click event.
125  It is up to the developer to ensure that the application interprets these events correctly.
126  */
127  virtual bool mouseDoubleClickEvent(QMouseEvent* e);
128 
129  //@}
130 
131  /*!
132  \brief It sets the tool cursor.
133 
134  \param cursor The cursor that will be used during the tool operation.
135  */
136  virtual void setCursor(const QCursor& cursor);
137 
138  protected:
139 
140  View* m_view; //!< The QGraphicsView associated with the tool.
141  QCursor m_cursor; //!< The default tool cursor.
142  };
143 
144  } // end namespace layout
145 } // end namespace te
146 
147 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_ABSTRACTTOOL_H
#define TELAYOUTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:99
Class representing the view. This view is child of QGraphicsView, part of Graphics View Framework...
Definition: View.h:89
View * m_view
The QGraphicsView associated with the tool.
QCursor m_cursor
The default tool cursor.