27 #include "../../../dataaccess/dataset/ObjectId.h"
28 #include "../../../dataaccess/dataset/ObjectIdSet.h"
29 #include "../../../qt/widgets/se/Utils.h"
30 #include "../../../se/Stroke.h"
43 #include <qwt_column_symbol.h>
51 m_histogram(histogram),
52 m_histogramStyle(style)
56 QVector<QwtIntervalSample> samples;
66 barBrush.setStyle(Qt::SolidPattern);
76 std::map<double, unsigned int> values;
79 std::map<double, unsigned int>::const_iterator it;
82 std::map<int, unsigned int> vmap;
90 while(vx <= values.rbegin()->first)
93 if(fabs(vx) < 0.000000000001)
95 while(it != values.end())
97 if(it->first >= ini && it->first < vx)
98 vmap[i] += it->second;
104 QwtInterval qinterval(ini, vx);
105 qinterval.setBorderFlags(QwtInterval::ExcludeMaximum);
106 samples.push_back(QwtIntervalSample(vmap[i], qinterval));
113 setData(
new QwtIntervalSeriesData(samples));
118 std::map<std::string, unsigned int> values;
121 std::map<std::string, unsigned int>::iterator it;
125 QVector<QwtIntervalSample> samples(values.size());
126 double LabelInterval = 0.0;
128 while (it != values.end())
130 QwtInterval qwtInterval(LabelInterval, LabelInterval+1);
131 qwtInterval.setBorderFlags(QwtInterval::ExcludeMaximum);
132 samples[LabelInterval] = QwtIntervalSample(it->second, qwtInterval);
137 setData(
new QwtIntervalSeriesData(samples));
141 std::map<double, unsigned int> values;
142 std::map<double, unsigned int>::const_iterator it;
145 double interval = 0.0;
147 while (it != values.end())
149 QwtInterval qwtInterval(interval, interval+1);
150 samples.push_back(QwtIntervalSample(it->second, qwtInterval));
155 QPen blankPen = QPen(Qt::transparent);
159 blankStroke->
setOpacity(QString::number(0,
'g', 2).toStdString());
162 setData(
new QwtIntervalSeriesData(samples));
177 delete m_histogramStyle;
180 delete m_histogramScaleDraw;
190 return m_histogramScaleDraw;
195 delete m_histogramScaleDraw;
196 m_histogramScaleDraw = newScaleDraw;
203 plot->setAxisScaleDraw(QwtPlot::xBottom, m_histogramScaleDraw);
204 plot->axisScaleDraw(QwtPlot::xBottom)->setLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
205 plot->axisScaleDraw(QwtPlot::xBottom)->setLabelRotation(-60);
208 QwtPlotHistogram::attach(plot);
219 m_histogram = newHistogram;
224 return m_histogramStyle->
clone();
229 delete m_histogramStyle;
230 m_histogramStyle = newStyle;
239 barBrush.setStyle(Qt::SolidPattern);
249 m_selection->detach();
251 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator itObjSet;
252 QwtSeriesData<QwtIntervalSample>* values = data();
261 std::map<double, unsigned int> highlightedIntervals;
264 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
266 double interval =
static_cast< const te::dt::Double*
>(m_histogram->find((*itObjSet)))->getValue();
267 highlightedIntervals.insert(std::make_pair(interval, 0));
271 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
273 double interval =
static_cast< const te::dt::Double*
>(m_histogram->find((*itObjSet)))->getValue();
274 ++highlightedIntervals.at(interval);
277 QVector<QwtIntervalSample> highlightedSamples(highlightedIntervals.size());
280 for(
size_t i = 0; i < values->size(); ++i)
282 for (std::map<double, unsigned int>::iterator it = highlightedIntervals.begin(); it != highlightedIntervals.end(); ++it)
285 if(values->sample(i).interval.minValue() == it->first)
287 QwtInterval qwtInterval(values->sample(i).interval.minValue(), values->sample(i).interval.maxValue());
288 highlightedSamples.push_back(QwtIntervalSample(it->second, qwtInterval));
292 m_selection->setData(
new QwtIntervalSeriesData(highlightedSamples));
299 std::map<std::string, unsigned int> highlightedIntervals;
302 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
304 std::string interval = m_histogram->find((*itObjSet))->
toString();
305 highlightedIntervals.insert(std::make_pair(interval,0));
309 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
311 std::string interval = m_histogram->find((*itObjSet))->toString();
312 ++highlightedIntervals.at(interval);
317 QVector<QwtIntervalSample> highlightedSamples(highlightedIntervals.size());
320 for(
size_t i = 0; i < values->size(); ++i)
322 for (std::map<std::string, unsigned int>::iterator it = highlightedIntervals.begin(); it != highlightedIntervals.end(); ++it)
325 if(m_histogramScaleDraw->label(i).text().toStdString() == it->first)
327 QwtInterval qwtInterval(values->sample(i).interval.minValue(), values->sample(i).interval.maxValue());
328 highlightedSamples.push_back(QwtIntervalSample(it->second, qwtInterval));
332 m_selection->setData(
new QwtIntervalSeriesData(highlightedSamples));
335 m_selection->attach(plot());
341 QwtSeriesData<QwtIntervalSample>* values = data();
346 for(
size_t i = 0; i < values->size(); ++i)
348 if(values->sample(i).interval.minValue() < point.rx() && values->sample(i).interval.maxValue() > point.rx() && values->sample(i).value > point.ry())
349 data.reset(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
352 return m_histogram->find(data.get());
356 std::auto_ptr<te::dt::Double> data(
new te::dt::Double(std::numeric_limits<double>::max()));
358 for(
size_t i = 0; i < values->size(); ++i)
360 if(values->sample(i).interval.minValue() < point.rx() && values->sample(i).interval.maxValue() > point.rx() && values->sample(i).value > point.ry())
361 data.reset(
new te::dt::Double(values->sample(i).interval.minValue()));
364 return m_histogram->find(data.get());
370 QwtSeriesData<QwtIntervalSample>* values = data();
371 std::vector<te::dt::AbstractData*> selected;
375 for(
size_t i = 0; i < values->size(); ++i)
377 int min = values->sample(i).interval.minValue();
378 int max = values->sample(i).interval.maxValue();
379 int frequency = values->sample(i).value;
382 if(min > rect.x() && (max < rect.x() + rect.width() || min < rect.x() + rect.width()) && frequency > rect.y())
383 selected.push_back(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
386 else if(min < rect.x() && max > rect.x() && frequency > rect.y())
387 selected.push_back(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
393 for(
size_t i = 0; i < values->size(); ++i)
396 int min = values->sample(i).interval.minValue();
397 int max = values->sample(i).interval.maxValue();
398 int frequency = values->sample(i).value;
401 if(min > rect.x() && (max < rect.x() + rect.width() || min < rect.x() + rect.width()) && frequency > rect.y())
402 selected.push_back(
new te::dt::Double(values->sample(i).interval.minValue()));
405 else if(min < rect.x() && max > rect.x() && frequency > rect.y())
406 selected.push_back(
new te::dt::Double(values->sample(i).interval.minValue()));
410 return m_histogram->find(selected);
415 m_selection->setBrush(selColor);
A class to represent a set of labels to be used on a histogram's chart.
virtual std::string toString() const
It returns the data value in a string representation.
A class used to define the style of a histogram's chart.
A class to represent a histogram.
void setOpacity(const std::string &opacity)
This class represents a set of unique ids created in the same context. i.e. from the same data set...
A class to represent a histogram chart.
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator end() const
Returns an iterator for the object ids in container.
A Stroke specifies the appearance of a linear geometry.
A template for atomic data types (integers, floats, strings and others).
std::set< ObjectId *, te::common::LessCmp< ObjectId * > >::const_iterator begin() const
Returns an iterator for the object ids in container.