27 #include "../../../dataaccess/dataset/ObjectId.h"
28 #include "../../../dataaccess/dataset/ObjectIdSet.h"
29 #include "../../../dataaccess/utils/Utils.h"
30 #include "../../../qt/widgets/se/Utils.h"
31 #include "../../../se/Stroke.h"
45 #include <qwt_column_symbol.h>
53 m_histogram(histogram),
54 m_histogramStyle(style)
64 barBrush.setStyle(Qt::SolidPattern);
84 QVector<QwtIntervalSample> samples;
89 std::map<double, unsigned int> values;
90 values = m_histogram->getValues();
92 std::map<double, unsigned int>::const_iterator it;
95 std::map<int, unsigned int> vmap;
99 double ini = m_histogram->getMinValue();
101 double vx = ini + m_histogram->getInterval();
103 while(vx <= values.rbegin()->first)
106 if(fabs(vx) < 0.000000000001)
108 while(it != values.end())
110 if(it->first >= ini && it->first < vx)
111 vmap[i] += it->second;
117 QwtInterval qinterval(ini, vx);
118 qinterval.setBorderFlags(QwtInterval::ExcludeMaximum);
119 samples.push_back(QwtIntervalSample(vmap[i], qinterval));
122 vx += m_histogram->getInterval();
130 std::map<std::string, unsigned int> values;
131 values = m_histogram->getStringValues();
133 std::map<std::string, unsigned int>::iterator it;
136 m_histogramScaleDraw =
new StringScaleDraw(m_histogram->getStringInterval());
137 QVector<QwtIntervalSample> samples(values.size());
138 double LabelInterval = 0.0;
140 while (it != values.end())
142 QwtInterval qwtInterval(LabelInterval, LabelInterval+1);
143 qwtInterval.setBorderFlags(QwtInterval::ExcludeMaximum);
144 samples[LabelInterval] = QwtIntervalSample(it->second, qwtInterval);
152 std::map<double, unsigned int> values;
153 std::map<double, unsigned int>::const_iterator it;
154 values = m_histogram->getValues();
157 while (it != values.end())
159 double interval = it->first;
160 QwtInterval qwtInterval(interval, interval+1);
161 samples.push_back(QwtIntervalSample(it->second, qwtInterval));
165 QPen blankPen = QPen(Qt::transparent);
169 blankStroke->
setOpacity(QString::number(0,
'g', 2).toStdString());
170 m_histogramStyle->setStroke(blankStroke);
178 delete m_histogramStyle;
181 delete m_histogramScaleDraw;
191 return m_histogramScaleDraw;
196 delete m_histogramScaleDraw;
197 m_histogramScaleDraw = newScaleDraw;
204 plot->setAxisScaleDraw(QwtPlot::xBottom, m_histogramScaleDraw);
205 plot->axisScaleDraw(QwtPlot::xBottom)->setLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
206 plot->axisScaleDraw(QwtPlot::xBottom)->setLabelRotation(-60);
209 QwtPlotHistogram::attach(plot);
220 m_histogram = newHistogram;
225 return m_histogramStyle->
clone();
230 delete m_histogramStyle;
231 m_histogramStyle = newStyle;
240 barBrush.setStyle(Qt::SolidPattern);
250 m_selection->detach();
252 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator itObjSet;
253 QwtSeriesData<QwtIntervalSample>* values = data();
261 std::map<double, unsigned int> highlightedIntervals;
262 std::set<std::string> highlightedPkeys;
265 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
271 highlightedIntervals.insert(std::make_pair(interval, 0));
276 std::pair<std::string, int> dsProps;
280 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
284 if(m_histogram->isSummarized())
286 if(highlightedPkeys.insert(pKey).second)
292 ++highlightedIntervals.at(interval);
302 ++highlightedIntervals.at(interval);
307 QVector<QwtIntervalSample> highlightedSamples(highlightedIntervals.size());
310 for(
size_t i = 0; i < values->size(); ++i)
312 for (std::map<double, unsigned int>::iterator it = highlightedIntervals.begin(); it != highlightedIntervals.end(); ++it)
315 if(values->sample(i).interval.minValue() == it->first)
317 QwtInterval qwtInterval(values->sample(i).interval.minValue(), values->sample(i).interval.maxValue());
318 highlightedSamples.push_back(QwtIntervalSample(it->second, qwtInterval));
322 m_selection->setData(
new QwtIntervalSeriesData(highlightedSamples));
329 std::map<std::string, unsigned int> highlightedIntervals;
332 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
334 std::string interval = m_histogram->find((*itObjSet))->toString();
335 highlightedIntervals.insert(std::make_pair(interval,0));
339 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
341 std::string interval = m_histogram->find((*itObjSet))->toString();
342 if(m_histogram->getStringValues().at(interval) > highlightedIntervals.at(interval))
343 ++highlightedIntervals.at(interval);
347 QVector<QwtIntervalSample> highlightedSamples(highlightedIntervals.size());
350 for(
size_t i = 0; i < values->size(); ++i)
352 for (std::map<std::string, unsigned int>::iterator it = highlightedIntervals.begin(); it != highlightedIntervals.end(); ++it)
355 if(m_histogramScaleDraw->label(i).text().toStdString() == it->first)
357 QwtInterval qwtInterval(values->sample(i).interval.minValue(), values->sample(i).interval.maxValue());
358 highlightedSamples.push_back(QwtIntervalSample(it->second, qwtInterval));
362 m_selection->setData(
new QwtIntervalSeriesData(highlightedSamples));
365 m_selection->attach(plot());
371 QwtSeriesData<QwtIntervalSample>* values = data();
376 for(
size_t i = 0; i < values->size(); ++i)
378 if(values->sample(i).interval.minValue() < point.rx() && values->sample(i).interval.maxValue() > point.rx() && values->sample(i).value > point.ry())
379 data.reset(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
382 return m_histogram->find(data.get());
386 std::auto_ptr<te::dt::Double> data(
new te::dt::Double(std::numeric_limits<double>::max()));
388 for(
size_t i = 0; i < values->size(); ++i)
390 if(values->sample(i).interval.minValue() < point.rx() && values->sample(i).interval.maxValue() > point.rx() && values->sample(i).value > point.ry())
391 data.reset(
new te::dt::Double(values->sample(i).interval.minValue()));
394 return m_histogram->find(data.get());
400 QwtSeriesData<QwtIntervalSample>* values = data();
401 std::vector<te::dt::AbstractData*> selected;
405 for(
size_t i = 0; i < values->size(); ++i)
407 int min = values->sample(i).interval.minValue();
408 int max = values->sample(i).interval.maxValue();
409 int frequency = values->sample(i).value;
412 if(min > rect.x() && (max < rect.x() + rect.width() || min < rect.x() + rect.width()) && (frequency > rect.y() && rect.y() + rect.height() > 0))
413 selected.push_back(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
416 else if(min < rect.x() && max > rect.x() && (frequency > rect.y() && rect.y() + rect.height() > 0))
417 selected.push_back(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
423 for(
size_t i = 0; i < values->size(); ++i)
426 int min = values->sample(i).interval.minValue();
427 int max = values->sample(i).interval.maxValue();
428 int frequency = values->sample(i).value;
431 if(min > rect.x() && (max < rect.x() + rect.width() || min < rect.x() + rect.width()) && (frequency > rect.y() && rect.y() + rect.height() > 0))
432 selected.push_back(
new te::dt::Double(values->sample(i).interval.minValue()));
435 else if(min < rect.x() && max > rect.x() && (frequency > rect.y() && rect.y() + rect.height() > 0))
436 selected.push_back(
new te::dt::Double(values->sample(i).interval.minValue()));
440 return m_histogram->find(selected);
445 m_selection->setBrush(selColor);
Utility functions for the data access module.
A class that models the description of a dataset.
T getValue() const
It returns the associated value.
A class to represent a set of labels to be used on a histogram's chart.
TEDATAACCESSEXPORT void GetOIDDatasetProps(const DataSetType *type, std::pair< std::string, int > &dsProps)
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.
TEDATAACCESSEXPORT std::string getBasePkey(te::da::ObjectId *oid, std::pair< std::string, int > &dsProps)
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.