Added support for ENC atlases (catalogues)
[GPXSee.git] / src / common / range.h
blob28dc0e9fbe65b3df05053591242b342df5b0c5a8
1 #ifndef RANGE_H
2 #define RANGE_H
4 #include <QtGlobal>
5 #include <QDebug>
7 class Range
9 public:
10 Range() {_min = 0; _max = 0;}
11 Range(int min, int max) : _min(min), _max(max) {}
13 bool operator==(const Range &other) const
14 {return _min == other._min && _max == other._max;}
15 bool operator!=(const Range &other) const
16 {return _min != other._min || _max != other._max;}
18 int size() const {return (_max - _min);}
19 int min() const {return _min;}
20 int max() const {return _max;}
22 bool isValid() const {return size() >= 0;}
23 bool isNull() const {return _min == 0 && _max == 0;}
25 void setMin(int min) {_min = min;}
26 void setMax(int max) {_max = max;}
28 bool contains(int val) const {return (val >= _min && val <= _max);}
30 private:
31 int _min, _max;
34 class RangeF
36 public:
37 RangeF() {_min = 0; _max = 0;}
38 RangeF(qreal min, qreal max) : _min(min), _max(max) {}
40 RangeF operator&(const RangeF &r) const;
41 RangeF &operator&=(const RangeF &r) {*this = *this & r; return *this;}
43 qreal min() const {return _min;}
44 qreal max() const {return _max;}
45 qreal size() const {return (_max - _min);}
47 bool isNull() const {return _min == 0 && _max == 0;}
48 bool isValid() const {return size() >= 0;}
50 void setMin(qreal min) {_min = min;}
51 void setMax(qreal max) {_max = max;}
53 void resize(qreal size);
55 private:
56 qreal _min, _max;
59 #ifndef QT_NO_DEBUG
60 QDebug operator<<(QDebug dbg, const Range &range);
61 QDebug operator<<(QDebug dbg, const RangeF &range);
62 #endif // QT_NO_DEBUG
64 #endif // RANGE_H