Utils.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/Utils.h
22 
23  \brief This file contains a set of utility chart functions
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_CHARTUTILS_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_CHARTUTILS_H
28 
29 //TerraLib
30 #include "../Config.h"
31 
32 //QWT
33 #include <qwt_symbol.h>
34 #include <qwt_text.h>
35 #include <qwt_plot_curve.h>
36 
37 //STL
38 #include <vector>
39 
40 namespace te
41 {
42  // Forward declarations
43  namespace color { class RGBAColor; }
44  namespace se { class Font; class Fill; class Stroke; class Mark; class Graphic;}
45  namespace da { class DataSet; class DataSetType; class ObjectId; }
46  namespace dt { class DateTime; }
47 
48  namespace qt
49  {
50 
51  namespace widgets
52  {
53 
54  class Scatter;
55  class Histogram;
56  class ChartDisplayWidget;
57 
58  /*!
59  \brief Scatter Creator
60 
61  \param dataset The dataset that will be used to populate the scatter's data
62  \param dataType The dataType that will be used to recover the objectIds associated with the given dataset.
63  \param propX The id of the property that contains the data of the x axis.
64  \param propY The id of the property that contains the data of the y axis.
65 
66  \note It will traverse the data set, using the moveNext() method
67  \note It will not take the ownership of the "dataset" pointer.
68  \note It will not take the ownership of the "dataType" pointer.
69  \note The caller will take the ownership of the returned scatter pointer.
70 
71  \return a new Scatter
72  */
73  TEQTWIDGETSEXPORT Scatter* createScatter(te::da::DataSet* dataset, te::da::DataSetType* dataType, int propX, int propY, int stat, bool readall = true);
74 
75  /*!
76  \brief Scatter Creator
77 
78  \param dataset The dataset that will be used to populate the scatter's data
79  \param dataType The dataType that will be used to recover the objectIds associated with the given dataset.
80  \param propX The id of the property that contains the data of the x axis.
81  \param propY The id of the property that contains the data of the y axis.
82 
83  \note It will traverse the data set, using the moveNext() method
84  \note It will not take the ownership of the "dataset" pointer.
85  \note It will not take the ownership of the "dataType" pointer.
86  \note The caller will take the ownership of the returned ChartDisplayWidget pointer.
87 
88  */
89  TEQTWIDGETSEXPORT ChartDisplayWidget* createScatterDisplay(te::da::DataSet* dataset, te::da::DataSetType* dataType, int propX, int propY, int stat = -1);
90 
91  /*!
92  \brief Histogram Creator
93 
94  \param dataset The dataset that will be used to populate the histogram's data
95  \param dataType The dataType that will be used to recover the objectIds associated with the given dataset.
96  \param propId The id of the property that contains the data
97  \param slices The desired number of intervals
98  \param stat The selected satistical function
99 
100  \note It will traverse the data set, using the moveNext() method
101  \note It will not take the ownership of the "dataset" pointer.
102  \note It will not take the ownership of the "dataType" pointer.
103  \note The caller will take the ownership of the returned histogram pointer.
104 
105  \return a new Histogram
106  */
107  TEQTWIDGETSEXPORT Histogram* createHistogram(te::da::DataSet* dataset, te::da::DataSetType* dataType, int propId, int slices, int stat);
108 
109  /*!
110  \brief Histogram Creator
111 
112  \param dataset The dataset that will be used to populate the histogram's data
113  \param dataType The dataType that will be used to recover the objectIds associated with the given dataset.
114  \param propId The id of the property that contains the data
115  \param stat The selected satistical function
116 
117  \note This version is used to create a histogram based on a set of labels (Strings), therefore there is no user-defined number of intervals, each unique label is an interval
118  \note It will traverse the data set, using the moveNext() method
119  \note It will not take the ownership of the "dataset" pointer.
120  \note It will not take the ownership of the "dataType" pointer.
121  \note The caller will take the ownership of the returned histogram pointer.
122 
123  \return a new Histogram
124  */
125  TEQTWIDGETSEXPORT Histogram* createHistogram(te::da::DataSet* dataset, te::da::DataSetType* dataType, int propId, int stat);
126 
127  /*!
128  \brief Histogram Creator
129 
130  \param dataset The dataset that will be used to populate the histogram's data
131  \param dataType The dataType that will be used to recover the objectIds associated with the given dataset.
132  \param propId The id of the property that contains the data
133  \param slices The desired number of intervals, the default is 10 and this parameter is not used when the preperty is a string
134  \param stat The selected satistical function, defaults to -1 (i.e. none)
135 
136  \note It will traverse the data set, using the moveNext() method
137  \note It will not take the ownership of the "dataset" pointer.
138  \note It will not take the ownership of the "dataType" pointer.
139  \note The caller will take the ownership of the returned ChartDisplayWidget pointer.
140 
141  \return A pointer to a new ChartDisplayWidget that contains the generated chart
142 
143  */
144  TEQTWIDGETSEXPORT ChartDisplayWidget* createHistogramDisplay(te::da::DataSet* dataset, te::da::DataSetType* dataType, int propId, int slices = 10, int stat = -1);
145 
146  /*!
147  \brief Histogram Creator
148 
149  \param dataset The dataset that will be used to populate the histogram's data
150  \param dataType The dataType that will be used to recover the objectIds associated with the given dataset.
151  \param propId The id of the property that contains the data
152  \param histogram THe histogram that will be displayed by the returned widget
153 
154  \note It will traverse the data set, using the moveNext() method
155  \note It will not take the ownership of the "dataset" pointer.
156  \note It will not take the ownership of the "dataType" pointer.
157  \note It will take ownership of the given histogram pointer and pass it along to the returned ChartDisplay.
158  \note The caller will take the ownership of the returned ChartDisplayWidget pointer.
159 
160  \return A pointer to a new ChartDisplayWidget that contains the generated chart
161  */
162  TEQTWIDGETSEXPORT ChartDisplayWidget* createHistogramDisplay(te::da::DataSet* dataset, te::da::DataSetType* dataType, int propId, std::string summary, Histogram* histogram);
163 
164  /*!
165  \function Terralib2Qwt
166 
167  This function returns a default QwtText.
168 
169  \param title A text.
170 
171  \return A QwtText
172 
173  \note The caller will take the ownership of the returned pointer.
174  */
175  TEQTWIDGETSEXPORT QwtText* Terralib2Qwt(const std::string& title);
176 
177 
178  /*!
179  \function Terralib2Qwt
180 
181  This function translates TerraLib text styles into a QwtText.
182 
183  \param text A text
184  \param color The text's color
185  \param font The text's font
186  \param backFill The text's background fill
187  \param backStroke The text's background stroke
188 
189  \return A QwtText
190 
191  \note The caller will take the ownership of the returned pointer.
192  \note It will not take the ownership of given "font", "backFill" and "backStroke"" pointers.
193  */
194  TEQTWIDGETSEXPORT QwtText* Terralib2Qwt(const std::string& text, te::color::RGBAColor* color,
195  te::se::Font* font, te::se::Fill* backFill,
196  te::se::Stroke* backStroke);
197 
198  /*!
199  \function Terralib2Qwt
200 
201  This function translates a terralib's Graphic object into a QWTSymbol object.
202 
203  \param graphic The graphic that will be used to generate the symbol.
204 
205  \return A QwtSymbol
206 
207  \note The caller will take the ownership of the returned pointer.
208  \note It will not take the ownership of the Graphic pointer.
209  */
210  TEQTWIDGETSEXPORT QwtSymbol* Terralib2Qwt(te::se::Graphic* graphic);
211 
212  /*!
213  \function createNormalDistribution
214 
215  This function translates a terralib's Graphic object into a QWTSymbol object.
216 
217  \param dataset The dataset that will be used calculate the normal distribution.
218  \param propId The id of the property that contains the data.
219 
220  \note The caller will take the ownership of the returned pointer.
221  \note It will not take the ownership of the "dataset" pointer.
222 
223  \return A pointer to a new ChartDisplayWidget that contains the generated chart
224  */
225  TEQTWIDGETSEXPORT ChartDisplayWidget* createNormalDistribution(te::da::DataSet* dataset, int propId);
226 
227  } // end namespace widgets
228  } // end namespace qt
229 } // end namespace te
230 
231 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_CHARTUTILS_H
232 
A class that models the description of a dataset.
Definition: DataSetType.h:72
A Graphic is a graphic symbol with an inherent shape, color(s), and possibly size.
Definition: Graphic.h:66
TEQTWIDGETSEXPORT ChartDisplayWidget * createNormalDistribution(te::da::DataSet *dataset, int propId)
TEQTWIDGETSEXPORT Scatter * createScatter(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propX, int propY, int stat, bool readall=true)
Scatter Creator.
TEQTWIDGETSEXPORT QwtText * Terralib2Qwt(const std::string &title)
URI C++ Library.
A Font specifies the text font to use in a text symbolizer.
Definition: Font.h:63
A Fill specifies the pattern for filling an area geometry.
Definition: Fill.h:59
TEQTWIDGETSEXPORT Histogram * createHistogram(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propId, int slices, int stat)
Histogram Creator.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
A Stroke specifies the appearance of a linear geometry.
Definition: Stroke.h:67
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
TEQTWIDGETSEXPORT ChartDisplayWidget * createHistogramDisplay(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propId, int slices=10, int stat=-1)
Histogram Creator.
TEQTWIDGETSEXPORT ChartDisplayWidget * createScatterDisplay(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propX, int propY, int stat=-1)
Scatter Creator.