NAPISD
PAHdb website C++ backend
Loading...
Searching...
No Matches
Axis.h
1#ifndef _AXIS_H_
2#define _AXIS_H_
3
4#include <array>
5#include <string>
6#include <string_view>
7#include <vector>
8
9#include <cmath>
10
11#include <plplot/plstream.h>
12
13typedef PLINT (*PLTICK_FUNC_callback)(PLINT axis, PLINT nticks, PLFLT *ticks,
14 PLFLT min, PLFLT max, PLPointer data);
15
16class Axis {
17
18public:
19 enum class Style : char { Default, WritePowerInFrame };
20
21 Axis();
22
23 std::string_view getAxisOptString() const;
24
25 void setTitle(std::string_view title);
26
27 std::string_view getTitle() const;
28
29 void setDrawZeroLine(bool on);
30
31 void setDrawConventionalAxis(bool on);
32
33 void setDrawUnconventionalAxis(bool on);
34
35 void setLabelsAsDate(bool on);
36
37 void setFixedPoint(bool on);
38
39 void setInvertedTicks(bool on);
40
41 void setLogarithmic(bool on);
42
43 void setDrawConventionalLabels(bool on);
44
45 void setDrawUnconventionalLabels(bool on);
46
47 void setDrawSubTicks(bool on);
48
49 void setDrawTicks(bool on);
50
51 void setWriteLabelsParallel(bool on);
52
53 void setPrecision(int precision);
54
55 const int &getPrecision() const;
56
57 void setMaxDigits(int max);
58
59 const int &getMaxDigits() const;
60
61 void setStyle(Style style);
62
63 const Style &getStyle() const;
64
65 void setReciprocalLabelFormatter();
66
67 void setReciprocalTickFinder();
68
69 PLLABEL_FUNC_callback getLabelFormatter();
70
71 PLTICK_FUNC_callback getTickFinder();
72
73private:
74 std::string _title;
75
76 std::string _axisoptstr;
77
78 int _precision;
79
80 int _maxdigits;
81
82 Style _style;
83
84 PLLABEL_FUNC_callback _label_callback;
85
86 PLTICK_FUNC_callback _tick_callback;
87
88 void _set(char option, bool on);
89
90 static void _reciprocal_labeller(PLINT axis, PLFLT value,
91 PLCHAR_NC_VECTOR label, PLINT length,
92 PLPointer data);
93
94 static PLINT _reciprocal_tickfinder(PLINT axis, PLINT nticks, PLFLT *ticks,
95 PLFLT min, PLFLT max, PLPointer data);
96};
97
98inline std::string_view Axis::getAxisOptString() const { return (_axisoptstr); }
99
100inline void Axis::setTitle(const std::string_view title) { _title = title; }
101
102inline std::string_view Axis::getTitle() const { return (_title); }
103
104inline void Axis::setDrawZeroLine(bool on = true) { _set('a', on); }
105
106inline void Axis::setDrawConventionalAxis(bool on = true) { _set('b', on); }
107
108inline void Axis::setDrawUnconventionalAxis(bool on = true) { _set('c', on); }
109
110inline void Axis::setLabelsAsDate(bool on = true) { _set('d', on); }
111
112inline void Axis::setFixedPoint(bool on = true) { _set('f', on); }
113
114inline void Axis::setInvertedTicks(bool on = true) { _set('i', on); }
115
116inline void Axis::setLogarithmic(bool on = true) { _set('l', on); }
117
118inline void Axis::setDrawConventionalLabels(bool on = true) { _set('n', on); }
119
120inline void Axis::setDrawUnconventionalLabels(bool on = true) { _set('m', on); }
121
122inline void Axis::setDrawSubTicks(bool on = true) { _set('s', on); }
123
124inline void Axis::setDrawTicks(bool on = true) { _set('t', on); }
125
126inline void Axis::setWriteLabelsParallel(bool on = true) { _set('v', on); }
127
128inline void Axis::setPrecision(int precision) { _precision = precision; }
129
130inline const int &Axis::getPrecision() const { return (_precision); }
131
132inline void Axis::setMaxDigits(int max) { _maxdigits = max; }
133
134inline const int &Axis::getMaxDigits() const { return (_maxdigits); }
135
136inline void Axis::setStyle(Axis::Style style) { _style = style; }
137
138inline const Axis::Style &Axis::getStyle() const { return (_style); }
139
140inline void Axis::setReciprocalLabelFormatter() {
141 _set('o', true);
142 _label_callback = Axis::_reciprocal_labeller;
143}
144
145inline void Axis::setReciprocalTickFinder() {
146 _tick_callback = Axis::_reciprocal_tickfinder;
147}
148
149inline PLLABEL_FUNC_callback Axis::getLabelFormatter() {
150 return _label_callback;
151}
152
153inline PLTICK_FUNC_callback Axis::getTickFinder() { return _tick_callback; }
154
155#endif /* _AXIS_H_ */
Definition Axis.h:16

Since FY2019 the NASA Ames PAH IR Spectroscopic Database is being supported through a directed Work Package at NASA Ames titled: "Laboratory Astrophysics - The NASA Ames PAH IR Spectroscopic Database".
Since FY2023 the NASA Ames PAH IR Spectroscopic Database is being supported through the Laboratory Astrophysics Rd 2 directed Work Package at NASA Ames.
© Copyright 2021-2025, Christiaan Boersma