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
te::edit::VertexTool::~VertexTool
~VertexTool()
Destructor.
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
te::edit::VertexTool::buildEnvelope
te::gm::Envelope buildEnvelope(const QPointF &pos)
te::edit::VertexTool::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::VertexTool::setStage
void setStage(StageType stage)
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::edit::VertexTool::m_isEdited
bool m_isEdited
Definition: VertexTool.h:155
te::sam::rtree::Index
A class that represents an R-tree.
Definition: Index.h:57
te::edit::VertexTool::m_currentVertexIndex
VertexIndex m_currentVertexIndex
Definition: VertexTool.h:152
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::VertexTool::updateRTree
void updateRTree()
te::edit::VertexTool::m_stack
UndoStackManager & m_stack
Definition: VertexTool.h:157
te::edit::VertexTool::m_currentStage
StageType m_currentStage
Definition: VertexTool.h:154
te::edit::VertexTool::pickFeature
void pickFeature(const te::map::AbstractLayerPtr &layer, const QPointF &pos)
te::edit::VertexTool::StageType
StageType
Defines the operation stage to this tool.
Definition: VertexTool.h:86
te::edit::VertexTool::storeUndoCommand
void storeUndoCommand()
te::edit::VertexTool
This class implements a concrete tool for vertex operations (move, add, etc.).
Definition: VertexTool.h:75
te::edit::UndoStackManager
Definition: UndoStackManager.h:50
te::edit::VertexTool::VERTEX_FOUND
@ VERTEX_FOUND
Definition: VertexTool.h:89
te::edit::VertexTool::m_rtree
te::sam::rtree::Index< VertexIndex, 8 > m_rtree
Definition: VertexTool.h:153
te::edit::VertexTool::VERTEX_MOVING
@ VERTEX_MOVING
Definition: VertexTool.h:90
te::edit::VertexTool::onExtentChanged
void onExtentChanged()
te::edit::VertexTool::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::VertexTool::VertexTool
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.
te::edit::VertexTool::onCommandFeedback
void onCommandFeedback()
te::edit::VertexTool::draw
void draw(te::gm::Point *virtualVertex=0)
te::edit::VertexTool::mouseDoubleClickEvent
bool mouseDoubleClickEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse double click events...
te::edit::VertexTool::mouseReleaseEvent
bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...
te::edit::VertexTool::updateCursor
void updateCursor()
te::edit::VertexTool::m_lines
std::vector< te::gm::LineString * > m_lines
Definition: VertexTool.h:151
te::edit::VertexTool::reset
void reset()
slots
#define slots
Definition: VirtualMachine.h:48
te::edit::VertexTool::FEATURE_SELECTION
@ FEATURE_SELECTION
Definition: VertexTool.h:87
te::edit::VertexTool::resetVisualizationTool
void resetVisualizationTool()
te::edit::VertexTool::pickFeature
void pickFeature(const te::map::AbstractLayerPtr &layer, const te::gm::Envelope &env)
te::edit::VertexTool::storeFeature
void storeFeature()
te::edit::VertexTool::m_fixGeometry
bool m_fixGeometry
Definition: VertexTool.h:156
GeometriesUpdateTool.h
te::edit::VertexIndex
Definition: Utils.h:62
te::edit::GeometriesUpdateTool
Definition: GeometriesUpdateTool.h:60
te::edit::VertexTool::VERTEX_SEARCH
@ VERTEX_SEARCH
Definition: VertexTool.h:88
te::gm::Point
A point with x and y coordinate values.
Definition: Point.h:51