Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
Painter.h
1/*
2 * Painter.h
3 *
4 * Created on: 17 lut 2024
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#ifndef HAL_FEATURES_HIST_PAINTER_H_
10#define HAL_FEATURES_HIST_PAINTER_H_
11
12#include <TObject.h>
13#include <vector>
17class TCanvas;
18class TVirtualPad;
19// TODO Ownership for HTML
20// TODO what to do with Paint - should it call parents paint or repaint?
21namespace Hal {
22 class Style;
23 class PadStyle;
24 class HistoStyle;
28 class Painter : public TObject {
29 private:
30 struct commonPointers {
31 std::vector<TCanvas*>* fCanvases = {nullptr};
32 std::vector<std::vector<TVirtualPad*>>* fPads = {nullptr};
33 };
34 commonPointers fCommonData;
35 Painter* fParent = {nullptr};
36 TVirtualPad* fTempPad = {nullptr};
37 std::vector<Painter*> fSubPainters;
38 Hal::PadStyle* fPadStyle = {nullptr};
39 Bool_t fOwnPad = {kTRUE};
40 Bool_t fPainted = {kFALSE};
41 ULong64_t fDrawFlags = {0};
42 void TryPaint();
43
44 protected:
45 static const int kHtmlBit;
46 static const int kGridBit;
52 void SetFlag(Int_t bit, Bool_t state);
57 void SetFlagForced(ULong64_t flag) { fDrawFlags = flag; };
64 void ResetFewBits(ULong64_t& flag, std::initializer_list<Int_t> bits, Int_t set = -1) const;
68 Bool_t fOptionsChanged = {kFALSE};
73 Bool_t OwnGraphic() const { return fOwnPad; }
79 Bool_t CheckOpt(Int_t opt) const { return TESTBIT(fDrawFlags, opt); };
84 ULong64_t GetDrawFlags() const { return fDrawFlags; }
97 virtual ULong64_t SetOptionInternal(TString opt, ULong64_t prev = 0) = 0;
101 virtual void OptionsApplied() { fOptionsChanged = kFALSE; }
105 virtual void SetDefaultFlag() { fDrawFlags = 0; }
111 virtual Bool_t CheckPads() const { return kTRUE; };
116 Bool_t CanvasExist(Int_t canvasNo = 0) const;
124 Bool_t GetPatterns(TString opt, TString flag, std::vector<double>& vals) const;
135 void ContitionalPattern(TString& option, TString pattern, ULong64_t& drawOpt, Int_t bit, Bool_t remove = kTRUE) const;
139 void LockPad();
143 void UnlockPad();
148 Int_t GetPadsNo(Int_t canvasNo = 0) const { return (*fCommonData.fPads)[canvasNo].size(); }
154 void GotoPad(Int_t no, Int_t canvasNo = 0);
160 void MakeCanvasPads(Int_t x = 1, Int_t y = 1, Int_t canvasNo = 0);
164 void UpdateAllPads();
168 void ClearCanvas(Int_t canvas);
172 virtual void InnerRepaint() {};
176 virtual void InnerPaint() {};
180 virtual void MakePadsAndCanvases() = 0;
184 void CleanCommonData();
185
186 Painter* GetAncestor() const;
187
188 public:
189 Painter();
194 Bool_t HasParent() const;
195 Painter(const Painter& other) = delete;
200 void AddPainter(Painter* painter);
211 virtual void SetOption(TString option);
216 void Paint();
221 Painter* GetParent() const { return fParent; }
222 Painter& operator=(const Painter& other) = delete;
227 TCanvas* GetCanvas(Int_t canvasNo = 0) const { return (*fCommonData.fCanvases)[canvasNo]; }
233 TVirtualPad* GetPad(Int_t index, Int_t canvasNo = 0) const;
234 void SetGlobalPadStyle(Hal::PadStyle& pad);
235 virtual ~Painter();
236 ClassDef(Painter, 0)
237 };
238
239} /* namespace Hal */
240
241#endif /* HAL_FEATURES_HIST_PAINTER_H_ */
virtual void InnerPaint()
Definition Painter.h:176
void SetFlagForced(ULong64_t flag)
Definition Painter.h:57
void CleanCommonData()
Definition Painter.cxx:213
virtual void SetDefaultFlag()
Definition Painter.h:105
Bool_t CanvasExist(Int_t canvasNo=0) const
Definition Painter.cxx:208
TCanvas * GetCanvas(Int_t canvasNo=0) const
Definition Painter.h:227
ULong64_t GetDrawFlags() const
Definition Painter.h:84
void UnlockPad()
Definition Painter.cxx:182
Bool_t OwnGraphic() const
Definition Painter.h:73
void LockPad()
Definition Painter.cxx:180
void SetFlag(Int_t bit, Bool_t state)
Definition Painter.cxx:63
void AddPainter(Painter *painter)
Definition Painter.cxx:34
Bool_t CheckOpt(Int_t opt) const
Definition Painter.h:79
virtual void MakePadsAndCanvases()=0
void ResetFewBits(ULong64_t &flag, std::initializer_list< Int_t > bits, Int_t set=-1) const
Definition Painter.cxx:228
virtual void OptionsApplied()
Definition Painter.h:101
void MakeCanvasPads(Int_t x=1, Int_t y=1, Int_t canvasNo=0)
Definition Painter.cxx:70
Painter * GetParent() const
Definition Painter.h:221
Int_t GetPadsNo(Int_t canvasNo=0) const
Definition Painter.h:148
Bool_t HasParent() const
Definition Painter.cxx:156
virtual Bool_t CheckPads() const
Definition Painter.h:111
virtual void InnerRepaint()
Definition Painter.h:172
void Paint()
Definition Painter.cxx:42
Bool_t fOptionsChanged
Definition Painter.h:68
void ContitionalPattern(TString &option, TString pattern, ULong64_t &drawOpt, Int_t bit, Bool_t remove=kTRUE) const
Definition Painter.cxx:174
virtual void SetOption(TString option)
Definition Painter.cxx:124
virtual ULong64_t SetOptionInternal(TString opt, ULong64_t prev=0)=0
TVirtualPad * GetPad(Int_t index, Int_t canvasNo=0) const
Definition Painter.cxx:196
void GotoPad(Int_t no, Int_t canvasNo=0)
Definition Painter.cxx:187
Bool_t GetPatterns(TString opt, TString flag, std::vector< double > &vals) const
Definition Painter.cxx:161
void ClearCanvas(Int_t canvas)
Definition Painter.cxx:189