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   16/08/00
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_TTreeViewer
0013 #define ROOT_TTreeViewer
0014 
0015 ////////////////////////////////////////////////////
0016 //                                                //
0017 // TTreeViewer - A GUI oriented tree viewer       //
0018 //                                                //
0019 ////////////////////////////////////////////////////
0020 
0021 #include "TGFrame.h"
0022 
0023 #include "TTree.h"
0024 
0025 class TTVLVContainer;
0026 class TTVLVEntry;
0027 class TTVSession;
0028 class TGSelectBox;
0029 class TBranch;
0030 class TContextMenu;
0031 class TList;
0032 class TGPicture;
0033 class TTimer;
0034 class TGLayoutHints;
0035 class TGMenuBar;
0036 class TGPopupMenu;
0037 class TGToolBar;
0038 class TGLabel;
0039 class TGCheckButton;
0040 class TGComboBox;
0041 class TGTextButton;
0042 class TGTextEntry;
0043 class TGDoubleVSlider;
0044 class TGPictureButton;
0045 class TGStatusBar;
0046 class TGCanvas;
0047 class TGListTree;
0048 class TGListTreeItem;
0049 class TGListView;
0050 class TGHProgressBar;
0051 class TGButton;
0052 
0053 
0054 class TTreeViewer : public TGMainFrame {
0055 
0056 friend class TGClient;
0057 friend class TGButton;
0058 
0059 public:
0060    /// Item types used as user data
0061    enum EListItemType {
0062       kLTNoType            = 0,
0063       kLTPackType          = BIT(0),
0064       kLTTreeType          = BIT(1),
0065       kLTBranchType        = BIT(2),
0066       kLTLeafType          = BIT(3),
0067       kLTActionType        = BIT(4),
0068       kLTDragType          = BIT(5),
0069       kLTExpressionType    = BIT(6),
0070       kLTCutType           = BIT(7)
0071    };
0072 
0073 private:
0074 
0075 ///@{
0076    TTree                *fTree;                 ///< Selected tree
0077    TTVSession           *fSession;              ///< Current tree-viewer session
0078    const char           *fFilename;             ///< Name of the file containing the tree
0079    const char           *fSourceFile;           ///< Name of the C++ source file - default treeviewer.C
0080    TString              fLastOption;            ///< Last graphic option
0081    TTree                *fMappedTree;           ///< Listed tree
0082    TBranch              *fMappedBranch;         ///< Listed branch
0083    Int_t                fDimension;             ///< Histogram dimension
0084    bool                 fVarDraw;               ///< True if an item is double-clicked
0085    bool                 fScanMode;              ///< Flag activated when Scan Box is double-clicked
0086    TContextMenu         *fContextMenu;          ///< Context menu for tree viewer
0087    TGSelectBox          *fDialogBox;            ///< Expression editor
0088    TList                *fTreeList;             ///< List of mapped trees
0089    Int_t                fTreeIndex;             ///< Index of current tree in list
0090    const TGPicture      *fPicX;                 ///< Pictures for X expressions
0091    const TGPicture      *fPicY;                 ///< Pictures for Y expressions
0092    const TGPicture      *fPicZ;                 ///< Pictures for Z expressions
0093    const TGPicture      *fPicDraw;              ///< Pictures for Draw buttons
0094    const TGPicture      *fPicStop;              ///< Pictures for Stop buttons
0095    const TGPicture      *fPicRefr;              ///< Pictures for Refresh buttons ///<ia
0096    Cursor_t             fDefaultCursor;         ///< Default cursor
0097    Cursor_t             fWatchCursor;           ///< Watch cursor
0098    TTimer               *fTimer;                ///< Tree viewer timer
0099    bool                 fCounting;              ///< True if timer is counting
0100    bool                 fStopMapping;           ///< True if branch don't need remapping
0101    bool                 fEnableCut;             ///< True if cuts are enabled
0102    Int_t                fNexpressions;          ///< Number of expression widgets
0103 ///@}
0104 
0105 ///@{
0106 /// @name Menu bar, menu bar entries and layouts
0107    TGLayoutHints        *fMenuBarLayout;
0108    TGLayoutHints        *fMenuBarItemLayout;
0109    TGLayoutHints        *fMenuBarHelpLayout;
0110    TGMenuBar            *fMenuBar;
0111    TGPopupMenu          *fFileMenu;
0112    TGPopupMenu          *fEditMenu;
0113    TGPopupMenu          *fRunMenu;
0114    TGPopupMenu          *fOptionsMenu;
0115    TGPopupMenu          *fOptionsGen;
0116    TGPopupMenu          *fOptions1D;
0117    TGPopupMenu          *fOptions2D;
0118    TGPopupMenu          *fHelpMenu;
0119 ///@}
0120 
0121 ///@{
0122 /// @name Toolbar and hints
0123    TGToolBar            *fToolBar;
0124    TGLayoutHints        *fBarLayout;
0125 ///@}
0126 
0127 ///@{
0128 /// @name Widgets on the toolbar
0129    TGLabel              *fBarLbl1;      ///< Label of command text entry
0130    TGLabel              *fBarLbl2;      ///< Label of option text entry
0131    TGLabel              *fBarLbl3;      ///< Label of histogram name text entry
0132    TGCheckButton        *fBarH;         ///< Checked for drawing current histogram with different graphic option
0133    TGCheckButton        *fBarScan;      ///< Checked for tree scan
0134    TGCheckButton        *fBarRec;       ///< Command recording toggle
0135    TGTextEntry          *fBarCommand;   ///< User command entry
0136    TGTextEntry          *fBarOption;    ///< Histogram drawing option entry
0137    TGTextEntry          *fBarHist;      ///< Histogram name entry
0138 ///@}
0139 
0140 ///@{
0141 /// @name Frames
0142    TGHorizontalFrame    *fHf;           ///< Main horizontal frame
0143    TGDoubleVSlider      *fSlider;       ///< Vertical slider to select processed tree entries;
0144    TGVerticalFrame      *fV1;           ///< List tree mother
0145    TGVerticalFrame      *fV2;           ///< List view mother
0146    TGCompositeFrame     *fTreeHdr;      ///< Header for list tree
0147    TGCompositeFrame     *fListHdr;      ///< Header for list view
0148    TGLabel              *fLbl1;         ///< Label for list tree
0149    TGLabel              *fLbl2;         ///< Label for list view
0150    TGHorizontalFrame    *fBFrame;       ///< Button frame
0151    TGHorizontalFrame    *fHpb;          ///< Progress bar frame
0152    TGHProgressBar       *fProgressBar;  ///< Progress bar
0153    TGLabel              *fBLbl4;        ///< Label for input list entry
0154    TGLabel              *fBLbl5;        ///< Label for output list entry
0155    TGTextEntry          *fBarListIn;    ///< Tree input event list name entry
0156    TGTextEntry          *fBarListOut;   ///< Pree output event list name entry
0157    TGPictureButton      *fDRAW;         ///< DRAW button
0158    TGTextButton         *fSPIDER;       ///< SPIDER button
0159    TGPictureButton      *fSTOP;         ///< Interrupt current command (not yet)
0160    TGPictureButton      *fREFR;         ///< REFRESH button  ///<ia
0161    TGStatusBar          *fStatusBar;    ///< Status bar
0162    TGComboBox           *fCombo;        ///< Combo box with session records
0163    TGPictureButton      *fBGFirst;
0164    TGPictureButton      *fBGPrevious;
0165    TGPictureButton      *fBGRecord;
0166    TGPictureButton      *fBGNext;
0167    TGPictureButton      *fBGLast;
0168    TGTextButton         *fReset;        ///< clear expression's entries
0169 ///@}
0170 
0171 ///@{
0172 /// @name  ListTree
0173    TGCanvas             *fTreeView;     ///< ListTree canvas container
0174    TGListTree           *fLt;           ///< ListTree with file and tree items
0175 ///@}
0176 
0177 ///@{
0178 /// @name ListView
0179    TGListView           *fListView;     ///< ListView with branches and leaves
0180    TTVLVContainer       *fLVContainer;  ///< Container for listview
0181 
0182    TList                *fWidgets;      ///< List of widgets to be deleted
0183 ///@}
0184 
0185 
0186 private:
0187 
0188    void          BuildInterface();
0189    const char   *Cut();
0190    Int_t         Dimension();
0191    const char   *EmptyBrackets(const char* name);
0192    const char   *Ex();
0193    const char   *Ey();
0194    const char   *Ez();
0195    const char   *En(Int_t n);
0196    void          MapBranch(TBranch *branch, const char *prefix="", TGListTreeItem *parent = nullptr, bool listIt = true);
0197    void          MapOptions(Long_t parm1);
0198    void          MapTree(TTree *tree, TGListTreeItem *parent = nullptr, bool listIt = true);
0199    void          SetFile();
0200    const char   *ScanList();
0201    void          SetParentTree(TGListTreeItem *item);
0202    void          DoError(int level, const char *location, const char *fmt, va_list va) const override;
0203 
0204 public:
0205    TTreeViewer(const char* treeName = nullptr);
0206    TTreeViewer(const TTree *tree);
0207          ~TTreeViewer() override;
0208 
0209    void          AppendTree(TTree *tree);
0210    void          ActivateButtons(bool first, bool previous,
0211                                  bool next , bool last);
0212    void  CloseWindow() override;
0213    void  Delete(Option_t *) override { }                          // *MENU*
0214    void          DoRefresh();
0215    void          EditExpression();
0216    void          Empty();
0217    void          EmptyAll();                                     // *MENU*
0218    void          ExecuteCommand(const char* command, bool fast = false); // *MENU*
0219    void          ExecuteDraw();
0220    void          ExecuteSpider();
0221    TTVLVEntry   *ExpressionItem(Int_t index);
0222    TList        *ExpressionList();
0223    const char   *GetGrOpt();
0224    TTree        *GetTree() {return fTree;}
0225    bool          HandleTimer(TTimer *timer) override;
0226    bool          IsCutEnabled() {return fEnableCut;}
0227    bool          IsScanRedirected();
0228    Int_t         MakeSelector(const char* selector = nullptr);         // *MENU*
0229    void          Message(const char* msg) override;
0230    void          NewExpression();                                // *MENU*
0231    void          PrintEntries();
0232    Long64_t      Process(const char* filename, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0); // *MENU*
0233    bool          ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0234    void          RemoveItem();
0235    void          RemoveLastRecord();                             // *MENU*
0236    void          SaveSource(const char* filename="", Option_t *option="") override;            // *MENU*
0237    void          SetHistogramTitle(const char *title);
0238    void          SetCutMode(bool enabled = true) {fEnableCut = enabled;}
0239    void          SetCurrentRecord(Long64_t entry);
0240    void          SetGrOpt(const char *option);
0241    void          SetNexpressions(Int_t expr);
0242    void          SetRecordName(const char *name);                // *MENU*
0243    void          SetScanFileName(const char *name="");           // *MENU*
0244    void          SetScanMode(bool mode=true) {fScanMode = mode;}
0245    void          SetScanRedirect(bool mode);
0246    void          SetSession(TTVSession *session);
0247    void          SetUserCode(const char *code, bool autoexec=true); // *MENU*
0248    void          SetTree(TTree* tree);
0249    void          SetTreeName(const char* treeName);              // *MENU*
0250    bool          SwitchTree(Int_t index);
0251    void          UpdateCombo();
0252    void          UpdateRecord(const char *name="new name");      // *MENU*
0253 
0254    ClassDefOverride(TTreeViewer,0)  // A GUI oriented tree viewer
0255 };
0256 
0257 #endif