Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TTVSession.h
Go to the documentation of this file.
1 // @(#)root/treeviewer:$Id$
2 //Author : Andrei Gheata 21/02/01
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TTVSession
13 #define ROOT_TTVSession
14 
15 ///////////////////////////////////////////////////////////////////////////////
16 // //
17 // TTVSession and TTVRecord - I/O classes for TreeViewer session handling //
18 // TTreeViewer //
19 // //
20 ///////////////////////////////////////////////////////////////////////////////
21 
22 #include "TObject.h"
23 #include "TString.h"
24 
25 class TTreeViewer;
26 class TClonesArray;
27 class TGVButtonGroup;
28 
29 class TTVRecord : public TObject {
30 
31 public:
32  TString fName; // name of this record
33  TString fX, fXAlias; // X expression and alias
34  TString fY, fYAlias; // Y expression and alias
35  TString fZ, fZAlias; // Z expression and alias
36  TString fCut, fCutAlias; // cut expression and alias
37  TString fOption; // graphic option
38  Bool_t fScanRedirected; // redirect switch
39  Bool_t fCutEnabled; // true if current cut is active
40  TString fUserCode; // command executed when record is conected
41  Bool_t fAutoexec; // autoexecute user code command
42 public:
43  TTVRecord(); // default constructor
44  ~TTVRecord() {} // destructor
45 
46  void ExecuteUserCode();
47  void FormFrom(TTreeViewer *tv);
48  void PlugIn(TTreeViewer *tv);
49  const char *GetX() const {return fX;}
50  const char *GetY() const {return fY;}
51  const char *GetZ() const {return fZ;}
52  virtual const char *GetName() const {return fName;}
53  const char *GetUserCode() const {return fUserCode;}
54  Bool_t HasUserCode() const {return fUserCode.Length() != 0 ? kTRUE : kFALSE;}
55  Bool_t MustExecuteCode() const {return fAutoexec;}
56  void SetAutoexec(Bool_t autoexec=kTRUE) {fAutoexec=autoexec;} // *TOGGLE* *GETTER=MustExecuteCode
57  void SetName(const char* name = "") {fName = name;}
58  void SetX(const char *x = "", const char *xal = "-empty-") {fX = x; fXAlias = xal;}
59  void SetY(const char *y = "", const char *yal = "-empty-") {fY = y; fYAlias = yal;}
60  void SetZ(const char *z = "", const char *zal = "-empty-") {fZ = z; fZAlias = zal;}
61  void SetCut(const char *cut = "", const char *cal = "-empty-") {fCut = cut; fCutAlias = cal;}
62  void SetOption(const char *option = "") {fOption = option;}
63  void SetRC(Bool_t redirect = kFALSE, Bool_t cut = kTRUE) {fScanRedirected = redirect; fCutEnabled = cut;}
64  void SetUserCode(const char *code, Bool_t autoexec=kTRUE) {fUserCode = code; fAutoexec=autoexec;} // *MENU*
65  void SaveSource(std::ofstream &out);
66 
67  ClassDef(TTVRecord, 0) // A draw record for TTreeViewer
68 };
69 
70 class TTVSession : public TObject {
71 
72 private:
73  TClonesArray *fList; // list of TV records
74  TString fName; // name of this session
75  TTreeViewer *fViewer; // associated tree viewer
76  Int_t fCurrent; // index of current record
77  Int_t fRecords; // number of records
78 
79 public:
80  TTVSession(TTreeViewer *tv);
81  ~TTVSession();
82  virtual const char *GetName() const {return fName;}
83  void SetName(const char *name) {fName = name;}
84  void SetRecordName(const char* name);
85  TTVRecord *AddRecord(Bool_t fromFile = kFALSE);
86  Int_t GetEntries() {return fRecords;}
87  TTVRecord *GetCurrent() {return GetRecord(fCurrent);}
88  TTVRecord *GetRecord(Int_t i);
89  TTVRecord *First() {return GetRecord(0);}
90  TTVRecord *Last() {return GetRecord(fRecords-1);}
91  TTVRecord *Next() {return GetRecord(fCurrent+1);}
92  TTVRecord *Previous() {return GetRecord(fCurrent-1);}
93 
94  void RemoveLastRecord();
95  void Show(TTVRecord *rec);
96  void SaveSource(std::ofstream &out);
97  void UpdateRecord(const char *name);
98 
99  ClassDef(TTVSession, 0) // A tree viewer session
100 };
101 
102 #endif