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