Jpp test-rotations-old-57-g407471f53
the software that should make you happy
Loading...
Searching...
No Matches
JStyle.hh
Go to the documentation of this file.
1#ifndef __JROOT__JSTYLE__
2#define __JROOT__JSTYLE__
3
4#include "TStyle.h"
5#include "TCanvas.h"
6
7#include "Jeep/JProperties.hh"
8
9
10/**
11 * \author mdejong
12 */
13
14namespace JROOT {}
15namespace JPP { using namespace JROOT; }
16
17namespace JROOT {
18
19 /**
20 * Wrapper class around ROOT TStyle.
21 */
22 class JStyle :
23 public TStyle
24 {
25 public:
26 struct JParameters {
27 /**
28 * Default constructor.
29 */
31 fontSize (1.0),
32 topMargin (0.1),
33 bottomMargin(0.15),
34 leftMargin (0.15),
35 rightMargin (0.10),
36 titleOffset (1.00),
37 tickLength (1.00),
38 titleX (0.50),
39 titleY (0.99)
40 {}
41
42
43 /**
44 * Get properties of this class.
45 */
47 {
48 return JParametersHelper(*this);
49 }
50
51
52 /**
53 * Get properties of this class.
54 */
56 {
57 return JParametersHelper(*this);
58 }
59
60 Double_t fontSize;
61 Double_t topMargin;
62 Double_t bottomMargin;
63 Double_t leftMargin;
64 Double_t rightMargin;
65 Double_t titleOffset;
66 Double_t tickLength;
67 Double_t titleX;
68 Double_t titleY;
69
70 private:
71 /**
72 * Auxiliary class for I/O of parameters.
73 */
75 public JProperties
76 {
77 public:
78 /**
79 * Constructor.
80 *
81 * \param object parameters
82 */
83 template<class JParameters_t>
84 JParametersHelper(JParameters_t& object)
85 {
86 insert(gmake_property(object.fontSize));
87 insert(gmake_property(object.topMargin));
88 insert(gmake_property(object.bottomMargin));
89 insert(gmake_property(object.leftMargin));
90 insert(gmake_property(object.rightMargin));
91 insert(gmake_property(object.titleOffset));
92 insert(gmake_property(object.tickLength));
93 insert(gmake_property(object.titleX));
94 insert(gmake_property(object.titleY));
95 }
96 };
97 };
98
99
100 /**
101 * Constructor.
102 *
103 * \param title title
104 * \param x number of pixels in X
105 * \param y number of pixels in Y
106 * \param parameters parameters
107 */
108 JStyle(const char* title,
109 const UInt_t x,
110 const UInt_t y,
111 const JParameters& parameters = JParameters()) :
112 TStyle(title, NULL)
113 {
114 const Double_t font_size = (Double_t) y * 0.7e-4 * parameters.fontSize;
115 const Double_t title_offset = 1.5 * parameters.titleOffset;
116 const Double_t tick_length = 3.0e-5 * parameters.tickLength;
117
118 SetPadTopMargin (parameters.topMargin);
119 SetPadBottomMargin(parameters.bottomMargin);
120 SetPadLeftMargin (parameters.leftMargin);
121 SetPadRightMargin (parameters.rightMargin);
122
123 SetCanvasColor(0);
124 SetCanvasBorderMode(0);
125 SetCanvasBorderSize(0);
126
127 SetPadColor(0);
128 SetPadBorderMode(0);
129 SetPadBorderSize(0);
130
131 for (const auto option : { "X", "Y", "Z"}) {
132 SetTickLength (tick_length * (x < y ? x : y), option);
133 SetLabelSize (font_size, option);
134 SetTitleOffset(title_offset, option);
135 SetTitleSize (font_size, option);
136 }
137
138 SetTitleX(parameters.titleX);
139 SetTitleY(parameters.titleY);
140
141 SetStatColor(0);
142 SetStatBorderSize(1);
143 SetStatFontSize(font_size);
144 SetOptStat(111111);
145 SetOptFit(1111);
146
147 SetPaintTextFormat("3.0f");
148 SetPalette(1);
149
150 SetTitleFillColor(0);
151 SetTitleAlign(23);
152 SetTitleX(0.5);
153 SetTitleBorderSize(0);
154 }
155
156
157 /**
158 * Scale font sizes.
159 *
160 * \param factor scale factor
161 */
162 void setFontSize(const Double_t factor)
163 {
164 for (const auto option : { "X", "Y", "Z"}) {
165 SetLabelSize(GetLabelSize(option) * factor, option);
166 SetTitleSize(GetTitleSize(option) * factor, option);
167 }
168 }
169 };
170}
171
172#endif
Utility class to parse parameter values.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
Utility class to parse parameter values.
Auxiliary class for I/O of parameters.
Definition JStyle.hh:76
JParametersHelper(JParameters_t &object)
Constructor.
Definition JStyle.hh:84
Wrapper class around ROOT TStyle.
Definition JStyle.hh:24
void setFontSize(const Double_t factor)
Scale font sizes.
Definition JStyle.hh:162
JStyle(const char *title, const UInt_t x, const UInt_t y, const JParameters &parameters=JParameters())
Constructor.
Definition JStyle.hh:108
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
JProperties getProperties()
Get properties of this class.
Definition JStyle.hh:46
JParameters()
Default constructor.
Definition JStyle.hh:30
JProperties getProperties() const
Get properties of this class.
Definition JStyle.hh:55