Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TTreeViewer.h
Go to the documentation of this file.
1 // @(#)root/treeviewer:$Id$
2 //Author : Andrei Gheata 16/08/00
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_TTreeViewer
13 #define ROOT_TTreeViewer
14 
15 ////////////////////////////////////////////////////
16 // //
17 // TTreeViewer - A GUI oriented tree viewer //
18 // //
19 ////////////////////////////////////////////////////
20 
21 #include "TGFrame.h"
22 
23 #include "TTree.h"
24 
25 class TTVLVContainer;
26 class TTVLVEntry;
27 class TTVSession;
28 class TGSelectBox;
29 class TBranch;
30 class TContextMenu;
31 class TList;
32 class TGPicture;
33 class TTimer;
34 class TGLayoutHints;
35 class TGMenuBar;
36 class TGPopupMenu;
37 class TGToolBar;
38 class TGLabel;
39 class TGCheckButton;
40 class TGComboBox;
41 class TGTextButton;
42 class TGTextEntry;
43 class TGDoubleVSlider;
44 class TGPictureButton;
45 class TGStatusBar;
46 class TGCanvas;
47 class TGListTree;
48 class TGListTreeItem;
49 class TGListView;
50 class TGHProgressBar;
51 class TGButton;
52 
53 
54 class TTreeViewer : public TGMainFrame {
55 
56 friend class TGClient;
57 friend class TGButton;
58 
59 public:
60  //---- item types used as user data
61  enum EListItemType {
62  kLTNoType = 0,
63  kLTPackType = BIT(0),
64  kLTTreeType = BIT(1),
65  kLTBranchType = BIT(2),
66  kLTLeafType = BIT(3),
67  kLTActionType = BIT(4),
68  kLTDragType = BIT(5),
69  kLTExpressionType = BIT(6),
70  kLTCutType = BIT(7)
71  };
72 
73 private:
74  TTree *fTree; // selected tree
75  TTVSession *fSession; // current tree-viewer session
76  const char *fFilename; // name of the file containing the tree
77  const char *fSourceFile; // name of the C++ source file - default treeviewer.C
78  TString fLastOption; // last graphic option
79  TTree *fMappedTree; // listed tree
80  TBranch *fMappedBranch; // listed branch
81  Int_t fDimension; // histogram dimension
82  Bool_t fVarDraw; // true if an item is double-clicked
83  Bool_t fScanMode; // flag activated when Scan Box is double-clicked
84  TContextMenu *fContextMenu; // context menu for tree viewer
85  TGSelectBox *fDialogBox; // expression editor
86  TList *fTreeList; // list of mapped trees
87  Int_t fTreeIndex; // index of current tree in list
88  const TGPicture *fPicX, *fPicY, *fPicZ; // pictures for X, Y and Z expressions
89  const TGPicture *fPicDraw, *fPicStop; // pictures for Draw/Stop buttons
90  const TGPicture *fPicRefr; // pictures for Refresh buttons //ia
91  Cursor_t fDefaultCursor; // default cursor
92  Cursor_t fWatchCursor; // watch cursor
93  TTimer *fTimer; // tree viewer timer
94  Bool_t fCounting; // true if timer is counting
95  Bool_t fStopMapping; // true if branch don't need remapping
96  Bool_t fEnableCut; // true if cuts are enabled
97  Int_t fNexpressions; // number of expression widgets
98 // menu bar, menu bar entries and layouts
99  TGLayoutHints *fMenuBarLayout;
100  TGLayoutHints *fMenuBarItemLayout;
101  TGLayoutHints *fMenuBarHelpLayout;
102  TGMenuBar *fMenuBar;
103  TGPopupMenu *fFileMenu;
104  TGPopupMenu *fEditMenu;
105  TGPopupMenu *fRunMenu;
106  TGPopupMenu *fOptionsMenu;
107  TGPopupMenu *fOptionsGen;
108  TGPopupMenu *fOptions1D;
109  TGPopupMenu *fOptions2D;
110  TGPopupMenu *fHelpMenu;
111 // toolbar and hints
112  TGToolBar *fToolBar;
113  TGLayoutHints *fBarLayout;
114 // widgets on the toolbar
115  TGLabel *fBarLbl1; // label of command text entry
116  TGLabel *fBarLbl2; // label of option text entry
117  TGLabel *fBarLbl3; // label of histogram name text entry
118  TGCheckButton *fBarH; // checked for drawing current histogram with different graphic option
119  TGCheckButton *fBarScan; // checked for tree scan
120  TGCheckButton *fBarRec; // command recording toggle
121  TGTextEntry *fBarCommand; // user command entry
122  TGTextEntry *fBarOption; // histogram drawing option entry
123  TGTextEntry *fBarHist; // histogram name entry
124 // frames
125  TGHorizontalFrame *fHf; // main horizontal frame
126  TGDoubleVSlider *fSlider; // vertical slider to select processed tree entries;
127  TGVerticalFrame *fV1; // list tree mother
128  TGVerticalFrame *fV2; // list view mother
129  TGCompositeFrame *fTreeHdr; // header for list tree
130  TGCompositeFrame *fListHdr; // header for list view
131  TGLabel *fLbl1; // label for list tree
132  TGLabel *fLbl2; // label for list view
133  TGHorizontalFrame *fBFrame; // button frame
134  TGHorizontalFrame *fHpb; // progress bar frame
135  TGHProgressBar *fProgressBar; // progress bar
136  TGLabel *fBLbl4; // label for input list entry
137  TGLabel *fBLbl5; // label for output list entry
138  TGTextEntry *fBarListIn; // tree input event list name entry
139  TGTextEntry *fBarListOut; // tree output event list name entry
140  TGPictureButton *fDRAW; // DRAW button
141  TGTextButton *fSPIDER; // SPIDER button
142  TGPictureButton *fSTOP; // interrupt current command (not yet)
143  TGPictureButton *fREFR; // REFRESH button //ia
144  TGStatusBar *fStatusBar; // status bar
145  TGComboBox *fCombo; // combo box with session records
146  TGPictureButton *fBGFirst;
147  TGPictureButton *fBGPrevious;
148  TGPictureButton *fBGRecord;
149  TGPictureButton *fBGNext;
150  TGPictureButton *fBGLast;
151  TGTextButton *fReset; // clear expression's entries
152 // ListTree
153  TGCanvas *fTreeView; // ListTree canvas container
154  TGListTree *fLt; // ListTree with file and tree items
155 // ListView
156  TGListView *fListView; // ListView with branches and leaves
157  TTVLVContainer *fLVContainer; // container for listview
158 
159  TList *fWidgets; // list of widgets to be deleted
160 
161 private:
162 // private methods
163  void BuildInterface();
164  const char *Cut();
165  Int_t Dimension();
166  const char *EmptyBrackets(const char* name);
167  const char *Ex();
168  const char *Ey();
169  const char *Ez();
170  const char *En(Int_t n);
171  void MapBranch(TBranch *branch, const char *prefix="", TGListTreeItem *parent = 0, Bool_t listIt = kTRUE);
172  void MapOptions(Long_t parm1);
173  void MapTree(TTree *tree, TGListTreeItem *parent = 0, Bool_t listIt = kTRUE);
174  void SetFile();
175  const char *ScanList();
176  void SetParentTree(TGListTreeItem *item);
177  void DoError(int level, const char *location, const char *fmt, va_list va) const;
178 
179 public:
180  TTreeViewer(const char* treeName = 0);
181  TTreeViewer(const TTree *tree);
182  virtual ~TTreeViewer();
183 // public methods
184  void AppendTree(TTree *tree);
185  void ActivateButtons(Bool_t first, Bool_t previous,
186  Bool_t next , Bool_t last);
187  virtual void CloseWindow();
188  virtual void Delete(Option_t *) { } // *MENU*
189  void DoRefresh();
190  void EditExpression();
191  void Empty();
192  void EmptyAll(); // *MENU*
193  void ExecuteCommand(const char* command, Bool_t fast = kFALSE); // *MENU*
194  void ExecuteDraw();
195  void ExecuteSpider();
196  TTVLVEntry *ExpressionItem(Int_t index);
197  TList *ExpressionList();
198  const char *GetGrOpt();
199  TTree *GetTree() {return fTree;}
200  Bool_t HandleTimer(TTimer *timer);
201  Bool_t IsCutEnabled() {return fEnableCut;}
202  Bool_t IsScanRedirected();
203  Int_t MakeSelector(const char* selector = 0); // *MENU*
204  void Message(const char* msg);
205  void NewExpression(); // *MENU*
206  void PrintEntries();
207  Long64_t Process(const char* filename, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0); // *MENU*
208  Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
209  void RemoveItem();
210  void RemoveLastRecord(); // *MENU*
211  void SaveSource(const char* filename="", Option_t *option=""); // *MENU*
212  void SetHistogramTitle(const char *title);
213  void SetCutMode(Bool_t enabled = kTRUE) {fEnableCut = enabled;}
214  void SetCurrentRecord(Long64_t entry);
215  void SetGrOpt(const char *option);
216  void SetNexpressions(Int_t expr);
217  void SetRecordName(const char *name); // *MENU*
218  void SetScanFileName(const char *name=""); // *MENU*
219  void SetScanMode(Bool_t mode=kTRUE) {fScanMode = mode;}
220  void SetScanRedirect(Bool_t mode);
221  void SetSession(TTVSession *session);
222  void SetUserCode(const char *code, Bool_t autoexec=kTRUE); // *MENU*
223  void SetTree(TTree* tree);
224  void SetTreeName(const char* treeName); // *MENU*
225  Bool_t SwitchTree(Int_t index);
226  void UpdateCombo();
227  void UpdateRecord(const char *name="new name"); // *MENU*
228 
229  ClassDef(TTreeViewer,0) // A GUI oriented tree viewer
230 };
231 
232 #endif