forked from alandefreitas/matplotplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathline.h
More file actions
198 lines (153 loc) 路 6.06 KB
/
Copy pathline.h
File metadata and controls
198 lines (153 loc) 路 6.06 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
//
// Created by Alan Freitas on 2020-07-04.
//
#ifndef MATPLOTPLUSPLUS_LINE_H
#define MATPLOTPLUSPLUS_LINE_H
#include <matplot/detail/config.h>
#include <matplot/core/axes_object.h>
#include <matplot/core/figure_type.h>
#include <matplot/core/line_spec.h>
#include <matplot/util/concepts.h>
#include <matplot/util/handle_types.h>
#include <array>
namespace matplot {
class axes_type;
class MATPLOT_EXPORTS line : public axes_object {
public:
explicit line(class axes_type *parent);
line(class axes_type *parent, const std::vector<double> &y_data,
std::string_view line_spec = "");
line(class axes_type *parent, const std::vector<double> &x_data,
const std::vector<double> &y_data,
std::string_view line_spec = "");
line(class axes_type *parent, const std::vector<double> &x_data,
const std::vector<double> &y_data,
const std::vector<double> &z_data,
std::string_view 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>
line(const axes_handle &parent, Args &&... args)
: line(parent.get(), std::forward<Args>(args)...) {}
virtual ~line() = default;
public /* mandatory virtual functions */:
void run_draw_commands() override;
std::string plot_string() override;
std::string legend_string(std::string_view 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;
bool requires_colormap() override;
public /* getters and setters */:
class line &line_style(std::string_view line_spec);
const matplot::line_spec &line_spec() const;
matplot::line_spec &line_spec();
class line &line_spec(const class line_spec &line_spec);
const std::vector<double> &y_data() const;
class line &y_data(const std::vector<double> &y_data);
const std::vector<double> &x_data() const;
class line &x_data(const std::vector<double> &x_data);
const std::vector<double> &z_data() const;
class line &z_data(const std::vector<double> &z_data);
const std::vector<size_t> &marker_indices() const;
class line &marker_indices(const std::vector<size_t> &marker_indices);
bool use_y2() const;
class line &use_y2(bool use_y_2);
bool impulse() const;
class line &impulse(bool impulse);
bool fill() const;
class line &fill(bool fill);
bool use_y_2() const;
class line &use_y_2(bool use_y_2);
bool polar() const;
class line &polar(bool polar);
bool visible() const;
class line &visible(bool visible);
public /* getters and setters bypassing the line_spec */:
float line_width() const;
class line &line_width(float line_width);
enum line_spec::marker_style marker_style() const;
template <class T> line &marker_style(T marker_style) {
line_spec_.marker_style(marker_style);
return *this;
}
enum line_spec::marker_style marker() const;
template <class T> line &marker(T marker) {
line_spec_.marker(marker);
return *this;
}
float marker_size() const;
class line &marker_size(float size);
class line &marker_size(const std::vector<float> &size_vector);
class line &marker_size(const std::vector<double> &size_vector);
bool marker_face() const;
class line &marker_face(bool size);
const std::array<float, 4> &color() const;
template <class T> line &color(T c) {
line_spec().color(c);
return *this;
}
inline class line &color(std::initializer_list<float> c) {
line_spec().color(c);
return *this;
}
const std::array<float, 4> &marker_color() const;
template <class T> line &marker_color(T c) {
line_spec().marker_color(c);
return *this;
}
inline class line &marker_color(std::initializer_list<float> c) {
line_spec().marker_color(c);
return *this;
}
inline class line &marker_colors(const std::vector<double> &cs) {
marker_colors_ = cs;
touch();
return *this;
}
const std::array<float, 4> &marker_face_color() const;
template <class T> line &marker_face_color(T c) {
line_spec().marker_face_color(c);
return *this;
}
inline class line &marker_face_color(std::initializer_list<float> c) {
line_spec().marker_face_color(c);
return *this;
}
inline float marker_face_alpha() {
return line_spec().marker_face_alpha();
}
inline class line &marker_face_alpha(float a) {
line_spec().marker_face_alpha(a);
return *this;
}
protected:
virtual std::vector<line_spec::style_to_plot> styles_to_plot();
void maybe_update_line_spec();
protected:
/// Line style
matplot::line_spec line_spec_;
/// Data in the xlim
std::vector<double> y_data_{};
std::vector<double> x_data_{};
std::vector<double> z_data_{};
/// Positions at which we want markers to appear
std::vector<size_t> marker_indices_{};
std::vector<float> marker_sizes_{};
std::vector<double> marker_colors_{};
/// Draw line as impulse
bool impulse_{false};
/// Draw line as filled area
bool fill_{false};
/// Use the y2 xlim
bool use_y2_{false};
/// This line is meant for a polar plot
bool polar_{false};
/// True if visible
bool visible_{true};
};
} // namespace matplot
#endif // MATPLOTPLUSPLUS_LINE_H