VertexTool.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/VertexTool.h
22 
23  \brief This class implements a concrete tool for vertex operations (move, add, etc.).
24 */
25 
26 #ifndef __TERRALIB_EDIT_QT_INTERNAL_VERTEXTOOL_H
27 #define __TERRALIB_EDIT_QT_INTERNAL_VERTEXTOOL_H
28 
29 // TerraLib
30 #include "../../../geometry/Envelope.h"
31 #ifndef Q_MOC_RUN
32 #include "../../../maptools/AbstractLayer.h"
33 #include "../../../sam/rtree/Index.h"
34 #include "../../Utils.h"
35 #include "../core/command/AddCommand.h"
36 #include "../core/UndoStackManager.h"
37 #include "GeometriesUpdateTool.h"
38 #endif
39 #include "../Config.h"
40 
41 // STL
42 #include <string>
43 #include <vector>
44 
45 namespace te
46 {
47 // Forward declarations
48  namespace gm
49  {
50  struct Coord2D;
51  class Geometry;
52  class LineString;
53  class Point;
54  }
55 
56  namespace qt
57  {
58  namespace widgets
59  {
60  class MapDisplay;
61  }
62  }
63 
64  namespace edit
65  {
66 // Forward declaration
67  class Feature;
68 
69  /*!
70  \class VertexTool
71 
72  \brief This class implements a concrete tool for vertex operations (move, add, etc.).
73  */
75  {
76  Q_OBJECT
77 
78  public:
79 
80  /*!
81  \enum StageType
82 
83  \brief Defines the operation stage to this tool.
84  */
85  enum StageType
86  {
87  FEATURE_SELECTION, /*!< Selection of feature. */
88  VERTEX_SEARCH, /*!< Search of vertex. */
89  VERTEX_FOUND, /*!< Vertex found. */
90  VERTEX_MOVING, /*!< Vertex movement. */
91  VERTEX_READY_TO_ADD /*!< Vertex add. */
92  };
93 
94  /** @name Initializer Methods
95  * Methods related to instantiation and destruction.
96  */
97  //@{
98 
99  /*!
100  \brief It constructs a vertex tool associated with the given map display.
101 
102  \param display The map display associated with the tool.
103  \param parent The tool's parent.
104 
105  \note The tool will NOT take the ownership of the given pointers.
106  */
107  VertexTool(te::qt::widgets::MapDisplay* display, const te::map::AbstractLayerPtr& layer, bool fixGeometry = false, QObject* parent = 0);
108 
109  /*! \brief Destructor. */
111 
112  //@}
113 
114  /** @name AbstractTool Methods
115  * Methods related with tool behavior.
116  */
117  //@{
118 
119  bool mousePressEvent(QMouseEvent* e);
120 
121  bool mouseMoveEvent(QMouseEvent* e);
122 
123  bool mouseReleaseEvent(QMouseEvent* e);
124 
125  bool mouseDoubleClickEvent(QMouseEvent* e);
126 
127  //@}
128 
130 
131  private:
132 
133  void reset();
134 
135  void pickFeature(const te::map::AbstractLayerPtr& layer, const QPointF& pos);
136 
137  void draw(te::gm::Point* virtualVertex = 0);
138 
139  void storeFeature();
140 
142 
143  private slots:
144 
146 
148 
149  protected:
150 
151  std::vector<te::gm::LineString*> m_lines;
158 
159  te::gm::Envelope buildEnvelope(const QPointF& pos);
160 
162 
163  void updateRTree();
164 
165  void updateCursor();
166 
167  void setStage(StageType stage);
168 
169  };
170 
171  } // end namespace edit
172 } // end namespace te
173 
174 #endif // __TERRALIB_EDIT_QT_INTERNAL_VERTEXTOOL_H
This class implements a concrete tool for vertex operations (move, add, etc.).
Definition: VertexTool.h:75
void draw(te::gm::Point *virtualVertex=0)
VertexIndex m_currentVertexIndex
Definition: VertexTool.h:152
bool mouseMoveEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse move events for the...
void pickFeature(const te::map::AbstractLayerPtr &layer, const QPointF &pos)
bool mousePressEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse press events for th...
te::sam::rtree::Index< VertexIndex, 8 > m_rtree
Definition: VertexTool.h:153
te::gm::Envelope buildEnvelope(const QPointF &pos)
std::vector< te::gm::LineString * > m_lines
Definition: VertexTool.h:151
StageType
Defines the operation stage to this tool.
Definition: VertexTool.h:86
bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...
void pickFeature(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &env)
StageType m_currentStage
Definition: VertexTool.h:154
void setStage(StageType stage)
UndoStackManager & m_stack
Definition: VertexTool.h:157
VertexTool(te::qt::widgets::MapDisplay *display, const te::map::AbstractLayerPtr &layer, bool fixGeometry=false, QObject *parent=0)
It constructs a vertex tool associated with the given map display.
~VertexTool()
Destructor.
bool mouseDoubleClickEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse double click events...
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
A point with x and y coordinate values.
Definition: Point.h:51
A widget to control the display of a set of layers.
Definition: MapDisplay.h:72
A class that represents an R-tree.
Definition: Index.h:57
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TerraLib.
#define slots
#define TEEDITQTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60