TDrawFeedback.cxx

Go to the documentation of this file.
00001 // @(#)root/proofplayer:$Id: TDrawFeedback.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Maarten Ballintijn   28/10/2003
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TDrawFeedback                                                        //
00015 //                                                                      //
00016 // Utility class to draw objects in the feedback list during queries.   //
00017 //                                                                      //
00018 //////////////////////////////////////////////////////////////////////////
00019 
00020 #include "TDrawFeedback.h"
00021 
00022 #include "THashList.h"
00023 #include "TObjString.h"
00024 #include "TProof.h"
00025 #include "TROOT.h"
00026 #include "TH1.h"
00027 #include "TH2.h"
00028 #include "TError.h"
00029 #include "TSeqCollection.h"
00030 #include "TVirtualPad.h"
00031 #include "TProofDebug.h"
00032 
00033 ClassImp(TDrawFeedback)
00034 
00035 
00036 //______________________________________________________________________________
00037 TDrawFeedback::TDrawFeedback(TProof *proof, TSeqCollection *names)
00038   : fAll(kFALSE)
00039 {
00040    // Constructor
00041 
00042    fNames = new THashList;
00043    fNames->SetOwner();
00044 
00045    if (proof == 0) proof = gProof;
00046 
00047    TProof *p = dynamic_cast<TProof*>(proof);
00048    if (p == 0) {
00049       Error("TDrawFeedback","no valid proof session found");
00050       return;
00051    }
00052    fProof = p;
00053 
00054    Bool_t ok = proof->Connect("Feedback(TList *objs)", "TDrawFeedback",
00055                   this, "Feedback(TList *objs)");
00056 
00057    if ( !ok ) {
00058       Error("TDrawFeedback","Connect() failed");
00059       return;
00060    }
00061 
00062    if (names != 0) {
00063       TIter next(names);
00064       TObjString *name;
00065       while((name = dynamic_cast<TObjString*>(next())) != 0) {
00066          fNames->Add(new TNamed(name->GetName(),""));
00067       }
00068    } else {
00069       fAll = kTRUE;
00070    }
00071    fOption = 0;
00072 }
00073 
00074 //______________________________________________________________________________
00075 TDrawFeedback::~TDrawFeedback()
00076 {
00077    // Destructor
00078 
00079    delete fNames;
00080    fProof->Disconnect("Feedback(TList*)", this, "Feedback(TList*");
00081 }
00082 
00083 //______________________________________________________________________________
00084 void TDrawFeedback::Feedback(TList *objs)
00085 {
00086    // Display feedback
00087 
00088    TSeqCollection *canvases = gROOT->GetListOfCanvases();
00089    TVirtualPad *save = gPad;
00090 
00091    PDB(kFeedback,1) Info("Feedback","%d Objects", objs->GetSize());
00092 
00093    TIter next(objs);
00094    TObject *o;
00095    while( (o = next()) )
00096    {
00097       TString name = o->GetName();
00098       if (fAll || fNames->FindObject(name.Data())) {
00099 
00100          name += "_canvas";
00101 
00102          TVirtualPad *p = (TVirtualPad*) canvases->FindObject(name.Data());
00103 
00104          if ( p == 0 ) {
00105             gROOT->MakeDefCanvas();
00106             gPad->SetName(name);
00107             PDB(kFeedback,2) Info("Feedback","Created canvas %s", name.Data());
00108          } else {
00109             p->cd();
00110             PDB(kFeedback,2) Info("Feedback","Used canvas %s", name.Data());
00111          }
00112 
00113          if (TH1 *h = dynamic_cast<TH1*>(o)) {
00114             h->DrawCopy(fOption);
00115          }
00116 
00117          gPad->Update();
00118       }
00119    }
00120 
00121    if (save != 0) {
00122       save->cd();
00123    } else {
00124       gPad = 0;
00125    }
00126 }

Generated on Tue Jul 5 14:52:17 2011 for ROOT_528-00b_version by  doxygen 1.5.1