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((
int)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();
158 if (m_histogram->getInterval() != std::numeric_limits<double>::max())
160 double ini = m_histogram->getMinValue();
161 double vx = ini + m_histogram->getInterval();
163 while (it != values.end())
165 QwtInterval qwtInterval(ini, vx);
166 samples.push_back(QwtIntervalSample(it->second, qwtInterval));
169 vx += m_histogram->getInterval();
174 while (it != values.end())
176 double interval = it->first;
177 QwtInterval qwtInterval(interval, interval + 1);
178 samples.push_back(QwtIntervalSample(it->second, qwtInterval));
183 QPen blankPen = QPen(Qt::transparent);
187 blankStroke->
setOpacity(QString::number(0,
'g', 2).toStdString());
188 m_histogramStyle->setStroke(blankStroke);
196 delete m_histogramStyle;
207 return m_histogramScaleDraw;
212 delete m_histogramScaleDraw;
213 m_histogramScaleDraw = newScaleDraw;
214 plot()->setAxisScaleDraw(QwtPlot::xBottom, m_histogramScaleDraw);
221 plot->setAxisScaleDraw(QwtPlot::xBottom, m_histogramScaleDraw);
222 plot->axisScaleDraw(QwtPlot::xBottom)->setLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
223 plot->axisScaleDraw(QwtPlot::xBottom)->setLabelRotation(-60);
226 QwtPlotHistogram::attach(plot);
237 m_histogram = newHistogram;
242 return m_histogramStyle->
clone();
247 delete m_histogramStyle;
248 m_histogramStyle = newStyle;
257 barBrush.setStyle(Qt::SolidPattern);
267 m_selection->detach();
269 std::set<te::da::ObjectId*, te::common::LessCmp<te::da::ObjectId*> >::const_iterator itObjSet;
270 QwtSeriesData<QwtIntervalSample>* values = data();
278 std::map<double, unsigned int> highlightedIntervals;
279 std::set<std::string> highlightedPkeys;
282 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
288 highlightedIntervals.insert(std::make_pair(interval, 0));
293 std::pair<std::string, int> dsProps;
297 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
301 if(m_histogram->isSummarized())
303 if(highlightedPkeys.insert(pKey).second)
309 ++highlightedIntervals.at(interval);
319 ++highlightedIntervals.at(interval);
324 QVector<QwtIntervalSample> highlightedSamples((
int)highlightedIntervals.size());
327 for(
size_t i = 0; i < values->size(); ++i)
329 for (std::map<double, unsigned int>::iterator it = highlightedIntervals.begin(); it != highlightedIntervals.end(); ++it)
332 if(values->sample(i).interval.minValue() == it->first)
334 QwtInterval qwtInterval(values->sample(i).interval.minValue(), values->sample(i).interval.maxValue());
335 highlightedSamples.push_back(QwtIntervalSample(it->second, qwtInterval));
339 m_selection->setData(
new QwtIntervalSeriesData(highlightedSamples));
346 std::map<std::string, unsigned int> highlightedIntervals;
349 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
354 std::string interval = data->
getValue();
355 highlightedIntervals.insert(std::make_pair(interval, 0));
360 for(itObjSet = oids->
begin(); itObjSet != oids->
end(); ++itObjSet)
362 std::string interval = m_histogram->find((*itObjSet))->toString();
363 if(m_histogram->getStringValues().at(interval) > highlightedIntervals.at(interval))
364 ++highlightedIntervals.at(interval);
368 QVector<QwtIntervalSample> highlightedSamples((
int)highlightedIntervals.size());
371 for(
size_t i = 0; i < values->size(); ++i)
373 for (std::map<std::string, unsigned int>::iterator it = highlightedIntervals.begin(); it != highlightedIntervals.end(); ++it)
376 if(m_histogramScaleDraw->label(i).text().toStdString() == it->first)
378 QwtInterval qwtInterval(values->sample(i).interval.minValue(), values->sample(i).interval.maxValue());
379 highlightedSamples.push_back(QwtIntervalSample(it->second, qwtInterval));
383 m_selection->setData(
new QwtIntervalSeriesData(highlightedSamples));
386 m_selection->attach(plot());
392 QwtSeriesData<QwtIntervalSample>* values = data();
397 for(
size_t i = 0; i < values->size(); ++i)
399 if(values->sample(i).interval.minValue() < point.rx() && values->sample(i).interval.maxValue() > point.rx() && values->sample(i).value > point.ry())
400 data.reset(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
403 return m_histogram->find(data.get());
407 std::auto_ptr<te::dt::Double> data(
new te::dt::Double(std::numeric_limits<double>::max()));
409 for(
size_t i = 0; i < values->size(); ++i)
411 if(values->sample(i).interval.minValue() < point.rx() && values->sample(i).interval.maxValue() > point.rx() && values->sample(i).value > point.ry())
412 data.reset(
new te::dt::Double(values->sample(i).interval.minValue()));
415 return m_histogram->find(data.get());
421 QwtSeriesData<QwtIntervalSample>* values = data();
422 std::vector<te::dt::AbstractData*> selected;
426 for(
size_t i = 0; i < values->size(); ++i)
428 int min = values->sample(i).interval.minValue();
429 int max = values->sample(i).interval.maxValue();
430 int frequency = values->sample(i).value;
433 if(min > rect.x() && (max < rect.x() + rect.width() || min < rect.x() + rect.width()) && (frequency > rect.y() && rect.y() + rect.height() > 0))
434 selected.push_back(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
437 else if(min < rect.x() && max > rect.x() && (frequency > rect.y() && rect.y() + rect.height() > 0))
438 selected.push_back(
new te::dt::String(m_histogramScaleDraw->label(i).text().toStdString()));
444 for(
size_t i = 0; i < values->size(); ++i)
447 int min = values->sample(i).interval.minValue();
448 int max = values->sample(i).interval.maxValue();
449 int frequency = values->sample(i).value;
452 if(min > rect.x() && (max < rect.x() + rect.width() || min < rect.x() + rect.width()) && (frequency > rect.y() && rect.y() + rect.height() > 0))
453 selected.push_back(
new te::dt::Double(values->sample(i).interval.minValue()));
456 else if(min < rect.x() && max > rect.x() && (frequency > rect.y() && rect.y() + rect.height() > 0))
457 selected.push_back(
new te::dt::Double(values->sample(i).interval.minValue()));
461 return m_histogram->find(selected);
466 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.