Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights 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 o 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_ou 18 if(!find_color(a_cmaps,a_s,a_col)) { 19 a_out << "tools::sg::set_style_color: colo 20 return false; 21 } 22 return true; 23 } 24 25 // a_font = font_arialbd_ttf(); //idem ROO 26 // a_font = font_roboto_bold_ttf(); //open sou 27 28 inline void set_style_font(text_style& a_style 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::ostrea 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/grey 44 //border: 45 if(!set_style_color(a_out,a_cmaps,"black",_s 46 _style.line_width = 0.003; // 0 = no border 47 } 48 49 // <!-- <style name="wall_style"><visible>fals 50 51 {style& _style = a_plotter.grid_style(); 52 _style.visible = false; 53 //if(!set_style_color(a_out,a_cmaps,"white",_s 54 } 55 56 // plot title done with the title_box (and n 57 {text_style& _style = a_plotter.title_style() 58 _style.visible = false; 59 } 60 {text_style& _style = a_plotter.title_box_sty 61 _style.visible = true; 62 if(!set_style_color(a_out,a_cmaps,"ROOT/grey 63 _style.back_shadow = 0.015f; //% of width. 64 if(!set_style_color(a_out,a_cmaps,"black",_s 65 set_style_font(_style,a_font);} 66 67 a_plotter.infos_width = 0.35f; 68 a_plotter.infos_x_margin = 0.01f; //from ri 69 a_plotter.infos_y_margin = 0.005f; //from t 70 {text_style& _style = a_plotter.infos_style() 71 _style.visible = true; 72 if(!set_style_color(a_out,a_cmaps,"ROOT/grey 73 _style.back_shadow = 0.015f; //% of width. 74 if(!set_style_color(a_out,a_cmaps,"black",_s 75 _style.modeling = infos_modeling_ROOT(); // 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",_s 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",_s 101 _style.width = 1.0f;} 102 103 {line_style& _style = _axis.ticks_style(); 104 if(!set_style_color(a_out,a_cmaps,"black",_s 105 _style.width = 1.0f;} 106 107 {text_style& _style = _axis.labels_style(); 108 if(!set_style_color(a_out,a_cmaps,"black",_s 109 _style.scale = 0.6; //To have a good matchi 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",_s 115 _style.scale = 0.6; //To have a good matchi 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",_s 120 _style.scale = 0.6; //To have a good matchi 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",_s 141 _style.width = 1.0f;} 142 143 {line_style& _style = _axis.ticks_style(); 144 if(!set_style_color(a_out,a_cmaps,"black",_s 145 _style.width = 1.0f;} 146 147 {text_style& _style = _axis.labels_style(); 148 if(!set_style_color(a_out,a_cmaps,"black",_s 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",_s 155 _style.scale = 0.6; //To have a good matchi 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",_s 160 _style.scale = 0.6; //To have a good matchi 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",_s 174 _style.width = 1.0f;} 175 176 {line_style& _style = _axis.ticks_style(); 177 if(!set_style_color(a_out,a_cmaps,"black",_s 178 _style.width = 1.0f;} 179 180 {text_style& _style = _axis.labels_style(); 181 if(!set_style_color(a_out,a_cmaps,"black",_s 182 _style.scale = 0.6;} 183 184 {text_style& _style = _axis.title_style(); 185 if(!set_style_color(a_out,a_cmaps,"black",_s 186 _style.scale = 0.6;} 187 188 {text_style& _style = _axis.mag_style(); 189 if(!set_style_color(a_out,a_cmaps,"black",_s 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",_s 210 _style.width = 1.0f;} 211 212 {line_style& _style = _axis.ticks_style(); 213 if(!set_style_color(a_out,a_cmaps,"black",_s 214 _style.width = 1.0f;} 215 216 {text_style& _style = _axis.labels_style(); 217 if(!set_style_color(a_out,a_cmaps,"black",_s 218 _style.scale = 0.6; //To have a good matchi 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",_s 224 _style.scale = 0.6; //To have a good matchi 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",_s 229 _style.scale = 0.6; //To have a good matchi 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",_s 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",_s 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 so 252 253 inline void set_hippodraw_style(std::ostream& 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>fals 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 * 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",_s 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 * 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",_s 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",_s 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",_s 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",_s 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::ostre 354 {axis& _axis = a_plotter.colormap_axis(); 355 _axis.label_to_axis = 0.01f;} 356 } 357 358 }} 359 360 #endif