Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
16 ClassImp(TPaveClass);
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 
34 TPaveClass::TPaveClass(): TPaveLabel()
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 
53 TPaveClass::~TPaveClass()
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 
111 void TPaveClass::ShowLinks(Option_t *option)
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 }