24 #ifndef COM_DAFER45_TBTK_CANVAS_3D
25 #define COM_DAFER45_TBTK_CANVAS_3D
27 #include "TBTK/Canvas.h"
35 class Canvas3D :
public Canvas{
44 void setBoundsX(
double minX,
double maxX);
47 void setBoundsY(
double minY,
double maxY);
50 void setBoundsZ(
double minZ,
double maxZ);
63 double getMinX()
const;
66 double getMaxX()
const;
69 double getMinY()
const;
72 double getMaxY()
const;
75 double getMinZ()
const;
78 double getMaxZ()
const;
81 void setLabelX(
const std::string &labelX);
84 void setLabelY(
const std::string &labelY);
87 void setLabelZ(
const std::string &labelZ);
90 const std::string& getLabelX()
const;
93 const std::string& getLabelY()
const;
96 const std::string& getLabelZ()
const;
99 void setHold(
bool hold);
102 void setTopView(
bool topView);
105 bool getTopView()
const;
109 const std::vector<std::vector<double>> &z,
110 const std::string &title =
"",
111 const std::vector<unsigned char> &color = {0, 0, 0}
116 const std::vector<double> &x,
117 const std::vector<double> &y,
118 const std::vector<std::vector<double>> &values,
119 const std::string &title =
"",
120 const std::vector<unsigned char> &color = {0, 0, 0}
124 virtual void clear();
129 unsigned int getNumDataSets()
const;
136 const std::vector<double>& getX(
unsigned int dataSet)
const;
143 const std::vector<double>& getY(
unsigned int dataSet)
const;
150 const std::vector<std::vector<double>>& getZ(
159 const std::string& getTitle(
unsigned int dataSet)
const;
166 const std::vector<unsigned char>& getColor(
unsigned int dataSet)
const;
169 double minX, maxX, minY, maxY, minZ, maxZ;
172 std::string labelX, labelY, labelZ;
186 std::vector<std::vector<double>>,
188 std::vector<unsigned char>
193 inline void Canvas3D::setBoundsX(
199 "Canvas3D::setBoundsX()",
200 "minX has to be smaller than maxX.",
205 this->minX = minX - 1e-10;
206 this->maxX = maxX + 1e-10;
214 inline void Canvas3D::setBoundsY(
220 "Canvas3D::setBoundsY()",
221 "minY has to be smaller than maxY.",
226 this->minY = minY - 1e-10;
227 this->maxY = maxY + 1e-10;
235 inline void Canvas3D::setBoundsZ(
241 "Canvas3D::setBoundsZ()",
242 "minZ has to be smaller than maxZ.",
247 this->minZ = minZ - 1e-10;
248 this->maxZ = maxZ + 1e-10;
256 inline void Canvas3D::setBounds(
264 setBoundsX(minX, maxX);
265 setBoundsY(minY, maxY);
266 setBoundsY(minZ, maxZ);
269 inline double Canvas3D::getMinX()
const{
273 inline double Canvas3D::getMaxX()
const{
277 inline double Canvas3D::getMinY()
const{
281 inline double Canvas3D::getMaxY()
const{
285 inline double Canvas3D::getMinZ()
const{
289 inline double Canvas3D::getMaxZ()
const{
293 inline void Canvas3D::setLabelX(
const std::string &labelX){
294 this->labelX = labelX;
297 inline void Canvas3D::setLabelY(
const std::string &labelY){
298 this->labelY = labelY;
301 inline void Canvas3D::setLabelZ(
const std::string &labelZ){
302 this->labelZ = labelZ;
305 inline const std::string& Canvas3D::getLabelX()
const{
309 inline const std::string& Canvas3D::getLabelY()
const{
313 inline const std::string& Canvas3D::getLabelZ()
const{
317 inline void Canvas3D::setHold(
bool hold){
321 inline void Canvas3D::setTopView(
bool topView){
322 this->topView = topView;
325 inline bool Canvas3D::getTopView()
const{
329 inline void Canvas3D::plot(
330 const std::vector<std::vector<double>> &z,
331 const std::string &title,
332 const std::vector<unsigned char> &color
341 std::vector<double> x;
342 for(
unsigned int n = 0; n < z.size(); n++)
345 std::vector<double> y;
346 for(
unsigned int n = 0; n < z[0].size(); n++)
349 plot(x, y, z, title, color);
352 inline void Canvas3D::plot(
353 const std::vector<double> &x,
354 const std::vector<double> &y,
355 const std::vector<std::vector<double>> &z,
356 const std::string &title,
357 const std::vector<unsigned char> &color
360 x.size() == z.size(),
362 "'x' and 'z' must have the same size, but z has size '"
363 << x.size() <<
"' while z has size'" << z.size() <<
"'.",
366 for(
unsigned int n = 0; n < z.size(); n++){
368 y.size() == z[n].size(),
370 "'y' and 'z[ << n << ]' must have the same size, but y"
371 <<
" has size'" << y.size() <<
"' while z[" << n
372 <<
"]' has size '" << z[n].size() <<
"'.",
379 "The color must have three components but have '"
380 << color.size() <<
"'.",
387 dataSets.push_back(std::make_tuple(x, y, z, title, color));
390 inline void Canvas3D::clear(){
394 inline unsigned int Canvas3D::getNumDataSets()
const{
395 return dataSets.size();
398 inline const std::vector<double>& Canvas3D::getX(
unsigned int dataSet)
const{
399 return std::get<0>(dataSets[dataSet]);
402 inline const std::vector<double>& Canvas3D::getY(
unsigned int dataSet)
const{
403 return std::get<1>(dataSets[dataSet]);
406 inline const std::vector<std::vector<double>>& Canvas3D::getZ(
409 return std::get<2>(dataSets[dataSet]);
412 inline const std::string& Canvas3D::getTitle(
unsigned int dataSet)
const{
413 return std::get<3>(dataSets[dataSet]);
416 inline const std::vector<unsigned char>& Canvas3D::getColor(
419 return std::get<4>(dataSets[dataSet]);