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,"black",_style.color.value())) {}
0044   _style.line_width = 0.003;  // 0 = no border. In % of width.
0045   }
0046 
0047  {style& _style = a_plotter.grid_style();
0048   _style.visible = false;
0049   }
0050 
0051   // plot title done with the title_box (and not plotter title):
0052  {text_style& _style = a_plotter.title_style();
0053   _style.visible = false;
0054   }
0055  {text_style& _style = a_plotter.title_box_style();
0056   _style.visible = true;
0057   if(!set_style_color(a_out,a_cmaps,"ROOT/grey19",_style.back_color.value())) {}
0058   _style.back_shadow = 0.015f;  //% of width.
0059   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0060   set_style_font(_style,a_font);}
0061 
0062   a_plotter.infos_width = 0.35f;
0063   a_plotter.infos_x_margin = 0.01f;  //from right border.
0064   a_plotter.infos_y_margin = 0.005f;  //from top border.
0065  {text_style& _style = a_plotter.infos_style();
0066   _style.visible = true;
0067   if(!set_style_color(a_out,a_cmaps,"ROOT/grey19",_style.back_color.value())) {}
0068   _style.back_shadow = 0.015f;  //% of width.
0069   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0070   _style.modeling = infos_modeling_ROOT();  //to have histo name as info title.
0071   set_style_font(_style,a_font);}
0072 
0073  {style& _style = a_plotter.inner_frame_style();
0074   _style.visible = true;
0075   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0076   _style.line_width = 1.0f;  
0077   }
0078 
0079   //////////////////////////////////////////////////////////
0080   /// x axis: //////////////////////////////////////////////
0081   //////////////////////////////////////////////////////////
0082  {axis& _axis = a_plotter.x_axis();
0083   _axis.modeling = tick_modeling_hplot();
0084   _axis.divisions = 510;
0085   _axis.title_hjust = right;
0086   _axis.label_to_axis = 0.005f;
0087   _axis.label_height = 0.04f;
0088   _axis.tick_length = 0.03f;
0089   _axis.title_to_axis = 0.05f; //YLAB = 0.05
0090   _axis.title_height = 0.04f;
0091   _axis.is_log = false;
0092 
0093  {line_style& _style = _axis.line_style();
0094   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0095   _style.width = 1.0f;}  
0096 
0097  {line_style& _style = _axis.ticks_style();
0098   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0099   _style.width = 1.0f;}
0100   
0101  {text_style& _style = _axis.labels_style();
0102   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0103   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0104   set_style_font(_style,a_font);}
0105   
0106  {text_style& _style = _axis.title_style();
0107   _style.visible = true;
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.mag_style();
0113   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0114   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0115   set_style_font(_style,a_font);}
0116   
0117   }
0118   
0119   //////////////////////////////////////////////////////////
0120   /// y axis: //////////////////////////////////////////////
0121   //////////////////////////////////////////////////////////
0122  {axis& _axis = a_plotter.y_axis();
0123   _axis.modeling = tick_modeling_hplot();
0124   _axis.divisions = 510;
0125   _axis.title_hjust = right;
0126   _axis.label_to_axis = 0.005f;
0127   _axis.label_height = 0.04f;
0128   _axis.tick_length = 0.03f;
0129   _axis.title_to_axis = 0.07f; //XLAB = 0.07
0130   _axis.title_height = 0.04f;
0131   _axis.is_log = false;
0132 
0133  {line_style& _style = _axis.line_style();
0134   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0135   _style.width = 1.0f;}  
0136 
0137  {line_style& _style = _axis.ticks_style();
0138   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0139   _style.width = 1.0f;}
0140   
0141  {text_style& _style = _axis.labels_style();
0142   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0143   _style.scale = 0.6;
0144   set_style_font(_style,a_font);}
0145   
0146  {text_style& _style = _axis.title_style();
0147   _style.visible = true;
0148   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0149   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0150   set_style_font(_style,a_font);}
0151   
0152  {text_style& _style = _axis.mag_style();
0153   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0154   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0155   set_style_font(_style,a_font);}
0156   
0157   }
0158   
0159   //////////////////////////////////////////////////////////
0160   /// z axis: //////////////////////////////////////////////
0161   //////////////////////////////////////////////////////////
0162  {axis& _axis = a_plotter.z_axis();
0163   _axis.modeling = tick_modeling_hplot();
0164   _axis.is_log = false;
0165 
0166  {line_style& _style = _axis.line_style();
0167   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0168   _style.width = 1.0f;}  
0169 
0170  {line_style& _style = _axis.ticks_style();
0171   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0172   _style.width = 1.0f;}
0173   
0174  {text_style& _style = _axis.labels_style();
0175   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0176   _style.scale = 0.6;}
0177   
0178  {text_style& _style = _axis.title_style();
0179   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0180   _style.scale = 0.6;}
0181   
0182  {text_style& _style = _axis.mag_style();
0183   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0184   _style.scale = 0.6;}
0185   
0186   }
0187   
0188   //////////////////////////////////////////////////////////
0189   /// colormap axis: ///////////////////////////////////////
0190   //////////////////////////////////////////////////////////
0191  {axis& _axis = a_plotter.colormap_axis();
0192   _axis.modeling = tick_modeling_hplot();
0193   _axis.divisions = 510;
0194   _axis.title_hjust = right;
0195   _axis.label_to_axis = 0.005f;
0196   _axis.label_height = 0.04f;
0197   _axis.tick_length = 0.03f;
0198   _axis.title_to_axis = 0.07f; //XLAB = 0.07
0199   _axis.title_height = 0.04f;
0200   _axis.is_log = false;
0201 
0202  {line_style& _style = _axis.line_style();
0203   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0204   _style.width = 1.0f;}  
0205 
0206  {line_style& _style = _axis.ticks_style();
0207   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0208   _style.width = 1.0f;}
0209   
0210  {text_style& _style = _axis.labels_style();
0211   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0212   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0213   set_style_font(_style,a_font);}
0214   
0215  {text_style& _style = _axis.title_style();
0216   _style.visible = true;
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.mag_style();
0222   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0223   _style.scale = 0.6;  //To have a good matching with ROOT text size.
0224   set_style_font(_style,a_font);}
0225   
0226   }
0227 
0228  {style& _style = a_plotter.bins_style(0);
0229   _style.modeling = modeling_top_lines();
0230   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0231   _style.line_width = 1.0f;
0232 //_style.line_pattern = line_solid;
0233   }
0234   
0235  {style& _style = a_plotter.func_style(0);
0236   _style.modeling = modeling_top_lines();
0237   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0238   _style.line_width = 3.0f;
0239   }
0240   
0241 }
0242 
0243 inline void set_hippodraw_style(std::ostream& a_out,const cmaps_t& a_cmaps,plotter& a_plotter,const std::string& a_font) {
0244   // In memory of P.Kunz.
0245 
0246   a_plotter.value_top_margin = 0.05f;
0247   a_plotter.bottom_margin = 0.12f;
0248   a_plotter.top_margin = 0.16f;
0249   a_plotter.left_margin = 0.16f;
0250   a_plotter.right_margin = 0.16f;
0251   a_plotter.title_to_axis = 0.1f;
0252   a_plotter.title_height = 0.03f;
0253 
0254  {style& _style = a_plotter.grid_style();
0255   _style.visible = false;}
0256  {style& _style = a_plotter.inner_frame_style();
0257   _style.visible = true;}
0258  {text_style& _style = a_plotter.infos_style();
0259   _style.visible = false;}
0260   
0261  {text_style& _style = a_plotter.title_style();
0262   set_style_font(_style,a_font);
0263   _style.visible = true;}
0264 
0265   //////////////////////////////////////////////////////////
0266   /// x axis: //////////////////////////////////////////////
0267   //////////////////////////////////////////////////////////
0268  {axis& _axis = a_plotter.x_axis();
0269   _axis.modeling = tick_modeling_hippo();
0270   _axis.title_hjust = center;
0271   _axis.label_to_axis = 0.015f;
0272   _axis.title_to_axis = 0.07f;
0273   _axis.title_height = 0.035f;
0274   _axis.label_height = 0.02625f;  //0.0175F * 1.5F
0275   
0276  {text_style& _style = _axis.title_style();
0277   _style.visible = true;
0278   set_style_font(_style,a_font);}
0279   
0280  {text_style& _style = _axis.labels_style();
0281   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0282   set_style_font(_style,a_font);}
0283   
0284   }
0285   
0286   //////////////////////////////////////////////////////////
0287   /// y axis: //////////////////////////////////////////////
0288   //////////////////////////////////////////////////////////
0289  {axis& _axis = a_plotter.y_axis();
0290   _axis.modeling = tick_modeling_hippo();
0291   _axis.title_hjust = center;
0292   _axis.title_to_axis = 0.2f;
0293   _axis.title_height = 0.035f;
0294   _axis.label_height = 0.02625f;  //0.0175F * 1.5F
0295   
0296  {text_style& _style = _axis.title_style();
0297   _style.visible = true;
0298   set_style_font(_style,a_font);}
0299   
0300  {text_style& _style = _axis.labels_style();
0301   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0302   set_style_font(_style,a_font);}
0303   
0304   }
0305   
0306   //////////////////////////////////////////////////////////
0307   /// z axis: //////////////////////////////////////////////
0308   //////////////////////////////////////////////////////////
0309  {axis& _axis = a_plotter.z_axis();
0310   
0311  {text_style& _style = _axis.title_style();
0312   _style.visible = true;
0313   set_style_font(_style,a_font);}
0314   
0315  {text_style& _style = _axis.labels_style();
0316   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0317   set_style_font(_style,a_font);}
0318   
0319   }
0320   
0321  {style& _style = a_plotter.bins_style(0);
0322   _style.modeling = modeling_top_lines();
0323   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0324   _style.line_width = 1.0f;
0325   }
0326   
0327  {style& _style = a_plotter.func_style(0);
0328   _style.modeling = modeling_top_lines();
0329   if(!set_style_color(a_out,a_cmaps,"black",_style.color.value())) {}
0330   _style.line_width = 1.0f;
0331   }
0332 
0333  {style& _style = a_plotter.errors_style(0);
0334   _style.visible = false;
0335   }
0336 
0337 }
0338 
0339 inline void set_inlib_default_style(std::ostream&,const cmaps_t&,plotter& a_plotter,const std::string&) {
0340  {axis& _axis = a_plotter.colormap_axis();
0341   _axis.label_to_axis = 0.01f;}  
0342 }
0343 
0344 }}
0345 
0346 #endif