DigitalAxis.hh
1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* DigitalAxis.hh
*
* Created on: 22 nov. 2013
* Author: CS
*/
#ifndef DIGITALAXIS_HH_
#define DIGITALAXIS_HH_
#include <cmath>
#include <ctgmath>
#include "Axis.hh"
namespace plot {
int computeScientificFormatPrecision(double min, double max);
void getDigitalLabel(double value, int precision, char* label, int length);
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;
static const int STANDARD_FORMAT_PRECISION;
/**
* Constant used to reinterpret log10(0).
*/
static const int LOG_CONSTANT;
enum Format {
STANDARD, SCIENTIFIC
};
DigitalAxis() :
Axis(), _scientific_format_precision(1) {
if (_showTickMark == true)
_labelGenerator->_function = generateDigitalLabel;
else
_labelGenerator->_function = generateNoDigitalLabel;
_labelGenerator->_data = this;
}
DigitalAxis(const DigitalAxis& axis) :
Axis(axis), _scientific_format_precision(axis._scientific_format_precision) {
if (_showTickMark == true)
_labelGenerator->_function = generateDigitalLabel;
else
_labelGenerator->_function = generateNoDigitalLabel;
_labelGenerator->_data = this;
}
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);
int getScientificFormatPrecision() {
return _scientific_format_precision;
}
private:
int _scientific_format_precision;
};
} /* namespace plot */
#endif /* DIGITALAXIS_HH_ */