Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
PadStyle.cxx
1/*
2 * PadStyle.cpp
3 *
4 * Created on: 30 lip 2024
5 * Author: daniel
6 */
7
8#include "PadStyle.h"
9
10#include <Rtypes.h>
11#include <TString.h>
12#include <TVirtualPad.h>
13
14#include "XMLNode.h"
15
16namespace Hal {
17 const unsigned short int PadStyle::kBottomMargin = 0;
18 const unsigned short int PadStyle::kLeftMargin = 1;
19 const unsigned short int PadStyle::kTopMargin = 2;
20 const unsigned short int PadStyle::kRightMargin = 3;
21 const unsigned short int PadStyle::kLogx = 4;
22 const unsigned short int PadStyle::kLogy = 5;
23 const unsigned short int PadStyle::kLogz = 6;
24 const unsigned short int PadStyle::kGridx = 7;
25 const unsigned short int PadStyle::kGridy = 8;
26 const unsigned short int PadStyle::kGridz = 9;
27
28 PadStyle::PadStyle(Double_t x1, Double_t y1, Double_t x2, Double_t y2) {
29 SetLeftMargin(x1);
30 SetRightMargin(x2);
32 SetTopMargin(y2);
33 }
34
35 void PadStyle::SetBottomMargin(Float_t val) { SetF(kBottomMargin, val); }
36
37 void PadStyle::SetLeftMargin(Float_t val) { SetF(kLeftMargin, val); }
38
39 void PadStyle::SetTopMargin(Float_t val) { SetF(kTopMargin, val); }
40
41 void PadStyle::SetRightMargin(Float_t val) { SetF(kRightMargin, val); }
42
43 void PadStyle::SetLogx(Int_t val) { SetI(kLogx, val); }
44
45 void PadStyle::SetLogy(Int_t val) { SetI(kLogy, val); }
46
47 void PadStyle::SetLogz(Int_t val) { SetI(kLogz, val); }
48
49 void PadStyle::SetGridx(Int_t val) { SetI(kGridx, val); }
50
51 void PadStyle::SetGridy(Int_t val) { SetI(kGridy, val); }
52
53 void PadStyle::SetGridz(Int_t val) { SetI(kGridz, val); }
54
55 Float_t PadStyle::GetBottomMargin() const { return GetF(kBottomMargin); }
56
57 Float_t PadStyle::GetLeftMargin() const { return GetF(kLeftMargin); }
58
59 Float_t PadStyle::GetTopMargin() const { return GetF(kTopMargin); }
60
61 Float_t PadStyle::GetRightMargin() const { return GetF(kRightMargin); }
62
63 Int_t PadStyle::GetLogx(Int_t val) const { return GetI(kLogx); }
64
65 Int_t PadStyle::GetLogy(Int_t val) const { return GetI(kLogy); }
66
67 Int_t PadStyle::GetLogz(Int_t val) const { return GetI(kLogz); }
68
69 Int_t PadStyle::GetGridx(Int_t val) const { return GetI(kGridx); }
70
71 Int_t PadStyle::GetGridy(Int_t val) const { return GetI(kGridy); }
72
73 Int_t PadStyle::GetGridz(Int_t val) const { return GetI(kGridz); }
74
75 PadStyle::PadStyle() {}
76
77 void PadStyle::Apply(TVirtualPad* obj) {
78 if (!obj) return;
79 if (Find(kBottomMargin)) obj->SetBottomMargin(GetF(kBottomMargin));
80 if (Find(kLeftMargin)) obj->SetLeftMargin(GetF(kLeftMargin));
81 if (Find(kTopMargin)) obj->SetTopMargin(GetF(kTopMargin));
82 if (Find(kRightMargin)) obj->SetRightMargin(GetF(kRightMargin));
83 if (Find(kLogx)) obj->SetLogx(GetI(kLogx));
84 if (Find(kLogy)) obj->SetLogy(GetI(kLogy));
85 if (Find(kLogz)) obj->SetLogz(GetI(kLogz));
86 if (Find(kGridx)) obj->SetGridx(GetI(kGridx));
87 if (Find(kGridy)) obj->SetGridy(GetI(kGridy));
88 }
89
90 void PadStyle::ExportToXML(XMLNode* node) const {
91
92 if (Find(kBottomMargin)) node->AddAttrib(new Hal::XMLAttrib("BottomMargin", Form("%4.4f", GetF(kBottomMargin))));
93 if (Find(kLeftMargin)) node->AddAttrib(new Hal::XMLAttrib("LeftMargin", Form("%4.4f", GetF(kLeftMargin))));
94 if (Find(kTopMargin)) node->AddAttrib(new Hal::XMLAttrib("TopMargin", Form("%4.4f", GetF(kTopMargin))));
95 if (Find(kRightMargin)) node->AddAttrib(new Hal::XMLAttrib("RightMargin", Form("%4.4f", GetF(kRightMargin))));
96 if (Find(kLogx)) node->AddAttrib(new Hal::XMLAttrib("Logx", Form("%i", GetI(kLogx))));
97 if (Find(kLogy)) node->AddAttrib(new Hal::XMLAttrib("Logy", Form("%i", GetI(kLogy))));
98 if (Find(kLogz)) node->AddAttrib(new Hal::XMLAttrib("Logz", Form("%i", GetI(kLogz))));
99 if (Find(kGridx)) node->AddAttrib(new Hal::XMLAttrib("Gridx", Form("%i", GetI(kGridx))));
100 if (Find(kGridy)) node->AddAttrib(new Hal::XMLAttrib("Gridy", Form("%i", GetI(kGridy))));
101 if (Find(kGridz)) node->AddAttrib(new Hal::XMLAttrib("Gridz", Form("%i", GetI(kGridz))));
102 }
103
104 void PadStyle::ImportFromXML(XMLNode* node) {
105
106 if (auto atr = node->GetAttrib("BottomMargin")) {
107 float x = atr->GetValue().Atof();
109 }
110 if (auto atr = node->GetAttrib("LeftMargin")) {
111 float x = atr->GetValue().Atof();
112 SetLeftMargin(x);
113 }
114 if (auto atr = node->GetAttrib("TopMargin")) {
115 float x = atr->GetValue().Atof();
116 SetTopMargin(x);
117 }
118 if (auto atr = node->GetAttrib("RightMargin")) {
119 float x = atr->GetValue().Atof();
120 SetRightMargin(x);
121 }
122 if (auto atr = node->GetAttrib("Logx")) {
123 int x = atr->GetValue().Atoi();
124 SetLogx(x);
125 }
126 if (auto atr = node->GetAttrib("Logy")) {
127 int x = atr->GetValue().Atoi();
128 SetLogy(x);
129 }
130 if (auto atr = node->GetAttrib("Logz")) {
131 int x = atr->GetValue().Atoi();
132 SetLogz(x);
133 }
134 if (auto atr = node->GetAttrib("Gridx")) {
135 int x = atr->GetValue().Atoi();
136 SetGridx(x);
137 }
138 if (auto atr = node->GetAttrib("Gridy")) {
139 int x = atr->GetValue().Atoi();
140 SetGridy(x);
141 }
142 if (auto atr = node->GetAttrib("Gridz")) {
143 int x = atr->GetValue().Atoi();
144 SetGridz(x);
145 }
146 }
147} /* namespace Hal */
void SetBottomMargin(Float_t val)
Definition PadStyle.cxx:35
Bool_t Find(Int_t bit) const
Definition Style.h:55