All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ExtentAcquire.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 /*!
21  \file terralib/qt/widgets/tools/ExtentAcquire.cpp
22 
23  \brief This class implements a concrete tool to define a boundary rectangle.
24 */
25 
26 // TerraLib
27 #include "../../../geometry/Envelope.h"
28 #include "../canvas/MapDisplay.h"
29 #include "ExtentAcquire.h"
30 
31 // Qt
32 #include <QMouseEvent>
33 
34 te::qt::widgets::ExtentAcquire::ExtentAcquire(te::qt::widgets::MapDisplay* display, const QCursor& cursor, QObject* parent)
35  : RubberBand(display, parent),
36  m_started(false)
37 {
38  setCursor(cursor);
39 }
40 
42 {
43 }
44 
46 {
47  if(e->button() != Qt::LeftButton)
48  return false;
49 
50  m_started = true;
51  m_rect = QRectF();
52 
54 }
55 
57 {
58  if(!m_started)
59  return false;
60 
62 }
63 
65 {
66  m_started = false;
67 
68  if(e->button() != Qt::LeftButton)
69  return false;
70 
72 
73  if(m_rect.isNull()) // Zoom by click
74  {
75  QRect displayRect = m_display->rect();
76  m_rect.moveCenter(m_origin);
77  }
78 
79  // Converts zoom boundary to world coordinates
80  QPointF ll(m_rect.left(), m_rect.bottom());
81  QPointF ur(m_rect.right(), m_rect.top());
82  ll = m_display->transform(ll);
83  ur = m_display->transform(ur);
84 
85  // Updates the map display with the new extent
86  te::gm::Envelope envelope(ll.x(), ll.y(), ur.x(), ur.y());
87 
88  emit extentAcquired(envelope);
89 
90  return true;
91 }
virtual bool mouseMoveEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse move events for the...
Definition: RubberBand.cpp:55
This class implements a concrete tool to define a boundary rectangle.
virtual bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...
Definition: RubberBand.cpp:72
bool mousePressEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse press events for th...
virtual bool mousePressEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse press events for th...
Definition: RubberBand.cpp:49
ExtentAcquire(MapDisplay *display, const QCursor &cursor, QObject *parent=0)
It constructs a extent acquire tool associated with the given map display and with the specified curs...
A widget to control the display of a set of layers.
Definition: MapDisplay.h:66
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual void setCursor(const QCursor &cursor)
It sets the tool cursor.
This class provides a rectangle that can indicate a boundary.
Definition: RubberBand.h:52
bool mouseMoveEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse move events for the...
bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...