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