24 #ifndef COM_DAFER45_TBTK_PLOTTER_2
25 #define COM_DAFER45_TBTK_PLOTTER_2
28 #include "TBTK/Canvas2D.h"
29 #include "TBTK/Canvas3D.h"
30 #include "TBTK/PNGCanvas2D.h"
31 #include "TBTK/PNGCanvas3D.h"
51 void setWidth(
unsigned int width);
54 void setHeight(
unsigned int height);
57 void setBoundsX(
double minX,
double maxX);
60 void setBoundsY(
double minY,
double maxY);
63 void setBounds(
double minX,
double maxX,
double minY,
double maxY);
66 void setAutoScaleX(
bool autoScaleX);
69 void setAutoScaleY(
bool autoScaleY);
72 void setAutoScale(
bool autoScale);
75 void setTitle(
const std::string &title);
78 void setLabelX(
const std::string &labelX);
81 void setLabelY(
const std::string &labelY);
84 void setLabelZ(
const std::string &labelZ);
88 const std::vector<double> &x,
89 const std::vector<double> &y,
90 const std::string &title =
"",
91 const std::vector<unsigned char> &color = {0, 0, 0},
97 const std::vector<double> &data,
98 const std::string &title =
"",
99 const std::vector<unsigned char> &color = {0, 0, 0},
100 unsigned int size = 1
105 const Property::DOS &dos,
107 unsigned int windowSize = 51
113 const Property::LDOS &ldos,
115 unsigned int windowSize = 51
119 void plot(
const Property::EigenValues &eigenValues);
123 const std::vector<std::vector<double>> &data,
124 const std::string &title =
""
129 const Array<double> &data,
130 const std::string &title =
"",
131 const std::vector<unsigned char> &color = {0, 0, 0},
132 unsigned int size = 1
148 void setHold(
bool hold);
152 void setTopView(
bool topView);
158 void save(std::string filename);
167 Canvas *currentCanvas;
170 bool autoScaleX, autoScaleY;
173 void setCurrentCanvas(Canvas &canvas);
176 inline void Plotter2::setWidth(
unsigned int width){
177 canvas2D.setWidth(width);
178 canvas3D.setWidth(width);
181 inline void Plotter2::setHeight(
unsigned int height){
182 canvas2D.setHeight(height);
183 canvas3D.setHeight(height);
186 inline void Plotter2::setBoundsX(
double minX,
double maxX){
189 "Plotter2::setBoundsX()",
190 "minX has to be smaller than maxX",
193 this->autoScaleX =
false;
194 canvas2D.setBoundsX(minX, maxX);
197 inline void Plotter2::setBoundsY(
double minY,
double maxY){
200 "Plotter2::setBoundsY()",
201 "minY has to be smaller than maxY",
204 this->autoScaleY =
false;
205 canvas2D.setBoundsY(minY, maxY);
208 inline void Plotter2::setBounds(
214 setBoundsX(minX, maxX);
215 setBoundsY(minY, maxY);
218 inline void Plotter2::setAutoScaleX(
bool autoScaleX){
219 this->autoScaleX = autoScaleX;
222 inline void Plotter2::setAutoScaleY(
bool autoScaleY){
223 this->autoScaleY = autoScaleY;
226 inline void Plotter2::setAutoScale(
bool autoScale){
227 setAutoScaleX(autoScale);
228 setAutoScaleY(autoScale);
231 inline void Plotter2::setTitle(
const std::string &title){
232 canvas2D.setTitle(title);
233 canvas3D.setTitle(title);
236 inline void Plotter2::setLabelX(
const std::string &labelX){
237 canvas2D.setLabelX(labelX);
238 canvas3D.setLabelX(labelX);
241 inline void Plotter2::setLabelY(
const std::string &labelY){
242 canvas2D.setLabelY(labelY);
243 canvas3D.setLabelY(labelY);
246 inline void Plotter2::setLabelZ(
const std::string &labelZ){
247 canvas3D.setLabelZ(labelZ);
250 inline void Plotter2::setHold(
bool hold){
251 canvas2D.setHold(hold);
252 canvas3D.setHold(hold);
255 inline void Plotter2::setTopView(
bool topView){
256 setCurrentCanvas(canvas3D);
257 canvas3D.setTopView(topView);
260 inline void Plotter2::clear(){
264 inline void Plotter2::save(std::string filename){
265 std::vector<std::string> tokens;
266 std::stringstream ss(filename);
268 while(std::getline(ss, token,
'.'))
269 tokens.push_back(token);
274 "Invalid filename '" << filename <<
"'.",
278 tokens.back().compare(
"png") == 0
279 || tokens.back().compare(
"PNG") == 0
281 if(currentCanvas == &canvas2D){
282 PNGCanvas2D canvas(canvas2D);
283 canvas.flush(filename);
285 else if(currentCanvas == &canvas3D){
286 PNGCanvas3D canvas(canvas3D);
287 canvas.flush(filename);
293 "Unknown file type '" << tokens.back() <<
"'.",