00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_DOUBLE_INTERVAL_H
00011 #define QWT_DOUBLE_INTERVAL_H
00012
00013 #include "qwt_global.h"
00014
00015 class QWT_EXPORT QwtDoubleInterval
00016 {
00017 public:
00018 inline QwtDoubleInterval();
00019 inline QwtDoubleInterval(double minValue, double maxValue);
00020
00021 inline void setInterval(double minValue, double maxValue);
00022
00023 QwtDoubleInterval normalized() const;
00024 QwtDoubleInterval invert() const;
00025 QwtDoubleInterval limit(double minValue, double maxValue) const;
00026
00027 inline int operator==(const QwtDoubleInterval &) const;
00028 inline int operator!=(const QwtDoubleInterval &) const;
00029
00030 inline double minValue() const;
00031 inline double maxValue() const;
00032
00033 inline double width() const;
00034
00035 inline void setMinValue(double);
00036 inline void setMaxValue(double);
00037
00038 bool contains(double value) const;
00039
00040 bool intersects(const QwtDoubleInterval &) const;
00041 QwtDoubleInterval intersect(const QwtDoubleInterval &) const;
00042 QwtDoubleInterval unite(const QwtDoubleInterval &) const;
00043
00044 inline QwtDoubleInterval operator|(const QwtDoubleInterval &) const;
00045 inline QwtDoubleInterval operator&(const QwtDoubleInterval &) const;
00046
00047 QwtDoubleInterval &operator|=(const QwtDoubleInterval &);
00048 QwtDoubleInterval &operator&=(const QwtDoubleInterval &);
00049
00050 QwtDoubleInterval extend(double value) const;
00051 inline QwtDoubleInterval operator|(double) const;
00052 QwtDoubleInterval &operator|=(double);
00053
00054 inline bool isValid() const;
00055 inline void invalidate();
00056
00057 QwtDoubleInterval symmetrize(double value) const;
00058
00059 private:
00060 double d_minValue;
00061 double d_maxValue;
00062 };
00063
00064 inline QwtDoubleInterval::QwtDoubleInterval():
00065 d_minValue(0.0),
00066 d_maxValue(-1.0)
00067 {
00068 }
00069
00070 inline QwtDoubleInterval::QwtDoubleInterval(double minValue, double maxValue):
00071 d_minValue(minValue),
00072 d_maxValue(maxValue)
00073 {
00074 }
00075
00076 inline void QwtDoubleInterval::setInterval(double minValue, double maxValue)
00077 {
00078 d_minValue = minValue;
00079 d_maxValue = maxValue;
00080 }
00081
00082 inline void QwtDoubleInterval::setMinValue(double minValue)
00083 {
00084 d_minValue = minValue;
00085 }
00086
00087 inline void QwtDoubleInterval::setMaxValue(double maxValue)
00088 {
00089 d_maxValue = maxValue;
00090 }
00091
00092 inline double QwtDoubleInterval::minValue() const
00093 {
00094 return d_minValue;
00095 }
00096
00097 inline double QwtDoubleInterval::maxValue() const
00098 {
00099 return d_maxValue;
00100 }
00101
00102 inline double QwtDoubleInterval::width() const
00103 {
00104 return isValid() ? (d_maxValue - d_minValue) : 0.0;
00105 }
00106
00107 inline QwtDoubleInterval QwtDoubleInterval::operator&(
00108 const QwtDoubleInterval &interval ) const
00109 {
00110 return intersect(interval);
00111 }
00112
00113 inline QwtDoubleInterval QwtDoubleInterval::operator|(
00114 const QwtDoubleInterval &interval) const
00115 {
00116 return unite(interval);
00117 }
00118
00119 inline int QwtDoubleInterval::operator==(const QwtDoubleInterval &other) const
00120 {
00121 return (d_minValue == other.d_minValue) &&
00122 (d_maxValue == other.d_maxValue);
00123 }
00124
00125 inline int QwtDoubleInterval::operator!=(const QwtDoubleInterval &other) const
00126 {
00127 return (!(*this == other));
00128 }
00129
00130 inline QwtDoubleInterval QwtDoubleInterval::operator|(double value) const
00131 {
00132 return extend(value);
00133 }
00134
00135 inline bool QwtDoubleInterval::isValid() const
00136 {
00137 return d_minValue < d_maxValue;
00138 }
00139
00140 inline void QwtDoubleInterval::invalidate()
00141 {
00142 d_minValue = 0.0;
00143 d_maxValue = -1.0;
00144 }
00145 #endif