Logo ROOT  
Reference Guide
TPaveClass.cxx
Go to the documentation of this file.
1// @(#)root/gpad:$Id$
2// Author: Rene Brun 06/08/99
3/*************************************************************************
4 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#include "TROOT.h"
12#include "Buttons.h"
13#include "TPaveClass.h"
14#include "TClassTree.h"
15
16#include <iostream>
17
19
20
21/** \class TPaveClass
22\ingroup gpad
23
24A TPaveLabel specialized to process classes inside a TClassTree.
25A TPaveClass object is used by the TClassTree to represent a class.
26A TPaveClass has the same graphical representation as a TPaveLabel.
27
28Using the context menu on can select additional options in the ClassTree:
29 - Show classes using this class
30 - Show all classes used by this class
31*/
32
33////////////////////////////////////////////////////////////////////////////////
34/// PaveClass default constructor.
35
37{
38 fClassTree = nullptr;
39}
40
41////////////////////////////////////////////////////////////////////////////////
42/// PaveClass normal constructor.
43
45 :TPaveLabel(x1,y1,x2,y2,label,"br")
46{
47 fClassTree = classtree;
48 SetName(label);
49 SetTextFont(61);
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// PaveClass default destructor.
54
56{
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// PaveClass copy constructor.
61
62TPaveClass::TPaveClass(const TPaveClass &PaveClass) : TPaveLabel(PaveClass)
63{
64 ((TPaveClass&)PaveClass).Copy(*this);
65}
66
67////////////////////////////////////////////////////////////////////////////////
68/// Copy this PaveClass to PaveClass.
69
70void TPaveClass::Copy(TObject &obj) const
71{
73 ((TPaveClass&)obj).fClassTree = fClassTree;
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// Draw classes.
78
79void TPaveClass::DrawClasses(const char *classes)
80{
81 if (!fClassTree) return;
82 if (!strcmp(classes,"this")) fClassTree->Draw(GetName());
83 else fClassTree->Draw(classes);
84}
85
86////////////////////////////////////////////////////////////////////////////////
87/// Save as.
88
89void TPaveClass::SaveAs(const char *filename, Option_t *option) const
90{
91 if (!fClassTree) return;
92 fClassTree->SaveAs(filename,option);
93}
94
95////////////////////////////////////////////////////////////////////////////////
96/// Set classes.
97
98void TPaveClass::SetClasses(const char *classes, Option_t *option)
99{
100 if (!fClassTree) return;
101 if (!strcmp(classes,"this")) fClassTree->SetClasses(GetName(),option);
102 else fClassTree->SetClasses(classes,option);
103}
104
105////////////////////////////////////////////////////////////////////////////////
106/// Set link options in the ClassTree object.
107///
108/// - "C" show References from code
109/// - "H" show "Has a" relations
110/// - "M" show Multiple Inheritance
111/// - "R" show References from data members
112
114{
115 if (!fClassTree) return;
116 fClassTree->ShowLinks(option);
117}
118
119////////////////////////////////////////////////////////////////////////////////
120/// Show classes used by.
121
122void TPaveClass::ShowClassesUsedBy(const char *classes)
123{
124 if (!fClassTree) return;
125 if (!strcmp(classes,"this")) fClassTree->ShowClassesUsedBy(GetName());
126 else fClassTree->ShowClassesUsedBy(classes);
127}
128
129////////////////////////////////////////////////////////////////////////////////
130/// Show classes using.
131
132void TPaveClass::ShowClassesUsing(const char *classes)
133{
134 if (!fClassTree) return;
135 if (!strcmp(classes,"this")) fClassTree->ShowClassesUsing(GetName());
136 else fClassTree->ShowClassesUsing(classes);
137}
138
139////////////////////////////////////////////////////////////////////////////////
140/// Save primitive as a C++ statement(s) on output stream out
141
142void TPaveClass::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
143{
144 char quote = '"';
145 out<<" "<<std::endl;
146 if (gROOT->ClassSaved(TPaveClass::Class())) {
147 out<<" ";
148 } else {
149 out<<" TPaveClass *";
150 }
151 out<<"pclass = new TPaveClass("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
152 <<","<<quote<<fLabel<<quote<<","<<quote<<fOption<<quote<<");"<<std::endl;
153
154 SaveFillAttributes(out,"pclass",0,1001);
155 SaveLineAttributes(out,"pclass",1,1,1);
156 SaveTextAttributes(out,"pclass",22,0,1,62,0);
157
158 out<<" pclass->Draw();"<<std::endl;
159}
void Class()
Definition: Class.C:29
static const double x2[5]
static const double x1[5]
double Double_t
Definition: RtypesCore.h:59
const char Option_t
Definition: RtypesCore.h:66
#define ClassImp(name)
Definition: Rtypes.h:364
#define gROOT
Definition: TROOT.h:404
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:236
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:273
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:45
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:352
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
Draw inheritance tree and their relations for a list of classes.
Definition: TClassTree.h:22
virtual void ShowClassesUsedBy(const char *classes)
mark classes used by the list of classes in classes
Definition: TClassTree.cxx:893
virtual void ShowLinks(Option_t *option="HMR")
Set link options in the ClassTree object.
virtual void SetClasses(const char *classes, Option_t *option="ID")
Set the list of classes for which the hierarchy is to be drawn See Paint for the syntax.
Definition: TClassTree.cxx:859
virtual void SaveAs(const char *filename="", Option_t *option="") const
save current configuration in a Root file if filename is blank, the name of the file will be the curr...
Definition: TClassTree.cxx:683
virtual void Draw(const char *classes="")
Draw the inheritance tree and relations for the list of classes see this class header for the syntax ...
Definition: TClassTree.cxx:261
virtual void ShowClassesUsing(const char *classes)
mark classes using any class in the list of classes in classes
Definition: TClassTree.cxx:924
Mother of all ROOT objects.
Definition: TObject.h:37
A TPaveLabel specialized to process classes inside a TClassTree.
Definition: TPaveClass.h:23
void Copy(TObject &PaveVar) const
Copy this PaveClass to PaveClass.
Definition: TPaveClass.cxx:70
virtual void ShowLinks(Option_t *option="HMR")
Set link options in the ClassTree object.
Definition: TPaveClass.cxx:113
virtual void ShowClassesUsedBy(const char *classes="this")
Show classes used by.
Definition: TPaveClass.cxx:122
virtual void DrawClasses(const char *classes="this")
Draw classes.
Definition: TPaveClass.cxx:79
TPaveClass()
PaveClass default constructor.
Definition: TPaveClass.cxx:36
virtual ~TPaveClass()
PaveClass default destructor.
Definition: TPaveClass.cxx:55
TClassTree * fClassTree
Pointer to the TClassTree referencing this object.
Definition: TPaveClass.h:26
virtual void ShowClassesUsing(const char *classes="this")
Show classes using.
Definition: TPaveClass.cxx:132
virtual void SetClasses(const char *classes="this", Option_t *option="ID")
Set classes.
Definition: TPaveClass.cxx:98
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save as.
Definition: TPaveClass.cxx:89
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TPaveClass.cxx:142
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:20
void Copy(TObject &pavelabel) const
Copy this pavelabel to pavelabel.
Definition: TPaveLabel.cxx:67
TString fLabel
Label written at the center of Pave.
Definition: TPaveLabel.h:23
virtual void SetName(const char *name="")
Definition: TPave.h:75
Option_t * GetName() const
Returns name of object.
Definition: TPave.h:56
TString fOption
Pave style.
Definition: TPave.h:30