forked from alandefreitas/matplotplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaxes_object.cpp
More file actions
135 lines (105 loc) 路 3.31 KB
/
Copy pathaxes_object.cpp
File metadata and controls
135 lines (105 loc) 路 3.31 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
//
// Created by Alan Freitas on 2020-07-05.
//
#include <matplot/core/axes.h>
#include <matplot/core/axes_object.h>
#include <matplot/util/common.h>
namespace matplot {
axes_object::axes_object(class axes* parent) : parent_(parent) {
const bool axes_have_legend = parent_->legend() != nullptr;
if (axes_have_legend) {
const bool all_objects_have_legend = parent_->legend()->strings().size() >= parent_->children().size();
if (all_objects_have_legend) {
parent_->legend()->strings().emplace_back("data " + num2str(parent_->children().size() + 1));
}
}
}
axes_object::axes_object(axes_handle parent) : axes_object(parent.get()) {};
const class axes* axes_object::parent() const {
return parent_;
}
class axes* &axes_object::parent() {
return parent_;
}
void axes_object::touch() {
parent_->touch();
}
void axes_object::parent(class axes* &parent) {
parent_ = parent;
}
std::string axes_object::data_string() {
return "";
}
std::string axes_object::set_variables_string() {
return "";
}
std::string axes_object::legend_string(const std::string& title) {
return "keyentry with boxes title \"" + escape(title) + "\"";
}
std::string axes_object::legend_string(std::vector<std::string>::iterator& titles_begin, std::vector<std::string>::iterator& titles_end) {
if (!display_name_.empty()) {
// if this object has its own display name
return legend_string(display_name_);
} else {
// by default, take just one title
std::string res;
if (titles_begin != titles_end) {
res += legend_string(*titles_begin);
}
++titles_begin;
return res;
}
}
std::string axes_object::unset_variables_string() {
return "";
}
double axes_object::xmax() {
return -10;
}
double axes_object::xmin() {
return +10;
}
double axes_object::ymax() {
return -10;
}
double axes_object::ymin() {
return +10;
}
double axes_object::zmax() {
return -10;
}
double axes_object::zmin() {
return +10;
}
enum axes_object::axes_category axes_object::axes_category() {
return axes_category::two_dimensional;
}
bool axes_object::requires_colormap() {
return true;
}
std::string axes_object::tag() {
return tag_;
}
void axes_object::tag(const std::string& tag_name) {
tag_ = tag_name;
}
bool axes_object::is_2d() {
return axes_category() == axes_category::two_dimensional;
}
bool axes_object::is_3d() {
return axes_category() == axes_category::three_dimensional || axes_category() == axes_category::three_dimensional_map;
}
bool axes_object::is_3d_map() {
return axes_category() == axes_category::three_dimensional_map;
}
bool axes_object::is_polar() {
return axes_category() == axes_category::polar;
}
const std::string &axes_object::display_name() const {
return display_name_;
}
void axes_object::display_name(const std::string &display_name) {
display_name_ = display_name;
touch();
}
}