GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4LabelPainter.h
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #ifndef TGO4LABELPAINTER_H
15 #define TGO4LABELPAINTER_H
16 
17 #include "TPaveText.h"
18 #include "TLine.h"
19 
27 class TGo4Label : public TPaveText {
28 
29 public:
30  TGo4Label() : TPaveText(), fxOwner(nullptr) { SetBit(kMustCleanup); /*SetBit(kCanDelete,kFALSE);*/ }
31 
32  TGo4Label(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option = "br")
33  : TPaveText(x1, y1, x2, y2, option), fxOwner(nullptr)
34  {
35  SetBit(kMustCleanup); /*SetBit(kCanDelete,kFALSE);*/
36  }
37 
38  virtual ~TGo4Label() { fxLastDeleted = this; }
39 
40  void SetOwner(TObject *ob) { fxOwner = ob; }
41 
42  void Paint(Option_t *opt = "") override;
43 
44  void ExecuteEvent(Int_t event, Int_t px, Int_t py) override;
45 
47  static const void *fxLastDeleted;
48 
49 private:
51  TObject *fxOwner{nullptr};
52 
53  ClassDefOverride(TGo4Label, 7)
54 };
55 
63 class TGo4LabelConnector : public TLine {
64 
65 public:
66  TGo4LabelConnector() : TLine(), fxOwner(nullptr) { SetBit(kMustCleanup); }
67 
68  TGo4LabelConnector(Double_t x1, Double_t y1, Double_t x2, Double_t y2) : TLine(x1, y1, x2, y2), fxOwner(nullptr)
69  {
70  SetBit(kMustCleanup);
71  }
72 
73  virtual ~TGo4LabelConnector() { fxLastDeleted = this; };
74 
75  void SetOwner(TObject *ob) { fxOwner = ob; }
76 
77  void Paint(Option_t *opt = "") override;
78 
80  static const void *fxLastDeleted;
81 
82 private:
84  TObject *fxOwner{nullptr};
85 
86  ClassDefOverride(TGo4LabelConnector, 6)
87 };
88 
97 class TGo4LabelPainter : public TNamed, public TAttLine, public TAttFill, public TAttText {
98  public:
100  TGo4LabelPainter(const char *name, const char *title = nullptr);
101  virtual ~TGo4LabelPainter();
102 
104  virtual void PaintLabel(Option_t *opt = "");
105 
107  virtual void UnPaintLabel(Option_t *opt = "");
108 
110  virtual void RePaintLabel(Option_t *opt = "");
111 
113  virtual void DisplayToFront(Option_t *opt = "");
114 
115  void SetCaption(const char *txt) { fxCaption=txt; }
116  void SetX0(Double_t x = 0.) { fdX0 = x; }
117  void SetY0(Double_t y = 0.) { fdY0 = y; }
118  void SetWidth(Double_t w = 0.) { fdWidth = w; }
119  void SetHeight(Double_t h = 0.) { fdHeight = h; }
120 
121  void AddToLabel(const char *txt) { if(fxLabel) fxLabel->AddText(txt); }
122 
124  void InitAttributes();
125 
127  Double_t GetLabelXlo();
128 
130  Double_t GetLabelYlo();
131 
133  Double_t GetLabelXup();
134 
136  Double_t GetLabelYup();
137 
138  private:
140  TGo4Label* fxLabel{nullptr};
141 
143  Double_t fdX0{0};
144 
146  Double_t fdY0{0};
147 
149  Double_t fdWidth{0};
150 
152  Double_t fdHeight{0};
153 
155  TString fxCaption;
156 
158  Bool_t fbIsLabStreamed{kFALSE};
159 
161  TGo4Label* CreateCurrentLabel(Double_t x, Double_t y);
162 
164  void LabelCoords(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax);
165 
167  Bool_t CheckLabel();
168 
169  ClassDefOverride(TGo4LabelPainter,6)
170 };
171 
172 #endif //TGO4LABELPAINTER_H
static const void * fxLastDeleted
virtual ~TGo4LabelConnector()
TGo4LabelConnector(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
TObject * fxOwner
TGo4Label(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Option_t *option="br")
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
void Paint(Option_t *opt="") override
void SetWidth(Double_t w=0.)
virtual ~TGo4Label()
static const void * fxLastDeleted
void SetCaption(const char *txt)
void SetOwner(TObject *ob)
void SetY0(Double_t y=0.)
void SetOwner(TObject *ob)
void SetX0(Double_t x=0.)
void SetHeight(Double_t h=0.)
void AddToLabel(const char *txt)