// @(#)root/treeviewer:$Id$
//Author : Andrei Gheata   21/02/01

/*************************************************************************
 * 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.             *
 *************************************************************************/

#ifndef ROOT_TTVSession
#define ROOT_TTVSession

///////////////////////////////////////////////////////////////////////////////
//                                                                           //
// TTVSession and TTVRecord - I/O classes for TreeViewer session handling    //
//     TTreeViewer                                                           //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif

class TTreeViewer;
class TClonesArray;
class TGVButtonGroup;

class TTVRecord : public TObject {

public:
   TString              fName;                  // name of this record
   TString              fX, fXAlias;            // X expression and alias
   TString              fY, fYAlias;            // Y expression and alias
   TString              fZ, fZAlias;            // Z expression and alias
   TString              fCut, fCutAlias;        // cut expression and alias
   TString              fOption;                // graphic option
   Bool_t               fScanRedirected;        // redirect switch
   Bool_t               fCutEnabled;            // true if current cut is active
   TString              fUserCode;              // command executed when record is conected
   Bool_t               fAutoexec;              // autoexecute user code command
public:
   TTVRecord();                                 // default constructor
   ~TTVRecord() {}                              // destructor

   void           ExecuteUserCode();
   void           FormFrom(TTreeViewer *tv);
   void           PlugIn(TTreeViewer *tv);
   const char    *GetX() const {return fX;}
   const char    *GetY() const {return fY;}
   const char    *GetZ() const {return fZ;}
   virtual const char *GetName() const {return fName;}
   const char    *GetUserCode() const {return fUserCode;}
   Bool_t         HasUserCode() const {return fUserCode.Length() != 0 ? kTRUE : kFALSE;}
   Bool_t         MustExecuteCode() const {return fAutoexec;}
   void           SetAutoexec(Bool_t autoexec=kTRUE) {fAutoexec=autoexec;} // *TOGGLE* *GETTER=MustExecuteCode
   void           SetName(const char* name = "") {fName = name;}
   void           SetX(const char *x = "", const char *xal = "-empty-") {fX = x; fXAlias = xal;}
   void           SetY(const char *y = "", const char *yal = "-empty-") {fY = y; fYAlias = yal;}
   void           SetZ(const char *z = "", const char *zal = "-empty-") {fZ = z; fZAlias = zal;}
   void           SetCut(const char *cut = "", const char *cal = "-empty-") {fCut = cut; fCutAlias = cal;}
   void           SetOption(const char *option = "")             {fOption = option;}
   void           SetRC(Bool_t redirect = kFALSE, Bool_t cut = kTRUE) {fScanRedirected = redirect; fCutEnabled = cut;}
   void           SetUserCode(const char *code, Bool_t autoexec=kTRUE) {fUserCode = code; fAutoexec=autoexec;} // *MENU*
   void           SaveSource(std::ofstream &out);

   ClassDef(TTVRecord, 0)    // A draw record for TTreeViewer
};

class TTVSession : public TObject {

private:
   TClonesArray  *fList;                        // list of TV records
   TString        fName;                        // name of this session
   TTreeViewer   *fViewer;                      // associated tree viewer
   Int_t          fCurrent;                     // index of current record
   Int_t          fRecords;                     // number of records

public:
   TTVSession(TTreeViewer *tv);
   ~TTVSession();
   virtual const char *GetName() const      {return fName;}
   void           SetName(const char *name) {fName = name;}
   void           SetRecordName(const char* name);
   TTVRecord     *AddRecord(Bool_t fromFile = kFALSE);
   Int_t          GetEntries() {return fRecords;}
   TTVRecord     *GetCurrent() {return GetRecord(fCurrent);}
   TTVRecord     *GetRecord(Int_t i);
   TTVRecord     *First()    {return GetRecord(0);}
   TTVRecord     *Last()     {return GetRecord(fRecords-1);}
   TTVRecord     *Next()     {return GetRecord(fCurrent+1);}
   TTVRecord     *Previous() {return GetRecord(fCurrent-1);}

   void           RemoveLastRecord();
   void           Show(TTVRecord *rec);
   void           SaveSource(std::ofstream &out);
   void           UpdateRecord(const char *name);

   ClassDef(TTVSession, 0)   // A tree viewer session
};

#endif
 TTVSession.h:1
 TTVSession.h:2
 TTVSession.h:3
 TTVSession.h:4
 TTVSession.h:5
 TTVSession.h:6
 TTVSession.h:7
 TTVSession.h:8
 TTVSession.h:9
 TTVSession.h:10
 TTVSession.h:11
 TTVSession.h:12
 TTVSession.h:13
 TTVSession.h:14
 TTVSession.h:15
 TTVSession.h:16
 TTVSession.h:17
 TTVSession.h:18
 TTVSession.h:19
 TTVSession.h:20
 TTVSession.h:21
 TTVSession.h:22
 TTVSession.h:23
 TTVSession.h:24
 TTVSession.h:25
 TTVSession.h:26
 TTVSession.h:27
 TTVSession.h:28
 TTVSession.h:29
 TTVSession.h:30
 TTVSession.h:31
 TTVSession.h:32
 TTVSession.h:33
 TTVSession.h:34
 TTVSession.h:35
 TTVSession.h:36
 TTVSession.h:37
 TTVSession.h:38
 TTVSession.h:39
 TTVSession.h:40
 TTVSession.h:41
 TTVSession.h:42
 TTVSession.h:43
 TTVSession.h:44
 TTVSession.h:45
 TTVSession.h:46
 TTVSession.h:47
 TTVSession.h:48
 TTVSession.h:49
 TTVSession.h:50
 TTVSession.h:51
 TTVSession.h:52
 TTVSession.h:53
 TTVSession.h:54
 TTVSession.h:55
 TTVSession.h:56
 TTVSession.h:57
 TTVSession.h:58
 TTVSession.h:59
 TTVSession.h:60
 TTVSession.h:61
 TTVSession.h:62
 TTVSession.h:63
 TTVSession.h:64
 TTVSession.h:65
 TTVSession.h:66
 TTVSession.h:67
 TTVSession.h:68
 TTVSession.h:69
 TTVSession.h:70
 TTVSession.h:71
 TTVSession.h:72
 TTVSession.h:73
 TTVSession.h:74
 TTVSession.h:75
 TTVSession.h:76
 TTVSession.h:77
 TTVSession.h:78
 TTVSession.h:79
 TTVSession.h:80
 TTVSession.h:81
 TTVSession.h:82
 TTVSession.h:83
 TTVSession.h:84
 TTVSession.h:85
 TTVSession.h:86
 TTVSession.h:87
 TTVSession.h:88
 TTVSession.h:89
 TTVSession.h:90
 TTVSession.h:91
 TTVSession.h:92
 TTVSession.h:93
 TTVSession.h:94
 TTVSession.h:95
 TTVSession.h:96
 TTVSession.h:97
 TTVSession.h:98
 TTVSession.h:99
 TTVSession.h:100
 TTVSession.h:101
 TTVSession.h:102
 TTVSession.h:103