TBTK
Need a break? Support the development by playing Polarity Puzzles
ContourfParameters.h
Go to the documentation of this file.
1 /* Copyright 2019 Kristofer Björnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
24 #ifndef COM_DAFER45_TBTK_VISUALIZATION_MAT_PLOT_LIB_CONTOURF_PARAMETERS
25 #define COM_DAFER45_TBTK_VISUALIZATION_MAT_PLOT_LIB_CONTOURF_PARAMETERS
26 
27 #include "TBTK/Visualization/MatPlotLib/matplotlibcpp.h"
28 
29 #include <string>
30 #include <utility>
31 
32 namespace TBTK{
33 namespace Visualization{
34 namespace MatPlotLib{
35 
37 public:
40 
42  void setTitle(const std::string &title, bool overwrite = true);
43 
45  void setLabelX(const std::string &labelX, bool overwrite = true);
46 
48  void setLabelY(const std::string &labelY, bool overwrite = true);
49 
51  void setBoundsX(double minX, double maxX, bool overwrite = true);
52 
54  void setBoundsY(double minY, double maxY, bool overwrite = true);
55 
57  void flush() const;
58 
60  void clear();
61 private:
62  std::pair<bool, std::string> title;
63  std::pair<bool, std::string> labelX;
64  std::pair<bool, std::string> labelY;
65  std::pair<bool, double> minX;
66  std::pair<bool, double> maxX;
67  std::pair<bool, double> minY;
68  std::pair<bool, double> maxY;
69 };
70 
72 ) :
73  title(false, ""),
74  labelX(false, ""),
75  labelY(false, ""),
76  minX(false, 0),
77  maxX(false, 1),
78  minY(false, 0),
79  maxY(false, 1)
80 {
81 }
82 
84  const std::string &title,
85  bool overwrite
86 ){
87  if(overwrite || !this->title.first)
88  this->title = {true, title};
89 }
90 
92  const std::string &labelX,
93  bool overwrite
94 ){
95  if(overwrite || !this->labelX.first)
96  this->labelX = {true, labelX};
97 }
98 
100  const std::string &labelY,
101  bool overwrite
102 ){
103  if(overwrite || !this->labelY.first)
104  this->labelY = {true, labelY};
105 }
106 
108  double minX,
109  double maxX,
110  bool overwrite
111 ){
112  if(overwrite || !this->minX.first)
113  this->minX = {true, minX};
114  if(overwrite || !this->maxX.first)
115  this->maxX = {true, maxX};
116 }
117 
119  double minY,
120  double maxY,
121  bool overwrite
122 ){
123  if(overwrite || !this->minY.first)
124  this->minY = {true, minY};
125  if(overwrite || !this->maxY.first)
126  this->maxY = {true, maxY};
127 }
128 
129 inline void ContourfParameters::flush() const{
130  if(title.first)
131  matplotlibcpp::title(title.second);
132  if(labelX.first)
133  matplotlibcpp::xlabel(labelX.second);
134  if(labelY.first)
135  matplotlibcpp::ylabel(labelY.second);
136  if(minX.first)
137  matplotlibcpp::xlim(minX.second, maxX.second);
138  if(minY.first)
139  matplotlibcpp::ylim(minY.second, maxY.second);
140 }
141 
143  title = {false, ""};
144  labelX = {false, ""};
145  labelY = {false, ""};
146  minX = {false, 0};
147  maxX = {false, 1};
148  minY = {false, 0};
149  maxY = {false, 1};
150 }
151 
152 }; //End namespace MatPlotLib
153 }; //End namespace Visualization
154 }; //End namespace TBTK
155 
156 #endif
void setTitle(const std::string &title, bool overwrite=true)
Definition: ContourfParameters.h:83
void flush() const
Definition: ContourfParameters.h:129
void setLabelX(const std::string &labelX, bool overwrite=true)
Definition: ContourfParameters.h:91
void setLabelY(const std::string &labelY, bool overwrite=true)
Definition: ContourfParameters.h:99
Definition: Boolean.h:32
void setBoundsX(double minX, double maxX, bool overwrite=true)
Definition: ContourfParameters.h:107
Definition: ContourfParameters.h:36
void setBoundsY(double minY, double maxY, bool overwrite=true)
Definition: ContourfParameters.h:118
void clear()
Definition: ContourfParameters.h:142
ContourfParameters()
Definition: ContourfParameters.h:71