20 const int Painter::kHtmlBit = 0;
21 const int Painter::kGridBit = 1;
24 fCommonData.fCanvases =
new std::vector<TCanvas*>();
25 fCommonData.fPads =
new std::vector<std::vector<TVirtualPad*>>();
30 for (
auto x : fSubPainters)
36 painter->fOwnPad = kFALSE;
37 painter->fParent =
this;
38 painter->fCommonData = fCommonData;
39 fSubPainters.push_back(painter);
53 auto grand = GetAncestor();
54 if (grand->fPainted) {
56 grand->UpdateAllPads();
65 SETBIT(fDrawFlags, bit);
67 CLRBIT(fDrawFlags, bit);
71 auto dividePads = [&]() {
75 for (
int i = 0; i < x; i++) {
76 for (
int j = 0; j < y; j++) {
77 (*fCommonData.fPads)[canvasNo].push_back(canva->cd(++count));
82 if (fCommonData.fCanvases->size() > canvasNo) {
85 for (
int i = fCommonData.fCanvases->size(); i <= canvasNo; i++) {
86 auto newCanv =
new TCanvas();
87 fCommonData.fCanvases->push_back(newCanv);
88 std::vector<TVirtualPad*> pads;
89 pads.push_back(newCanv);
90 fCommonData.fPads->push_back(pads);
97 void Painter::UpdateAllPads() {
99 for (
auto pads : *fCommonData.fPads) {
100 for (
unsigned int i = 1; i < pads.size(); i++) {
102 if (fPadStyle) { fPadStyle->Apply(pad); }
103 pad->Modified(kTRUE);
109 void Painter::TryPaint() {
114 HalCoutDebug(
"Cannot paint this object due to failing pads dependencies");
120 for (
auto x : fSubPainters)
125 if (Hal::Std::FindParam(option,
"skip"))
return;
126 if (Hal::Std::FindParam(option,
"default!")) {
130 if (Hal::Std::FindParam(option,
"grid")) {
134 SetGlobalPadStyle(style);
137 ULong64_t defFlags = 0;
138 if (Hal::Std::FindParam(option,
"keep", kTRUE)) { defFlags = fDrawFlags; }
139 if (Hal::Std::FindParam(option,
"html", kTRUE)) {
140 SETBIT(defFlags, kHtmlBit);
141 if (defFlags != fDrawFlags) {
143 fDrawFlags = defFlags;
147 CLRBIT(defFlags, kHtmlBit);
150 if (newOpt != fDrawFlags) {
157 if (fParent)
return kTRUE;
162 auto vec = Hal::Std::ExplodeString(opt,
',');
163 if (vec.size() == 0)
return kFALSE;
164 TString match = Form(
"%s=", flag.Data());
165 if (!vec[0].Contains(match))
return kFALSE;
166 vec[0].ReplaceAll(match,
"");
168 double val = i.Atof();
175 Int_t flag = Hal::Std::FindParam2(option, pattern, remove);
176 if (flag == 1) SETBIT(drawOpt, bit);
177 if (flag == -1) CLRBIT(drawOpt, bit);
184 if (gPad) gPad->cd();
187 void Painter::GotoPad(Int_t no, Int_t canvasNo) { (*fCommonData.fPads)[canvasNo][no]->cd(); }
190 for (
auto canv : (*fCommonData.fCanvases)) {
192 (*fCommonData.fPads)[canvasNo].clear();
197 if (index < 0) index = 0;
198 return (*fCommonData.fPads)[canvasNo][index];
201 Painter* Painter::GetAncestor()
const {
203 return GetAncestor();
209 if (fCommonData.fCanvases->size() > canvasNo)
return kTRUE;
214 if (!fOwnPad)
return;
215 if (fCommonData.fCanvases) {
216 for (
auto canv : *fCommonData.fCanvases)
218 delete fCommonData.fCanvases;
219 fCommonData.fCanvases =
nullptr;
221 if (fCommonData.fPads) {
222 delete fCommonData.fPads;
223 fCommonData.fPads =
nullptr;
229 for (
auto ibit : bits)
231 if (set >= 0) SETBIT(flag, set);
virtual void InnerPaint()
virtual void SetDefaultFlag()
Bool_t CanvasExist(Int_t canvasNo=0) const
TCanvas * GetCanvas(Int_t canvasNo=0) const
void SetFlag(Int_t bit, Bool_t state)
void AddPainter(Painter *painter)
virtual void MakePadsAndCanvases()=0
void ResetFewBits(ULong64_t &flag, std::initializer_list< Int_t > bits, Int_t set=-1) const
void MakeCanvasPads(Int_t x=1, Int_t y=1, Int_t canvasNo=0)
Painter * GetParent() const
virtual Bool_t CheckPads() const
virtual void InnerRepaint()
void ContitionalPattern(TString &option, TString pattern, ULong64_t &drawOpt, Int_t bit, Bool_t remove=kTRUE) const
virtual void SetOption(TString option)
virtual ULong64_t SetOptionInternal(TString opt, ULong64_t prev=0)=0
TVirtualPad * GetPad(Int_t index, Int_t canvasNo=0) const
void GotoPad(Int_t no, Int_t canvasNo=0)
Bool_t GetPatterns(TString opt, TString flag, std::vector< double > &vals) const
void ClearCanvas(Int_t canvas)