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
15Utility class to draw objects in the feedback list during queries.
16Draws histograms in separated canvases and user-defined objects via
17Draw(). Users requiring advanced treatment should implement their
18own 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;
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}
#define h(i)
Definition: RSha256.hxx:106
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
#define PDB(mask, level)
Definition: TProofDebug.h:56
R__EXTERN TProof * gProof
Definition: TProof.h:1077
#define gROOT
Definition: TROOT.h:415
#define gPad
Definition: TVirtualPad.h:286
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
Utility class to draw objects in the feedback list during queries.
Definition: TDrawFeedback.h:35
void Feedback(TList *objs)
Display feedback.
~TDrawFeedback()
Destructor.
THashList * fNames
Definition: TDrawFeedback.h:39
TProof * fProof
Definition: TDrawFeedback.h:43
Option_t * fOption
Definition: TDrawFeedback.h:42
TDrawFeedback(TProof *proof=0, TSeqCollection *names=0)
Constructor.
The TH1 histogram class.
Definition: TH1.h:56
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
A doubly linked list.
Definition: TList.h:44
virtual void Add(TObject *obj)
Definition: TList.h:87
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Collectable string class.
Definition: TObjString.h:28
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:316
const char * GetSessionTag() const
Definition: TProof.h:909
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:867
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:1025
Sequenceable collection abstract base class.
Basic string class.
Definition: TString.h:131
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:50
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition: TROOT.h:404