ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
55  fName = fProof->GetSessionTag();
56 
57  Bool_t ok = proof->Connect("Feedback(TList *objs)", "TDrawFeedback",
58  this, "Feedback(TList *objs)");
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  fProof->Disconnect("Feedback(TList*)", this, "Feedback(TList*");
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// Display feedback
88 
90 {
91  TSeqCollection *canvases = gROOT->GetListOfCanvases();
92  TVirtualPad *save = gPad;
93 
94  PDB(kFeedback,1) Info("Feedback","%d Objects", objs->GetSize());
95 
96  TIter next(objs);
97  TObject *o;
98  while( (o = next()) )
99  {
100  TString name = o->GetName();
101  if (fAll || fNames->FindObject(name.Data())) {
102 
103  if (TH1 *h = dynamic_cast<TH1*>(o)) {
104 
105  // Basic service provided fro histograms, each one drawn in
106  // a separate canvas named '<histogram_name>_canvas'
107 
108  name += "_canvas";
109 
110  TVirtualPad *p = (TVirtualPad*) canvases->FindObject(name.Data());
111 
112  if ( p == 0 ) {
113  gROOT->MakeDefCanvas();
114  gPad->SetName(name);
115  PDB(kFeedback,2) Info("Feedback","Created canvas %s", name.Data());
116  } else {
117  p->cd();
118  PDB(kFeedback,2) Info("Feedback","Used canvas %s", name.Data());
119  }
120 
121  h->DrawCopy(fOption);
122  gPad->Update();
123 
124  } else {
125 
126  // Call the Draw method of the object; this is intended for user-defined
127  // objects handling their canvas needs inside Draw() as needed
128  o->Draw();
129  }
130 
131  }
132  }
133 
134  if (save != 0) {
135  save->cd();
136  } else {
137  gPad = 0;
138  }
139 }
const char * GetName() const
Returns name of object.
Definition: TObjString.h:42
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Collectable string class.
Definition: TObjString.h:32
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:213
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TH1 * h
Definition: legend2.C:5
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
THashList * fNames
Definition: TDrawFeedback.h:43
#define gROOT
Definition: TROOT.h:344
Basic string class.
Definition: TString.h:137
const char * GetSessionTag() const
Definition: TProof.h:945
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:254
void Feedback(TList *objs)
Display feedback.
ClassImp(TDrawFeedback) TDrawFeedback
Constructor.
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
const char * Data() const
Definition: TString.h:349
Sequenceable collection abstract base class.
#define PDB(mask, level)
Definition: TProofDebug.h:58
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TProof * fProof
Definition: TDrawFeedback.h:47
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
Definition: TH1.cxx:2925
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
void Error(const char *location, const char *msgfmt,...)
A doubly linked list.
Definition: TList.h:47
Option_t * fOption
Definition: TDrawFeedback.h:46
R__EXTERN TProof * gProof
Definition: TProof.h:1113
virtual Int_t GetSize() const
Definition: TCollection.h:95
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
This class controls a Parallel ROOT Facility, PROOF, cluster.
Definition: TProof.h:342
The TH1 histogram class.
Definition: TH1.h:80
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:1293
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
const char Int_t const char TProof * proof
Definition: TXSlave.cxx:46
Utility class to draw objects in the feedback list during queries.
Definition: TDrawFeedback.h:39
#define gPad
Definition: TVirtualPad.h:288
const Bool_t kTRUE
Definition: Rtypes.h:91
~TDrawFeedback()
Destructor.