BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
BesPaveText.cxx
Go to the documentation of this file.
1
2#include <TPad.h>
3#include "BesVisLib/BesPaveText.h"
4#include <iostream>
5
6using namespace std;
7
8#ifndef __CINT__
10#endif
11
12//______________________________________________________________________________
13BesPaveText::BesPaveText(): TPaveText()
14{
15}
16
17//______________________________________________________________________________
18BesPaveText::BesPaveText(Double_t x1, Double_t y1,Double_t x2, Double_t y2, Option_t *option)
19 :TPaveText(x1,y1,x2,y2,option)
20{
21 SetFillColor(1001);
22 SetBorderSize(1);
23 SetCornerRadius(0.2);
24
25 fTextSize = 0.025;
26}
27
28//______________________________________________________________________________
29BesPaveText::BesPaveText(const BesPaveText &pavetext) : TPaveText()
30{
31
32}
33
34//______________________________________________________________________________
35void BesPaveText::SetText(vector<TString> infoCon)
36{
37 Int_t n = infoCon.size();
38 Double_t margin = GetMargin();
39 Double_t dy = (1.0-margin*2)/n;
40
41 Double_t coordx = 0.0;
42 Double_t coordy = 0.0;
43 for (Int_t i = 0; i < n; i++) {
44 coordy = 1.0 - (i+1)*dy;
45 if (n == 1) coordy = 1.0;
46
47 TText* tdata = AddText(coordx, coordy, infoCon[i].Data());
48 tdata->SetTextSize(fTextSize/1.2);
49 tdata->SetTextFont(42);
50 if (i == 0 && n > 4) {
51 tdata->SetTextSize(fTextSize);
52 tdata->SetTextFont(62);
53 }
54 tdata->SetTextColor(1);
55 tdata->SetTextAlign(12);
56
57 if (infoCon[i] == TString("Fired")) {
58 tdata->SetTextColor(kRed);
59 //tdata->SetTextSize(fTextSize);
60 tdata->SetTextFont(72);
61 }
62 }
63
64 fdxNDC = fTextSize * fLongest / 2.2;
65 fdyNDC = fTextSize * n * 1.2; //fLines->GetSize() * 1.2;
66
67 ConvertNDCtoPad();
68 // This is necessary, or when fTip was drawn the first time, it will in center, as its fX1 fX2 fY1 fY2 have not been changed.
69 SetX1NDC(0.0);
70 SetY1NDC(0.0);
71 SetX2NDC(fdxNDC);
72 SetY2NDC(fdyNDC);
73}
74
75//______________________________________________________________________________
76void BesPaveText::SetPos(Int_t px, Int_t py)
77{
78 if (!gPad) {
79 cout << "BesPaveText::SetPos, gPad does not exist" << endl;
80 return;
81 }
82
83 Double_t x = gPad->AbsPixeltoX(px+10);
84 Double_t y = gPad->AbsPixeltoY(py-10);
85 Double_t x1, y1, x2, y2, xNDC, yNDC;
86 gPad->GetRange(x1, y1, x2, y2);
87 xNDC = (x-x1)/(x2-x1);
88 yNDC = (y-y1)/(y2-y1);
89 //cout << xNDC << " " << yNDC << endl;
90
91 x1 = xNDC;
92 y1 = yNDC;
93 x2 = xNDC + fdxNDC;
94 y2 = yNDC + fdyNDC;
95
96 Double_t delta = 0.02;
97 if (x2 > 1.0 && y2 > 1.0) {
98 x1 -= (fdxNDC+delta);
99 x2 -= (fdxNDC+delta);
100 y1 -= (fdyNDC+delta);
101 y2 -= (fdyNDC+delta);
102 }
103 else if (x2 > 1.0) {
104 x1 -= fdxNDC;
105 x2 -= fdxNDC;
106 }
107 if (y2 > 1.0) {
108 y1 -= fdyNDC;
109 y2 -= fdyNDC;
110 }
111
112 SetX1NDC(x1);
113 SetY1NDC(y1);
114 SetX2NDC(x2);
115 SetY2NDC(y2);
116 ConvertNDCtoPad();
117}
ClassImp(BesPaveText) BesPaveText
Definition: BesPaveText.cxx:9
const Int_t n
Double_t x[10]
virtual void SetText(std::vector< TString > infoCon)
virtual void SetPos(Int_t px, Int_t py)
Definition: BesPaveText.cxx:76