Logo ROOT   6.08/07
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-2000, 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 "Riostream.h"
12 #include "TROOT.h"
13 #include "Buttons.h"
14 #include "TPaveClass.h"
15 
17 
18 
19 /** \class TPaveClass
20 \ingroup gpad
21 
22 A TPaveLabel specialized to process classes inside a TClassTree.
23 A TPaveClass object is used by the TClassTree to represent a class.
24 A TPaveClass has the same graphical representation as a TPaveLabel.
25 
26 Using the context menu on can select additional options in the ClassTree:
27  - Show classes using this class
28  - Show all classes used by this class
29 */
30 
31 ////////////////////////////////////////////////////////////////////////////////
32 /// PaveClass default constructor.
33 
35 {
36  fClassTree = 0;
37 }
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// PaveClass normal constructor.
41 
42 TPaveClass::TPaveClass(Double_t x1, Double_t y1,Double_t x2, Double_t y2, const char *label, TClassTree *classtree)
43  :TPaveLabel(x1,y1,x2,y2,label,"br")
44 {
45  fClassTree = classtree;
46  SetName(label);
47  SetTextFont(61);
48 }
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// PaveClass default destructor.
52 
54 {
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// PaveClass copy constructor.
59 
60 TPaveClass::TPaveClass(const TPaveClass &PaveClass) : TPaveLabel(PaveClass)
61 {
62  ((TPaveClass&)PaveClass).Copy(*this);
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 /// Copy this PaveClass to PaveClass.
67 
68 void TPaveClass::Copy(TObject &obj) const
69 {
70  TPaveLabel::Copy(obj);
71  ((TPaveClass&)obj).fClassTree = fClassTree;
72 }
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Draw classes.
76 
77 void TPaveClass::DrawClasses(const char *classes)
78 {
79  if (!fClassTree) return;
80  if (!strcmp(classes,"this")) fClassTree->Draw(GetName());
81  else fClassTree->Draw(classes);
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// Save as.
86 
87 void TPaveClass::SaveAs(const char *filename, Option_t *option) const
88 {
89  if (!fClassTree) return;
90  fClassTree->SaveAs(filename,option);
91 }
92 
93 ////////////////////////////////////////////////////////////////////////////////
94 /// Set classes.
95 
96 void TPaveClass::SetClasses(const char *classes, Option_t *option)
97 {
98  if (!fClassTree) return;
99  if (!strcmp(classes,"this")) fClassTree->SetClasses(GetName(),option);
100  else fClassTree->SetClasses(classes,option);
101 }
102 
103 ////////////////////////////////////////////////////////////////////////////////
104 /// Set link options in the ClassTree object.
105 ///
106 /// - "C" show References from code
107 /// - "H" show "Has a" relations
108 /// - "M" show Multiple Inheritance
109 /// - "R" show References from data members
110 
112 {
113  if (!fClassTree) return;
114  fClassTree->ShowLinks(option);
115 }
116 
117 ////////////////////////////////////////////////////////////////////////////////
118 /// Show classes used by.
119 
120 void TPaveClass::ShowClassesUsedBy(const char *classes)
121 {
122  if (!fClassTree) return;
123  if (!strcmp(classes,"this")) fClassTree->ShowClassesUsedBy(GetName());
124  else fClassTree->ShowClassesUsedBy(classes);
125 }
126 
127 ////////////////////////////////////////////////////////////////////////////////
128 /// Show classes using.
129 
130 void TPaveClass::ShowClassesUsing(const char *classes)
131 {
132  if (!fClassTree) return;
133  if (!strcmp(classes,"this")) fClassTree->ShowClassesUsing(GetName());
134  else fClassTree->ShowClassesUsing(classes);
135 }
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Save primitive as a C++ statement(s) on output stream out
139 
140 void TPaveClass::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
141 {
142  char quote = '"';
143  out<<" "<<std::endl;
144  if (gROOT->ClassSaved(TPaveClass::Class())) {
145  out<<" ";
146  } else {
147  out<<" TPaveClass *";
148  }
149  out<<"pclass = new TPaveClass("<<fX1<<","<<fY1<<","<<fX2<<","<<fY2
150  <<","<<quote<<fLabel<<quote<<","<<quote<<fOption<<quote<<");"<<std::endl;
151 
152  SaveFillAttributes(out,"pclass",0,1001);
153  SaveLineAttributes(out,"pclass",1,1,1);
154  SaveTextAttributes(out,"pclass",22,0,1,62,0);
155 
156  out<<" pclass->Draw();"<<std::endl;
157 }
void Copy(TObject &pavelabel) const
Copy this pavelabel to pavelabel.
Definition: TPaveLabel.cxx:67
A TPaveLabel specialized to process classes inside a TClassTree.
Definition: TPaveClass.h:23
TPaveClass()
PaveClass default constructor.
Definition: TPaveClass.cxx:34
virtual void SetName(const char *name="")
Definition: TPave.h:76
TClassTree * fClassTree
Pointer to the TClassTree referencing this object.
Definition: TPaveClass.h:26
virtual ~TPaveClass()
PaveClass default destructor.
Definition: TPaveClass.cxx:53
const char Option_t
Definition: RtypesCore.h:62
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:865
Double_t fY2
Y of 2nd point.
Definition: TBox.h:45
virtual void ShowClassesUsing(const char *classes)
mark classes using any class in the list of classes in classes
Definition: TClassTree.cxx:930
#define gROOT
Definition: TROOT.h:364
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:690
const char * Class
Definition: TXMLSetup.cxx:64
virtual void ShowClassesUsedBy(const char *classes)
mark classes used by the list of classes in classes
Definition: TClassTree.cxx:899
virtual void ShowLinks(Option_t *option="HMR")
Set link options in the ClassTree object.
TString fLabel
Label written at the center of Pave.
Definition: TPaveLabel.h:27
Double_t fY1
Y of 1st point.
Definition: TBox.h:43
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
Definition: TAttText.h:51
static const double x2[5]
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:260
virtual void ShowClassesUsing(const char *classes="this")
Show classes using.
Definition: TPaveClass.cxx:130
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:24
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:347
Double_t fX2
X of 2nd point.
Definition: TBox.h:44
virtual void SetClasses(const char *classes="this", Option_t *option="ID")
Set classes.
Definition: TPaveClass.cxx:96
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:232
Double_t fX1
X of 1st point.
Definition: TBox.h:42
Option_t * GetName() const
Returns name of object.
Definition: TPave.h:57
static const double x1[5]
#define ClassImp(name)
Definition: Rtypes.h:279
virtual void DrawClasses(const char *classes="this")
Draw classes.
Definition: TPaveClass.cxx:77
double Double_t
Definition: RtypesCore.h:55
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:268
void Copy(TObject &PaveVar) const
Copy this PaveClass to PaveClass.
Definition: TPaveClass.cxx:68
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save as.
Definition: TPaveClass.cxx:87
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: TPaveClass.cxx:140
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void ShowLinks(Option_t *option="HMR")
Set link options in the ClassTree object.
Definition: TPaveClass.cxx:111
virtual void ShowClassesUsedBy(const char *classes="this")
Show classes used by.
Definition: TPaveClass.cxx:120
TString fOption
Pave style.
Definition: TPave.h:34
Draw inheritance tree and their relations for a list of classes.
Definition: TClassTree.h:23