Series of samples of a value and an interval. More...
#include <qwt_interval_data.h>
Public Member Functions | |
QwtIntervalData () | |
Constructor. | |
QwtIntervalData (const QMemArray< QwtDoubleInterval > &, const QMemArray< double > &) | |
Constructor. | |
~QwtIntervalData () | |
Destructor. | |
void | setData (const QMemArray< QwtDoubleInterval > &, const QMemArray< double > &) |
Assign samples. | |
vcl_size_t | size () const |
const QwtDoubleInterval & | interval (vcl_size_t i) const |
double | value (vcl_size_t i) const |
QwtDoubleRect | boundingRect () const |
Series of samples of a value and an interval.
QwtIntervalData is a series of samples of a value and an interval. F.e. error bars are built from samples [x, y1-y2], while a histogram might consist of [x1-x2, y] samples.
Definition at line 37 of file qwt_interval_data.h.
QwtIntervalData::QwtIntervalData | ( | ) |
QwtIntervalData::QwtIntervalData | ( | const QMemArray< QwtDoubleInterval > & | intervals, |
const QMemArray< double > & | values | ||
) |
Constructor.
Definition at line 19 of file qwt_interval_data.cpp.
: d_intervals(intervals), d_values(values) { }
QwtIntervalData::~QwtIntervalData | ( | ) |
QwtDoubleRect QwtIntervalData::boundingRect | ( | ) | const |
Calculate the bounding rectangle of the samples
The x coordinates of the rectangle are built from the intervals, the y coordinates from the values.
Definition at line 49 of file qwt_interval_data.cpp.
References interval(), QwtDoubleInterval::isValid(), QwtDoubleInterval::maxValue(), QwtDoubleInterval::minValue(), size(), and value().
Referenced by QmitkHistogram::boundingRect().
{ double minX, maxX, minY, maxY; minX = maxX = minY = maxY = 0.0; bool isValid = false; const size_t sz = size(); for ( size_t i = 0; i < sz; i++ ) { const QwtDoubleInterval intv = interval(i); if ( !intv.isValid() ) continue; const double v = value(i); if ( !isValid ) { minX = intv.minValue(); maxX = intv.maxValue(); minY = maxY = v; isValid = true; } else { if ( intv.minValue() < minX ) minX = intv.minValue(); if ( intv.maxValue() > maxX ) maxX = intv.maxValue(); if ( v < minY ) minY = v; if ( v > maxY ) maxY = v; } } if ( !isValid ) return QwtDoubleRect(1.0, 1.0, -2.0, -2.0); // invalid return QwtDoubleRect(minX, minY, maxX - minX, maxY - minY); }
const QwtDoubleInterval & QwtIntervalData::interval | ( | vcl_size_t | i ) | const [inline] |
Interval of a sample
i | Sample index |
Definition at line 73 of file qwt_interval_data.h.
References int().
Referenced by boundingRect(), and QmitkHistogram::draw().
{ return d_intervals[int(i)]; }
void QwtIntervalData::setData | ( | const QMemArray< QwtDoubleInterval > & | intervals, |
const QMemArray< double > & | values | ||
) |
Assign samples.
Definition at line 33 of file qwt_interval_data.cpp.
{ d_intervals = intervals; d_values = values; }
vcl_size_t QwtIntervalData::size | ( | ) | const [inline] |
Definition at line 61 of file qwt_interval_data.h.
References qwtMin.
Referenced by boundingRect(), and QmitkHistogram::draw().
{ return qwtMin(d_intervals.size(), d_values.size()); }
double QwtIntervalData::value | ( | vcl_size_t | i ) | const [inline] |
Value of a sample
i | Sample index |
Definition at line 85 of file qwt_interval_data.h.
References int().
Referenced by boundingRect(), and QmitkHistogram::draw().
{ return d_values[int(i)]; }