Logo ROOT  
Reference Guide
TDrawFeedback.cxx
Go to the documentation of this file.
1 // @(#)root/proofplayer:$Id$
2 // Author: Maarten Ballintijn 28/10/2003
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 /** \class TDrawFeedback
13 \ingroup proofkernel
14 
15 Utility class to draw objects in the feedback list during queries.
16 Draws histograms in separated canvases and user-defined objects via
17 Draw(). Users requiring advanced treatment should implement their
18 own version following this example. See also TStatsFeedback.
19 
20 */
21 
22 #include "TDrawFeedback.h"
23 
24 #include "THashList.h"
25 #include "TObjString.h"
26 #include "TProof.h"
27 #include "TROOT.h"
28 #include "TH1.h"
29 #include "TH2.h"
30 #include "TError.h"
31 #include "TSeqCollection.h"
32 #include "TVirtualPad.h"
33 #include "TProofDebug.h"
34 
36 
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Constructor
40 
42  : fAll(kFALSE)
43 {
44  fNames = new THashList;
45  fNames->SetOwner();
46 
47  if (proof == 0) proof = gProof;
48 
49  TProof *p = dynamic_cast<TProof*>(proof);
50  if (p == 0) {
51  Error("TDrawFeedback","no valid proof session found");
52  return;
53  }
54  fProof = p;
56 
57  Bool_t ok = proof->Connect("Feedback(TList*)", "TDrawFeedback",
58  this, "Feedback(TList*)");
59 
60  if ( !ok ) {
61  Error("TDrawFeedback","Connect() failed");
62  return;
63  }
64 
65  if (names != 0) {
66  TIter next(names);
68  while((name = dynamic_cast<TObjString*>(next())) != 0) {
69  fNames->Add(new TNamed(name->GetName(),""));
70  }
71  } else {
72  fAll = kTRUE;
73  }
74  fOption = 0;
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Destructor
79 
81 {
82  delete fNames;
83 
84  // Required since we overload TObject::Hash.
86 
87  fProof->Disconnect("Feedback(TList*)", this, "Feedback(TList*");
88 }
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 /// Display feedback
92 
94 {
95  TSeqCollection *canvases = gROOT->GetListOfCanvases();
96  TVirtualPad *save = gPad;
97 
98  PDB(kFeedback,1) Info("Feedback","%d Objects", objs->GetSize());
99 
100  TIter next(objs);
101  TObject *o;
102  while( (o = next()) )
103  {
104  TString name = o->GetName();
105  if (fAll || fNames->FindObject(name.Data())) {
106 
107  if (TH1 *h = dynamic_cast<TH1*>(o)) {
108 
109  // Basic service provided fro histograms, each one drawn in
110  // a separate canvas named '<histogram_name>_canvas'
111 
112  name += "_canvas";
113 
114  TVirtualPad *p = (TVirtualPad*) canvases->FindObject(name.Data());
115 
116  if ( p == 0 ) {
117  gROOT->MakeDefCanvas();
118  gPad->SetName(name);
119  PDB(kFeedback,2) Info("Feedback","Created canvas %s", name.Data());
120  } else {
121  p->cd();
122  PDB(kFeedback,2) Info("Feedback","Used canvas %s", name.Data());
123  }
124 
125  h->DrawCopy(fOption);
126  gPad->Update();
127 
128  } else {
129 
130  // Call the Draw method of the object; this is intended for user-defined
131  // objects handling their canvas needs inside Draw() as needed
132  o->Draw();
133  }
134 
135  }
136  }
137 
138  if (save != 0) {
139  save->cd();
140  } else {
141  gPad = 0;
142  }
143 }
TQObject::Disconnect
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1022
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
PDB
#define PDB(mask, level)
Definition: TProofDebug.h:56
gProof
R__EXTERN TProof * gProof
Definition: TProof.h:1077
TProofDebug.h
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TObjString.h
TDrawFeedback::fOption
Option_t * fOption
Definition: TDrawFeedback.h:42
TObject::Info
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:864
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TCollection::SetOwner
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Definition: TCollection.cxx:746
TVirtualPad::cd
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
TDrawFeedback::~TDrawFeedback
~TDrawFeedback()
Destructor.
Definition: TDrawFeedback.cxx:80
TDrawFeedback::fName
TString fName
Definition: TDrawFeedback.h:37
TDrawFeedback::fAll
Bool_t fAll
Definition: TDrawFeedback.h:38
TString
Definition: TString.h:136
TDrawFeedback::Feedback
void Feedback(TList *objs)
Display feedback.
Definition: TDrawFeedback.cxx:93
bool
TROOT.h
TObjString
Definition: TObjString.h:28
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
TDrawFeedback::TDrawFeedback
TDrawFeedback(TProof *proof=0, TSeqCollection *names=0)
Constructor.
Definition: TDrawFeedback.cxx:41
TSeqCollection.h
TDrawFeedback::fNames
THashList * fNames
Definition: TDrawFeedback.h:39
THashList
Definition: THashList.h:34
h
#define h(i)
Definition: RSha256.hxx:124
TDrawFeedback::fProof
TProof * fProof
Definition: TDrawFeedback.h:43
THashList::FindObject
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
TNamed
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TProof.h
TProof::GetSessionTag
const char * GetSessionTag() const
Definition: TProof.h:909
TVirtualPad.h
TH2.h
TDrawFeedback.h
THashList.h
TSeqCollection
Definition: TSeqCollection.h:28
TObject::Draw
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:197
TQObject::Connect
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:864
TVirtualPad
Definition: TVirtualPad.h:50
TCollection::GetSize
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TObject
Definition: TObject.h:37
TH1
Definition: TH1.h:57
name
char name[80]
Definition: TGX11.cxx:110
gPad
#define gPad
Definition: TVirtualPad.h:287
TIter
Definition: TCollection.h:233
TProof
Definition: TProof.h:316
ROOT::CallRecursiveRemoveIfNeeded
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition: TROOT.h:395
TCollection::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Definition: TCollection.cxx:312
TH1.h
TDrawFeedback
Definition: TDrawFeedback.h:35
TList
Definition: TList.h:44
gROOT
#define gROOT
Definition: TROOT.h:406
TError.h