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 "TError.h"
17
18
19
20/** \class TPavesText
21\ingroup BasicGraphics
22
23A PaveText (see TPaveText) with several stacked paves.
24
25\image html graf_pavestext.png
26*/
27
28////////////////////////////////////////////////////////////////////////////////
29/// Pavestext default constructor.
30
35
36////////////////////////////////////////////////////////////////////////////////
37/// Pavestext normal constructor.
38///
39/// The PavesText is by default defined both bordersize=1 and option ="br".
40/// - option = "T" Top frame
41/// - option = "B" Bottom frame
42/// - option = "R" Right frame
43/// - option = "L" Left frame
44/// - option = "NDC" x1,y1,x2,y2 are given in NDC
45/// - option = "ARC" corners are rounded
46/// To add a shadow to the TPavesText, use the function TPave::SetBorderSize
47
54
55////////////////////////////////////////////////////////////////////////////////
56/// Pavestext default destructor.
57
61
62////////////////////////////////////////////////////////////////////////////////
63/// Pavestext copy constructor.
64
69
70////////////////////////////////////////////////////////////////////////////////
71/// Draw this pavestext with its current attributes.
72
77
78////////////////////////////////////////////////////////////////////////////////
79/// Paint this pavestext with its current attributes.
80
82{
83 if (!gPad) return;
84 // Draw the fNpaves-1 stacked paves
85 // The spacing between paves is set to 3 times the bordersize
87 const char *opt = GetOption();
89 if (strstr(opt,"l")) signx = -1;
90 else signx = 1;
91 if (strstr(opt,"b")) signy = -1;
92 else signy = 1;
93 Double_t dx = 3*signx*(gPad->PixeltoX(bordersize) - gPad->PixeltoX(0));
94 Double_t dy = 3*signy*(gPad->PixeltoY(bordersize) - gPad->PixeltoY(0));
95
97
98 for (Int_t ipave=fNpaves;ipave>1;ipave--) {
104 }
105
106 // Draw the top pavetext
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Save primitive as a C++ statement(s) on output stream out
112
114{
115 if (!strcmp(GetName(), "stats") || !strcmp(GetName(), "title"))
116 return;
117
119
120 if (strcmp(GetName(), "TPave"))
121 out << " pst->SetName(\"" << GetName() << "\");\n";
122 if (fLabel.Length() > 0)
123 out << " pst->SetLabel(\"" << TString(fLabel).ReplaceSpecialCppChars() << "\");\n";
124 if (fBorderSize != 4)
125 out << " pst->SetBorderSize(" << fBorderSize << ");\n";
126 SaveFillAttributes(out, "pst", -1, -1);
127 SaveLineAttributes(out, "pst", 1, 1, 1);
128 SaveTextAttributes(out, "pst", 22, 0, 1, 62, 0);
129 SaveLines(out, "pst", kTRUE);
130 SavePrimitiveDraw(out, "pst", option);
131}
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 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:240
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:289
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:399
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
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
Definition TObject.cxx:844
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:776
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)
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:56
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
Definition TPave.cxx:138
const char * GetName() const override
Returns name of object.
Definition TPave.h:58
TString GetSavePaveArgs(const char *extra_arg=nullptr, Bool_t save_option=kTRUE)
Returns arguments which should be used when saving primitive constructor Check if coordinates are ini...
Definition TPave.cxx:610
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:79
Option_t * GetOption() const override
Definition TPave.h:59
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:314
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 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.
Basic string class.
Definition TString.h:137
Ssiz_t Length() const
Definition TString.h:426
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460