Loading...
Searching...
No Matches
Histogram.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/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
39namespace 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 */
64
65 /*!
66 \brief Destructor.
67 */
69
70 /*!
71 \brief It returns the histogram's type.
72
73 \return An 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 a boolean that holds whether the histogram has been created from summarized values or not
86
87 \return A boolean that holds whether the histogram has been created from summarized values or not
88 */
90
91 /*!
92 \brief It sets the property that holds whether the histogram has been created from summarized values or not
93
94 \param summarized A boolean that holds whether the histogram has been created from summarized values or not
95 */
96 void setSummarized(bool summarized);
97
98 /*!
99 \brief It returns the map containing the histogram values.
100 The key is the minimum values of the histogram's interval, and the unsigned int is the frequency of that interval.
101
102 \return A map containing the histogram values.
103 */
104 std::map<double, unsigned int> getValues();
105
106 /*!
107 \brief It sets the histogram's values.
108
109 \param values The new values.
110 /note Any current data will be lost.
111 /noter The ObjectIds will have to be manually adjusted later.
112 */
113 void setValues(std::map<te::dt::AbstractData*, unsigned int> values);
114
115 /*!
116 \brief It returns the map containing the histogram String values.
117 The key is a unique string that represents an interval and the unsigned int is the frequency of that interval.
118
119 \return A map containing the histogram values.
120 */
121 std::map<std::string, unsigned int> getStringValues();
122
123 /*!
124 \brief It returns the histogram's minimum value.
125 Will be invalid if the histogram was created based on string intervals.
126
127 \return The histogram's minimum value.
128 */
129 double& getMinValue();
130
131 /*!
132 \brief It sets the histogram's minimum value.
133
134 \param new_minValue The new minimum value.
135 */
136 void setMinValue(double new_minValue);
137
138 /*!
139 \brief It returns the histogram's interval.
140 Will be invalid if the histogram was created based on string intervals.
141
142 \return The histogram's interval.
143 */
144 double& getInterval();
145
146 /*!
147 \brief It sets the histogram's interval.
148
149 \param new_values The new histogram's interval.
150 */
151 void setInterval(double new_Interval);
152
153 /*!
154 \brief It returns the histogram's string set of intervals.
155 Will be invalid if the histogram was created based on numeric (double, float, etc) intervals.
156
157 \return The histogram's interval.
158 */
159 std::set <std::string>& getStringInterval();
160
161 /*!
162 \brief It sets the histogram's string set of intervals.
163
164 \param new_values The new histogram's interval.
165 */
166 void setStringInterval( std::set <std::string> new_Interval);
167
168 /*!
169 \brief It adds a new value to the map containing the histogram values.
170
171 \param new_value The value that will be added. The AbstractData represents the interval and the unsigned int represents that interval's frequency.
172 \param valuesOIds A vector containing all the ObjectIds contained by the interval
173
174 \note It will take the ownwership of the given pointers
175 */
176 void insert (std::pair<te::dt::AbstractData*, unsigned int> new_value, std::vector<te::da::ObjectId*> valuesOIds);
177
178 /*!
179 \brief It adds a new value to the map containing the histogram values.
180 The AbstractData represents the interval and the unsigned int represents that interval's frequency.
181
182 \param new_value The value that will be added.
183 */
184 void insert(std::pair<te::dt::AbstractData*, unsigned int> new_value);
185
186 /*!
187 \brief It adds a new value to the map containing the histogram values.
188
189 \param interval The AbstractData that represents the interval and the unsigned int wil represent that intervals frequency.
190 \param frequency The unsigned int that represents that interval's frequency.
191 \param valuesOIds A vector containing all the ObjectIds contained by the interval
192
193 \note It will take the ownwership of the given pointers
194 */
195 void insert (te::dt::AbstractData* interval, unsigned int frequency, std::vector<te::da::ObjectId*> valuesOIds);
196
197 /*!
198 \brief It adds a new value to the map containing the histogram values.
199 The AbstractData will represent the interval and the unsigned int wil represent that intervals frequency.
200
201 \param interval The AbstractData that represents the interval and the unsigned int wil represent that intervals frequency.
202 \param frequency The unsigned int that represents that interval's frequency.
203 */
204 void insert(te::dt::AbstractData* interval, unsigned int frequency);
205
206 /*!
207 \brief A function used to clear the contents of the histogram, deleting the pointers contained by the boost containers used to store the histogram's data.
208 */
209 void clear();
210
211 /*!
212 \brief It returns an ObjectIdSet containing all the object Ids associeted with the given interval.
213
214 \param interval The interval that will be searched.
215 \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)
216 \note The caller will take ownership of the returned pointer
217 */
219
220 /*!
221 \brief It returns an ObjectIdSet containing all the object Ids associeted with the given interval list.
222
223 \param intervals A vector containing all the intervals within the selection box
224
225 \return An ObjectIdSet containing all the selected object Ids
226
227 \note The caller will take ownership of the returned pointer
228 \note It will take ownership of the given pointers
229 */
230 te::da::ObjectIdSet* find(std::vector<te::dt::AbstractData*> intervals);
231
232 /*!
233 \brief It returns an AbstractData representing the interval that contains the given ObjectId
234
235 \param oid The ObjectId that will be searched.
236 \note Returns NULL if no matching interval was found
237 */
239
240 /*!
241 \brief It will populate the IntervalToObjectIdSet with the given interval and it's matching objectIds.
242
243 \param interval The interval that contains the given objectIds.
244 \param valuesOIds The vector containing the ObjectIds related to the given interval
245 */
246 void adjustOids(te::dt::AbstractData* interval, std::vector<te::da::ObjectId*> valuesOIds);
247
248 private:
249
250 bool m_isSummarized; //!< This property holds whether the histogram has been created from summarized values or not
251 int m_histogramType; //!< Histogram's type
252 double m_minValue; //!< Histogram's minimum numeric value
253 double m_interval; //!< Histogram's numeric interval
254 std::set <std::string> m_StringIntervals; //!< Histogram unique strings set, represents string intervals
255 HistogramValues m_values; //!< Histogram's values;
256 IntervalToObjectIdSet m_valuesOids; //!< The intervals and ObjecIds ordered in a boost multi index container
257 };
258 } // end namespace widgets
259 } // end namespace qt
260} // end namespace te
261
262#endif // __TERRALIB_QT_WIDGETS_INTERNAL_HISTOGRAM_H
This file contains a set of utility histogram functions.
This class represents a set of unique ids created in the same context. i.e. from the same data set.
Definition: ObjectIdSet.h:56
This class represents an unique id for a data set element.
Definition: ObjectId.h:48
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:56
A class to represent a Histogram.
Definition: Histogram.h:57
void insert(te::dt::AbstractData *interval, unsigned int frequency, std::vector< te::da::ObjectId * > valuesOIds)
It adds a new value to the map containing the histogram values.
HistogramValues m_values
Histogram's values;.
Definition: Histogram.h:255
std::set< std::string > m_StringIntervals
Histogram unique strings set, represents string intervals.
Definition: Histogram.h:254
std::map< std::string, unsigned int > getStringValues()
It returns the map containing the histogram String values. The key is a unique string that represents...
void setStringInterval(std::set< std::string > new_Interval)
It sets the histogram's string set of intervals.
void setInterval(double new_Interval)
It sets the histogram's interval.
double m_minValue
Histogram's minimum numeric value.
Definition: Histogram.h:252
bool m_isSummarized
This property holds whether the histogram has been created from summarized values or not.
Definition: Histogram.h:250
void insert(te::dt::AbstractData *interval, unsigned int frequency)
It adds a new value to the map containing the histogram values. The AbstractData will represent the i...
std::set< std::string > & getStringInterval()
It returns the histogram's string set of intervals. Will be invalid if the histogram was created base...
int & getType()
It returns the histogram's type.
double & getMinValue()
It returns the histogram's minimum value. Will be invalid if the histogram was created based on strin...
void setValues(std::map< te::dt::AbstractData *, unsigned int > values)
It sets the histogram's values.
void setSummarized(bool summarized)
It sets the property that holds whether the histogram has been created from summarized values or not.
te::da::ObjectIdSet * find(std::vector< te::dt::AbstractData * > intervals)
It returns an ObjectIdSet containing all the object Ids associeted with the given interval list.
const te::dt::AbstractData * find(const te::da::ObjectId *oid)
It returns an AbstractData representing the interval that contains the given ObjectId.
void clear()
A function used to clear the contents of the histogram, deleting the pointers contained by the boost ...
double & getInterval()
It returns the histogram's interval. Will be invalid if the histogram was created based on string int...
double m_interval
Histogram's numeric interval.
Definition: Histogram.h:253
void insert(std::pair< te::dt::AbstractData *, unsigned int > new_value)
It adds a new value to the map containing the histogram values. The AbstractData represents the inter...
std::map< double, unsigned int > getValues()
It returns the map containing the histogram values. The key is the minimum values of the histogram's ...
te::da::ObjectIdSet * find(te::dt::AbstractData *interval)
It returns an ObjectIdSet containing all the object Ids associeted with the given interval.
int m_histogramType
Histogram's type.
Definition: Histogram.h:251
void adjustOids(te::dt::AbstractData *interval, std::vector< te::da::ObjectId * > valuesOIds)
It will populate the IntervalToObjectIdSet with the given interval and it's matching objectIds.
IntervalToObjectIdSet m_valuesOids
The intervals and ObjecIds ordered in a boost multi index container.
Definition: Histogram.h:256
void setType(int new_type)
It sets the histogram's type.
bool isSummarized()
It returns a boolean that holds whether the histogram has been created from summarized values or not.
void insert(std::pair< te::dt::AbstractData *, unsigned int > new_value, std::vector< te::da::ObjectId * > valuesOIds)
It adds a new value to the map containing the histogram values.
void setMinValue(double new_minValue)
It sets the histogram's minimum value.
std::map< te::dt::AbstractData *, unsigned int, CompareHistogramInterval > HistogramValues
Histogram's values.
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
TerraLib.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63