forked from wanttobeno/matplotplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurface.h
More file actions
253 lines (191 loc) 路 7.8 KB
/
Copy pathsurface.h
File metadata and controls
253 lines (191 loc) 路 7.8 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
//
// Created by Alan Freitas on 2020-07-04.
//
#ifndef MATPLOTPLUSPLUS_SURFACE_H
#define MATPLOTPLUSPLUS_SURFACE_H
#include <array>
#include <matplot/core/figure.h>
#include <matplot/util/concepts.h>
#include <matplot/util/handle_types.h>
#include <optional>
#include <matplot/core/axes_object.h>
#include <matplot/core/line_spec.h>
#include <matplot/util/common.h>
namespace matplot {
class axes;
/// Surfaces might include data for contours but, if you only want contours,
/// it's best to use the contour, contourf, fcontour functions to plot it in
/// 2d
class surface : public axes_object {
public:
explicit surface(class axes *parent);
/// Grid surface
surface(class axes *parent, const vector_2d &X, const vector_2d &Y,
const vector_2d &Z, const vector_2d &C,
const std::string &line_spec = "");
/// Parametric surface
// surface(class xlim* parent, const vector_1d& x, const
// vector_1d& y, const vector_1d& z, const vector_1d& c, const
// std::string& line_spec = "");
/// If we receive an axes_handle, we can convert it to a raw
/// pointer because there is no ownership involved here
template <class... Args>
surface(const axes_handle &parent, Args... args)
: surface(parent.get(), args...) {}
public /* mandatory virtual functions */:
std::string set_variables_string() override;
std::string plot_string() override;
std::string legend_string(const std::string &title) override;
std::string data_string() override;
double xmax() override;
double xmin() override;
double ymax() override;
double ymin() override;
enum axes_object::axes_category axes_category() override;
public /* getters and setters */:
class surface &line_style(const std::string &line_spec);
const matplot::line_spec &line_spec() const;
matplot::line_spec &line_spec();
class surface &line_spec(const class line_spec &line_spec);
const vector_2d &Y_data() const;
class surface &Y_data(const vector_2d &Y_data);
const vector_2d &X_data() const;
class surface &X_data(const vector_2d &X_data);
const vector_2d &Z_data() const;
class surface &Z_data(const vector_2d &Z_data);
size_t norm() const;
class surface &norm(size_t norm);
const vector_2d &x_data() const;
class surface &x_data(const vector_2d &x_data);
const vector_2d &y_data() const;
class surface &y_data(const vector_2d &y_data);
const vector_2d &z_data() const;
class surface &z_data(const vector_2d &z_data);
bool hidden_3d() const;
class surface &hidden_3d(bool hidden_3_d);
bool surface_visible() const;
class surface &surface_visible(bool surface_visible);
bool surface_in_2d() const;
class surface &surface_in_2d(bool surface_in_2d);
bool palette_map_at_bottom() const;
class surface &palette_map_at_bottom(bool palette_map_at_bottom);
bool palette_map_at_surface() const;
class surface &palette_map_at_surface(bool palette_map_at_surface);
bool palette_map_at_top() const;
class surface &palette_map_at_top(bool palette_map_at_top);
bool contour_base() const;
class surface &contour_base(bool contour_base);
bool contour_surface() const;
class surface &contour_surface(bool contour_surface);
size_t contour_levels() const;
class surface &contour_levels(size_t contour_levels);
const std::vector<double> &contour_values() const;
class surface &
contour_values(const std::vector<double> &contour_values);
bool contour_text() const;
class surface &contour_text(bool contour_text);
const float font_size() const;
class surface &font_size(const float &font_size);
const std::string font() const;
class surface &font(const std::string &font);
const std::string &font_weight() const;
class surface &font_weight(const std::string &font_weight);
const color_array &font_color() const;
class surface &font_color(const color_array &font_color);
class surface &font_color(const std::string &font_color);
bool depthorder() const;
class surface &depthorder(bool depthorder);
float face_alpha() const;
class surface &face_alpha(float face_alpha);
bool lighting() const;
class surface &lighting(bool lighting);
float primary() const;
class surface &primary(float amount);
float specular() const;
class surface &specular(float amount);
const class line_spec &contour_line_spec() const;
class line_spec &contour_line_spec();
class surface &
contour_line_spec(const class line_spec &contour_line_spec);
bool curtain() const;
class surface &curtain(bool curtain);
bool waterfall() const;
class surface &waterfall(bool waterfall);
bool fences() const;
class surface &fences(bool fences);
bool ribbons() const;
class surface &ribbons(bool ribbons);
double ribbon_width() const;
class surface &ribbon_width(double ribbon_width);
bool visible() const;
class surface &visible(bool visible);
public /* getters and setters bypassing the line_spec */:
float line_width() const;
class surface &line_width(float line_width);
const std::array<float, 4> &edge_color() const;
template <class T> surface &edge_color(T c) {
line_spec().color(c);
touch();
return *this;
}
inline class surface &edge_color(std::initializer_list<float> c) {
line_spec().color(c);
touch();
return *this;
}
double zmin() override;
double zmax() override;
protected:
void maybe_update_line_spec();
std::string grid_data_string();
std::string ribbon_data_string();
size_t create_line_index();
protected:
/// Data in the xlim
vector_2d X_data_{};
vector_2d Y_data_{};
vector_2d Z_data_{};
vector_2d C_data_{};
/// Interpret data as a flat array of parametrics values
/// If false, data needs to represent a grid
/// If true, data represents a free form
bool is_parametric_{false};
/// Preprocess zmin / zmax
double zmin_{NaN};
double zmax_{NaN};
/// Style
size_t norm_{2};
bool hidden3d_{false};
bool depthorder_{false};
float face_alpha_{.95};
class line_spec line_spec_;
bool lighting_{false};
float primary_{-1.};
float specular_{-1.};
bool curtain_{false};
bool waterfall_{false};
bool fences_{false};
bool ribbons_{false};
double ribbon_width_{0.75};
// Line surface
bool surface_visible_{true};
bool surface_in_2d_{false};
// Solid surface
bool palette_map_at_bottom_{false};
bool palette_map_at_surface_{true};
bool palette_map_at_top_{false};
class line_spec contour_line_spec_;
bool contour_base_{false};
bool contour_surface_{false};
size_t contour_levels_{9};
std::vector<double> contour_values_{};
bool contour_text_{false};
std::optional<float> font_size_{std::nullopt};
std::optional<std::string> font_{std::nullopt};
std::string font_weight_{"normal"};
color_array font_color_{0, 0, 0, 0};
/// True if visible
bool visible_{true};
};
} // namespace matplot
#endif // MATPLOTPLUSPLUS_SURFACE_H