Loading...
Searching...
No Matches
CreatePolygonTool.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/CreatePolygonTool.h
22
23 \brief This class implements a concrete tool to create polygons.
24*/
25
26#ifndef __TERRALIB_EDIT_QT_INTERNAL_CREATEPOLYGONTOOL_H
27#define __TERRALIB_EDIT_QT_INTERNAL_CREATEPOLYGONTOOL_H
28
29// TerraLib
30#include "../../../geometry/Coord2D.h"
31#ifndef Q_MOC_RUN
32#include "../../../maptools/AbstractLayer.h"
33#include "../core/command/AddCommand.h"
34#include "../core/UndoStackManager.h"
36#endif
37#include "../Config.h"
38
39// STL
40#include <vector>
41
42namespace te
43{
44 namespace gm
45 {
46 class Geometry;
47 }
48
49 namespace qt
50 {
51 namespace widgets
52 {
53 class MapDisplay;
54 }
55 }
56
57 namespace edit
58 {
59 /*!
60 \class CreatePolygonTool
61
62 \brief This class implements a concrete tool to create polygons.
63 */
65 {
66 Q_OBJECT
67
68 public:
69
70 /** @name Initializer Methods
71 * Methods related to instantiation and destruction.
72 */
73 //@{
74
75 /*!
76 \brief It constructs a create polygon tool associated with the given map display.
77
78 \param display The map display associated with the tool.
79 \param parent The tool's parent.
80
81 \note The tool will NOT take the ownership of the given pointers.
82 */
83 CreatePolygonTool(te::qt::widgets::MapDisplay* display, const te::map::AbstractLayerPtr& layer, const QCursor& cursor,
84 bool showVertexes = true, QObject* parent = 0);
85
86 /*! \brief Destructor. */
88
89 //@}
90
91 /** @name AbstractTool Methods
92 * Methods related with tool behavior.
93 */
94 //@{
95
96 bool mousePressEvent(QMouseEvent* e);
97
98 bool mouseMoveEvent(QMouseEvent* e);
99
100 bool mouseDoubleClickEvent(QMouseEvent* e);
101
102 bool mouseReleaseEvent(QMouseEvent* e);
103
104 //@}
105
107
108 private:
109
110 void draw(bool closeGeometry);
111
113
114 void drawLine();
115
116 void clear();
117
119
121
123
125
127
128 private slots:
129
131
133
134 protected:
135
136 std::vector<te::gm::Coord2D> m_coords; //!< The coord list managed by this tool.
137 te::gm::Coord2D m_lastPos; //!< The last position captured on mouse move event.
138 bool m_continuousMode; //!< A flag that indicates if the tool is working in 'continuous mode'. i.e. the coordinates will be acquired from each mouseMove.
139 bool m_isFinished; //!< A flag that indicates if the operations was finished.
140 bool m_showVertexes; //!< A flag that indicates whether the tool will display the vertices.
142
143 };
144
145 } // end namespace edit
146} // end namespace te
147
148#endif // __TERRALIB_EDIT_QT_INTERNAL_CREATEPOLYGONTOOL_H
This class implements a concrete tool to create polygons.
void draw(bool closeGeometry)
bool mouseMoveEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse move events for the...
te::gm::Geometry * buildLine()
bool m_isFinished
A flag that indicates if the operations was finished.
bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...
std::vector< te::gm::Coord2D > m_coords
The coord list managed by this tool.
bool mouseDoubleClickEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse double click events...
bool m_showVertexes
A flag that indicates whether the tool will display the vertices.
te::gm::Coord2D m_lastPos
The last position captured on mouse move event.
te::gm::Geometry * buildPolygon()
CreatePolygonTool(te::qt::widgets::MapDisplay *display, const te::map::AbstractLayerPtr &layer, const QCursor &cursor, bool showVertexes=true, QObject *parent=0)
It constructs a create polygon tool associated with the given map display.
bool m_continuousMode
A flag that indicates if the tool is working in 'continuous mode'. i.e. the coordinates will be acqui...
bool mousePressEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse press events for th...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
A widget to control the display of a set of layers.
Definition: MapDisplay.h:72
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TerraLib.
#define slots
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:41
#define TEEDITQTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60