Public Member Functions

QwtIntervalData Class Reference

Series of samples of a value and an interval. More...

#include <qwt_interval_data.h>

List of all members.

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 QwtDoubleIntervalinterval (vcl_size_t i) const
double value (vcl_size_t i) const
QwtDoubleRect boundingRect () const

Detailed Description

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.


Constructor & Destructor Documentation

QwtIntervalData::QwtIntervalData (  )

Constructor.

Definition at line 14 of file qwt_interval_data.cpp.

{
}
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 (  )

Destructor.

Definition at line 28 of file qwt_interval_data.cpp.

{
}

Member Function Documentation

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.

Returns:
Bounding rectangle

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

Parameters:
iSample index
Returns:
Interval
See also:
value(), size()

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]
Returns:
Number of samples

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

Parameters:
iSample index
Returns:
Value
See also:
interval(), size()

Definition at line 85 of file qwt_interval_data.h.

References int().

Referenced by boundingRect(), and QmitkHistogram::draw().

{
    return d_values[int(i)];
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines