Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:31

0001 // @(#)root/treeviewer:$Id$
0002 //Author : Andrei Gheata   21/02/01
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TTVSession
0013 #define ROOT_TTVSession
0014 
0015 ///////////////////////////////////////////////////////////////////////////////
0016 //                                                                           //
0017 // TTVSession and TTVRecord - I/O classes for TreeViewer session handling    //
0018 //     TTreeViewer                                                           //
0019 //                                                                           //
0020 ///////////////////////////////////////////////////////////////////////////////
0021 
0022 #include "TObject.h"
0023 #include "TString.h"
0024 
0025 class TTreeViewer;
0026 class TClonesArray;
0027 class TGVButtonGroup;
0028 
0029 class TTVRecord : public TObject {
0030 
0031 public:
0032    TString              fName;                  ///< Name of this record
0033    TString              fX;                     ///< X expression
0034    TString              fXAlias;                ///< X alias
0035    TString              fY;                     ///< Y expression
0036    TString              fYAlias;                ///< Y alias
0037    TString              fZ;                     ///< Z expression
0038    TString              fZAlias;                ///< Z alias
0039    TString              fCut;                   ///< Cut expression
0040    TString              fCutAlias;              ///< Cut alias
0041    TString              fOption;                ///< Graphic option
0042    bool                 fScanRedirected;        ///< Redirect switch
0043    bool                 fCutEnabled;            ///< True if current cut is active
0044    TString              fUserCode;              ///< Command executed when record is connected
0045    bool                 fAutoexec;              ///< Autoexecute user code command
0046 
0047 public:
0048    TTVRecord();                                 ///< Default constructor
0049    ~TTVRecord() override {}                              ///< Destructor
0050 
0051    void           ExecuteUserCode();
0052    void           FormFrom(TTreeViewer *tv);
0053    void           PlugIn(TTreeViewer *tv);
0054    const char    *GetX() const {return fX;}
0055    const char    *GetY() const {return fY;}
0056    const char    *GetZ() const {return fZ;}
0057    const char *GetName() const override {return fName;}
0058    const char    *GetUserCode() const {return fUserCode;}
0059    bool           HasUserCode() const {return fUserCode.Length() != 0 ? true : false;}
0060    bool           MustExecuteCode() const {return fAutoexec;}
0061    void           SetAutoexec(bool autoexec=true) {fAutoexec=autoexec;} // *TOGGLE* *GETTER=MustExecuteCode
0062    void           SetName(const char* name = "") {fName = name;}
0063    void           SetX(const char *x = "", const char *xal = "-empty-") {fX = x; fXAlias = xal;}
0064    void           SetY(const char *y = "", const char *yal = "-empty-") {fY = y; fYAlias = yal;}
0065    void           SetZ(const char *z = "", const char *zal = "-empty-") {fZ = z; fZAlias = zal;}
0066    void           SetCut(const char *cut = "", const char *cal = "-empty-") {fCut = cut; fCutAlias = cal;}
0067    void           SetOption(const char *option = "")             {fOption = option;}
0068    void           SetRC(bool redirect = false, bool cut = true) {fScanRedirected = redirect; fCutEnabled = cut;}
0069    void           SetUserCode(const char *code, bool autoexec=true) {fUserCode = code; fAutoexec=autoexec;} // *MENU*
0070    void           SaveSource(std::ofstream &out);
0071 
0072    ClassDefOverride(TTVRecord, 0)    // A draw record for TTreeViewer
0073 };
0074 
0075 class TTVSession : public TObject {
0076 
0077 private:
0078    TClonesArray  *fList;                        ///< List of TV records
0079    TString        fName;                        ///< Name of this session
0080    TTreeViewer   *fViewer;                      ///< Associated tree viewer
0081    Int_t          fCurrent;                     ///< Index of current record
0082    Int_t          fRecords;                     ///< Number of records
0083 
0084 public:
0085    TTVSession(TTreeViewer *tv);
0086    ~TTVSession() override;
0087    const char *GetName() const override      {return fName;}
0088    void           SetName(const char *name) {fName = name;}
0089    void           SetRecordName(const char* name);
0090    TTVRecord     *AddRecord(bool fromFile = false);
0091    Int_t          GetEntries() {return fRecords;}
0092    TTVRecord     *GetCurrent() {return GetRecord(fCurrent);}
0093    TTVRecord     *GetRecord(Int_t i);
0094    TTVRecord     *First()    {return GetRecord(0);}
0095    TTVRecord     *Last()     {return GetRecord(fRecords-1);}
0096    TTVRecord     *Next()     {return GetRecord(fCurrent+1);}
0097    TTVRecord     *Previous() {return GetRecord(fCurrent-1);}
0098 
0099    void           RemoveLastRecord();
0100    void           Show(TTVRecord *rec);
0101    void           SaveSource(std::ofstream &out);
0102    void           UpdateRecord(const char *name);
0103 
0104    ClassDefOverride(TTVSession, 0)   // A tree viewer session
0105 };
0106 
0107 #endif