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5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef tools_sg_plotter_some_styles
  5 #define tools_sg_plotter_some_styles
  6 
  7 //  Functions to set some common styles.
  8 // Typically ROOT_default (the default style of ROOT), hippodraw
  9 // or return/reset to the default inlib style.
 10 
 11 #include "plotter"
 12 #include "style_colormap"
 13 
 14 namespace tools {
 15 namespace sg {
 16 
 17 inline bool set_style_color(std::ostream& a_out,const cmaps_t& a_cmaps,const std::string& a_s,colorf& a_col){
 18   if(!find_color(a_cmaps,a_s,a_col)) {
 19     a_out << "tools::sg::set_style_color: color " << sout(a_s) << " not found." << std::endl;
 20     return false;
 21   }
 22   return true;
 23 }
 24 
 25 // a_font = font_arialbd_ttf();     //idem ROOT 62.
 26 // a_font = font_roboto_bold_ttf(); //open source replacement for arialbd.
 27 
 28 inline void set_style_font(text_style& a_style,const std::string& a_font){
 29   a_style.font = a_font;
 30   a_style.front_face = winding_cw;
 31   a_style.smoothing = true;
 32 }
 33 
 34 inline void set_ROOT_default_style(std::ostream& a_out,const cmaps_t& a_cmaps,plotter& a_plotter,const std::string& a_font) {
 35   a_plotter.value_top_margin = 0.05f;
 36   a_plotter.bottom_margin = 0.1f;
 37   a_plotter.top_margin = 0.1f;
 38   a_plotter.left_margin = 0.1f;
 39   a_plotter.right_margin = 0.1f;
 40 
 41  {style& _style = a_plotter.background_style();
 42   _style.visible = true;
 43 //if(!set_style_color(a_out,a_cmaps,"ROOT/grey19",_style.back_color.value())) {}
 44   //border:
 45   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
 46   _style.line_width = 0.003;  // 0 = no border. In % of width.
 47   }
 48 
 49 // <!-- <style name="wall_style"><visible>false</visible></style> -->
 50 
 51  {style& _style = a_plotter.grid_style();
 52   _style.visible = false;
 53 //if(!set_style_color(a_out,a_cmaps,"white",_style.color.value())) {}
 54   }
 55 
 56   // plot title done with the title_box (and not plotter title):
 57  {text_style& _style = a_plotter.title_style();
 58   _style.visible = false;
 59   }
 60  {text_style& _style = a_plotter.title_box_style();
 61   _style.visible = true;
 62   if(!set_style_color(a_out,a_cmaps,"ROOT/grey19",_style.back_color.value())) {}
 63   _style.back_shadow = 0.015f;  //% of width.
 64   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
 65   set_style_font(_style,a_font);}
 66 
 67   a_plotter.infos_width = 0.35f;
 68   a_plotter.infos_x_margin = 0.01f;  //from right border.
 69   a_plotter.infos_y_margin = 0.005f;  //from top border.
 70  {text_style& _style = a_plotter.infos_style();
 71   _style.visible = true;
 72   if(!set_style_color(a_out,a_cmaps,"ROOT/grey19",_style.back_color.value())) {}
 73   _style.back_shadow = 0.015f;  //% of width.
 74   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
 75   _style.modeling = infos_modeling_ROOT();  //to have histo name as info title.
 76   set_style_font(_style,a_font);}
 77 
 78  {style& _style = a_plotter.inner_frame_style();
 79   _style.visible = true;
 80   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
 81   _style.line_width = 1.0f;  
 82 //_style.line_pattern = line_solid;
 83   }
 84 
 85   //////////////////////////////////////////////////////////
 86   /// x axis: //////////////////////////////////////////////
 87   //////////////////////////////////////////////////////////
 88  {axis& _axis = a_plotter.x_axis();
 89   _axis.modeling = tick_modeling_hplot();
 90   _axis.divisions = 510;
 91   _axis.title_hjust = right;
 92   _axis.label_to_axis = 0.005f;
 93   _axis.label_height = 0.04f;
 94   _axis.tick_length = 0.03f;
 95   _axis.title_to_axis = 0.05f; //YLAB = 0.05
 96   _axis.title_height = 0.04f;
 97   _axis.is_log = false;
 98 
 99  {line_style& _style = _axis.line_style();
100   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
101   _style.width = 1.0f;}  
102 
103  {line_style& _style = _axis.ticks_style();
104   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
105   _style.width = 1.0f;}
106   
107  {text_style& _style = _axis.labels_style();
108   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
109   _style.scale = 0.6;  //To have a good matching with ROOT text size.
110   set_style_font(_style,a_font);}
111   
112  {text_style& _style = _axis.title_style();
113   _style.visible = true;
114   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
115   _style.scale = 0.6;  //To have a good matching with ROOT text size.
116   set_style_font(_style,a_font);}
117   
118  {text_style& _style = _axis.mag_style();
119   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
120   _style.scale = 0.6;  //To have a good matching with ROOT text size.
121   set_style_font(_style,a_font);}
122   
123   }
124   
125   //////////////////////////////////////////////////////////
126   /// y axis: //////////////////////////////////////////////
127   //////////////////////////////////////////////////////////
128  {axis& _axis = a_plotter.y_axis();
129   _axis.modeling = tick_modeling_hplot();
130   _axis.divisions = 510;
131   _axis.title_hjust = right;
132   _axis.label_to_axis = 0.005f;
133   _axis.label_height = 0.04f;
134   _axis.tick_length = 0.03f;
135   _axis.title_to_axis = 0.07f; //XLAB = 0.07
136   _axis.title_height = 0.04f;
137   _axis.is_log = false;
138 
139  {line_style& _style = _axis.line_style();
140   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
141   _style.width = 1.0f;}  
142 
143  {line_style& _style = _axis.ticks_style();
144   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
145   _style.width = 1.0f;}
146   
147  {text_style& _style = _axis.labels_style();
148   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
149   _style.scale = 0.6;
150   set_style_font(_style,a_font);}
151   
152  {text_style& _style = _axis.title_style();
153   _style.visible = true;
154   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
155   _style.scale = 0.6;  //To have a good matching with ROOT text size.
156   set_style_font(_style,a_font);}
157   
158  {text_style& _style = _axis.mag_style();
159   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
160   _style.scale = 0.6;  //To have a good matching with ROOT text size.
161   set_style_font(_style,a_font);}
162   
163   }
164   
165   //////////////////////////////////////////////////////////
166   /// z axis: //////////////////////////////////////////////
167   //////////////////////////////////////////////////////////
168  {axis& _axis = a_plotter.z_axis();
169   _axis.modeling = tick_modeling_hplot();
170   _axis.is_log = false;
171 
172  {line_style& _style = _axis.line_style();
173   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
174   _style.width = 1.0f;}  
175 
176  {line_style& _style = _axis.ticks_style();
177   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
178   _style.width = 1.0f;}
179   
180  {text_style& _style = _axis.labels_style();
181   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
182   _style.scale = 0.6;}
183   
184  {text_style& _style = _axis.title_style();
185   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
186   _style.scale = 0.6;}
187   
188  {text_style& _style = _axis.mag_style();
189   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
190   _style.scale = 0.6;}
191   
192   }
193   
194   //////////////////////////////////////////////////////////
195   /// colormap axis: ///////////////////////////////////////
196   //////////////////////////////////////////////////////////
197  {axis& _axis = a_plotter.colormap_axis();
198   _axis.modeling = tick_modeling_hplot();
199   _axis.divisions = 510;
200   _axis.title_hjust = right;
201   _axis.label_to_axis = 0.005f;
202   _axis.label_height = 0.04f;
203   _axis.tick_length = 0.03f;
204   _axis.title_to_axis = 0.07f; //XLAB = 0.07
205   _axis.title_height = 0.04f;
206   _axis.is_log = false;
207 
208  {line_style& _style = _axis.line_style();
209   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
210   _style.width = 1.0f;}  
211 
212  {line_style& _style = _axis.ticks_style();
213   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
214   _style.width = 1.0f;}
215   
216  {text_style& _style = _axis.labels_style();
217   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
218   _style.scale = 0.6;  //To have a good matching with ROOT text size.
219   set_style_font(_style,a_font);}
220   
221  {text_style& _style = _axis.title_style();
222   _style.visible = true;
223   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
224   _style.scale = 0.6;  //To have a good matching with ROOT text size.
225   set_style_font(_style,a_font);}
226   
227  {text_style& _style = _axis.mag_style();
228   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
229   _style.scale = 0.6;  //To have a good matching with ROOT text size.
230   set_style_font(_style,a_font);}
231   
232   }
233 
234  {style& _style = a_plotter.bins_style(0);
235   _style.modeling = modeling_top_lines();
236   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
237   _style.line_width = 1.0f;
238 //_style.line_pattern = line_solid;
239   }
240   
241  {style& _style = a_plotter.func_style(0);
242   _style.modeling = modeling_top_lines();
243   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
244   _style.line_width = 3.0f;
245 //_style.line_pattern = line_solid;
246   }
247   
248 }
249 
250 // a_font = font_helvetica_ttf();
251 // a_font = font_lato_regular_ttf(); //open source replacement for helvetica
252 
253 inline void set_hippodraw_style(std::ostream& a_out,const cmaps_t& a_cmaps,plotter& a_plotter,const std::string& a_font) {
254   // In memory of P.Kunz.
255 
256   a_plotter.value_top_margin = 0.05f;
257   a_plotter.bottom_margin = 0.12f;
258   a_plotter.top_margin = 0.16f;
259   a_plotter.left_margin = 0.16f;
260   a_plotter.right_margin = 0.16f;
261   a_plotter.title_to_axis = 0.1f;
262   a_plotter.title_height = 0.03f;
263 
264 // <!-- <style name="wall_style"><visible>false</visible></style> -->
265 
266  {style& _style = a_plotter.grid_style();
267   _style.visible = false;}
268  {style& _style = a_plotter.inner_frame_style();
269   _style.visible = true;}
270  {text_style& _style = a_plotter.infos_style();
271   _style.visible = false;}
272   
273  {text_style& _style = a_plotter.title_style();
274   set_style_font(_style,a_font);
275   _style.visible = true;}
276 
277   //////////////////////////////////////////////////////////
278   /// x axis: //////////////////////////////////////////////
279   //////////////////////////////////////////////////////////
280  {axis& _axis = a_plotter.x_axis();
281   _axis.modeling = tick_modeling_hippo();
282   _axis.title_hjust = center;
283   _axis.label_to_axis = 0.015f;
284   _axis.title_to_axis = 0.07f;
285   _axis.title_height = 0.035f;
286   _axis.label_height = 0.02625f;  //0.0175F * 1.5F
287   
288  {text_style& _style = _axis.title_style();
289   _style.visible = true;
290   set_style_font(_style,a_font);}
291   
292  {text_style& _style = _axis.labels_style();
293   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
294   set_style_font(_style,a_font);}
295   
296   }
297   
298   //////////////////////////////////////////////////////////
299   /// y axis: //////////////////////////////////////////////
300   //////////////////////////////////////////////////////////
301  {axis& _axis = a_plotter.y_axis();
302   _axis.modeling = tick_modeling_hippo();
303   _axis.title_hjust = center;
304   _axis.title_to_axis = 0.2f;
305   _axis.title_height = 0.035f;
306   _axis.label_height = 0.02625f;  //0.0175F * 1.5F
307   
308  {text_style& _style = _axis.title_style();
309   _style.visible = true;
310   set_style_font(_style,a_font);}
311   
312  {text_style& _style = _axis.labels_style();
313   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
314   set_style_font(_style,a_font);}
315   
316   }
317   
318   //////////////////////////////////////////////////////////
319   /// z axis: //////////////////////////////////////////////
320   //////////////////////////////////////////////////////////
321  {axis& _axis = a_plotter.z_axis();
322   
323  {text_style& _style = _axis.title_style();
324   _style.visible = true;
325   set_style_font(_style,a_font);}
326   
327  {text_style& _style = _axis.labels_style();
328   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
329   set_style_font(_style,a_font);}
330   
331   }
332   
333  {style& _style = a_plotter.bins_style(0);
334   _style.modeling = modeling_top_lines();
335   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
336   _style.line_width = 1.0f;
337 //_style.line_pattern = line_solid;
338   }
339   
340  {style& _style = a_plotter.func_style(0);
341   _style.modeling = modeling_top_lines();
342   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
343   _style.line_width = 1.0f;
344 //_style.line_pattern = line_solid;
345   }
346 
347  {style& _style = a_plotter.errors_style(0);
348   _style.visible = false;
349   }
350 
351 }
352 
353 inline void set_inlib_default_style(std::ostream&,const cmaps_t&,plotter& a_plotter,const std::string&) {
354  {axis& _axis = a_plotter.colormap_axis();
355   _axis.label_to_axis = 0.01f;}  
356 }
357 
358 }}
359 
360 #endif