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