qwt_interval_data.h 1.64 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

#ifndef QWT_INTERVAL_DATA_H
#define QWT_INTERVAL_DATA_H 1

#include "qwt_global.h"
#include "qwt_math.h"
#include "qwt_array.h"
#include "qwt_double_interval.h"
#include "qwt_double_rect.h"

#if defined(_MSC_VER) && (_MSC_VER > 1310)
#include <string.h>
#endif

#if defined(QWT_TEMPLATEDLL)
// MOC_SKIP_BEGIN
template class QWT_EXPORT QwtArray<QwtDoubleInterval>;
template class QWT_EXPORT QwtArray<double>;
// MOC_SKIP_END
#endif

/*!
  \brief Interval data class.

*/
class QWT_EXPORT QwtIntervalData
{
public:
    QwtIntervalData();
38 39 40 41 42
    QwtIntervalData(const QwtArray<QwtDoubleInterval> &,
                    const QwtArray<double> &);

    void setData(const QwtArray<QwtDoubleInterval> &,
                 const QwtArray<double> &);
pixhawk's avatar
pixhawk committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

    size_t size() const;
    const QwtDoubleInterval &interval(size_t i) const;
    double value(size_t i) const;

    QwtDoubleRect boundingRect() const;

private:
    QwtArray<QwtDoubleInterval> d_intervals;
    QwtArray<double> d_values;
};

inline size_t QwtIntervalData::size() const
{
    return qwtMin(d_intervals.size(), d_values.size());
}

inline const QwtDoubleInterval &QwtIntervalData::interval(size_t i) const
{
    return d_intervals[int(i)];
}

inline double QwtIntervalData::value(size_t i) const
{
    return d_values[int(i)];
}

70
#endif