All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MoveGeometryTool.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/edit/qt/tools/MoveGeometryTool.h
22 
23  \brief This class implements a concrete tool to move geometries.
24 */
25 
26 #ifndef __TERRALIB_EDIT_QT_INTERNAL_MOVEGEOMETRYTOOL_H
27 #define __TERRALIB_EDIT_QT_INTERNAL_MOVEGEOMETRYTOOL_H
28 
29 // TerraLib
30 #include "../../../geometry/Envelope.h"
31 #include "../../../maptools/AbstractLayer.h"
32 #include "../../../qt/widgets/tools/AbstractTool.h"
33 #include "../Config.h"
34 
35 // Qt
36 #include <QPointF>
37 
38 namespace te
39 {
40  namespace qt
41  {
42  namespace widgets
43  {
44  class Canvas;
45  class MapDisplay;
46  }
47  }
48 
49  namespace edit
50  {
51 // Forward declaration
52  class Feature;
53 
54  /*!
55  \class MoveGeometryTool
56 
57  \brief This class implements a concrete tool to move geometries.
58  */
60  {
61  Q_OBJECT
62 
63  public:
64 
65  /** @name Initializer Methods
66  * Methods related to instantiation and destruction.
67  */
68  //@{
69 
70  /*!
71  \brief It constructs a move geometry tool associated with the given map display.
72 
73  \param display The map display associated with the tool.
74  \param parent The tool's parent.
75 
76  \note The tool will NOT take the ownership of the given pointers.
77  */
78  MoveGeometryTool(te::qt::widgets::MapDisplay* display, const te::map::AbstractLayerPtr& layer, QObject* parent = 0);
79 
80  /*! \brief Destructor. */
82 
83  //@}
84 
85  /** @name AbstractTool Methods
86  * Methods related with tool behavior.
87  */
88  //@{
89 
90  bool mousePressEvent(QMouseEvent* e);
91 
92  bool mouseMoveEvent(QMouseEvent* e);
93 
94  bool mouseReleaseEvent(QMouseEvent* e);
95 
96  bool mouseDoubleClickEvent(QMouseEvent* e);
97 
98  //@}
99 
100  private:
101 
102  void reset();
103 
104  void pickFeature(const te::map::AbstractLayerPtr& layer, const QPointF& pos);
105 
106  te::gm::Envelope buildEnvelope(const QPointF& pos);
107 
108  void draw();
109 
110  void updateCursor();
111 
112  void storeEditedFeature();
113 
114  private slots:
115 
116  void onExtentChanged();
117 
118  protected:
119 
122  bool m_moveStarted; //!< Flag that indicates if move operation was started.
123  QPointF m_origin; //!< Origin point on mouse pressed.
124  QPointF m_delta; //!< Difference between pressed point and destination point on mouse move.
125  };
126 
127  } // end namespace edit
128 } // end namespace te
129 
130 #endif // __TERRALIB_EDIT_QT_INTERNAL_MOVEGEOMETRYTOOL_H
#define TEEDITQTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
This class implements a concrete tool to move geometries.
A widget to control the display of a set of layers.
Definition: MapDisplay.h:66
This class defines an interface for objects that can receive application events and respond to them...
Definition: AbstractTool.h:62
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
te::map::AbstractLayerPtr m_layer
QPointF m_delta
Difference between pressed point and destination point on mouse move.
QPointF m_origin
Origin point on mouse pressed.
bool m_moveStarted
Flag that indicates if move operation was started.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr