AbstractViewTool.cpp
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 // TerraLib
21 #include "AbstractViewTool.h"
22 #include "View.h"
23 
24 // Qt
25 #include <QtGui/QMouseEvent>
26 
27 // STL
28 #include <cassert>
29 
31  : QObject(parent),
32  m_view(view),
33  m_cursor(Qt::BlankCursor)
34 {
35  assert(m_view);
36 }
37 
39 {
40  // Roll back the default map display cursor
41  m_view->viewport()->setCursor(Qt::ArrowCursor);
42 }
43 
44 bool te::layout::AbstractViewTool::eventFilter(QObject* watched, QEvent* e)
45 {
46  switch(e->type())
47  {
48  case QEvent::MouseButtonPress:
49  return mousePressEvent(static_cast<QMouseEvent*>(e));
50 
51  case QEvent::MouseMove:
52  return mouseMoveEvent(static_cast<QMouseEvent*>(e));
53 
54  case QEvent::MouseButtonRelease:
55  return mouseReleaseEvent(static_cast<QMouseEvent*>(e));
56 
57  case QEvent::MouseButtonDblClick:
58  return mouseDoubleClickEvent(static_cast<QMouseEvent*>(e));
59 
60  case QEvent::Enter:
61  {
62  if(m_cursor.shape() != Qt::BlankCursor)
63  m_view->viewport()->setCursor(m_cursor);
64  return false;
65  }
66 
67  default:
68  return QObject::eventFilter(watched, e);
69  }
70 }
71 
73 {
74  return false;
75 }
76 
78 {
79  return false;
80 }
81 
83 {
84  return false;
85 }
86 
88 {
89  return false;
90 }
91 
92 void te::layout::AbstractViewTool::setCursor(const QCursor& cursor)
93 {
94  m_cursor = cursor;
95 }
virtual bool mouseDoubleClickEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse double click events...
virtual void setCursor(const QCursor &cursor)
It sets the tool cursor.
virtual bool mousePressEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse press events for th...
AbstractViewTool(View *view, QObject *parent=0)
It constructs a tool associated with the given map display and with the specified cursor...
Class representing the view. This view is child of QGraphicsView, part of Graphics View Framework...
Definition: View.h:89
virtual bool eventFilter(QObject *watched, QEvent *e)
Filters events if this object has been installed as an event filter for the watched object...
Class representing the view. This view is child of QGraphicsView, part of Graphics View Framework...
virtual bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...
virtual ~AbstractViewTool()
Destructor.
virtual bool mouseMoveEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse move events for the...
View * m_view
The QGraphicsView associated with the tool.