Logo ROOT  
Reference Guide
TPavesText.cxx
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Rene Brun 19/11/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include <iostream>
13 #include "TROOT.h"
14 #include "TPavesText.h"
15 #include "TVirtualPad.h"
16 #include "TBufferFile.h"
17 #include "TError.h"
18 
20 
21 
22 /** \class TPavesText
23 \ingroup BasicGraphics
24 
25 A PaveText (see TPaveText) with several stacked paves.
26 
27 \image html graf_pavestext.png
28 */
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// Pavestext default constructor.
32 
34 {
35  fNpaves = 5;
36 }
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Pavestext normal constructor.
40 ///
41 /// The PavesText is by default defined both bordersize=1 and option ="br".
42 /// - option = "T" Top frame
43 /// - option = "B" Bottom frame
44 /// - option = "R" Right frame
45 /// - option = "L" Left frame
46 /// - option = "NDC" x1,y1,x2,y2 are given in NDC
47 /// - option = "ARC" corners are rounded
48 
50  :TPaveText(x1,y1,x2,y2,option)
51 {
52  fNpaves = npaves;
53  SetBorderSize(1);
54 }
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Pavestext default destructor.
58 
60 {
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// Pavestext copy constructor.
65 
67 {
69  TPavesText *p = (TPavesText*)(&pavestext);
70  p->Streamer(b);
71  b.SetReadMode();
72  b.SetBufferOffset(0);
73  Streamer(b);
74 }
75 
76 ////////////////////////////////////////////////////////////////////////////////
77 /// Draw this pavestext with its current attributes.
78 
80 {
81  AppendPad(option);
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Paint this pavestext with its current attributes.
86 
88 {
89  // Draw the fNpaves-1 stacked paves
90  // The spacing between paves is set to 3 times the bordersize
91  Int_t bordersize = GetBorderSize();
92  const char *opt = GetOption();
93  Double_t signx, signy;
94  if (strstr(opt,"l")) signx = -1;
95  else signx = 1;
96  if (strstr(opt,"b")) signy = -1;
97  else signy = 1;
98  Double_t dx = 3*signx*(gPad->PixeltoX(bordersize) - gPad->PixeltoX(0));
99  Double_t dy = 3*signy*(gPad->PixeltoY(bordersize) - gPad->PixeltoY(0));
100 
102 
103  for (Int_t ipave=fNpaves;ipave>1;ipave--) {
104  Double_t x1 = fX1 + dx*Double_t(ipave-1);
105  Double_t y1 = fY1 - dy*Double_t(ipave-1);
106  Double_t x2 = fX2 + dx*Double_t(ipave-1);
107  Double_t y2 = fY2 - dy*Double_t(ipave-1);
108  TPave::PaintPave(x1,y1,x2,y2,bordersize,option);
109  }
110 
111  // Draw the top pavetext
112  TPaveText::Paint(option);
113 }
114 
115 ////////////////////////////////////////////////////////////////////////////////
116 /// Save primitive as a C++ statement(s) on output stream out
117 
118 void TPavesText::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
119 {
120  if (!strcmp(GetName(),"stats")) return;
121  if (!strcmp(GetName(),"title")) return;
122  Bool_t saved = gROOT->ClassSaved(TPavesText::Class());
123  char quote = '"';
124  out<<" "<<std::endl;
125  if (saved) {
126  out<<" ";
127  } else {
128  out<<" TPavesText *";
129  }
130  out<<"pst = new TPavesText("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
131  <<","<<fNpaves<<","<<quote<<fOption<<quote<<");"<<std::endl;
132 
133  if (strcmp(GetName(),"TPave")) {
134  out<<" pst->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
135  }
136  if (fLabel.Length() > 0) {
137  out<<" pst->SetLabel("<<quote<<fLabel<<quote<<");"<<std::endl;
138  }
139  if (fBorderSize != 4) {
140  out<<" pst->SetBorderSize("<<fBorderSize<<");"<<std::endl;
141  }
142  SaveFillAttributes(out,"pst",0,1001);
143  SaveLineAttributes(out,"pst",1,1,1);
144  SaveTextAttributes(out,"pst",22,0,1,62,0);
145  TPaveText::SaveLines(out,"pst",saved);
146  out<<" pst->Draw();"<<std::endl;
147 }
TPave::SetBorderSize
virtual void SetBorderSize(Int_t bordersize=4)
Definition: TPave.h:79
TPavesText::Paint
virtual void Paint(Option_t *option="")
Paint this pavestext with its current attributes.
Definition: TPavesText.cxx:87
TPave::GetBorderSize
Int_t GetBorderSize() const
Definition: TPave.h:60
TPaveText::Paint
virtual void Paint(Option_t *option="")
Paint this pavetext with its current attributes.
Definition: TPaveText.cxx:411
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TPave::ConvertNDCtoPad
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
Definition: TPave.cxx:139
TAttText::SaveTextAttributes
virtual void SaveTextAttributes(std::ostream &out, const char *name, Int_t alidef=12, Float_t angdef=0, Int_t coldef=1, Int_t fondef=61, Float_t sizdef=1)
Save text attributes as C++ statement(s) on output stream out.
Definition: TAttText.cxx:344
TBox::fX2
Double_t fX2
X of 2nd point.
Definition: TBox.h:30
TObject::AppendPad
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:107
TBox::fX1
Double_t fX1
X of 1st point.
Definition: TBox.h:28
TAttLine::SaveLineAttributes
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Definition: TAttLine.cxx:270
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TPavesText::~TPavesText
virtual ~TPavesText()
Pavestext default destructor.
Definition: TPavesText.cxx:59
TAttFill::SaveFillAttributes
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
Definition: TAttFill.cxx:234
TPavesText::TPavesText
TPavesText()
Pavestext default constructor.
Definition: TPavesText.cxx:33
TPavesText::Draw
virtual void Draw(Option_t *option="")
Draw this pavestext with its current attributes.
Definition: TPavesText.cxx:79
b
#define b(i)
Definition: RSha256.hxx:118
bool
x1
static const double x1[5]
Definition: RooGaussKronrodIntegrator1D.cxx:346
TROOT.h
TPavesText
Definition: TPavesText.h:18
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TPaveText::fLabel
TString fLabel
Label written at the top of the pavetext.
Definition: TPaveText.h:24
TPave::GetName
Option_t * GetName() const
Returns name of object.
Definition: TPave.h:62
TVirtualPad.h
TPavesText.h
TBox::fY1
Double_t fY1
Y of 1st point.
Definition: TBox.h:29
TPavesText::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TPavesText.cxx:118
TPave::fBorderSize
Int_t fBorderSize
window box bordersize in pixels
Definition: TPave.h:32
Double_t
double Double_t
Definition: RtypesCore.h:59
TPavesText::fNpaves
Int_t fNpaves
Number of stacked paves.
Definition: TPavesText.h:27
TPave::fOption
TString fOption
Pave style.
Definition: TPave.h:36
TBufferFile.h
TBox::fY2
Double_t fY2
Y of 2nd point.
Definition: TBox.h:31
TPaveText::SaveLines
virtual void SaveLines(std::ostream &out, const char *name, Bool_t saved)
Save lines of this pavetext as C++ statements on output stream out.
Definition: TPaveText.cxx:677
x2
static const double x2[5]
Definition: RooGaussKronrodIntegrator1D.cxx:364
gPad
#define gPad
Definition: TVirtualPad.h:287
TPaveText
Definition: TPaveText.h:21
Class
void Class()
Definition: Class.C:29
TBufferFile
Definition: TBufferFile.h:47
TPave::PaintPave
virtual void PaintPave(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t bordersize=4, Option_t *option="br")
Draw this pave with new coordinates.
Definition: TPave.cxx:312
TBuffer::kWrite
@ kWrite
Definition: TBuffer.h:73
TPave::GetOption
Option_t * GetOption() const
Definition: TPave.h:63
gROOT
#define gROOT
Definition: TROOT.h:406
int
TError.h