27 #include "../../../dataaccess/dataset/ObjectId.h"
28 #include "../../../dataaccess/dataset/ObjectIdSet.h"
29 #include "../../../qt/widgets/se/Utils.h"
42 #include <qwt_column_symbol.h>
50 m_histogram(histogram),
51 m_histogramStyle(style)
55 QVector<QwtIntervalSample> samples;
61 std::map<double, unsigned int> values;
64 std::map<double, unsigned int>::const_iterator it;
67 std::map<int, unsigned int> vmap;
75 while(vx <= values.rbegin()->first)
78 if(fabs(vx) < 0.000000000001)
80 while(it != values.end())
82 if(it->first >= ini && it->first < vx)
83 vmap[i] += it->second;
89 QwtInterval qinterval(ini, vx);
90 qinterval.setBorderFlags(QwtInterval::ExcludeMaximum);
91 samples.push_back(QwtIntervalSample(vmap[i], qinterval));
98 setData(
new QwtIntervalSeriesData(samples));
103 std::map<std::string, unsigned int> values;
106 std::map<std::string, unsigned int>::iterator it;
110 QVector<QwtIntervalSample> samples(values.size());
111 double LabelInterval = 0.0;
113 while (it != values.end())
115 QwtInterval qwtInterval(LabelInterval, LabelInterval+1);
116 qwtInterval.setBorderFlags(QwtInterval::ExcludeMaximum);
117 samples[LabelInterval] = QwtIntervalSample(it->second, qwtInterval);
122 setData(
new QwtIntervalSeriesData(samples));
126 std::map<double, unsigned int> values;
127 std::map<double, unsigned int>::const_iterator it;
130 double interval = 0.0;
132 while (it != values.end())
134 QwtInterval qwtInterval(interval, interval+1);
135 samples.push_back(QwtIntervalSample(it->second, qwtInterval));
140 setData(
new QwtIntervalSeriesData(samples));
151 barBrush.setStyle(Qt::SolidPattern);
169 delete m_histogramStyle;
172 delete m_histogramScaleDraw;
182 return m_histogramScaleDraw;
187 delete m_histogramScaleDraw;
188 m_histogramScaleDraw = newScaleDraw;
195 plot->setAxisScaleDraw(QwtPlot::xBottom, m_histogramScaleDraw);
196 plot->axisScaleDraw(QwtPlot::xBottom)->setLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
197 plot->axisScaleDraw(QwtPlot::xBottom)->setLabelRotation(-60);
200 QwtPlotHistogram::attach(plot);
211 m_histogram = newHistogram;
216 return m_histogramStyle->
clone();
221 delete m_histogramStyle;
222 m_histogramStyle = newStyle;
231 barBrush.setStyle(Qt::SolidPattern);
241 m_selection->detach();
243 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator itObjSet;
244 QwtSeriesData<QwtIntervalSample>* values = data();
253 std::map<double, unsigned int> highlightedIntervals;
256 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
258 double interval =
static_cast< const te::dt::Double*
>(m_histogram->find((*itObjSet)))->getValue();
259 highlightedIntervals.insert(std::make_pair(interval, 0));
263 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
265 double interval =
static_cast< const te::dt::Double*
>(m_histogram->find((*itObjSet)))->getValue();
266 ++highlightedIntervals.at(interval);
269 QVector<QwtIntervalSample> highlightedSamples(highlightedIntervals.size());
272 for(
size_t i = 0; i < values->size(); ++i)
274 for (std::map<double, unsigned int>::iterator it = highlightedIntervals.begin(); it != highlightedIntervals.end(); ++it)
277 if(values->sample(i).interval.minValue() == it->first)
279 QwtInterval qwtInterval(values->sample(i).interval.minValue(), values->sample(i).interval.maxValue());
280 highlightedSamples.push_back(QwtIntervalSample(it->second, qwtInterval));
284 m_selection->setData(
new QwtIntervalSeriesData(highlightedSamples));
291 std::map<std::string, unsigned int> highlightedIntervals;
294 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
296 std::string interval = m_histogram->find((*itObjSet))->
toString();
297 highlightedIntervals.insert(std::make_pair(interval,0));
301 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
303 std::string interval = m_histogram->find((*itObjSet))->toString();
304 ++highlightedIntervals.at(interval);
309 QVector<QwtIntervalSample> highlightedSamples(highlightedIntervals.size());
312 for(
size_t i = 0; i < values->size(); ++i)
314 for (std::map<std::string, unsigned int>::iterator it = highlightedIntervals.begin(); it != highlightedIntervals.end(); ++it)
317 if(m_histogramScaleDraw->label(i).text().toStdString() == it->first)
319 QwtInterval qwtInterval(values->sample(i).interval.minValue(), values->sample(i).interval.maxValue());
320 highlightedSamples.push_back(QwtIntervalSample(it->second, qwtInterval));
324 m_selection->setData(
new QwtIntervalSeriesData(highlightedSamples));
327 m_selection->attach(plot());
333 QwtSeriesData<QwtIntervalSample>* values = data();
338 for(
size_t i = 0; i < values->size(); ++i)
340 if(values->sample(i).interval.minValue() < point.rx() && values->sample(i).interval.maxValue() > point.rx() && values->sample(i).value > point.ry())
341 data.reset(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
344 return m_histogram->find(data.get());
348 std::auto_ptr<te::dt::Double> data(
new te::dt::Double(std::numeric_limits<double>::max()));
350 for(
size_t i = 0; i < values->size(); ++i)
352 if(values->sample(i).interval.minValue() < point.rx() && values->sample(i).interval.maxValue() > point.rx() && values->sample(i).value > point.ry())
353 data.reset(
new te::dt::Double(values->sample(i).interval.minValue()));
356 return m_histogram->find(data.get());
362 m_selection->setBrush(selColor);
HistogramStyle * clone()
Returns a pointer to a clone of this HistogramStyle.
double & getInterval()
It returns the histogram's interval. Will be invalid if the histogram was created based on string int...
void highlight(const te::da::ObjectIdSet *oids)
Highlights the objects identified by oids.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
void Config(QPen &pen, const te::se::Stroke *stroke)
It configs the given pen based on Symbology Enconding Stroke element.
te::qt::widgets::Histogram * getHistogram()
It returns the chart's histogram.
double & getMinValue()
It returns the histogram's minimum value. Will be invalid if the histogram was created based on strin...
A class to represent a Histogram.
A template for atomic data types (integers, floats, strings and others).
A class used to define the style of a histogram's chart.
A class to represent a histogram.
void setScaleDraw(StringScaleDraw *newScaleDraw)
It sets the chart's scale draw.
virtual int rtti() const
Returns the chart's type.
StringScaleDraw * getScaleDraw()
It returns the chart's scale draw.
HistogramChart(Histogram *data, te::qt::widgets::HistogramStyle *style=0)
Constructor.
int & getType()
It returns the histogram's type.
te::qt::widgets::HistogramStyle * m_histogramStyle
The histogram's style as displayed by this widget.
StringScaleDraw * m_histogramScaleDraw
Scale draw that defines how a label will be displayed on this chart.
A class to represent a set of labels to be used on a histogram's chart.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator end() const
Returns an iterator for the object ids in container.
A class to represent a histogram chart.
QwtPlotHistogram * m_selection
The PlotItems to be highlighted when a selection occurs;.
~HistogramChart()
Destructor.
te::qt::widgets::HistogramStyle * getHistogramStyle()
Returns a clone of the pointer to the histogram's style.
void attach(QwtPlot *plot)
It atttaches a QwtPlot to this Cahrt.
te::se::Fill * getFill()
Returns a pointer to the histogram bar's fill.
virtual std::string toString() const
It returns the data value in a string representation.
void setHistogramStyle(te::qt::widgets::HistogramStyle *newStyle)
It sets the chart's style.
void setSelectionColor(QColor selColor)
color used to hgihlight selected objects on this chart.
te::se::Stroke * getStroke()
Returns a pointer to the histogram bar's stroke.
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 setHistogram(te::qt::widgets::Histogram *newHistogram)
It sets the chart's histogram.
std::set< std::string > & getStringInterval()
It returns the histogram's string set of intervals. Will be invalid if the histogram was created base...
std::map< double, unsigned int > getValues()
It returns the map containing the histogram values. The key is the minimum values of the histogram's ...