All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Scatter.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2013 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 idx-th value of the scatter X axis, as a double.
89 
90  \param idx The index of the element.
91 
92  \return The idx-th value of the scatter X axis, as a double.
93  */
94  double getX(unsigned int idx);
95 
96  /*!
97  \brief It returns a pointer to the first value of the scatter X axis.
98 
99  \return A pointer to the first value of the scatter X axis.
100 
101  \note The caller will not take the ownership of the returned pointer.
102  */
103  double* getX();
104 
105  /*!
106  \brief It returns the idx-th value of the scatter Y axis, as a double.
107 
108  \param idx The index of the element.
109 
110  \return The idx-th value of the scatter Y axis, as a double.
111  */
112  double getY(unsigned int idx);
113 
114  /*!
115  \brief It returns a pointer to the first value of the scatter Y axis.
116 
117  \return A pointer to the first value of the scatter Y axis.
118 
119  \note The caller will not take the ownership of the returned pointer.
120  */
121  double* getY();
122 
123  /*!
124  \brief It returns the minimum value of the X axis.
125 
126  \return The minimum value of the X axis.
127 
128  \note The caller will not have the ownership of the returned pointer.
129  */
130  double getMinX();
131 
132  /*!
133  \brief It returns the maximum value of the X axis.
134 
135  \return The maximum value of the X axis.
136 
137  \note The caller will not have the ownership of the returned pointer.
138  */
139  double getMaxX();
140 
141  /*!
142  \brief It returns the minimum value of the Y axis.
143 
144  \return The minimum value of the Y axis.
145 
146  \note The caller will not have the ownership of the returned pointer.
147  */
148  double getMinY();
149 
150  /*!
151  \brief It returns the maximum value of the Y axis.
152 
153  \return The maximum value of the Y axis.
154 
155  \note The caller will not have the ownership of the returned pointer.
156  */
157  double getMaxY();
158 
159  /*!
160  \brief It sets the minimum value of the X axis.
161  */
162  void setMinX(double& new_minX);
163 
164  /*!
165  \brief It sets the maximum value of the X axis.
166  */
167  void setMaxX(double& new_maxX);
168 
169  /*!
170  \brief It sets the minimum value of the Y axis.
171  */
172  void setMinY(double& new_minY);
173 
174  /*!
175  \brief It sets the maximum value of the Y axis.
176  */
177  void setMaxY(double& maxY);
178 
179  /*!
180  \brief It adds a new value to the vector containing the X axis values.
181 
182  \param xValue The new value to be added to the vector.
183 
184  */
185  void addX(double& xValue);
186 
187  /*!
188  \brief It adds a new value to the vector containing the Y axis values.
189 
190  \param yValue The new value to be added to the vector.
191  */
192  void addY(double& yValue);
193 
194  /*!
195  \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.
196 
197  \param xValue The new x axis value to be added to the vector.
198  \param yValue The new y axis value to be added to the vector.
199  \param oid The ObjectId that will be added to the container
200 
201  \note it will take ownership of the given ObjectId pointer
202  */
203  void addData(double& xValue, double& yValue, te::da::ObjectId* oid);
204 
205  /*!
206  \brief It returns a pointer to an ObjectIdSet that contains all of the scatter's selected points.
207 
208  \param xValue The x axis value to be searched.
209  \param yValue The x axis value to be searched.
210 
211  \note The caller will take ownership of the returned pointer
212  */
213  te::da::ObjectIdSet* find(double& xValue, double& yValue);
214 
215  /*!
216  \brief It returns a pointer to an ObjectIdSet that contains all of the scatter's selected points.
217 
218  \param selectedPoints A vector containing all the points within the selection box
219 
220  \note The caller will take ownership of the returned pointer
221  */
222  te::da::ObjectIdSet* find(std::vector<QPointF> selectedPoints);
223 
224  /*!
225  \brief It returns a pair representing the point that contais the secected ObjectId.
226 
227  \param oid The ObjectId to be searched.
228 
229  */
230  const std::pair<double, double> find(const te::da::ObjectId* oid);
231 
232  private:
233 
234  PointToObjectIdSet m_valuesOids; //!< The intervals and ObjecIds ordered in a boost multi index container
235  std::vector<double> m_xValues; //!< Double values for axis X
236  std::vector<double> m_yValues; //!< Double values for axis Y
237 
238  double m_minX; //!< The minimum value of the x Axis.
239  double m_maxX; //!< The maximum value of the x Axis.
240  double m_minY; //!< The minimum value of the y Axis.
241  double m_maxY; //!< The maximum value of the y Axis.
242  };
243  } // end namespace widgets
244  } // end namespace qt
245 } // end namespace te
246 
247 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_SCATTER_H
248 
std::vector< double > m_yValues
Double values for axis Y.
Definition: Scatter.h:236
This file contains a set of utility scatter functions.
double m_maxX
The maximum value of the x Axis.
Definition: Scatter.h:239
std::vector< double > m_xValues
Double values for axis X.
Definition: Scatter.h:235
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:53
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
PointToObjectIdSet m_valuesOids
The intervals and ObjecIds ordered in a boost multi index container.
Definition: Scatter.h:234
double m_minX
The minimum value of the x Axis.
Definition: Scatter.h:238
double m_minY
The minimum value of the y Axis.
Definition: Scatter.h:240
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:66
double m_maxY
The maximum value of the y Axis.
Definition: Scatter.h:241
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