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