Blame view

src/ParamOutputImpl/Plot/DigitalAxis.hh 1.95 KB
fbe3c2bb   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
/*
 * DigitalAxis.hh
 *
 *  Created on: 22 nov. 2013
 *      Author: CS
 */

#ifndef DIGITALAXIS_HH_
#define DIGITALAXIS_HH_

46ca92d0   Elena.Budnik   add / move header...
11
12
#include <cmath>
#include <ctgmath>
fbe3c2bb   Benjamin Renard   First commit
13
14
15
16
#include "Axis.hh"

namespace plot {

b358ee7d   Benjamin Renard   Adapt axes labels...
17
int computeScientificFormatPrecision(double min, double max);
3371b1c8   Erdogan Furkan   #11199 - done
18
void getDigitalLabel(double value, int precision, char* label, int length, double min, double max);
fbe3c2bb   Benjamin Renard   First commit
19
20
21
22
23
24
25
void generateDigitalLabel(PLINT axis, PLFLT value, char *label, PLINT length, PLPointer data);
void generateNoDigitalLabel(PLINT axis, PLFLT value, char *label, PLINT length,	PLPointer data);

class DigitalAxis: public plot::Axis {

public:
	static const int MAX_DIGIT_NUMBER;
fbe3c2bb   Benjamin Renard   First commit
26
27
28
29
30
31
32
33
34
35
36
	static const int STANDARD_FORMAT_PRECISION;
	/**
	 * Constant used to reinterpret log10(0).
	 */
	static const int LOG_CONSTANT;

	enum Format {
		STANDARD, SCIENTIFIC
	};

	DigitalAxis() :
b358ee7d   Benjamin Renard   Adapt axes labels...
37
			Axis(), _scientific_format_precision(1) {
fbe3c2bb   Benjamin Renard   First commit
38
39
40
41
		if (_showTickMark == true)
			_labelGenerator->_function = generateDigitalLabel;
		else
			_labelGenerator->_function = generateNoDigitalLabel;
b358ee7d   Benjamin Renard   Adapt axes labels...
42
                _labelGenerator->_data = this;
fbe3c2bb   Benjamin Renard   First commit
43
44
45
	}

	DigitalAxis(const DigitalAxis& axis) :
b358ee7d   Benjamin Renard   Adapt axes labels...
46
			Axis(axis), _scientific_format_precision(axis._scientific_format_precision) {
fbe3c2bb   Benjamin Renard   First commit
47
48
49
50
		if (_showTickMark == true)
			_labelGenerator->_function = generateDigitalLabel;
		else
			_labelGenerator->_function = generateNoDigitalLabel;
b358ee7d   Benjamin Renard   Adapt axes labels...
51
                _labelGenerator->_data = this;
fbe3c2bb   Benjamin Renard   First commit
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
	}

	virtual ~DigitalAxis() {
	}

	void dump(std::ostream& out) {
		Axis::dump(out);
		out << std::endl;
	}

	virtual std::string getPlotOpt();

	virtual Range getRange();

	virtual Format getFormat();

	virtual std::pair<int, int> getTickMarkSize();

	/**
	 * @overrides Axis::getComputedValues
	 */
	virtual double* getComputedValues(double* values_, int size_, double min, double max);
b358ee7d   Benjamin Renard   Adapt axes labels...
74
75
76
77
        
        int getScientificFormatPrecision() {
            return _scientific_format_precision;
        }
fbe3c2bb   Benjamin Renard   First commit
78

b358ee7d   Benjamin Renard   Adapt axes labels...
79
80
private:
        int _scientific_format_precision;
fbe3c2bb   Benjamin Renard   First commit
81
82
83
84
85
};

} /* namespace plot */

#endif /* DIGITALAXIS_HH_ */