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