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"
35 #include "GeometriesUpdateTool.h"
36 #endif
37 #include "../Config.h"
38 
39 // STL
40 #include <vector>
41 
42 namespace 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 
112  void drawPolygon();
113 
114  void drawLine();
115 
116  void clear();
117 
119 
121 
123 
125 
126  void storeFeature();
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
te::edit::CreatePolygonTool::mouseReleaseEvent
bool mouseReleaseEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse release events for ...
te::edit::CreatePolygonTool::onExtentChanged
void onExtentChanged()
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::edit::CreatePolygonTool::resetVisualizationTool
void resetVisualizationTool()
te::edit::CreatePolygonTool::editingFinished
bool editingFinished()
te::edit::CreatePolygonTool::CreatePolygonTool
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.
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::CreatePolygonTool::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::CreatePolygonTool::~CreatePolygonTool
~CreatePolygonTool()
Destructor.
te::edit::CreatePolygonTool::drawPolygon
void drawPolygon()
te::edit::CreatePolygonTool::drawLine
void drawLine()
te::edit::UndoStackManager
Definition: UndoStackManager.h:50
te::edit::CreatePolygonTool::mouseDoubleClickEvent
bool mouseDoubleClickEvent(QMouseEvent *e)
This event handler can be reimplemented in a concrete tool class to receive mouse double click events...
te::edit::CreatePolygonTool::m_continuousMode
bool m_continuousMode
A flag that indicates if the tool is working in 'continuous mode'. i.e. the coordinates will be acqui...
Definition: CreatePolygonTool.h:138
slots
#define slots
Definition: VirtualMachine.h:48
te::edit::CreatePolygonTool::m_stack
UndoStackManager & m_stack
Definition: CreatePolygonTool.h:141
te::edit::CreatePolygonTool
This class implements a concrete tool to create polygons.
Definition: CreatePolygonTool.h:65
te::edit::CreatePolygonTool::buildPolygon
te::gm::Geometry * buildPolygon()
te::edit::CreatePolygonTool::onCommandFeedback
void onCommandFeedback()
te::edit::CreatePolygonTool::storeFeature
void storeFeature()
te::edit::CreatePolygonTool::m_isFinished
bool m_isFinished
A flag that indicates if the operations was finished.
Definition: CreatePolygonTool.h:139
te::gm::Coord2D
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:41
GeometriesUpdateTool.h
te::edit::CreatePolygonTool::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::CreatePolygonTool::storeUndoCommand
void storeUndoCommand()
te::edit::CreatePolygonTool::buildLine
te::gm::Geometry * buildLine()
te::edit::GeometriesUpdateTool
Definition: GeometriesUpdateTool.h:60
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
te::edit::CreatePolygonTool::m_showVertexes
bool m_showVertexes
A flag that indicates whether the tool will display the vertices.
Definition: CreatePolygonTool.h:140
te::edit::CreatePolygonTool::clear
void clear()
te::edit::CreatePolygonTool::m_coords
std::vector< te::gm::Coord2D > m_coords
The coord list managed by this tool.
Definition: CreatePolygonTool.h:136
te::edit::CreatePolygonTool::m_lastPos
te::gm::Coord2D m_lastPos
The last position captured on mouse move event.
Definition: CreatePolygonTool.h:137
te::edit::CreatePolygonTool::draw
void draw(bool closeGeometry)