ra4_draw  4bd0201e3d922d42bd545d4b045ed44db33454a4
plot_opt.hpp
Go to the documentation of this file.
1 #ifndef H_PLOT_OPT
2 #define H_PLOT_OPT
3 
4 #include <cstddef>
5 
6 #include <set>
7 #include <string>
8 
9 namespace PlotOptTypes{
10  enum class BottomType{off, ratio, diff};
11  enum class YAxisType{linear, log};
15 }
16 
17 class PlotOpt{
18 public:
19  PlotOpt();
20  PlotOpt(const std::string &file_name,
21  const std::string &config_name);
22  PlotOpt(const PlotOpt &) = default;
23  PlotOpt& operator=(const PlotOpt &) = default;
24  PlotOpt(PlotOpt &&) = default;
25  PlotOpt& operator=(PlotOpt &&) = default;
26  ~PlotOpt() = default;
27 
28  PlotOpt operator()() const;
29 
30  PlotOpt & LoadOptions(const std::string &file_name,
31  const std::string &config_name);
32 
33  PlotOpt & Bottom(PlotOptTypes::BottomType bottom_type);
34  PlotOptTypes::BottomType Bottom() const;
35 
36  PlotOpt & YAxis(PlotOptTypes::YAxisType y_axis_type);
37  PlotOptTypes::YAxisType YAxis() const;
38 
39  PlotOpt & Title(PlotOptTypes::TitleType title_type);
40  PlotOptTypes::TitleType Title() const;
41 
42  PlotOpt & Stack(PlotOptTypes::StackType stack_type);
43  PlotOptTypes::StackType Stack() const;
44 
45  PlotOpt & Overflow(PlotOptTypes::OverflowType overflow_type);
46  PlotOptTypes::OverflowType Overflow() const;
47 
48  PlotOpt & FileExtensions(const std::set<std::string> &file_extensions);
49  const std::set<std::string> & FileExtensions() const;
50 
51  PlotOpt & LabelSize(double label_size);
52  double LabelSize() const;
53 
54  PlotOpt & TitleSize(double title_size);
55  double TitleSize() const;
56 
57  PlotOpt & XTitleOffset(double x_title_offset);
58  double XTitleOffset() const;
59 
60  PlotOpt & YTitleOffset(double y_title_offset);
61  double YTitleOffset() const;
62 
63  PlotOpt & ZTitleOffset(double z_title_offset);
64  double ZTitleOffset() const;
65 
66  PlotOpt & AutoYAxis(bool auto_y_axis);
67  bool AutoYAxis() const;
68 
69  PlotOpt & CanvasSize(int width, int height);
70  PlotOpt & CanvasWidth(int width);
71  int CanvasWidth() const;
72  PlotOpt & CanvasHeight(int height);
73  int CanvasHeight() const;
74 
75  PlotOpt & Margin(double left, double right, double bottom, double top);
76  PlotOpt & LeftMargin(double left);
77  double LeftMargin() const;
78  PlotOpt & RightMargin(double right);
79  double RightMargin() const;
80  PlotOpt & BottomMargin(double bottom);
81  double BottomMargin() const;
82  PlotOpt & TopMargin(double top);
83  double TopMargin() const;
84 
85  PlotOpt & BottomHeight(double bottom_height);
86  double BottomHeight() const;
87 
88  PlotOpt & LegendColumns(int columns);
89  int LegendColumns() const;
90  PlotOpt & LegendEntryHeight(double height);
91  double LegendEntryHeight() const;
92  PlotOpt & LegendMaxHeight(double height);
93  double LegendMaxHeight() const;
94  PlotOpt & LegendMarkerWidth(double width);
95  double LegendMarkerWidth() const;
96  PlotOpt & LegendPad(double pad);
97  double LegendPad() const;
98  PlotOpt & LegendDensity(double density);
99  double LegendDensity() const;
100 
101  PlotOpt & LogMinimum(double log_minimum);
102  double LogMinimum() const;
103 
104  PlotOpt & RatioMinimum(double ratio_minimum);
105  double RatioMinimum() const;
106  PlotOpt & RatioMaximum(double ratio_maximum);
107  double RatioMaximum() const;
108 
109  PlotOpt & NDivisions(int n_divisions);
110  int NDivisions() const;
111  PlotOpt & NDivisionsBottom(int n_divisions);
112  int NDivisionsBottom() const;
113 
114  PlotOpt & Font(int font);
115  int Font() const;
116 
117  PlotOpt & ShowBackgroundError(bool show_background_error);
118  bool ShowBackgroundError() const;
119 
120  PlotOpt & UseCMYK(bool use_cmyk);
121  bool UseCMYK() const;
122 
123  PlotOpt & PrintVals(bool print_vals);
124  bool PrintVals() const;
125 
126  double TopToGlobalYNDC(double top_y) const;
127  double GlobalToTopYNDC(double global_y) const;
128  double BottomToGlobalYNDC(double bottom_y) const;
129  double GlobalToBottomYNDC(double global_y) const;
130 
131  double TrueLegendHeight(std::size_t num_entries) const;
132  double TrueLegendEntryHeight(std::size_t num_entries) const;
133  double TrueLegendWidth(std::size_t num_entries) const;
134 
135  bool BackgroundsStacked() const;
136  bool DisplayLumiEntry() const;
137 
138  std::string TypeString() const;
139 
140  void MakeSane();
141 
142 private:
148  std::set<std::string> file_extensions_;
149  double title_size_, label_size_;
150  double x_title_offset_, y_title_offset_, z_title_offset_;
152  int canvas_width_, canvas_height_;
153  double left_margin_, right_margin_, bottom_margin_, top_margin_;
156  double legend_entry_height_, legend_max_height_;
157  double legend_marker_width_, legend_pad_, legend_density_;
158  double log_minimum_;
159  double ratio_minimum_, ratio_maximum_;
160  int n_divisions_, n_divisions_bottom_;
161  int font_;
163  bool use_cmyk_;
165 
166  void SetProperty(const std::string &property_name,
167  const std::string &value_string);
168 };
169 
170 #endif
double legend_max_height_
Definition: plot_opt.hpp:156
int legend_columns_
Definition: plot_opt.hpp:155
PlotOptTypes::BottomType bottom_type_
Definition: plot_opt.hpp:143
double title_size_
Definition: plot_opt.hpp:149
bool auto_y_axis_
Definition: plot_opt.hpp:151
PlotOptTypes::StackType stack_type_
Definition: plot_opt.hpp:146
int canvas_width_
Definition: plot_opt.hpp:152
bool print_vals_
Definition: plot_opt.hpp:164
double top_margin_
Definition: plot_opt.hpp:153
bool use_cmyk_
Definition: plot_opt.hpp:163
double z_title_offset_
Definition: plot_opt.hpp:150
std::set< std::string > file_extensions_
Definition: plot_opt.hpp:148
double legend_pad_
Definition: plot_opt.hpp:157
int font_
Definition: plot_opt.hpp:161
double ratio_minimum_
Definition: plot_opt.hpp:159
double bottom_height_
Definition: plot_opt.hpp:154
PlotOptTypes::YAxisType y_axis_type_
Definition: plot_opt.hpp:144
double log_minimum_
Definition: plot_opt.hpp:158
PlotOptTypes::OverflowType overflow_type_
Definition: plot_opt.hpp:147
int n_divisions_bottom_
Definition: plot_opt.hpp:160
bool show_background_error_
Definition: plot_opt.hpp:162
PlotOptTypes::TitleType title_type_
Definition: plot_opt.hpp:145