/* * Range.hh * * Created on: 20 nov. 2013 * Author: CS */ #ifndef RANGE_HH_ #define RANGE_HH_ #include #include #include #include namespace plot { class Range { public: Range() : _extend(true), _margin(0), _range(nan(""), nan("")) { } Range(double min, double max) : _extend(true), _margin(0), _range(min, max){ } Range(double min, double max, double margin) : _extend(true), _margin(margin) ,_range(min, max){ } Range(const Range& pRange) : _extend(pRange._extend), _margin(pRange._margin), _range(pRange._range) { } virtual ~Range() { } double getMin() const { return _range.first; } double getMax() const { return _range.second; } void setMin(double min) { _range.first = min; } void setMax(double max) { _range.second = max; } void setMargin(double margin) { _margin = margin; } double getMargin() { return _margin; } bool isSet() { return !std::isnan(_range.first) || !std::isnan(_range.second); } void dump(std::ostream& out, std::string& prefix) { out << prefix << "range.min=" << getMin() << std::endl; out << prefix << "range.max=" << getMax() << std::endl; } bool _extend; double _margin; private: std::pair _range; }; inline std::ostream& operator <<(std::ostream& out, const Range& range) { out << "[" << range.getMin() << ", " << range.getMax() << "]" << std::endl; return out; } double extend2UpperValue(double lValue); double extend2LowerValue(double lValue); Range extendRange(Range pRange); void fixRange(Range &pRange, bool isLogScale); } /* namespace plot */ #endif /* RANGE_HH_ */