Scatter.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/qt/widgets/charts/Scatter.h
22 
23  \brief A class to represent a scatter.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_SCATTER_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_SCATTER_H
28 
29 //TerraLib
30 #include "../Config.h"
31 #include "ScatterUtils.h"
32 
33 #include <QPointF>
34 
35 namespace te
36 {
37  // Forward declarations
38  namespace da { class ObjectIdSet;}
39 
40  namespace qt
41  {
42  namespace widgets
43  {
44  /*!
45  \class Scatter
46 
47  \brief A class to represent a scatter.
48 
49  \ingroup widgets
50  */
52  {
53  public:
54 
55  /*!
56  \brief Constructor
57  */
58  Scatter(const std::vector<double>& axisX, const std::vector<double>& axisY);
59 
60  /*!
61  \brief Constructor
62  */
63  Scatter();
64 
65  /*! \brief Destructor. */
66  ~Scatter();
67 
68  /*!
69  \brief Calculates the minimum and maximum values for both the X and Y axis
70  */
71  void calculateMinMaxValues();
72 
73  /*!
74  \brief It returns the size of the scatter.
75 
76  \return The number of the scatter elements on the X axis.
77  */
78  std::size_t sizeX();
79 
80  /*!
81  \brief It returns the size of the scatter.
82 
83  \return The number of the scatter elements on the Y axis.
84  */
85  std::size_t sizeY();
86 
87  /*!
88  \brief It returns the vector containing the values of the scatter X axis.
89 
90  \return A vector containing the values of the scatter X axis.
91 
92  */
93  std::vector<double> getXValues();
94 
95  /*!
96  \brief It returns the idx-th value of the scatter X axis, as a double.
97 
98  \param idx The index of the element.
99 
100  \return The idx-th value of the scatter X axis, as a double.
101  */
102  double getX(unsigned int idx);
103 
104  /*!
105  \brief It returns a pointer to the first value of the scatter X axis.
106 
107  \return A pointer to the first value of the scatter X axis.
108 
109  \note The caller will not take the ownership of the returned pointer.
110  */
111  double* getX();
112 
113  /*!
114  \brief It returns the vector containing the values of the scatter Y axis.
115 
116  \return A vector containing the values of the scatter Y axis.
117 
118  */
119  std::vector<double> getYValues();
120 
121  /*!
122  \brief It returns the idx-th value of the scatter Y axis, as a double.
123 
124  \param idx The index of the element.
125 
126  \return The idx-th value of the scatter Y axis, as a double.
127  */
128  double getY(unsigned int idx);
129 
130  /*!
131  \brief It returns a pointer to the first value of the scatter Y axis.
132 
133  \return A pointer to the first value of the scatter Y axis.
134 
135  \note The caller will not take the ownership of the returned pointer.
136  */
137  double* getY();
138 
139  /*!
140  \brief It returns the minimum value of the X axis.
141 
142  \return The minimum value of the X axis.
143 
144  \note The caller will not have the ownership of the returned pointer.
145  */
146  double getMinX();
147 
148  /*!
149  \brief It returns the maximum value of the X axis.
150 
151  \return The maximum value of the X axis.
152 
153  \note The caller will not have the ownership of the returned pointer.
154  */
155  double getMaxX();
156 
157  /*!
158  \brief It returns the minimum value of the Y axis.
159 
160  \return The minimum value of the Y axis.
161 
162  \note The caller will not have the ownership of the returned pointer.
163  */
164  double getMinY();
165 
166  /*!
167  \brief It returns the maximum value of the Y axis.
168 
169  \return The maximum value of the Y axis.
170 
171  \note The caller will not have the ownership of the returned pointer.
172  */
173  double getMaxY();
174 
175  /*!
176  \brief It sets the values of the X axis.
177 
178  \param xValues The vector containing the new values.
179  */
180  void setXValues(std::vector<double> xValues);
181 
182  /*!
183  \brief It sets the minimum value of the X axis.
184  */
185  void setMinX(double& new_minX);
186 
187  /*!
188  \brief It sets the maximum value of the X axis.
189  */
190  void setMaxX(double& new_maxX);
191 
192  /*!
193  \brief It sets the values of the Y axis.
194 
195  \param yValues The vector containing the new values.
196  */
197  void setYValues(std::vector<double> yValues);
198 
199  /*!
200  \brief It sets the minimum value of the Y axis.
201  */
202  void setMinY(double& new_minY);
203 
204  /*!
205  \brief It sets the maximum value of the Y axis.
206  */
207  void setMaxY(double& maxY);
208 
209  /*!
210  \brief It adds a new value to the vector containing the X axis values.
211 
212  \param xValue The new value to be added to the vector.
213 
214  */
215  void addX(double& xValue);
216 
217  /*!
218  \brief It adds a new value to the vector containing the Y axis values.
219 
220  \param yValue The new value to be added to the vector.
221  */
222  void addY(double& yValue);
223 
224  /*!
225  \brief It adds the x and Y axis values to the scatter's vectors and the associeted objectId to the scatter's multi_index container.
226 
227  \param xValue The new x axis value to be added to the vector.
228  \param yValue The new y axis value to be added to the vector.
229  \param oid The ObjectId that will be added to the container
230 
231  \note it will take ownership of the given ObjectId pointer
232  */
233  void addData(double& xValue, double& yValue, te::da::ObjectId* oid);
234 
235  /*!
236  \brief It returns a pointer to an ObjectIdSet that contains all of the scatter's selected points.
237 
238  \param xValue The x axis value to be searched.
239  \param yValue The x axis value to be searched.
240 
241  \note The caller will take ownership of the returned pointer
242  */
243  te::da::ObjectIdSet* find(double& xValue, double& yValue);
244 
245  /*!
246  \brief It returns a pointer to an ObjectIdSet that contains all of the scatter's selected points.
247 
248  \param selectedPoints A vector containing all the points within the selection box
249 
250  \note The caller will take ownership of the returned pointer
251  */
252  te::da::ObjectIdSet* find(std::vector<QPointF> selectedPoints);
253 
254  /*!
255  \brief It returns a pair representing the point that contais the secected ObjectId.
256 
257  \param oid The ObjectId to be searched.
258  \note Returns NULL if no matching point was found
259  */
260  const std::pair<double, double> find(const te::da::ObjectId* oid);
261 
262  private:
263 
264  PointToObjectIdSet m_valuesOids; //!< The points and ObjecIds ordered in a boost multi index container
265  std::vector<double> m_xValues; //!< Double values for axis X
266  std::vector<double> m_yValues; //!< Double values for axis Y
267 
268  double m_minX; //!< The minimum value of the x Axis.
269  double m_maxX; //!< The maximum value of the x Axis.
270  double m_minY; //!< The minimum value of the y Axis.
271  double m_maxY; //!< The maximum value of the y Axis.
272  };
273  } // end namespace widgets
274  } // end namespace qt
275 } // end namespace te
276 
277 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_SCATTER_H
278 
std::vector< double > m_yValues
Double values for axis Y.
Definition: Scatter.h:266
This file contains a set of utility scatter functions.
double m_maxX
The maximum value of the x Axis.
Definition: Scatter.h:269
std::vector< double > m_xValues
Double values for axis X.
Definition: Scatter.h:265
A class to represent a scatter.
Definition: Scatter.h:51
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
URI C++ Library.
PointToObjectIdSet m_valuesOids
The points and ObjecIds ordered in a boost multi index container.
Definition: Scatter.h:264
double m_minX
The minimum value of the x Axis.
Definition: Scatter.h:268
double m_minY
The minimum value of the y Axis.
Definition: Scatter.h:270
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
double m_maxY
The maximum value of the y Axis.
Definition: Scatter.h:271
boost::multi_index::multi_index_container< PointToObjectId, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::identity< PointToObjectId > >, boost::multi_index::ordered_unique< boost::multi_index::const_mem_fun< PointToObjectId, std::string,&PointToObjectId::getObjIdAsString > > > > PointToObjectIdSet
Definition: ScatterUtils.h:85