All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Histogram.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/Histogram.h
22 
23  \brief A class to represent a histogram.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_HISTOGRAM_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_HISTOGRAM_H
28 
29 //TerraLib
30 #include "../Config.h"
31 #include "HistogramUtils.h"
32 
33 //STL
34 #include <map>
35 #include <set>
36 #include <string>
37 #include <vector>
38 
39 namespace te
40 {
41 
42  namespace da { class ObjectId; class ObjectIdSet;}
43  namespace dt { class AbstractData; }
44 
45  namespace qt
46  {
47  namespace widgets
48  {
49  /*!
50  \class Histogram
51 
52  \brief A class to represent a Histogram.
53 
54  \ingroup widgets
55  */
57  {
58  public:
59 
60  /*!
61  \brief Constructor
62  */
63  Histogram();
64 
65  /*!
66  \brief Destructor.
67  */
68  ~Histogram();
69 
70  /*!
71  \brief It returns the histogram's type.
72 
73  \return And int that represents the histogram's type.
74  */
75  int& getType();
76 
77  /*!
78  \brief It sets the histogram's type.
79 
80  \param new_type The new type
81  */
82  void setType(int new_type);
83 
84  /*!
85  \brief It returns the map containing the histogram values.
86  The key is the minimum values of the histogram's interval, and the unsigned int is the frequency of that interval.
87 
88  \return A map containing the histogram values.
89  */
90  std::map<double, unsigned int> getValues();
91 
92  /*!
93  \brief It returns the map containing the histogram String values.
94  The key is a unique string that represents an interval and the unsigned int is the frequency of that interval.
95 
96  \return A map containing the histogram values.
97  */
98  std::map<std::string, unsigned int> getStringValues();
99 
100  /*!
101  \brief It returns the histogram's minimum value.
102  Will be invalid if the histogram was created based on string intervals.
103 
104  \return The histogram's minimum value.
105  */
106  double& getMinValue();
107 
108  /*!
109  \brief It sets the histogram's minimum value.
110 
111  \param new_minValue The new minimum value.
112  */
113  void setMinValue(double new_minValue);
114 
115  /*!
116  \brief It returns the histogram's interval.
117  Will be invalid if the histogram was created based on string intervals.
118 
119  \return The histogram's interval.
120  */
121  double& getInterval();
122 
123  /*!
124  \brief It sets the histogram's interval.
125 
126  \param new_values The new histogram's interval.
127  */
128  void setInterval(double new_Interval);
129 
130  /*!
131  \brief It returns the histogram's string set of intervals.
132  Will be invalid if the histogram was created based on numeric (double, float, etc) intervals.
133 
134  \return The histogram's interval.
135  */
136  std::set <std::string>& getStringInterval();
137 
138  /*!
139  \brief It sets the histogram's string set of intervals.
140 
141  \param new_values The new histogram's interval.
142  */
143  void setStringInterval( std::set <std::string> new_Interval);
144 
145  /*!
146  \brief It adds a new value to the map containing the histogram values.
147 
148  \param new_value The value that will be added. The AbstractData represents the interval and the unsigned int represents that interval's frequency.
149  \param valuesOIds A vector containing all the ObjectIds contained by the interval
150 
151  \note It will take the ownwership of the given pointers
152  */
153  void insert (std::pair<te::dt::AbstractData*, unsigned int> new_value, std::vector<te::da::ObjectId*> valuesOIds);
154 
155  /*!
156  \brief It adds a new value to the map containing the histogram values.
157  The AbstractData represents the interval and the unsigned int represents that interval's frequency.
158 
159  \param new_value The value that will be added.
160  */
161  void insert(std::pair<te::dt::AbstractData*, unsigned int> new_value);
162 
163  /*!
164  \brief It adds a new value to the map containing the histogram values.
165 
166  \param interval The AbstractData that represents the interval and the unsigned int wil represent that intervals frequency.
167  \param frequency The unsigned int that represents that interval's frequency.
168  \param valuesOIds A vector containing all the ObjectIds contained by the interval
169 
170  \note It will take the ownwership of the given pointers
171  */
172  void insert (te::dt::AbstractData* interval, unsigned int frequency, std::vector<te::da::ObjectId*> valuesOIds);
173 
174  /*!
175  \brief It adds a new value to the map containing the histogram values.
176  The AbstractData will represent the interval and the unsigned int wil represent that intervals frequency.
177 
178  \param interval The AbstractData that represents the interval and the unsigned int wil represent that intervals frequency.
179  \param frequency The unsigned int that represents that interval's frequency.
180  */
181  void insert(te::dt::AbstractData* interval, unsigned int frequency);
182 
183  /*!
184  \brief It returns an ObjectIdSet containing all the object Ids associeted with the given interval.
185 
186  \param interval The interval that will be searched.
187  \note it can return an empty ObjectIdSet if none ObjectIds were found. (f.e. if the user clicks on an empty area of the chart)
188  \note The caller will take ownership of the returned pointer
189  */
190  te::da::ObjectIdSet* find(te::dt::AbstractData* interval);
191 
192  /*!
193  \brief It returns an AbstractData representing the interval that contains the given ObjectId
194 
195  \param oid The ObjectId that will be searched.
196  */
197  const te::dt::AbstractData* find(const te::da::ObjectId* oid);
198 
199  /*!
200  \brief It will populate the IntervalToObjectIdSet with the given interval and it's matching objectIds.
201 
202  \param interval The interval that contains the given objectIds.
203  \param valuesOIds The vector containing the ObjectIds related to the given interval
204  */
205  void adjustOids(te::dt::AbstractData* interval, std::vector<te::da::ObjectId*> valuesOIds);
206 
207  private:
208 
209  int m_histogramType; //!< Histogram's type
210  HistogramValues m_values; //!< Histogram's values;
211  double m_minValue; //!< Histogram's minimum numeric value
212  double m_interval; //!< Histogram's numeric interval
213  std::set <std::string> m_StringIntervals; //!< Histogram unique strings set, represents string intervals
214  IntervalToObjectIdSet m_valuesOids; //!< The intervals and ObjecIds ordered in a boost multi index container
215  };
216  } // end namespace widgets
217  } // end namespace qt
218 } // end namespace te
219 
220 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_HISTOGRAM_H
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:101
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:53
boost::multi_index::multi_index_container< IntervalToObjectId, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< boost::multi_index::identity< IntervalToObjectId > >, boost::multi_index::ordered_unique< boost::multi_index::const_mem_fun< IntervalToObjectId, std::string,&IntervalToObjectId::getObjIdAsString > > > > IntervalToObjectIdSet
A class to represent a Histogram.
Definition: Histogram.h:56
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
IntervalToObjectIdSet m_valuesOids
The intervals and ObjecIds ordered in a boost multi index container.
Definition: Histogram.h:214
This file contains a set of utility histogram functions.
HistogramValues m_values
Histogram&#39;s values;.
Definition: Histogram.h:210
std::set< std::string > m_StringIntervals
Histogram unique strings set, represents string intervals.
Definition: Histogram.h:213
int m_histogramType
Histogram&#39;s type.
Definition: Histogram.h:209
std::map< te::dt::AbstractData *, unsigned int, CompareHistogramInterval > HistogramValues
Histogram&#39;s values.
double m_interval
Histogram&#39;s numeric interval.
Definition: Histogram.h:212
This class represents an unique id for a data set element.
Definition: ObjectId.h:47
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
double m_minValue
Histogram&#39;s minimum numeric value.
Definition: Histogram.h:211