Grid.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 canvas/Grid.h
22  *
23  * \brief Contains an implementation of a grid.
24  */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_GRID_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_GRID_H
28 
29 //TerraLib
30 #include "../Config.h"
31 
32 // Qt
33 #include <QFrame>
34 
35 // STL
36 #include <vector>
37 
38 // Forward Declarations
39 class QPixmap;
40 
41 namespace te
42 {
43  namespace gm
44  {
45  // Forward Declarations
46  class LineString;
47  }
48 
49  namespace qt
50  {
51  namespace widgets
52  {
53  // Forward declaration
54  class MapDisplay;
55 
56  /*!
57  * \enum GridTypes
58  *
59  * \brief Defines the types of grid that can be used.
60  */
61  enum GridTypes
62  {
63  PLANAR, //!< Planar grid.
64  GEOGRAPHIC //!< Geographic grid.
65  };
66 
67  /*!
68  * \class Grid
69  *
70  * \brief This class implements the grid, planar or geographic, to be used with the MapDisplay
71  *
72  * \ingroup widgets
73  */
74  class TEQTWIDGETSEXPORT Grid : public QFrame
75  {
76  Q_OBJECT
77 
78  public:
79 
80  /** @name Constructor and destructor methods.
81  * Methods related to instantiation and destruction.
82  */
83  //@{
84 
85  /*!
86  * \brief Constructor.
87  *
88  * \param parent The display over what the scale will reflect.
89  */
90  Grid(MapDisplay* parent);
91 
92  /*!
93  * \brief Destuctor.
94  */
95  ~Grid();
96  //@}
97 
98  /** @name Public methods
99  * Methods to access the internal attributes of the class.
100  */
101  //@{
102 
103  /*!
104  * \brief Returns the current color being used.
105  *
106  * \return The current color of the grid and texts.
107  */
108  QColor getColor() const;
109 
110  /*!
111  * \brief Returns the current font being used.
112  *
113  * \return The current font of the texts.
114  */
115  QFont getFont() const;
116 
117  /*!
118  * \brief Returns the current type of grid being used.
119  *
120  * \return The current type of grid being used.
121  *
122  * \sa GridTypes
123  */
124  int getType() const;
125  //@}
126 
127  public slots:
128 
129  /** @name Public slots.
130  * Methods to update the internal attributes of the class, using the signal-slot mechanism of QT.
131  */
132  //@{
133 
134  /*!
135  * \brief Updates the color of the lines and texts.
136  *
137  * \param color The new color to be used.
138  */
139  void setColor(const QColor& color);
140 
141  /*!
142  * \brief Updates the font of the texts.
143  *
144  * \param font New font to be used.
145  */
146  void setFont(const QFont& font);
147 
148  /*!
149  * \brief Updates the type of grid: planar or geographic.
150  * \param type The new type.
151  */
152  void setGridType(const int& type);
153 
154  /*!
155  * \brief Refresh the grid image. This method MUST BE called when the area of visualization changes in MapDisplay.
156  */
157  void redraw();
158  //@}
159 
160  signals:
161 
162  /** @name Signals
163  * Signals emmited by the widget.
164  */
165  //@{
166 
167  /*!
168  * Signal emmited when the widget is about to be closed.
169  */
170  void aboutToBeclosed();
171  //@}
172 
173  /** @name Protected methods
174  * Methods used internally by the object.
175  */
176  //@{
177 
178  protected:
179  /*!
180  * \brief Initializes the object.
181  */
182  void initialize();
183 
184  /*!
185  * \brief Builds the planar grid.
186  */
187  void makePlanarGrid();
188 
189  /*!
190  * \brief Builds the geographic grid.
191  */
192  void makeGeographicGrid();
193 
194  /*!
195  * \brief Reimplementation of the QFrame method.
196  *
197  * \param event The event generated.
198  */
199  void paintEvent(QPaintEvent* event);
200 
201  /*!
202  * \brief Reimplementation of the QFrame method.
203  *
204  * \param event The event generated.
205  */
206  void closeEvent(QCloseEvent *event);
207  //@}
208 
209  MapDisplay* m_display; //!< Pointer to a MapDisplay.
210  int m_maxGap; //!< Maximum number of lines to be presented on the grid.
211  double m_verticalGap; //!< Distance between lines in y-axis.
212  double m_horizontalGap; //!< Distance between lines in x-axis.
213  double m_initialX; //!< Initial coordinate in x-axis.
214  double m_initialY; //!< Initial coordinate in y-axis.
215  QPixmap* m_backGround; //!< Pixmap with the grid image.
216  std::vector<te::gm::LineString> m_hlines; //!< Grid lines.
217  std::vector<te::gm::LineString> m_vlines; //!< Grid lines.
218  int m_srid; //!< SRID being used to reproject the world box to a planar coordinate system.
219  int m_geoSrid; //!< Geographic SRID being used to reproject the world box to a geographic coordinate system.
220  QColor m_color; //!< Color to be used.
221  QFont m_font; //!< Font to be used.
222  GridTypes m_type; //!< Type of the grid (planar or geographic).
223  };
224  }
225  }
226 }
227 
228 #endif //__TERRALIB_QT_WIDGETS_INTERNAL_GRID_H
#define slots
Planar grid.
Definition: Grid.h:63
int m_geoSrid
Geographic SRID being used to reproject the world box to a geographic coordinate system.
Definition: Grid.h:219
int m_srid
SRID being used to reproject the world box to a planar coordinate system.
Definition: Grid.h:218
MapDisplay * m_display
Pointer to a MapDisplay.
Definition: Grid.h:209
Geographic grid.
Definition: Grid.h:64
QFont m_font
Font to be used.
Definition: Grid.h:221
A widget to control the display of a set of layers.
Definition: MapDisplay.h:71
double m_initialY
Initial coordinate in y-axis.
Definition: Grid.h:214
double m_horizontalGap
Distance between lines in x-axis.
Definition: Grid.h:212
QPixmap * m_backGround
Pixmap with the grid image.
Definition: Grid.h:215
URI C++ Library.
QColor m_color
Color to be used.
Definition: Grid.h:220
GridTypes
Defines the types of grid that can be used.
Definition: Grid.h:61
This class implements the grid, planar or geographic, to be used with the MapDisplay.
Definition: Grid.h:74
GridTypes m_type
Type of the grid (planar or geographic).
Definition: Grid.h:222
std::vector< te::gm::LineString > m_hlines
Grid lines.
Definition: Grid.h:216
std::vector< te::gm::LineString > m_vlines
Grid lines.
Definition: Grid.h:217
double m_verticalGap
Distance between lines in y-axis.
Definition: Grid.h:211
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
double m_initialX
Initial coordinate in x-axis.
Definition: Grid.h:213
int m_maxGap
Maximum number of lines to be presented on the grid.
Definition: Grid.h:210