10#include <RtypesCore.h>
17 const unsigned short int AxisStyle::kTitleOffset = 0;
18 const unsigned short int AxisStyle::kLabelOffset = 1;
19 const unsigned short int AxisStyle::kTitleSize = 2;
20 const unsigned short int AxisStyle::kLabelSize = 3;
21 const unsigned short int AxisStyle::kTickLength = 4;
22 const unsigned short int AxisStyle::kNdivisions = 5;
23 const unsigned short int AxisStyle::kAxisColor = 6;
24 const unsigned short int AxisStyle::kLabelColor = 7;
25 const unsigned short int AxisStyle::kTitleColor = 8;
26 const unsigned short int AxisStyle::kTitleFont = 9;
27 const unsigned short int AxisStyle::kCenterTitle = 10;
28 const unsigned short int AxisStyle::kRangeMin = 11;
29 const unsigned short int AxisStyle::kRangeMax = 12;
30 const unsigned short int AxisStyle::kTitle = 13;
32 void AxisStyle::SetTitleOffset(Float_t val) { SetF(kTitleOffset, val); }
34 void AxisStyle::SetLabelOffset(Float_t val) { SetF(kLabelOffset, val); }
36 void AxisStyle::SetTitleSize(Float_t val) { SetF(kTitleSize, val); }
38 void AxisStyle::SetLabelSize(Float_t val) { SetF(kLabelSize, val); }
40 void AxisStyle::SetTickLength(Float_t val) { SetF(kTickLength, val); }
42 void AxisStyle::SetNdivisions(Int_t val) { SetI(kNdivisions, val); }
44 void AxisStyle::SetAxisColor(Int_t val) { SetI(kAxisColor, val); }
46 void AxisStyle::SetLabelColor(Int_t val) { SetI(kLabelColor, val); }
48 void AxisStyle::SetTitleColor(Int_t val) { SetI(kTitleColor, val); }
50 void AxisStyle::SetTitleFont(Int_t val) { SetI(kTitleFont, val); }
52 void AxisStyle::SetCenterTitle(Int_t val) { SetI(kCenterTitle, val); }
54 Float_t AxisStyle::GetTitleOffset()
const {
return GetF(kTitleOffset); }
56 Float_t AxisStyle::GetLabelOffset()
const {
return GetF(kLabelOffset); }
58 Float_t AxisStyle::GetTitleSize()
const {
return GetF(kTitleSize); }
60 Float_t AxisStyle::GetLabelSize()
const {
return GetF(kLabelSize); }
62 Float_t AxisStyle::GetTickLength()
const {
return GetF(kTickLength); }
64 Int_t AxisStyle::GetNDivisions()
const {
return GetI(kNdivisions); }
66 Int_t AxisStyle::GetAxisColor()
const {
return GetI(kAxisColor); }
68 Int_t AxisStyle::GetLabelColor()
const {
return GetI(kLabelColor); }
70 Int_t AxisStyle::GetTitleColor()
const {
return GetI(kTitleColor); }
72 Int_t AxisStyle::GetTitleFont()
const {
return GetI(kTitleFont); }
74 Int_t AxisStyle::GetCenterTitle()
const {
return GetI(kCenterTitle); }
76 void AxisStyle::Apply(TAxis& obj)
const {
77 if (
Find(kTitleOffset)) obj.SetTitleOffset(GetF(kTitleOffset));
78 if (
Find(kLabelOffset)) obj.SetLabelOffset(GetF(kLabelOffset));
79 if (
Find(kTitleSize)) obj.SetTitleSize(GetF(kTitleSize));
80 if (
Find(kLabelSize)) obj.SetLabelSize(GetF(kLabelSize));
81 if (
Find(kTickLength)) obj.SetTickLength(GetF(kTickLength));
82 if (
Find(kNdivisions)) obj.SetNdivisions(GetI(kNdivisions));
83 if (
Find(kAxisColor)) obj.SetAxisColor(GetI(kAxisColor));
84 if (
Find(kLabelColor)) obj.SetLabelColor(GetI(kLabelColor));
85 if (
Find(kTitleColor)) obj.SetTitleColor(GetI(kTitleColor));
86 if (
Find(kTitleFont)) obj.SetTitleFont(GetI(kTitleFont));
87 if (
Find(kCenterTitle)) obj.CenterTitle(GetI(kCenterTitle));
88 if (
Find(kTitle)) obj.SetTitle(fTitle);
89 if (
Find(kRangeMin) &&
Find(kRangeMin)) obj.SetRangeUser(GetF(kRangeMin), GetF(kRangeMax));
92 void AxisStyle::SetTitle(TString val) {
97 void AxisStyle::ExportToXML(XMLNode* node)
const {
98 if (
Find(kTitleOffset)) node->AddAttrib(
new Hal::XMLAttrib(
"TitleOffset", Form(
"%4.4f", GetF(kTitleOffset))));
99 if (
Find(kLabelOffset)) node->AddAttrib(
new Hal::XMLAttrib(
"LabelOffset", Form(
"%4.4f", GetF(kLabelOffset))));
100 if (
Find(kTitleSize)) node->AddAttrib(
new Hal::XMLAttrib(
"TitleSize", Form(
"%4.4f", GetF(kTitleSize))));
101 if (
Find(kLabelSize)) node->AddAttrib(
new Hal::XMLAttrib(
"LabelSize", Form(
"%4.4f", GetF(kLabelSize))));
102 if (
Find(kTickLength)) node->AddAttrib(
new Hal::XMLAttrib(
"TickLength", Form(
"%4.4f", GetF(kTickLength))));
103 if (
Find(kNdivisions)) node->AddAttrib(
new Hal::XMLAttrib(
"Ndivisions", Form(
"%i", GetI(kNdivisions))));
104 if (
Find(kAxisColor)) node->AddAttrib(
new Hal::XMLAttrib(
"AxisColor", Form(
"%i", GetI(kAxisColor))));
105 if (
Find(kLabelColor)) node->AddAttrib(
new Hal::XMLAttrib(
"LabelColor", Form(
"%i", GetI(kLabelColor))));
106 if (
Find(kTitleColor)) node->AddAttrib(
new Hal::XMLAttrib(
"TitleColor", Form(
"%i", GetI(kTitleColor))));
107 if (
Find(kTitleFont)) node->AddAttrib(
new Hal::XMLAttrib(
"TitleFont", Form(
"%i", GetI(kTitleFont))));
108 if (
Find(kCenterTitle)) node->AddAttrib(
new Hal::XMLAttrib(
"CenterTitle", Form(
"%i", GetI(kCenterTitle))));
110 if (
Find(kRangeMin)) node->AddAttrib(
new Hal::XMLAttrib(
"RangeMin", Form(
"%4.4f", GetF(kRangeMin))));
111 if (
Find(kRangeMax)) node->AddAttrib(
new Hal::XMLAttrib(
"RangeMax", Form(
"%4.4f", GetF(kRangeMax))));
114 void AxisStyle::SetRangeUser(Float_t min, Float_t max) {
115 SetF(kRangeMin, min);
116 SetF(kRangeMax, max);
119 void AxisStyle::ImportFromXML(XMLNode* node) {
121 if (
auto atr = node->GetAttrib(
"TitleOffset")) {
122 float x = atr->GetValue().Atof();
125 if (
auto atr = node->GetAttrib(
"LabelOffset")) {
126 float x = atr->GetValue().Atof();
129 if (
auto atr = node->GetAttrib(
"TitleSize")) {
130 float x = atr->GetValue().Atof();
133 if (
auto atr = node->GetAttrib(
"LabelSize")) {
134 float x = atr->GetValue().Atof();
137 if (
auto atr = node->GetAttrib(
"TickLength")) {
138 float x = atr->GetValue().Atof();
141 if (
auto atr = node->GetAttrib(
"Ndivisions")) {
142 int x = atr->GetValue().Atoi();
145 if (
auto atr = node->GetAttrib(
"AxisColor")) {
146 int x = atr->GetValue().Atoi();
149 if (
auto atr = node->GetAttrib(
"LabelColor")) {
150 int x = atr->GetValue().Atoi();
153 if (
auto atr = node->GetAttrib(
"TitleColor")) {
154 int x = atr->GetValue().Atoi();
157 if (
auto atr = node->GetAttrib(
"TitleFont")) {
158 int x = atr->GetValue().Atoi();
161 if (
auto atr = node->GetAttrib(
"CenterTitle")) {
162 int x = atr->GetValue().Atoi();
166 if (node->GetAttrib(
"RangeMin") && node->GetAttrib(
"RangeMin")) {
167 auto atr1 = node->GetAttrib(
"RangeMin");
168 auto atr2 = node->GetAttrib(
"RangeMax");
169 float mini = atr1->GetValue().Atof();
170 float maxi = atr2->GetValue().Atof();
171 SetRangeUser(mini, maxi);
174 if (
auto atr = node->GetAttrib(
"CenterTitle")) {
175 int x = atr->GetValue().Atoi();
178 if (
auto atr = node->GetAttrib(
"Title")) {
179 TString x = atr->GetValue();
184 AxisStyle::AxisStyle() {}
186 AxisStyle::AxisStyle(Double_t titleSize, Double_t labelSize, Double_t titleOffset, Double_t labelOffset) {
187 SetTitleSize(titleSize);
188 SetLabelSize(labelSize);
189 SetTitleOffset(titleOffset);
190 SetLabelOffset(labelOffset);
Bool_t Find(Int_t bit) const