Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/plotter_some_styles is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_sg_plotter_some_styles
0005 #define tools_sg_plotter_some_styles
0006 
0007 //  Functions to set some common styles.
0008 // Typically ROOT_default (the default style of ROOT), hippodraw
0009 // or return/reset to the default inlib style.
0010 
0011 #include "plotter"
0012 #include "style_colormap"
0013 
0014 namespace tools {
0015 namespace sg {
0016 
0017 inline bool set_style_color(std::ostream& a_out,const cmaps_t& a_cmaps,const std::string& a_s,colorf& a_col){
0018   if(!find_color(a_cmaps,a_s,a_col)) {
0019     a_out << "tools::sg::set_style_color: color " << sout(a_s) << " not found." << std::endl;
0020     return false;
0021   }
0022   return true;
0023 }
0024 
0025 // a_font = font_arialbd_ttf();     //idem ROOT 62.
0026 // a_font = font_roboto_bold_ttf(); //open source replacement for arialbd.
0027 
0028 inline void set_style_font(text_style& a_style,const std::string& a_font){
0029   a_style.font = a_font;
0030   a_style.front_face = winding_cw;
0031   a_style.smoothing = true;
0032 }
0033 
0034 inline void set_ROOT_default_style(std::ostream& a_out,const cmaps_t& a_cmaps,plotter& a_plotter,const std::string& a_font) {
0035   a_plotter.value_top_margin = 0.05f;
0036   a_plotter.bottom_margin = 0.1f;
0037   a_plotter.top_margin = 0.1f;
0038   a_plotter.left_margin = 0.1f;
0039   a_plotter.right_margin = 0.1f;
0040 
0041  {style& _style = a_plotter.background_style();
0042   _style.visible = true;
0043 //if(!set_style_color(a_out,a_cmaps,"ROOT/grey19",_style.back_color.value())) {}
0044   //border:
0045   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0046   _style.line_width = 0.003;  // 0 = no border. In % of width.
0047   }
0048 
0049 // <!-- <style name="wall_style"><visible>false</visible></style> -->
0050 
0051  {style& _style = a_plotter.grid_style();
0052   _style.visible = false;
0053 //if(!set_style_color(a_out,a_cmaps,"white",_style.color.value())) {}
0054   }
0055 
0056   // plot title done with the title_box (and not plotter title):
0057  {text_style& _style = a_plotter.title_style();
0058   _style.visible = false;
0059   }
0060  {text_style& _style = a_plotter.title_box_style();
0061   _style.visible = true;
0062   if(!set_style_color(a_out,a_cmaps,"ROOT/grey19",_style.back_color.value())) {}
0063   _style.back_shadow = 0.015f;  //% of width.
0064   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0065   set_style_font(_style,a_font);}
0066 
0067   a_plotter.infos_width = 0.35f;
0068   a_plotter.infos_x_margin = 0.01f;  //from right border.
0069   a_plotter.infos_y_margin = 0.005f;  //from top border.
0070  {text_style& _style = a_plotter.infos_style();
0071   _style.visible = true;
0072   if(!set_style_color(a_out,a_cmaps,"ROOT/grey19",_style.back_color.value())) {}
0073   _style.back_shadow = 0.015f;  //% of width.
0074   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0075   _style.modeling = infos_modeling_ROOT();  //to have histo name as info title.
0076   set_style_font(_style,a_font);}
0077 
0078  {style& _style = a_plotter.inner_frame_style();
0079   _style.visible = true;
0080   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0081   _style.line_width = 1.0f;  
0082 //_style.line_pattern = line_solid;
0083   }
0084 
0085   //////////////////////////////////////////////////////////
0086   /// x axis: //////////////////////////////////////////////
0087   //////////////////////////////////////////////////////////
0088  {axis& _axis = a_plotter.x_axis();
0089   _axis.modeling = tick_modeling_hplot();
0090   _axis.divisions = 510;
0091   _axis.title_hjust = right;
0092   _axis.label_to_axis = 0.005f;
0093   _axis.label_height = 0.04f;
0094   _axis.tick_length = 0.03f;
0095   _axis.title_to_axis = 0.05f; //YLAB = 0.05
0096   _axis.title_height = 0.04f;
0097   _axis.is_log = false;
0098 
0099  {line_style& _style = _axis.line_style();
0100   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0101   _style.width = 1.0f;}  
0102 
0103  {line_style& _style = _axis.ticks_style();
0104   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0105   _style.width = 1.0f;}
0106   
0107  {text_style& _style = _axis.labels_style();
0108   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0109   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0110   set_style_font(_style,a_font);}
0111   
0112  {text_style& _style = _axis.title_style();
0113   _style.visible = true;
0114   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0115   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0116   set_style_font(_style,a_font);}
0117   
0118  {text_style& _style = _axis.mag_style();
0119   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0120   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0121   set_style_font(_style,a_font);}
0122   
0123   }
0124   
0125   //////////////////////////////////////////////////////////
0126   /// y axis: //////////////////////////////////////////////
0127   //////////////////////////////////////////////////////////
0128  {axis& _axis = a_plotter.y_axis();
0129   _axis.modeling = tick_modeling_hplot();
0130   _axis.divisions = 510;
0131   _axis.title_hjust = right;
0132   _axis.label_to_axis = 0.005f;
0133   _axis.label_height = 0.04f;
0134   _axis.tick_length = 0.03f;
0135   _axis.title_to_axis = 0.07f; //XLAB = 0.07
0136   _axis.title_height = 0.04f;
0137   _axis.is_log = false;
0138 
0139  {line_style& _style = _axis.line_style();
0140   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0141   _style.width = 1.0f;}  
0142 
0143  {line_style& _style = _axis.ticks_style();
0144   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0145   _style.width = 1.0f;}
0146   
0147  {text_style& _style = _axis.labels_style();
0148   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0149   _style.scale = 0.6;
0150   set_style_font(_style,a_font);}
0151   
0152  {text_style& _style = _axis.title_style();
0153   _style.visible = true;
0154   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0155   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0156   set_style_font(_style,a_font);}
0157   
0158  {text_style& _style = _axis.mag_style();
0159   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0160   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0161   set_style_font(_style,a_font);}
0162   
0163   }
0164   
0165   //////////////////////////////////////////////////////////
0166   /// z axis: //////////////////////////////////////////////
0167   //////////////////////////////////////////////////////////
0168  {axis& _axis = a_plotter.z_axis();
0169   _axis.modeling = tick_modeling_hplot();
0170   _axis.is_log = false;
0171 
0172  {line_style& _style = _axis.line_style();
0173   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0174   _style.width = 1.0f;}  
0175 
0176  {line_style& _style = _axis.ticks_style();
0177   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0178   _style.width = 1.0f;}
0179   
0180  {text_style& _style = _axis.labels_style();
0181   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0182   _style.scale = 0.6;}
0183   
0184  {text_style& _style = _axis.title_style();
0185   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0186   _style.scale = 0.6;}
0187   
0188  {text_style& _style = _axis.mag_style();
0189   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0190   _style.scale = 0.6;}
0191   
0192   }
0193   
0194   //////////////////////////////////////////////////////////
0195   /// colormap axis: ///////////////////////////////////////
0196   //////////////////////////////////////////////////////////
0197  {axis& _axis = a_plotter.colormap_axis();
0198   _axis.modeling = tick_modeling_hplot();
0199   _axis.divisions = 510;
0200   _axis.title_hjust = right;
0201   _axis.label_to_axis = 0.005f;
0202   _axis.label_height = 0.04f;
0203   _axis.tick_length = 0.03f;
0204   _axis.title_to_axis = 0.07f; //XLAB = 0.07
0205   _axis.title_height = 0.04f;
0206   _axis.is_log = false;
0207 
0208  {line_style& _style = _axis.line_style();
0209   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0210   _style.width = 1.0f;}  
0211 
0212  {line_style& _style = _axis.ticks_style();
0213   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0214   _style.width = 1.0f;}
0215   
0216  {text_style& _style = _axis.labels_style();
0217   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0218   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0219   set_style_font(_style,a_font);}
0220   
0221  {text_style& _style = _axis.title_style();
0222   _style.visible = true;
0223   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0224   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0225   set_style_font(_style,a_font);}
0226   
0227  {text_style& _style = _axis.mag_style();
0228   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0229   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0230   set_style_font(_style,a_font);}
0231   
0232   }
0233 
0234  {style& _style = a_plotter.bins_style(0);
0235   _style.modeling = modeling_top_lines();
0236   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0237   _style.line_width = 1.0f;
0238 //_style.line_pattern = line_solid;
0239   }
0240   
0241  {style& _style = a_plotter.func_style(0);
0242   _style.modeling = modeling_top_lines();
0243   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0244   _style.line_width = 3.0f;
0245 //_style.line_pattern = line_solid;
0246   }
0247   
0248 }
0249 
0250 // a_font = font_helvetica_ttf();
0251 // a_font = font_lato_regular_ttf(); //open source replacement for helvetica
0252 
0253 inline void set_hippodraw_style(std::ostream& a_out,const cmaps_t& a_cmaps,plotter& a_plotter,const std::string& a_font) {
0254   // In memory of P.Kunz.
0255 
0256   a_plotter.value_top_margin = 0.05f;
0257   a_plotter.bottom_margin = 0.12f;
0258   a_plotter.top_margin = 0.16f;
0259   a_plotter.left_margin = 0.16f;
0260   a_plotter.right_margin = 0.16f;
0261   a_plotter.title_to_axis = 0.1f;
0262   a_plotter.title_height = 0.03f;
0263 
0264 // <!-- <style name="wall_style"><visible>false</visible></style> -->
0265 
0266  {style& _style = a_plotter.grid_style();
0267   _style.visible = false;}
0268  {style& _style = a_plotter.inner_frame_style();
0269   _style.visible = true;}
0270  {text_style& _style = a_plotter.infos_style();
0271   _style.visible = false;}
0272   
0273  {text_style& _style = a_plotter.title_style();
0274   set_style_font(_style,a_font);
0275   _style.visible = true;}
0276 
0277   //////////////////////////////////////////////////////////
0278   /// x axis: //////////////////////////////////////////////
0279   //////////////////////////////////////////////////////////
0280  {axis& _axis = a_plotter.x_axis();
0281   _axis.modeling = tick_modeling_hippo();
0282   _axis.title_hjust = center;
0283   _axis.label_to_axis = 0.015f;
0284   _axis.title_to_axis = 0.07f;
0285   _axis.title_height = 0.035f;
0286   _axis.label_height = 0.02625f;  //0.0175F * 1.5F
0287   
0288  {text_style& _style = _axis.title_style();
0289   _style.visible = true;
0290   set_style_font(_style,a_font);}
0291   
0292  {text_style& _style = _axis.labels_style();
0293   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0294   set_style_font(_style,a_font);}
0295   
0296   }
0297   
0298   //////////////////////////////////////////////////////////
0299   /// y axis: //////////////////////////////////////////////
0300   //////////////////////////////////////////////////////////
0301  {axis& _axis = a_plotter.y_axis();
0302   _axis.modeling = tick_modeling_hippo();
0303   _axis.title_hjust = center;
0304   _axis.title_to_axis = 0.2f;
0305   _axis.title_height = 0.035f;
0306   _axis.label_height = 0.02625f;  //0.0175F * 1.5F
0307   
0308  {text_style& _style = _axis.title_style();
0309   _style.visible = true;
0310   set_style_font(_style,a_font);}
0311   
0312  {text_style& _style = _axis.labels_style();
0313   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0314   set_style_font(_style,a_font);}
0315   
0316   }
0317   
0318   //////////////////////////////////////////////////////////
0319   /// z axis: //////////////////////////////////////////////
0320   //////////////////////////////////////////////////////////
0321  {axis& _axis = a_plotter.z_axis();
0322   
0323  {text_style& _style = _axis.title_style();
0324   _style.visible = true;
0325   set_style_font(_style,a_font);}
0326   
0327  {text_style& _style = _axis.labels_style();
0328   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0329   set_style_font(_style,a_font);}
0330   
0331   }
0332   
0333  {style& _style = a_plotter.bins_style(0);
0334   _style.modeling = modeling_top_lines();
0335   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0336   _style.line_width = 1.0f;
0337 //_style.line_pattern = line_solid;
0338   }
0339   
0340  {style& _style = a_plotter.func_style(0);
0341   _style.modeling = modeling_top_lines();
0342   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0343   _style.line_width = 1.0f;
0344 //_style.line_pattern = line_solid;
0345   }
0346 
0347  {style& _style = a_plotter.errors_style(0);
0348   _style.visible = false;
0349   }
0350 
0351 }
0352 
0353 inline void set_inlib_default_style(std::ostream&,const cmaps_t&,plotter& a_plotter,const std::string&) {
0354  {axis& _axis = a_plotter.colormap_axis();
0355   _axis.label_to_axis = 0.01f;}  
0356 }
0357 
0358 }}
0359 
0360 #endif