// @(#)root/sessionviewer:$Id$
// Author: Fons Rademakers   21/03/03

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

#ifndef ROOT_TProofProgressDialog
#define ROOT_TProofProgressDialog


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TProofProgressDialog                                                 //
//                                                                      //
// This class provides a query progress bar.                            //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TTime
#include "TTime.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif

class TGTransientFrame;
class TGProgressBar;
class TGTextButton;
class TGCheckButton;
class TGLabel;
class TGTextBuffer;
class TGTextEntry;
class TProof;
class TProofProgressLog;
class TProofProgressMemoryPlot;
class TNtuple;
class TGraph;
class TGSpeedo;

class TProofProgressDialog {

   friend class TProofProgressLog;
   friend class TProofProgressMemoryPlot;

private:
   enum EQueryStatus { kRunning = 0, kDone, kStopped, kAborted, kIncomplete };

   TGTransientFrame   *fDialog;  // transient frame, main dialog window
   TGProgressBar      *fBar;     // progress bar
   TGTextButton       *fClose;
   TGTextButton       *fStop;
   TGTextButton       *fAbort;
   TGTextButton       *fAsyn;
   TGTextButton       *fLog;
   TGTextButton       *fRatePlot;
   TGTextButton       *fMemPlot;
   TGTextButton       *fUpdtSpeedo;
   TGCheckButton      *fKeepToggle;
   TGCheckButton      *fLogQueryToggle;
   TGTextBuffer       *fTextQuery;
   TGTextEntry        *fEntry;
   TGLabel            *fTitleLab;
   TGLabel            *fFilesEvents;
   TGLabel            *fTimeLab;
   TGLabel            *fProcessed;
   TGLabel            *fEstim;
   TGLabel            *fTotal;
   TGLabel            *fRate;
   TGLabel            *fInit;
   TGLabel            *fSelector;
   Bool_t              fSpeedoEnabled;    // whether to enable the speedometer
   TGSpeedo           *fSpeedo;           // speedometer
   TGCheckButton      *fSmoothSpeedo;     // use smooth speedometer update
   TProofProgressLog  *fLogWindow;        // transient frame for logs
   TProofProgressMemoryPlot *fMemWindow;  // transient frame for memory plots
   TProof             *fProof;
   TTime               fStartTime;
   TTime               fEndTime;
   Long64_t            fPrevProcessed;
   Long64_t            fPrevTotal;
   Long64_t            fFirst;
   Long64_t            fEntries;
   Int_t               fFiles;
   EQueryStatus        fStatus;
   Bool_t              fKeep;
   Bool_t              fLogQuery;
   TNtuple            *fRatePoints;
   TGraph             *fRateGraph;
   TGraph             *fMBRtGraph;
   TGraph             *fActWGraph;
   TGraph             *fTotSGraph;
   TGraph             *fEffSGraph;
   Float_t             fInitTime;
   Float_t             fProcTime;
   Double_t            fAvgRate;
   Double_t            fAvgMBRate;
   Int_t               fRightInfo;

   TString             fSessionUrl;

   Float_t             AdjustBytes(Float_t mbs, TString &sf);

   static Bool_t       fgKeepDefault;
   static Bool_t       fgLogQueryDefault;
   static TString      fgTextQueryDefault;

public:
   TProofProgressDialog(TProof *proof, const char *selector,
                        Int_t files, Long64_t first, Long64_t entries);
   virtual ~TProofProgressDialog();

   void ResetProgressDialog(const char *sel, Int_t sz, Long64_t fst, Long64_t ent);
   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) {
                 Progress(total, processed, bytesread, initTime, procTime,
                          evtrti, mbrti, -1, -1, -1.); }
   void Progress(Long64_t total, Long64_t processed, Long64_t bytesread,
                 Float_t initTime, Float_t procTime,
                 Float_t evtrti, Float_t mbrti, Int_t actw, Int_t tses, Float_t eses);
   void DisableAsyn();
   void IndicateStop(Bool_t aborted);
   void LogMessage(const char *msg, Bool_t all);

   void CloseWindow();
   void DoClose();
   void DoLog();
   void DoKeep(Bool_t on);
   void DoSetLogQuery(Bool_t on);
   void DoStop();
   void DoAbort();
   void DoAsyn();
   void DoPlotRateGraph();
   void DoMemoryPlot();
   void DoEnableSpeedo();
   void ToggleOdometerInfos();
   void ToggleThreshold();

   ClassDef(TProofProgressDialog,0)  //PROOF progress dialog
};

#endif
 TProofProgressDialog.h:1
 TProofProgressDialog.h:2
 TProofProgressDialog.h:3
 TProofProgressDialog.h:4
 TProofProgressDialog.h:5
 TProofProgressDialog.h:6
 TProofProgressDialog.h:7
 TProofProgressDialog.h:8
 TProofProgressDialog.h:9
 TProofProgressDialog.h:10
 TProofProgressDialog.h:11
 TProofProgressDialog.h:12
 TProofProgressDialog.h:13
 TProofProgressDialog.h:14
 TProofProgressDialog.h:15
 TProofProgressDialog.h:16
 TProofProgressDialog.h:17
 TProofProgressDialog.h:18
 TProofProgressDialog.h:19
 TProofProgressDialog.h:20
 TProofProgressDialog.h:21
 TProofProgressDialog.h:22
 TProofProgressDialog.h:23
 TProofProgressDialog.h:24
 TProofProgressDialog.h:25
 TProofProgressDialog.h:26
 TProofProgressDialog.h:27
 TProofProgressDialog.h:28
 TProofProgressDialog.h:29
 TProofProgressDialog.h:30
 TProofProgressDialog.h:31
 TProofProgressDialog.h:32
 TProofProgressDialog.h:33
 TProofProgressDialog.h:34
 TProofProgressDialog.h:35
 TProofProgressDialog.h:36
 TProofProgressDialog.h:37
 TProofProgressDialog.h:38
 TProofProgressDialog.h:39
 TProofProgressDialog.h:40
 TProofProgressDialog.h:41
 TProofProgressDialog.h:42
 TProofProgressDialog.h:43
 TProofProgressDialog.h:44
 TProofProgressDialog.h:45
 TProofProgressDialog.h:46
 TProofProgressDialog.h:47
 TProofProgressDialog.h:48
 TProofProgressDialog.h:49
 TProofProgressDialog.h:50
 TProofProgressDialog.h:51
 TProofProgressDialog.h:52
 TProofProgressDialog.h:53
 TProofProgressDialog.h:54
 TProofProgressDialog.h:55
 TProofProgressDialog.h:56
 TProofProgressDialog.h:57
 TProofProgressDialog.h:58
 TProofProgressDialog.h:59
 TProofProgressDialog.h:60
 TProofProgressDialog.h:61
 TProofProgressDialog.h:62
 TProofProgressDialog.h:63
 TProofProgressDialog.h:64
 TProofProgressDialog.h:65
 TProofProgressDialog.h:66
 TProofProgressDialog.h:67
 TProofProgressDialog.h:68
 TProofProgressDialog.h:69
 TProofProgressDialog.h:70
 TProofProgressDialog.h:71
 TProofProgressDialog.h:72
 TProofProgressDialog.h:73
 TProofProgressDialog.h:74
 TProofProgressDialog.h:75
 TProofProgressDialog.h:76
 TProofProgressDialog.h:77
 TProofProgressDialog.h:78
 TProofProgressDialog.h:79
 TProofProgressDialog.h:80
 TProofProgressDialog.h:81
 TProofProgressDialog.h:82
 TProofProgressDialog.h:83
 TProofProgressDialog.h:84
 TProofProgressDialog.h:85
 TProofProgressDialog.h:86
 TProofProgressDialog.h:87
 TProofProgressDialog.h:88
 TProofProgressDialog.h:89
 TProofProgressDialog.h:90
 TProofProgressDialog.h:91
 TProofProgressDialog.h:92
 TProofProgressDialog.h:93
 TProofProgressDialog.h:94
 TProofProgressDialog.h:95
 TProofProgressDialog.h:96
 TProofProgressDialog.h:97
 TProofProgressDialog.h:98
 TProofProgressDialog.h:99
 TProofProgressDialog.h:100
 TProofProgressDialog.h:101
 TProofProgressDialog.h:102
 TProofProgressDialog.h:103
 TProofProgressDialog.h:104
 TProofProgressDialog.h:105
 TProofProgressDialog.h:106
 TProofProgressDialog.h:107
 TProofProgressDialog.h:108
 TProofProgressDialog.h:109
 TProofProgressDialog.h:110
 TProofProgressDialog.h:111
 TProofProgressDialog.h:112
 TProofProgressDialog.h:113
 TProofProgressDialog.h:114
 TProofProgressDialog.h:115
 TProofProgressDialog.h:116
 TProofProgressDialog.h:117
 TProofProgressDialog.h:118
 TProofProgressDialog.h:119
 TProofProgressDialog.h:120
 TProofProgressDialog.h:121
 TProofProgressDialog.h:122
 TProofProgressDialog.h:123
 TProofProgressDialog.h:124
 TProofProgressDialog.h:125
 TProofProgressDialog.h:126
 TProofProgressDialog.h:127
 TProofProgressDialog.h:128
 TProofProgressDialog.h:129
 TProofProgressDialog.h:130
 TProofProgressDialog.h:131
 TProofProgressDialog.h:132
 TProofProgressDialog.h:133
 TProofProgressDialog.h:134
 TProofProgressDialog.h:135
 TProofProgressDialog.h:136
 TProofProgressDialog.h:137
 TProofProgressDialog.h:138
 TProofProgressDialog.h:139
 TProofProgressDialog.h:140
 TProofProgressDialog.h:141
 TProofProgressDialog.h:142
 TProofProgressDialog.h:143
 TProofProgressDialog.h:144
 TProofProgressDialog.h:145
 TProofProgressDialog.h:146
 TProofProgressDialog.h:147
 TProofProgressDialog.h:148