Qwt User's Guide 5.2.2

qwt_interval_data.h

00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_INTERVAL_DATA_H
00011 #define QWT_INTERVAL_DATA_H 1
00012 
00013 #include "qwt_global.h"
00014 #include "qwt_math.h"
00015 #include "qwt_array.h"
00016 #include "qwt_double_interval.h"
00017 #include "qwt_double_rect.h"
00018 
00019 #if defined(_MSC_VER) && (_MSC_VER > 1310)
00020 #include <string.h>
00021 #endif
00022 
00023 #if defined(QWT_TEMPLATEDLL)
00024 // MOC_SKIP_BEGIN
00025 template class QWT_EXPORT QwtArray<QwtDoubleInterval>;
00026 template class QWT_EXPORT QwtArray<double>;
00027 // MOC_SKIP_END
00028 #endif
00029 
00037 class QWT_EXPORT QwtIntervalData
00038 {
00039 public:
00040     QwtIntervalData();
00041     QwtIntervalData(const QwtArray<QwtDoubleInterval> &, 
00042         const QwtArray<double> &);
00043 
00044     ~QwtIntervalData();
00045     
00046     void setData(const QwtArray<QwtDoubleInterval> &, 
00047         const QwtArray<double> &);
00048 
00049     size_t size() const;
00050     const QwtDoubleInterval &interval(size_t i) const;
00051     double value(size_t i) const;
00052 
00053     QwtDoubleRect boundingRect() const;
00054 
00055 private:
00056     QwtArray<QwtDoubleInterval> d_intervals;
00057     QwtArray<double> d_values;
00058 };
00059 
00061 inline size_t QwtIntervalData::size() const
00062 {
00063     return qwtMin(d_intervals.size(), d_values.size());
00064 }
00065 
00073 inline const QwtDoubleInterval &QwtIntervalData::interval(size_t i) const
00074 {
00075     return d_intervals[int(i)];
00076 }
00077 
00085 inline double QwtIntervalData::value(size_t i) const
00086 {
00087     return d_values[int(i)];
00088 }
00089 
00090 #endif