Blame view

src/ParamOutputImpl/Plot/Range.hh 1.69 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * Range.hh
 *
 *  Created on: 20 nov. 2013
 *      Author: CS
 */

#ifndef RANGE_HH_
#define RANGE_HH_

#include <utility>
#include <cmath>
#include <string>
#include <ostream>

namespace plot {

class Range {
public:
	Range() :
641ba7e4   Hacene SI HADJ MOHAND   ok for time plot
21
			_extend(true), _margin(0), _range(nan(""), nan("")) {
fbe3c2bb   Benjamin Renard   First commit
22
23
	}
	Range(double min, double max) :
641ba7e4   Hacene SI HADJ MOHAND   ok for time plot
24
25
26
27
			_extend(true), _margin(0), _range(min, max){
	}
                    Range(double min, double max, double margin) :
			_extend(true), _margin(margin) ,_range(min, max){
fbe3c2bb   Benjamin Renard   First commit
28
29
30
	}

	Range(const Range& pRange) :
641ba7e4   Hacene SI HADJ MOHAND   ok for time plot
31
				_extend(pRange._extend), _margin(pRange._margin), _range(pRange._range) {
fbe3c2bb   Benjamin Renard   First commit
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	}
	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;
	}
641ba7e4   Hacene SI HADJ MOHAND   ok for time plot
49
50
51
52
53
54
55
        
        	void setMargin(double margin) {
		_margin = margin;
	}
	double getMargin() {
		return _margin;
	}
fbe3c2bb   Benjamin Renard   First commit
56
57
58
59
60
61
62
63
64
65
66

	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;
641ba7e4   Hacene SI HADJ MOHAND   ok for time plot
67
68
        
                    double _margin;
fbe3c2bb   Benjamin Renard   First commit
69
70
71

private:
	std::pair<double, double> _range;
641ba7e4   Hacene SI HADJ MOHAND   ok for time plot
72
                   
fbe3c2bb   Benjamin Renard   First commit
73
74
75
76
77
78
79
80
81
82
83
84
85
};

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);

faf4d845   Benjamin Renard   Add common functi...
86
void fixRange(Range &pRange, bool isLogScale);
e062d6ef   Benjamin Renard   Fix axes range wh...
87

fbe3c2bb   Benjamin Renard   First commit
88
89
} /* namespace plot */
#endif /* RANGE_HH_ */