forked from alandefreitas/matplotplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_function.cpp
More file actions
80 lines (67 loc) 路 2.05 KB
/
Copy pathstring_function.cpp
File metadata and controls
80 lines (67 loc) 路 2.05 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
//
// Created by Alan Freitas on 2020-07-06.
//
#include <matplot/axes_objects/string_function.h>
#include <matplot/core/axes_type.h>
namespace matplot {
string_function::string_function(class axes_type *parent)
: string_function(parent, "x", "") {}
string_function::string_function(class axes_type *parent,
std::string_view equation,
std::string_view line_spec)
: line(parent, {}, line_spec), equation_(equation) {}
std::string string_function::plot_string() {
maybe_update_line_spec();
std::string res;
bool first = true;
for (const auto &style : styles_to_plot()) {
if (!first) {
res += ",";
}
res += " " + equation_ + " " + line_spec_.plot_string(style, true);
if (first) {
first = false;
}
}
return res;
}
std::string string_function::data_string() { return ""; }
double string_function::xmax() {
if (is_polar()) {
return 2;
}
return axes_object::xmax();
}
double string_function::xmin() {
if (is_polar()) {
return -2;
}
return axes_object::xmin();
}
double string_function::ymax() {
if (is_polar()) {
return 2;
}
return axes_object::ymax();
}
double string_function::ymin() {
if (is_polar()) {
return -2;
}
return axes_object::ymin();
}
enum axes_object::axes_category string_function::axes_category() {
if (polar_) {
return axes_object::axes_category::polar;
} else {
return axes_object::axes_category::two_dimensional;
}
}
const std::string &string_function::equation() const { return equation_; }
class string_function &
string_function::equation(std::string_view equation) {
equation_ = equation;
parent()->draw();
return *this;
}
} // namespace matplot