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 #ifndef Q_MOC_RUN
32 #include "../../../maptools/AbstractLayer.h"
33 #endif
34 #include "../core/command/AddCommand.h"
35 #include "../core/UndoStackManager.h"
36 #include "../Config.h"
37 #include "GeometriesUpdateTool.h"
38 
39 // Qt
40 #include <QPointF>
41 
42 //STL
43 #include <map>
44 
45 namespace te
46 {
47  namespace qt
48  {
49  namespace widgets
50  {
51  class Canvas;
52  class MapDisplay;
53  }
54  }
55 
56  namespace edit
57  {
58 // Forward declaration
59  class Feature;
60 
61  /*!
62  \class MoveGeometryTool
63 
64  \brief This class implements a concrete tool to move geometries.
65  */
67  {
68  Q_OBJECT
69 
70  public:
71 
72  /** @name Initializer Methods
73  * Methods related to instantiation and destruction.
74  */
75  //@{
76 
77  /*!
78  \brief It constructs a move geometry tool associated with the given map display.
79 
80  \param display The map display associated with the tool.
81  \param parent The tool's parent.
82 
83  \note The tool will NOT take the ownership of the given pointers.
84  */
85  MoveGeometryTool(te::qt::widgets::MapDisplay* display, const te::map::AbstractLayerPtr& layer, const te::edit::MouseEventEdition mouseEventToSave, QObject *parent = 0);
86  /*! \brief Destructor. */
88 
89  //@}
90 
91  /** @name AbstractTool Methods
92  * Methods related with tool behavior.
93  */
94  //@{
95 
96  bool mousePressEvent(QMouseEvent* e);
97 
98  bool mouseMoveEvent(QMouseEvent* e);
99 
100  bool mouseReleaseEvent(QMouseEvent* e);
101 
102  //@}
103 
104  void resetVisualizationTool();
105 
106  private:
107 
108  void reset();
109 
110  void pickFeature(const QPointF& pos);
111 
112  te::gm::Envelope buildEnvelope(const QPointF& pos);
113 
114  void draw();
115 
116  void updateCursor();
117 
118  void storeFeature();
119 
120  void storeUndoCommand();
121 
122  protected:
123 
125  bool m_moveStarted; //!< Flag that indicates if move operation was started.
126  QPointF m_origin; //!< Origin point on mouse pressed.
127  QPointF m_delta; //!< Difference between pressed point and destination point on mouse move.
128  std::vector<te::edit::Feature*> m_vecFeature;
131  };
132 
133  } // end namespace edit
134 } // end namespace te
135 
136 #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:60
This class implements a concrete tool to move geometries.
UndoStackManager & m_stack
A widget to control the display of a set of layers.
Definition: MapDisplay.h:69
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
URI C++ Library.
QPointF m_delta
Difference between pressed point and destination point on mouse move.
std::vector< te::edit::Feature * > m_vecFeature
QPointF m_origin
Origin point on mouse pressed.
bool m_moveStarted
Flag that indicates if move operation was started.
MouseEventEdition m_mouseEventToSave
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
MouseEventEdition
Defines which mouse event will be used in the tool to complete an operation.
Definition: Utils.h:102