From 4d544aa1be0adc34a5327b4fb39bee9c1eeb079f Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Fri, 17 Nov 2006 15:42:13 +0000
Subject: [PATCH] From Bertrand: - Implemented the new Progress() method,
 according the latest changes in PROOF. - Improve behavior when switching
 between queries in the left tree view. - Added missing protection

git-svn-id: http://root.cern.ch/svn/root/trunk@16803 27541ba8-7e3a-0410-8455-c3a389f83636
---
 treeviewer/inc/TSessionViewer.h    |  6 +++-
 treeviewer/src/TSessionDialogs.cxx |  8 +++--
 treeviewer/src/TSessionViewer.cxx  | 48 +++++++++++++++++++++++++-----
 3 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/treeviewer/inc/TSessionViewer.h b/treeviewer/inc/TSessionViewer.h
index a9be6f726d1..67ac7c61ce6 100644
--- a/treeviewer/inc/TSessionViewer.h
+++ b/treeviewer/inc/TSessionViewer.h
@@ -1,4 +1,4 @@
-// @(#)root/treeviewer:$Name:  $:$Id: TSessionViewer.h,v 1.36 2006/10/02 14:27:25 rdm Exp $
+// @(#)root/treeviewer:$Name:  $:$Id: TSessionViewer.h,v 1.37 2006/11/06 00:00:26 rdm Exp $
 // Author: Marek Biskup, Jakub Madejczyk, Bertrand Bellenot 10/08/2005
 
 /*************************************************************************
@@ -441,6 +441,10 @@ public:
 
    void     Feedback(TList *objs);
    void     Progress(Long64_t total, Long64_t processed);
+   void     Progress(Long64_t total, Long64_t processed,
+                     Long64_t bytesread, Float_t initTime, 
+                     Float_t procTime, Float_t evtrti, 
+                     Float_t mbrti);
    void     ProgressLocal(Long64_t total, Long64_t processed);
    void     IndicateStop(Bool_t aborted);
    void     ResetProgressDialog(const char *selec, Int_t files, Long64_t first, Long64_t entries);
diff --git a/treeviewer/src/TSessionDialogs.cxx b/treeviewer/src/TSessionDialogs.cxx
index 6872077f2cd..7cc89aa8e4e 100644
--- a/treeviewer/src/TSessionDialogs.cxx
+++ b/treeviewer/src/TSessionDialogs.cxx
@@ -1,4 +1,4 @@
-// @(#)root/treeviewer:$Name:  $:$Id: TSessionDialogs.cxx,v 1.30 2006/10/02 14:27:25 rdm Exp $
+// @(#)root/treeviewer:$Name:  $:$Id: TSessionDialogs.cxx,v 1.31 2006/11/06 00:00:26 rdm Exp $
 // Author: Marek Biskup, Jakub Madejczyk, Bertrand Bellenot 10/08/2005
 
 /*************************************************************************
@@ -81,7 +81,7 @@ TNewChainDlg::TNewChainDlg(const TGWindow *p, const TGWindow *main) :
    Pixel_t backgnd;
    if (!p || !main) return;
    SetCleanup(kDeepCleanup);
-   fClient->GetColorByName("#D0EED0", backgnd);
+   fClient->GetColorByName("#F0FFF0", backgnd);
    AddFrame(new TGLabel(this, new TGHotString("List of Chains in Memory :")),
             new TGLayoutHints(kLHintsLeft, 5, 5, 7, 2) );
 
@@ -702,7 +702,9 @@ void TNewQueryDlg::UpdateFields(TQueryDescription *desc)
 
    fQuery = desc;
    fTxtQueryName->SetText(desc->fQueryName);
-   fTxtChain->SetText(desc->fTDSetString);
+   fTxtChain->SetText("");
+   if (desc->fChain)
+      fTxtChain->SetText(desc->fTDSetString);
    fTxtSelector->SetText(desc->fSelectorString);
    fTxtOptions->SetText(desc->fOptions);
    fNumEntries->SetIntNumber(desc->fNoEntries);
diff --git a/treeviewer/src/TSessionViewer.cxx b/treeviewer/src/TSessionViewer.cxx
index ae020a8ba61..839fc87cfd6 100644
--- a/treeviewer/src/TSessionViewer.cxx
+++ b/treeviewer/src/TSessionViewer.cxx
@@ -1,4 +1,4 @@
-// @(#)root/treeviewer:$Name:  $:$Id: TSessionViewer.cxx,v 1.80 2006/11/06 11:40:30 rdm Exp $
+// @(#)root/treeviewer:$Name:  $:$Id: TSessionViewer.cxx,v 1.81 2006/11/06 13:15:55 rdm Exp $
 // Author: Marek Biskup, Jakub Madejczyk, Bertrand Bellenot 10/08/2005
 
 /*************************************************************************
@@ -565,11 +565,14 @@ void TSessionServerFrame::OnBtnConnectClicked()
       fClient->NeedRedraw(fViewer->GetSessionHierarchy());
       // connect to progress related signals
       fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t)",
-                                 "TSessionQueryFrame", fViewer->GetQueryFrame(),
-                                 "Progress(Long64_t,Long64_t)");
+                 "TSessionQueryFrame", fViewer->GetQueryFrame(),
+                 "Progress(Long64_t,Long64_t)");
+      fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
+                 "TSessionQueryFrame", fViewer->GetQueryFrame(),
+                 "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
       fViewer->GetActDesc()->fProof->Connect("StopProcess(Bool_t)",
-                                 "TSessionQueryFrame", fViewer->GetQueryFrame(),
-                                 "IndicateStop(Bool_t)");
+                 "TSessionQueryFrame", fViewer->GetQueryFrame(),
+                 "IndicateStop(Bool_t)");
       fViewer->GetActDesc()->fProof->Connect(
                   "ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)",
                   "TSessionQueryFrame", fViewer->GetQueryFrame(),
@@ -2246,10 +2249,12 @@ void TEditQueryFrame::UpdateFields(TQueryDescription *desc)
 
    fChain = 0;
    fQuery = desc;
-   if (desc->fChain)
+   fTxtChain->SetText("");
+   if (desc->fChain) {
       fChain = desc->fChain;
+      fTxtChain->SetText(desc->fTDSetString);
+   }
    fTxtQueryName->SetText(desc->fQueryName);
-   fTxtChain->SetText(desc->fTDSetString);
    fTxtSelector->SetText(desc->fSelectorString);
    fTxtOptions->SetText(desc->fOptions);
    fNumEntries->SetIntNumber(desc->fNoEntries);
@@ -2562,6 +2567,18 @@ void TSessionQueryFrame::Progress(Long64_t total, Long64_t processed)
    fFB->Layout();
 }
 
+//______________________________________________________________________________
+void TSessionQueryFrame::Progress(Long64_t total, Long64_t processed,
+                                  Long64_t /*bytesread*/ , Float_t /*initTime*/, 
+                                  Float_t /*procTime*/, Float_t /*evtrti*/, 
+                                  Float_t /*mbrti*/)
+{
+   // New version of Progress (just forward to the old version
+   // for the time being).
+
+   Progress(total, processed);
+}
+
 //______________________________________________________________________________
 void TSessionQueryFrame::ProgressLocal(Long64_t total, Long64_t processed)
 {
@@ -2686,6 +2703,8 @@ void TSessionQueryFrame::IndicateStop(Bool_t aborted)
        fViewer->GetActDesc()->fProof->IsValid()) {
       fViewer->GetActDesc()->fProof->Disconnect("Progress(Long64_t,Long64_t)",
                this, "Progress(Long64_t,Long64_t)");
+      fViewer->GetActDesc()->fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
+               this, "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
       fViewer->GetActDesc()->fProof->Disconnect("StopProcess(Bool_t)", this,
                "IndicateStop(Bool_t)");
    }
@@ -2718,6 +2737,9 @@ void TSessionQueryFrame::ResetProgressDialog(const char * /*selector*/, Int_t fi
        fViewer->GetActDesc()->fProof->IsValid()) {
       fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t)",
                "TSessionQueryFrame", this, "Progress(Long64_t,Long64_t)");
+      fViewer->GetActDesc()->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
+               "TSessionQueryFrame", this,
+               "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
       fViewer->GetActDesc()->fProof->Connect("StopProcess(Bool_t)",
                "TSessionQueryFrame", this, "IndicateStop(Bool_t)");
       sprintf(buf, "PROOF cluster : \"%s\" - %d worker nodes",
@@ -2976,6 +2998,7 @@ void TSessionQueryFrame::OnBtnSubmit()
                   newquery->fOptions,
                   newquery->fNoEntries > 0 ? newquery->fNoEntries : 1234567890,
                   newquery->fFirstEntry);
+            ((TChain *)newquery->fChain)->SetTimerInterval(0);
             OnBtnRetrieve();
             TChain *chain = (TChain *)newquery->fChain;
             ProgressLocal(chain->GetEntries(),
@@ -3693,6 +3716,9 @@ void TSessionViewer::UpdateListOfProofs()
                            fActDesc->fProof->Connect("Progress(Long64_t,Long64_t)",
                                     "TSessionQueryFrame", fQueryFrame,
                                     "Progress(Long64_t,Long64_t)");
+                           fActDesc->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
+                                    "TSessionQueryFrame", fQueryFrame,
+                                    "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
                            fActDesc->fProof->Connect("StopProcess(Bool_t)",
                                     "TSessionQueryFrame", fQueryFrame,
                                     "IndicateStop(Bool_t)");
@@ -3762,6 +3788,9 @@ void TSessionViewer::UpdateListOfProofs()
                   newdesc->fProof->Connect("Progress(Long64_t,Long64_t)",
                            "TSessionQueryFrame", fQueryFrame,
                            "Progress(Long64_t,Long64_t)");
+                  newdesc->fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
+                           "TSessionQueryFrame", fQueryFrame,
+                           "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
                   newdesc->fProof->Connect("StopProcess(Bool_t)",
                            "TSessionQueryFrame", fQueryFrame,
                            "IndicateStop(Bool_t)");
@@ -4742,7 +4771,8 @@ Bool_t TSessionViewer::HandleTimer(TTimer *)
          (fActDesc->fActQuery->fStatus ==
          TQueryDescription::kSessionQueryRunning)) {
          TChain *chain = (TChain *)fActDesc->fActQuery->fChain;
-         fQueryFrame->ProgressLocal(chain->GetEntries(),
+         if (chain)
+            fQueryFrame->ProgressLocal(chain->GetEntries(),
                         chain->GetChainEntryNumber(chain->GetReadEntry())+1);
       }
    }
@@ -5293,6 +5323,8 @@ void TSessionViewer::OnCascadeMenu()
          fActDesc->fNbHistos++;
       i++;
    }
+   fQueryFrame->GetStatsCanvas()->SetEditable(kTRUE);
+   fQueryFrame->GetStatsCanvas()->Clear();
    if (fActDesc->fNbHistos == 4)
       fQueryFrame->GetStatsCanvas()->Divide(2, 2);
    else if (fActDesc->fNbHistos > 4)
-- 
GitLab