forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TPavesText.cxx
154 lines (124 loc) · 4.52 KB
/
TPavesText.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// @(#)root/graf:$Id$
// Author: Rene Brun 19/11/95
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "Riostream.h"
#include "TROOT.h"
#include "TPavesText.h"
#include "TVirtualPad.h"
#include "TBufferFile.h"
#include "TError.h"
ClassImp(TPavesText)
//______________________________________________________________________________
// A PavesText is a PaveText (see TPaveText) with several stacked paves.
//Begin_Html
/*
<img src="gif/pavestext.gif">
*/
//End_Html
//
////////////////////////////////////////////////////////////////////////////////
/// Pavestext default constructor.
TPavesText::TPavesText(): TPaveText()
{
fNpaves = 5;
}
////////////////////////////////////////////////////////////////////////////////
/// Pavestext normal constructor.
///
/// The PavesText is by default defined bith bordersize=1 and option ="br".
/// option = "T" Top frame
/// option = "B" Bottom frame
/// option = "R" Right frame
/// option = "L" Left frame
/// option = "NDC" x1,y1,x2,y2 are given in NDC
/// option = "ARC" corners are rounded
TPavesText::TPavesText(Double_t x1, Double_t y1,Double_t x2, Double_t y2, Int_t npaves,Option_t *option)
:TPaveText(x1,y1,x2,y2,option)
{
fNpaves = npaves;
SetBorderSize(1);
}
////////////////////////////////////////////////////////////////////////////////
/// Pavestext default destructor.
TPavesText::~TPavesText()
{
}
////////////////////////////////////////////////////////////////////////////////
/// Pavestext copy constructor.
TPavesText::TPavesText(const TPavesText &pavestext) : TPaveText()
{
TBufferFile b(TBuffer::kWrite);
TPavesText *p = (TPavesText*)(&pavestext);
p->Streamer(b);
b.SetReadMode();
b.SetBufferOffset(0);
Streamer(b);
}
////////////////////////////////////////////////////////////////////////////////
/// Draw this pavestext with its current attributes.
void TPavesText::Draw(Option_t *option)
{
AppendPad(option);
}
////////////////////////////////////////////////////////////////////////////////
/// Paint this pavestext with its current attributes.
void TPavesText::Paint(Option_t *option)
{
// Draw the fNpaves-1 stacked paves
// The spacing between paves is set to 3 times the bordersize
Int_t bordersize = GetBorderSize();
const char *opt = GetOption();
Double_t signx, signy;
if (strstr(opt,"l")) signx = -1;
else signx = 1;
if (strstr(opt,"b")) signy = -1;
else signy = 1;
Double_t dx = 3*signx*(gPad->PixeltoX(bordersize) - gPad->PixeltoX(0));
Double_t dy = 3*signy*(gPad->PixeltoY(bordersize) - gPad->PixeltoY(0));
TPave::ConvertNDCtoPad();
for (Int_t ipave=fNpaves;ipave>1;ipave--) {
Double_t x1 = fX1 + dx*Double_t(ipave-1);
Double_t y1 = fY1 - dy*Double_t(ipave-1);
Double_t x2 = fX2 + dx*Double_t(ipave-1);
Double_t y2 = fY2 - dy*Double_t(ipave-1);
TPave::PaintPave(x1,y1,x2,y2,bordersize,option);
}
// Draw the top pavetext
TPaveText::Paint(option);
}
////////////////////////////////////////////////////////////////////////////////
/// Save primitive as a C++ statement(s) on output stream out
void TPavesText::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
{
if (!strcmp(GetName(),"stats")) return;
if (!strcmp(GetName(),"title")) return;
char quote = '"';
out<<" "<<std::endl;
if (gROOT->ClassSaved(TPavesText::Class())) {
out<<" ";
} else {
out<<" TPavesText *";
}
out<<"pst = new TPavesText("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
<<","<<fNpaves<<","<<quote<<fOption<<quote<<");"<<std::endl;
if (strcmp(GetName(),"TPave")) {
out<<" pst->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
}
if (fLabel.Length() > 0) {
out<<" pst->SetLabel("<<quote<<fLabel<<quote<<");"<<std::endl;
}
if (fBorderSize != 4) {
out<<" pst->SetBorderSize("<<fBorderSize<<");"<<std::endl;
}
SaveFillAttributes(out,"pst",0,1001);
SaveLineAttributes(out,"pst",1,1,1);
SaveTextAttributes(out,"pst",22,0,1,62,0);
TPaveText::SaveLines(out,"pst");
out<<" pst->Draw();"<<std::endl;
}