NAPISD
PAHdb website C++ backend
Loading...
Searching...
No Matches
Plot.h
1#ifndef _PLOT_H_
2#define _PLOT_H_
3
4#include "CanvasItem.h"
5
6#include "Line.h"
7
8#include "LineProperties.h"
9
10#include "Curve.h"
11
12#include "Axis.h"
13
14#include <array>
15#include <memory>
16#include <string>
17#include <string_view>
18#include <vector>
19
20class Plot : public CanvasItem, public LineProperties {
21
22public:
23 typedef std::vector<std::unique_ptr<CanvasItem>>::iterator iterator;
24
25 Plot();
26 virtual Plot *clone() const;
27 Plot(Plot const &other);
28 CanvasItem &operator[](std::size_t idx);
29
30 iterator begin() noexcept { return (_items.begin()); }
31
32 iterator end() noexcept { return (_items.end()); }
33
34 void add(CanvasItem &item);
35
36 void add(std::vector<CanvasItem> &items);
37
38 void clear();
39
40 void erase(std::vector<std::unique_ptr<CanvasItem>>::iterator begin,
41 std::vector<std::unique_ptr<CanvasItem>>::iterator end);
42
43 void setXLimits(const std::array<double, 2> &limits);
44
45 std::array<double, 2> const &getXLimits() const;
46
47 void setYLimits(const std::array<double, 2> &limits);
48
49 std::array<double, 2> const &getYLimits() const;
50
51 void setZLimits(const std::array<double, 2> &limits);
52
53 std::array<double, 2> const &getZLimits() const;
54
55 void setXMargins(const std::array<double, 2> &margins);
56
57 std::array<double, 2> const &getXMargins() const;
58
59 void setYMargins(const std::array<double, 2> &margins);
60
61 std::array<double, 2> const &getYMargins() const;
62
63 void setZMargins(const std::array<double, 2> &margins);
64
65 std::array<double, 2> const &getZMargins() const;
66
67 void setTitle(std::string_view title);
68
69 std::string_view getTitle() const;
70
71 void setDrawHorizontalGrid(bool on);
72
73 LineProperties &getHorizontalGrid();
74
75 bool isDrawHorizontalGrid() const;
76
77 void setDrawVerticalGrid(bool on);
78
79 LineProperties &getVerticalGrid();
80
81 bool isDrawVerticalGrid() const;
82
83 void setDrawHorizontalFineGrid(bool on);
84
85 bool isDrawHorizontalFineGrid() const;
86
87 void setDrawVerticalFineGrid(bool on);
88
89 bool isDrawVerticalFineGrid() const;
90
91 void setAdvance(bool on);
92
93 bool isAdvance() const;
94
95 std::vector<Axis> &getXAxis();
96
97 std::vector<Axis> &getYAxis();
98
99 std::vector<Axis> &getZAxis();
100
101 void setFontSize(double size);
102
103 const double &getFontSize() const;
104
105 void setMajorTickLength(double length);
106
107 const double &getMajorTickLength() const;
108
109 void setMinorTickLength(double length);
110
111 const double &getMinorTickLength() const;
112
113 void test() {
114 for (auto &item : _items) {
115 printf("%d\n", (int)item->type);
116 }
117 }
118
119private:
120 std::vector<std::unique_ptr<CanvasItem>> _items;
121
122 std::array<double, 2> _xlimits;
123
124 std::array<double, 2> _ylimits;
125
126 std::array<double, 2> _zlimits;
127
128 std::array<double, 2> _xmargins;
129
130 std::array<double, 2> _ymargins;
131
132 std::array<double, 2> _zmargins;
133
134 std::string _title;
135
136 LineProperties _horizontalgrid;
137
138 LineProperties _verticalgrid;
139
140 std::vector<Axis> _xaxis;
141
142 std::vector<Axis> _yaxis;
143
144 std::vector<Axis> _zaxis;
145
146 double _fontsize;
147
148 double _majorticklength;
149
150 double _minorticklength;
151
152 bool _drawhorizontalgrid;
153
154 bool _drawverticalgrid;
155
156 bool _drawhorizontalfinegrid;
157
158 bool _drawverticalfinegrid;
159
160 bool _advance;
161};
162
163inline CanvasItem &Plot::operator[](std::size_t idx) { return (*_items[idx]); }
164
165inline void Plot::clear() { _items.clear(); }
166
167inline void
168Plot::erase(std::vector<std::unique_ptr<CanvasItem>>::iterator begin,
169 std::vector<std::unique_ptr<CanvasItem>>::iterator end) {
170 _items.erase(begin, end);
171}
172
173inline void Plot::setXLimits(const std::array<double, 2> &limits) {
174 _xlimits = limits;
175}
176
177inline void Plot::setYLimits(const std::array<double, 2> &limits) {
178 _ylimits = limits;
179}
180
181inline void Plot::setZLimits(const std::array<double, 2> &limits) {
182 _zlimits = limits;
183}
184
185inline void Plot::setXMargins(const std::array<double, 2> &margins) {
186 _xmargins = margins;
187}
188
189inline void Plot::setYMargins(const std::array<double, 2> &margins) {
190 _ymargins = margins;
191}
192
193inline void Plot::setZMargins(const std::array<double, 2> &margins) {
194 _zmargins = margins;
195}
196
197inline void Plot::setTitle(std::string_view title) { _title = title; }
198
199inline std::string_view Plot::getTitle() const { return (_title); }
200
201inline std::array<double, 2> const &Plot::getXLimits() const {
202 return (_xlimits);
203}
204
205inline std::array<double, 2> const &Plot::getYLimits() const {
206 return (_ylimits);
207}
208
209inline std::array<double, 2> const &Plot::getZLimits() const {
210 return (_zlimits);
211}
212
213inline std::array<double, 2> const &Plot::getXMargins() const {
214 return (_xmargins);
215}
216
217inline std::array<double, 2> const &Plot::getYMargins() const {
218 return (_ymargins);
219}
220
221inline std::array<double, 2> const &Plot::getZMargins() const {
222 return (_zmargins);
223}
224
225inline void Plot::setDrawHorizontalGrid(bool on = true) {
226 _drawhorizontalgrid = on;
227}
228
229inline LineProperties &Plot::getHorizontalGrid() { return (_horizontalgrid); }
230
231inline bool Plot::isDrawHorizontalGrid() const { return (_drawhorizontalgrid); }
232
233inline void Plot::setDrawVerticalGrid(bool on = true) {
234 _drawverticalgrid = on;
235}
236
237inline LineProperties &Plot::getVerticalGrid() { return (_verticalgrid); }
238
239inline bool Plot::isDrawVerticalGrid() const { return (_drawverticalgrid); }
240
241inline void Plot::setDrawHorizontalFineGrid(bool on = true) {
242 _drawhorizontalfinegrid = on;
243}
244
245inline bool Plot::isDrawHorizontalFineGrid() const {
246 return (_drawhorizontalfinegrid);
247}
248
249inline void Plot::setDrawVerticalFineGrid(bool on = true) {
250 _drawverticalfinegrid = on;
251}
252
253inline bool Plot::isDrawVerticalFineGrid() const {
254 return (_drawverticalfinegrid);
255}
256
257inline bool Plot::isAdvance() const { return (_advance); }
258
259inline void Plot::setAdvance(bool on = true) { _advance = on; }
260
261inline void Plot::setFontSize(double fontsize) { _fontsize = fontsize; }
262
263inline const double &Plot::getFontSize() const { return (_fontsize); }
264
265inline void Plot::setMajorTickLength(double length) {
266 _majorticklength = length;
267}
268
269inline const double &Plot::getMajorTickLength() const {
270 return (_majorticklength);
271}
272
273inline void Plot::setMinorTickLength(double length) {
274 _minorticklength = length;
275}
276
277inline const double &Plot::getMinorTickLength() const {
278 return (_minorticklength);
279}
280
281inline std::vector<Axis> &Plot::getXAxis() { return (_xaxis); }
282
283inline std::vector<Axis> &Plot::getYAxis() { return (_yaxis); }
284
285inline std::vector<Axis> &Plot::getZAxis() { return (_zaxis); }
286
287#endif /* _PLOT_H_ */
Definition Plot.h:20

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