Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
25A 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/// To add a shadow to the TPavesText, use the function TPave::SetBorderSize
49
52{
53 fNpaves = npaves;
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// Pavestext default destructor.
59
61{
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Pavestext copy constructor.
66
68{
70 TPavesText *p = (TPavesText*)(&pavestext);
71 p->Streamer(b);
72 b.SetReadMode();
73 b.SetBufferOffset(0);
74 Streamer(b);
75}
76
77////////////////////////////////////////////////////////////////////////////////
78/// Draw this pavestext with its current attributes.
79
81{
83}
84
85////////////////////////////////////////////////////////////////////////////////
86/// Paint this pavestext with its current attributes.
87
89{
90 if (!gPad) return;
91 // Draw the fNpaves-1 stacked paves
92 // The spacing between paves is set to 3 times the bordersize
93 Int_t bordersize = GetBorderSize();
94 const char *opt = GetOption();
95 Double_t signx, signy;
96 if (strstr(opt,"l")) signx = -1;
97 else signx = 1;
98 if (strstr(opt,"b")) signy = -1;
99 else signy = 1;
100 Double_t dx = 3*signx*(gPad->PixeltoX(bordersize) - gPad->PixeltoX(0));
101 Double_t dy = 3*signy*(gPad->PixeltoY(bordersize) - gPad->PixeltoY(0));
102
104
105 for (Int_t ipave=fNpaves;ipave>1;ipave--) {
106 Double_t x1 = fX1 + dx*Double_t(ipave-1);
107 Double_t y1 = fY1 - dy*Double_t(ipave-1);
108 Double_t x2 = fX2 + dx*Double_t(ipave-1);
109 Double_t y2 = fY2 - dy*Double_t(ipave-1);
110 TPave::PaintPave(x1,y1,x2,y2,bordersize,option);
111 }
112
113 // Draw the top pavetext
115}
116
117////////////////////////////////////////////////////////////////////////////////
118/// Save primitive as a C++ statement(s) on output stream out
119
120void TPavesText::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
121{
122 if (!strcmp(GetName(),"stats")) return;
123 if (!strcmp(GetName(),"title")) return;
124 Bool_t saved = gROOT->ClassSaved(TPavesText::Class());
125 char quote = '"';
126 out<<" "<<std::endl;
127 if (saved) {
128 out<<" ";
129 } else {
130 out<<" TPavesText *";
131 }
132 out<<"pst = new TPavesText("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
133 <<","<<fNpaves<<","<<quote<<fOption<<quote<<");"<<std::endl;
134
135 if (strcmp(GetName(),"TPave")) {
136 out<<" pst->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
137 }
138 if (fLabel.Length() > 0) {
139 out<<" pst->SetLabel("<<quote<<fLabel<<quote<<");"<<std::endl;
140 }
141 if (fBorderSize != 4) {
142 out<<" pst->SetBorderSize("<<fBorderSize<<");"<<std::endl;
143 }
144 SaveFillAttributes(out,"pst",0,1001);
145 SaveLineAttributes(out,"pst",1,1,1);
146 SaveTextAttributes(out,"pst",22,0,1,62,0);
147 TPaveText::SaveLines(out,"pst",saved);
148 out<<" pst->Draw();"<<std::endl;
149}
#define b(i)
Definition RSha256.hxx:100
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
#define gROOT
Definition TROOT.h:406
#define gPad
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:239
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:275
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:373
Double_t fX1
X of 1st point.
Definition TBox.h:28
Double_t fY2
Y of 2nd point.
Definition TBox.h:31
Double_t fX2
X of 2nd point.
Definition TBox.h:30
Double_t fY1
Y of 1st point.
Definition TBox.h:29
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition TBufferFile.h:47
@ kWrite
Definition TBuffer.h:73
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:202
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
virtual void SaveLines(std::ostream &out, const char *name, Bool_t saved)
Save lines of this pavetext as C++ statements on output stream out.
void Paint(Option_t *option="") override
Paint this pavetext with its current attributes.
TString fLabel
Label written at the top of the pavetext.
Definition TPaveText.h:24
Int_t GetBorderSize() const
Definition TPave.h:54
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
Definition TPave.cxx:139
const char * GetName() const override
Returns name of object.
Definition TPave.h:56
Int_t fBorderSize
window box bordersize in pixels
Definition TPave.h:26
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
Definition TPave.h:77
TString fOption
Pave style.
Definition TPave.h:30
Option_t * GetOption() const override
Definition TPave.h:57
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:315
A PaveText (see TPaveText) with several stacked paves.
Definition TPavesText.h:18
static TClass * Class()
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void Paint(Option_t *option="") override
Paint this pavestext with its current attributes.
~TPavesText() override
Pavestext default destructor.
void Streamer(TBuffer &) override
Stream an object of class TPave.
void Draw(Option_t *option="") override
Draw this pavestext with its current attributes.
Int_t fNpaves
Number of stacked paves.
Definition TPavesText.h:21
TPavesText()
Pavestext default constructor.
Ssiz_t Length() const
Definition TString.h:417
void Streamer(TBuffer &) override
Stream an object of class TObject.