All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #include "../../../maptools/AbstractLayer.h"
32 #include "../../../qt/widgets/tools/AbstractTool.h"
33 #include "../Config.h"
34 
35 // STL
36 #include <vector>
37 
38 namespace te
39 {
40  namespace gm
41  {
42  class Geometry;
43  }
44 
45  namespace qt
46  {
47  namespace widgets
48  {
49  class MapDisplay;
50  }
51  }
52 
53  namespace edit
54  {
55  /*!
56  \class CreatePolygonTool
57 
58  \brief This class implements a concrete tool to create polygons.
59  */
61  {
62  Q_OBJECT
63 
64  public:
65 
66  /** @name Initializer Methods
67  * Methods related to instantiation and destruction.
68  */
69  //@{
70 
71  /*!
72  \brief It constructs a create polygon tool associated with the given map display.
73 
74  \param display The map display associated with the tool.
75  \param parent The tool's parent.
76 
77  \note The tool will NOT take the ownership of the given pointers.
78  */
79  CreatePolygonTool(te::qt::widgets::MapDisplay* display, const te::map::AbstractLayerPtr& layer, const QCursor& cursor, QObject* parent = 0);
80 
81  /*! \brief Destructor. */
83 
84  //@}
85 
86  /** @name AbstractTool Methods
87  * Methods related with tool behavior.
88  */
89  //@{
90 
91  bool mousePressEvent(QMouseEvent* e);
92 
93  bool mouseMoveEvent(QMouseEvent* e);
94 
95  bool mouseReleaseEvent(QMouseEvent* e);
96 
97  bool mouseDoubleClickEvent(QMouseEvent* e);
98 
99  //@}
100 
101  private:
102 
103  void draw();
104 
105  void drawPolygon();
106 
107  void drawLine();
108 
109  void clear();
110 
111  te::gm::Geometry* buildPolygon();
112 
113  te::gm::Geometry* buildLine();
114 
115  void storeNewGeometry();
116 
117  private slots:
118 
119  void onExtentChanged();
120 
121  protected:
122 
123  te::map::AbstractLayerPtr m_layer; //!< The layer used by this tool.
124  std::vector<te::gm::Coord2D> m_coords; //!< The coord list managed by this tool.
125  te::gm::Coord2D m_lastPos; //!< The last position captured on mouse move event.
126  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.
127  bool m_isFinished; //!< A flag that indicates if the operations was finished.
128  };
129 
130  } // end namespace edit
131 } // end namespace te
132 
133 #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:63
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:66
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
This class defines an interface for objects that can receive application events and respond to them...
Definition: AbstractTool.h:62
This class implements a concrete tool to create polygons.
te::map::AbstractLayerPtr m_layer
The layer used by this tool.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
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