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 #endif
34 #include "../core/command/AddCommand.h"
35 #include "../core/UndoStackManager.h"
36 #include "../Config.h"
37 #include "GeometriesUpdateTool.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  const te::edit::MouseEventEdition mouseEventToSave, 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 
106  void resetVisualizationTool();
107 
108  private:
109 
110  void draw();
111 
112  void drawPolygon();
113 
114  void drawLine();
115 
116  void clear();
117 
118  te::gm::Geometry* buildPolygon();
119 
120  te::gm::Geometry* buildLine();
121 
122  void storeFeature();
123 
124  void storeUndoCommand();
125 
126  private slots:
127 
128  void onExtentChanged();
129 
130  void onUndoFeedback(std::vector<te::gm::Coord2D> coords);
131 
132  protected:
133 
134  std::vector<te::gm::Coord2D> m_coords; //!< The coord list managed by this tool.
135  te::gm::Coord2D m_lastPos; //!< The last position captured on mouse move event.
136  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.
137  bool m_isFinished; //!< A flag that indicates if the operations was finished.
141 
142  };
143 
144  } // end namespace edit
145 } // end namespace te
146 
147 #endif // __TERRALIB_EDIT_QT_INTERNAL_CREATEPOLYGONTOOL_H
bool m_isFinished
A flag that indicates if the operations was finished.
#define TEEDITQTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:60
te::gm::Coord2D m_lastPos
The last position captured on mouse move event.
A widget to control the display of a set of layers.
Definition: MapDisplay.h:69
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
This class implements a concrete tool to create polygons.
MouseEventEdition m_mouseEventToSave
URI C++ Library.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:74
std::vector< te::gm::Coord2D > m_coords
The coord list managed by this tool.
bool m_continuousMode
A flag that indicates if the tool is working in 'continuous mode'. i.e. the coordinates will be acqui...
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
MouseEventEdition
Defines which mouse event will be used in the tool to complete an operation.
Definition: Utils.h:102