sciplot  0.3.1
A modern C++ plotting library powered by gnuplot
BorderSpecs.hpp
1 // sciplot - a modern C++ scientific plotting library powered by gnuplot
2 // https://github.com/sciplot/sciplot
3 //
4 // Licensed under the MIT License <http://opensource.org/licenses/MIT>.
5 //
6 // Copyright (c) 2018-2021 Allan Leal
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 // C++ includes
29 #include <bitset>
30 #include <sciplot/Default.hpp>
31 #include <sciplot/specs/DepthSpecsOf.hpp>
32 #include <sciplot/specs/LineSpecsOf.hpp>
33 #include <sciplot/Utils.hpp>
34 
35 // sciplot includes
36 
37 namespace sciplot {
38 
40 class BorderSpecs : public LineSpecsOf<BorderSpecs>, public DepthSpecsOf<BorderSpecs>
41 {
42  public:
44  BorderSpecs();
45 
47  auto clear() -> BorderSpecs&;
48 
50  auto none() -> BorderSpecs&;
51 
53  auto bottom() -> BorderSpecs&;
54 
56  auto left() -> BorderSpecs&;
57 
59  auto top() -> BorderSpecs&;
60 
62  auto right() -> BorderSpecs&;
63 
65  auto bottomLeftFront() -> BorderSpecs&;
66 
68  auto bottomLeftBack() -> BorderSpecs&;
69 
71  auto bottomRightFront() -> BorderSpecs&;
72 
74  auto bottomRightBack() -> BorderSpecs&;
75 
77  auto leftVertical() -> BorderSpecs&;
78 
80  auto backVertical() -> BorderSpecs&;
81 
83  auto rightVertical() -> BorderSpecs&;
84 
86  auto frontVertical() -> BorderSpecs&;
87 
89  auto topLeftBack() -> BorderSpecs&;
90 
92  auto topRightBack() -> BorderSpecs&;
93 
95  auto topLeftFront() -> BorderSpecs&;
96 
98  auto topRightFront() -> BorderSpecs&;
99 
101  auto polar() -> BorderSpecs&;
102 
104  auto repr() const -> std::string;
105 
106  private:
108  std::bitset<13> m_encoding;
109 
111  std::string m_depth;
112 };
113 
115 {
116  left();
117  bottom();
118  lineType(internal::DEFAULT_BORDER_LINETYPE);
119  lineWidth(internal::DEFAULT_BORDER_LINEWIDTH);
120  lineColor(internal::DEFAULT_BORDER_LINECOLOR);
121  front();
122 }
123 
125 {
126  m_encoding.reset();
127  return *this;
128 }
129 
131 {
132  return clear();
133 }
134 
136 {
137  m_encoding.set(0);
138  return *this;
139 }
140 
142 {
143  m_encoding.set(1);
144  return *this;
145 }
146 
147 inline auto BorderSpecs::top() -> BorderSpecs&
148 {
149  m_encoding.set(2);
150  return *this;
151 }
152 
154 {
155  m_encoding.set(3);
156  return *this;
157 }
158 
160 {
161  m_encoding.set(0);
162  return *this;
163 }
164 
166 {
167  m_encoding.set(1);
168  return *this;
169 }
170 
172 {
173  m_encoding.set(2);
174  return *this;
175 }
176 
178 {
179  m_encoding.set(3);
180  return *this;
181 }
182 
184 {
185  m_encoding.set(4);
186  return *this;
187 }
188 
190 {
191  m_encoding.set(5);
192  return *this;
193 }
194 
196 {
197  m_encoding.set(6);
198  return *this;
199 }
200 
202 {
203  m_encoding.set(7);
204  return *this;
205 }
206 
208 {
209  m_encoding.set(8);
210  return *this;
211 }
212 
214 {
215  m_encoding.set(9);
216  return *this;
217 }
218 
220 {
221  m_encoding.set(10);
222  return *this;
223 }
224 
226 {
227  m_encoding.set(11);
228  return *this;
229 }
230 
232 {
233  m_encoding.set(2);
234  return *this;
235 }
236 
237 inline auto BorderSpecs::repr() const -> std::string
238 {
239  std::stringstream ss;
240  ss << "set border " << m_encoding.to_ulong() << " ";
241  ss << DepthSpecsOf<BorderSpecs>::repr() << " ";
242  ss << LineSpecsOf<BorderSpecs>::repr();
243  return internal::removeExtraWhitespaces(ss.str());
244 }
245 
246 } // namespace sciplot
auto top() -> BorderSpecs &
Activate the top border edge on the xy plane for a 2d plot.
Definition: BorderSpecs.hpp:147
auto topRightFront() -> BorderSpecs &
Activate the border edge on the top xy plane going from the right corder to front corner in a 3d pers...
Definition: BorderSpecs.hpp:225
auto bottomRightFront() -> BorderSpecs &
Activate the border edge on the bottom xy plane going from the right corner to front corner in a 3d p...
Definition: BorderSpecs.hpp:171
auto backVertical() -> BorderSpecs &
Activate the back vertical border edge in a 3d perspective.
Definition: BorderSpecs.hpp:189
auto bottomRightBack() -> BorderSpecs &
Activate the border edge on the bottom xy plane going from the right corder to back corner in a 3d pe...
Definition: BorderSpecs.hpp:177
auto lineWidth(int value) -> BorderSpecs &
Set the line width of the underlying line object.
Definition: LineSpecsOf.hpp:101
The class used to attach depth options to a type.
Definition: DepthSpecsOf.hpp:36
auto none() -> BorderSpecs &
Set all border edges to inactive. Methods none and clear have identical effect.
Definition: BorderSpecs.hpp:130
auto lineColor(std::string value) -> BorderSpecs &
Set the line color of the underlying line object.
Definition: LineSpecsOf.hpp:108
auto frontVertical() -> BorderSpecs &
Activate the front vertical border edge in a 3d perspective.
Definition: BorderSpecs.hpp:201
auto front() -> BorderSpecs &
Set the underlying plot element to be displayed on the front of all plot elements.
Definition: DepthSpecsOf.hpp:70
auto left() -> BorderSpecs &
Activate the left border edge on the xy plane for a 2d plot.
Definition: BorderSpecs.hpp:141
The class used to attach line options to a type.
Definition: LineSpecsOf.hpp:38
auto lineType(int value) -> BorderSpecs &
Set the line type of the underlying line object.
Definition: LineSpecsOf.hpp:94
auto bottom() -> BorderSpecs &
Activate the bottom border edge on the xy plane for a 2d plot.
Definition: BorderSpecs.hpp:135
auto bottomLeftBack() -> BorderSpecs &
Activate the border edge on the bottom xy plane going from the left corder to back corner in a 3d per...
Definition: BorderSpecs.hpp:165
auto leftVertical() -> BorderSpecs &
Activate the left vertical border edge in a 3d perspective.
Definition: BorderSpecs.hpp:183
auto repr() const -> std::string
Convert this BorderSpecs object into a gnuplot formatted string.
Definition: BorderSpecs.hpp:237
auto topLeftBack() -> BorderSpecs &
Activate the border edge on the top xy plane going from the left corner to back corner in a 3d perspe...
Definition: BorderSpecs.hpp:207
auto polar() -> BorderSpecs &
Set the border for polar plot.
Definition: BorderSpecs.hpp:231
auto right() -> BorderSpecs &
Activate the right border edge on the xy plane for a 2d plot.
Definition: BorderSpecs.hpp:153
auto bottomLeftFront() -> BorderSpecs &
Activate the border edge on the bottom xy plane going from the left corner to front corner in a 3d pe...
Definition: BorderSpecs.hpp:159
auto clear() -> BorderSpecs &
Remove all border edges from a 2d or 3d plot.
Definition: BorderSpecs.hpp:124
The class used to specify options for plot border.
Definition: BorderSpecs.hpp:41
auto rightVertical() -> BorderSpecs &
Activate the right vertical border edge in a 3d perspective.
Definition: BorderSpecs.hpp:195
BorderSpecs()
Construct a default border instance.
Definition: BorderSpecs.hpp:114
auto topRightBack() -> BorderSpecs &
Activate the border edge on the top xy plane going from the right corder to back corner in a 3d persp...
Definition: BorderSpecs.hpp:213
auto topLeftFront() -> BorderSpecs &
Activate the border edge on the top xy plane going from the left corner to front corner in a 3d persp...
Definition: BorderSpecs.hpp:219