ROOT logo
// @(#)root/proofplayer:$Id: TDrawFeedback.cxx 20882 2007-11-19 11:31:26Z rdm $
// Author: Maarten Ballintijn   28/10/2003

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TDrawFeedback                                                        //
//                                                                      //
// Utility class to draw objects in the feedback list during queries.   //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TDrawFeedback.h"

#include "THashList.h"
#include "TObjString.h"
#include "TProof.h"
#include "TROOT.h"
#include "TH1.h"
#include "TH2.h"
#include "TError.h"
#include "TSeqCollection.h"
#include "TVirtualPad.h"
#include "TProofDebug.h"

ClassImp(TDrawFeedback)


//______________________________________________________________________________
TDrawFeedback::TDrawFeedback(TProof *proof, TSeqCollection *names)
  : fAll(kFALSE)
{
   // Constructor

   fNames = new THashList;
   fNames->SetOwner();

   if (proof == 0) proof = gProof;

   TProof *p = dynamic_cast<TProof*>(proof);
   if (p == 0) {
      Error("TDrawFeedback","no valid proof session found");
      return;
   }
   fProof = p;

   Bool_t ok = proof->Connect("Feedback(TList *objs)", "TDrawFeedback",
                  this, "Feedback(TList *objs)");

   if ( !ok ) {
      Error("TDrawFeedback","Connect() failed");
      return;
   }

   if (names != 0) {
      TIter next(names);
      TObjString *name;
      while((name = dynamic_cast<TObjString*>(next())) != 0) {
         fNames->Add(new TNamed(name->GetName(),""));
      }
   } else {
      fAll = kTRUE;
   }
   fOption = 0;
}

//______________________________________________________________________________
TDrawFeedback::~TDrawFeedback()
{
   // Destructor

   delete fNames;
   fProof->Disconnect("Feedback(TList*)", this, "Feedback(TList*");
}

//______________________________________________________________________________
void TDrawFeedback::Feedback(TList *objs)
{
   // Display feedback

   TSeqCollection *canvases = gROOT->GetListOfCanvases();
   TVirtualPad *save = gPad;

   PDB(kFeedback,1) Info("Feedback","%d Objects", objs->GetSize());

   TIter next(objs);
   TObject *o;
   while( (o = next()) )
   {
      TString name = o->GetName();
      if (fAll || fNames->FindObject(name.Data())) {

         name += "_canvas";

         TVirtualPad *p = (TVirtualPad*) canvases->FindObject(name.Data());

         if ( p == 0 ) {
            gROOT->MakeDefCanvas();
            gPad->SetName(name);
            PDB(kFeedback,2) Info("Feedback","Created canvas %s", name.Data());
         } else {
            p->cd();
            PDB(kFeedback,2) Info("Feedback","Used canvas %s", name.Data());
         }

         if (TH1 *h = dynamic_cast<TH1*>(o)) {
            h->DrawCopy(fOption);
         }

         gPad->Update();
      }
   }

   if (save != 0) {
      save->cd();
   } else {
      gPad = 0;
   }
}
 TDrawFeedback.cxx:1
 TDrawFeedback.cxx:2
 TDrawFeedback.cxx:3
 TDrawFeedback.cxx:4
 TDrawFeedback.cxx:5
 TDrawFeedback.cxx:6
 TDrawFeedback.cxx:7
 TDrawFeedback.cxx:8
 TDrawFeedback.cxx:9
 TDrawFeedback.cxx:10
 TDrawFeedback.cxx:11
 TDrawFeedback.cxx:12
 TDrawFeedback.cxx:13
 TDrawFeedback.cxx:14
 TDrawFeedback.cxx:15
 TDrawFeedback.cxx:16
 TDrawFeedback.cxx:17
 TDrawFeedback.cxx:18
 TDrawFeedback.cxx:19
 TDrawFeedback.cxx:20
 TDrawFeedback.cxx:21
 TDrawFeedback.cxx:22
 TDrawFeedback.cxx:23
 TDrawFeedback.cxx:24
 TDrawFeedback.cxx:25
 TDrawFeedback.cxx:26
 TDrawFeedback.cxx:27
 TDrawFeedback.cxx:28
 TDrawFeedback.cxx:29
 TDrawFeedback.cxx:30
 TDrawFeedback.cxx:31
 TDrawFeedback.cxx:32
 TDrawFeedback.cxx:33
 TDrawFeedback.cxx:34
 TDrawFeedback.cxx:35
 TDrawFeedback.cxx:36
 TDrawFeedback.cxx:37
 TDrawFeedback.cxx:38
 TDrawFeedback.cxx:39
 TDrawFeedback.cxx:40
 TDrawFeedback.cxx:41
 TDrawFeedback.cxx:42
 TDrawFeedback.cxx:43
 TDrawFeedback.cxx:44
 TDrawFeedback.cxx:45
 TDrawFeedback.cxx:46
 TDrawFeedback.cxx:47
 TDrawFeedback.cxx:48
 TDrawFeedback.cxx:49
 TDrawFeedback.cxx:50
 TDrawFeedback.cxx:51
 TDrawFeedback.cxx:52
 TDrawFeedback.cxx:53
 TDrawFeedback.cxx:54
 TDrawFeedback.cxx:55
 TDrawFeedback.cxx:56
 TDrawFeedback.cxx:57
 TDrawFeedback.cxx:58
 TDrawFeedback.cxx:59
 TDrawFeedback.cxx:60
 TDrawFeedback.cxx:61
 TDrawFeedback.cxx:62
 TDrawFeedback.cxx:63
 TDrawFeedback.cxx:64
 TDrawFeedback.cxx:65
 TDrawFeedback.cxx:66
 TDrawFeedback.cxx:67
 TDrawFeedback.cxx:68
 TDrawFeedback.cxx:69
 TDrawFeedback.cxx:70
 TDrawFeedback.cxx:71
 TDrawFeedback.cxx:72
 TDrawFeedback.cxx:73
 TDrawFeedback.cxx:74
 TDrawFeedback.cxx:75
 TDrawFeedback.cxx:76
 TDrawFeedback.cxx:77
 TDrawFeedback.cxx:78
 TDrawFeedback.cxx:79
 TDrawFeedback.cxx:80
 TDrawFeedback.cxx:81
 TDrawFeedback.cxx:82
 TDrawFeedback.cxx:83
 TDrawFeedback.cxx:84
 TDrawFeedback.cxx:85
 TDrawFeedback.cxx:86
 TDrawFeedback.cxx:87
 TDrawFeedback.cxx:88
 TDrawFeedback.cxx:89
 TDrawFeedback.cxx:90
 TDrawFeedback.cxx:91
 TDrawFeedback.cxx:92
 TDrawFeedback.cxx:93
 TDrawFeedback.cxx:94
 TDrawFeedback.cxx:95
 TDrawFeedback.cxx:96
 TDrawFeedback.cxx:97
 TDrawFeedback.cxx:98
 TDrawFeedback.cxx:99
 TDrawFeedback.cxx:100
 TDrawFeedback.cxx:101
 TDrawFeedback.cxx:102
 TDrawFeedback.cxx:103
 TDrawFeedback.cxx:104
 TDrawFeedback.cxx:105
 TDrawFeedback.cxx:106
 TDrawFeedback.cxx:107
 TDrawFeedback.cxx:108
 TDrawFeedback.cxx:109
 TDrawFeedback.cxx:110
 TDrawFeedback.cxx:111
 TDrawFeedback.cxx:112
 TDrawFeedback.cxx:113
 TDrawFeedback.cxx:114
 TDrawFeedback.cxx:115
 TDrawFeedback.cxx:116
 TDrawFeedback.cxx:117
 TDrawFeedback.cxx:118
 TDrawFeedback.cxx:119
 TDrawFeedback.cxx:120
 TDrawFeedback.cxx:121
 TDrawFeedback.cxx:122
 TDrawFeedback.cxx:123
 TDrawFeedback.cxx:124
 TDrawFeedback.cxx:125
 TDrawFeedback.cxx:126