ROOT  6.06/09
Reference Guide
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 #ifndef ROOT_TGFrame
22 #include "TGFrame.h"
23 #endif
24 
25 #ifndef ROOT_TTree
26 #include "TTree.h"
27 #endif
28 
29 class TTreeViewer;
30 class TTVLVContainer;
31 class TTVLVEntry;
32 class TTVSession;
33 class TGSelectBox;
34 class TTree;
35 class TBranch;
36 class TContextMenu;
37 class TList;
38 class TGPicture;
39 class TTimer;
40 class TGLayoutHints;
41 class TGMenuBar;
42 class TGPopupMenu;
43 class TGToolBar;
44 class TGLabel;
45 class TGCheckButton;
46 class TGComboBox;
47 class TGTextButton;
48 class TGTextEntry;
49 class TGDoubleVSlider;
50 class TGPictureButton;
51 class TGStatusBar;
52 class TGCanvas;
53 class TGListTree;
54 class TGListTreeItem;
55 class TGListView;
56 class TGHProgressBar;
57 class TGButton;
58 
59 
60 class TTreeViewer : public TGMainFrame {
61 
62 friend class TGClient;
63 friend class TGButton;
64 
65 public:
66  //---- item types used as user data
68  kLTNoType = 0,
77  };
78 
79 private:
80  TTree *fTree; // selected tree
81  TTVSession *fSession; // current tree-viewer session
82  const char *fFilename; // name of the file containing the tree
83  const char *fSourceFile; // name of the C++ source file - default treeviewer.C
84  TString fLastOption; // last graphic option
85  TTree *fMappedTree; // listed tree
86  TBranch *fMappedBranch; // listed branch
87  Int_t fDimension; // histogram dimension
88  Bool_t fVarDraw; // true if an item is double-clicked
89  Bool_t fScanMode; // flag activated when Scan Box is double-clicked
90  TContextMenu *fContextMenu; // context menu for tree viewer
91  TGSelectBox *fDialogBox; // expression editor
92  TList *fTreeList; // list of mapped trees
93  Int_t fTreeIndex; // index of current tree in list
94  const TGPicture *fPicX, *fPicY, *fPicZ; // pictures for X, Y and Z expressions
95  const TGPicture *fPicDraw, *fPicStop; // pictures for Draw/Stop buttons
96  const TGPicture *fPicRefr; // pictures for Refresh buttons //ia
97  Cursor_t fDefaultCursor; // default cursor
98  Cursor_t fWatchCursor; // watch cursor
99  TTimer *fTimer; // tree viewer timer
100  Bool_t fCounting; // true if timer is counting
101  Bool_t fStopMapping; // true if branch don't need remapping
102  Bool_t fEnableCut; // true if cuts are enabled
103  Int_t fNexpressions; // number of expression widgets
104 // menu bar, menu bar entries and layouts
117 // toolbar and hints
120 // widgets on the toolbar
121  TGLabel *fBarLbl1; // label of command text entry
122  TGLabel *fBarLbl2; // label of option text entry
123  TGLabel *fBarLbl3; // label of histogram name text entry
124  TGCheckButton *fBarH; // checked for drawing current histogram with different graphic option
125  TGCheckButton *fBarScan; // checked for tree scan
126  TGCheckButton *fBarRec; // command recording toggle
127  TGTextEntry *fBarCommand; // user command entry
128  TGTextEntry *fBarOption; // histogram drawing option entry
129  TGTextEntry *fBarHist; // histogram name entry
130 // frames
131  TGHorizontalFrame *fHf; // main horizontal frame
132  TGDoubleVSlider *fSlider; // vertical slider to select processed tree entries;
133  TGVerticalFrame *fV1; // list tree mother
134  TGVerticalFrame *fV2; // list view mother
135  TGCompositeFrame *fTreeHdr; // header for list tree
136  TGCompositeFrame *fListHdr; // header for list view
137  TGLabel *fLbl1; // label for list tree
138  TGLabel *fLbl2; // label for list view
139  TGHorizontalFrame *fBFrame; // button frame
140  TGHorizontalFrame *fHpb; // progress bar frame
141  TGHProgressBar *fProgressBar; // progress bar
142  TGLabel *fBLbl4; // label for input list entry
143  TGLabel *fBLbl5; // label for output list entry
144  TGTextEntry *fBarListIn; // tree input event list name entry
145  TGTextEntry *fBarListOut; // tree output event list name entry
146  TGPictureButton *fDRAW; // DRAW button
147  TGTextButton *fSPIDER; // SPIDER button
148  TGPictureButton *fSTOP; // interrupt current command (not yet)
149  TGPictureButton *fREFR; // REFRESH button //ia
150  TGStatusBar *fStatusBar; // status bar
151  TGComboBox *fCombo; // combo box with session records
157  TGTextButton *fReset; // clear expression's entries
158 // ListTree
159  TGCanvas *fTreeView; // ListTree canvas container
160  TGListTree *fLt; // ListTree with file and tree items
161 // ListView
162  TGListView *fListView; // ListView with branches and leaves
163  TTVLVContainer *fLVContainer; // container for listview
164 
165  TList *fWidgets; // list of widgets to be deleted
166 
167 private:
168 // private methods
169  void BuildInterface();
170  const char *Cut();
171  Int_t Dimension();
172  const char *EmptyBrackets(const char* name);
173  const char *Ex();
174  const char *Ey();
175  const char *Ez();
176  const char *En(Int_t n);
177  void MapBranch(TBranch *branch, const char *prefix="", TGListTreeItem *parent = 0, Bool_t listIt = kTRUE);
178  void MapOptions(Long_t parm1);
179  void MapTree(TTree *tree, TGListTreeItem *parent = 0, Bool_t listIt = kTRUE);
180  void SetFile();
181  const char *ScanList();
182  void SetParentTree(TGListTreeItem *item);
183  void DoError(int level, const char *location, const char *fmt, va_list va) const;
184 
185 public:
186  TTreeViewer(const char* treeName = 0);
187  TTreeViewer(const TTree *tree);
188  virtual ~TTreeViewer();
189 // public methods
190  void AppendTree(TTree *tree);
191  void ActivateButtons(Bool_t first, Bool_t previous,
192  Bool_t next , Bool_t last);
193  virtual void CloseWindow();
194  virtual void Delete(Option_t *) { } // *MENU*
195  void DoRefresh();
196  void EditExpression();
197  void Empty();
198  void EmptyAll(); // *MENU*
199  void ExecuteCommand(const char* command, Bool_t fast = kFALSE); // *MENU*
200  void ExecuteDraw();
201  void ExecuteSpider();
204  const char *GetGrOpt();
205  TTree *GetTree() {return fTree;}
209  Int_t MakeSelector(const char* selector = 0); // *MENU*
210  void Message(const char* msg);
211  void NewExpression(); // *MENU*
212  void PrintEntries();
213  Long64_t Process(const char* filename, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0); // *MENU*
214  Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
215  void RemoveItem();
216  void RemoveLastRecord(); // *MENU*
217  void SaveSource(const char* filename="", Option_t *option=""); // *MENU*
218  void SetHistogramTitle(const char *title);
219  void SetCutMode(Bool_t enabled = kTRUE) {fEnableCut = enabled;}
221  void SetGrOpt(const char *option);
222  void SetNexpressions(Int_t expr);
223  void SetRecordName(const char *name); // *MENU*
224  void SetScanFileName(const char *name=""); // *MENU*
225  void SetScanMode(Bool_t mode=kTRUE) {fScanMode = mode;}
226  void SetScanRedirect(Bool_t mode);
227  void SetSession(TTVSession *session);
228  void SetUserCode(const char *code, Bool_t autoexec=kTRUE); // *MENU*
229  void SetTree(TTree* tree);
230  void SetTreeName(const char* treeName); // *MENU*
231  Bool_t SwitchTree(Int_t index);
232  void UpdateCombo();
233  void UpdateRecord(const char *name="new name"); // *MENU*
234 
235  ClassDef(TTreeViewer,0) // A GUI oriented tree viewer
236 };
237 
238 #endif
TGTextButton * fSPIDER
Definition: TTreeViewer.h:147
TGPictureButton * fBGPrevious
Definition: TTreeViewer.h:153
TGPictureButton * fSTOP
Definition: TTreeViewer.h:148
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other commands generated.
void Empty()
Empty the content of the selected expression.
TTVSession * fSession
Definition: TTreeViewer.h:81
void SetNexpressions(Int_t expr)
Change the number of expression widgets.
Int_t fNexpressions
Definition: TTreeViewer.h:103
long long Long64_t
Definition: RtypesCore.h:69
TGCheckButton * fBarH
Definition: TTreeViewer.h:124
TGPictureButton * fBGRecord
Definition: TTreeViewer.h:154
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
void ExecuteDraw()
Called when the DRAW button is executed.
TGLayoutHints * fBarLayout
Definition: TTreeViewer.h:119
const TGPicture * fPicRefr
Definition: TTreeViewer.h:96
void SetRecordName(const char *name)
Set record name.
const char Option_t
Definition: RtypesCore.h:62
void NewExpression()
Create new expression.
TTree * GetTree()
Definition: TTreeViewer.h:205
void PrintEntries()
Print the number of selected entries on status-bar.
TGLabel * fLbl2
Definition: TTreeViewer.h:138
#define BIT(n)
Definition: Rtypes.h:120
Handle_t Cursor_t
Definition: GuiTypes.h:35
TGMenuBar * fMenuBar
Definition: TTreeViewer.h:108
void SetUserCode(const char *code, Bool_t autoexec=kTRUE)
user defined command for current record
void UpdateCombo()
Updates combo box to current session entries.
static const char * filename()
const char * Ex()
Get the expression to be drawn on X axis.
void DoRefresh()
This slot is called when button REFR is clicked.
void ActivateButtons(Bool_t first, Bool_t previous, Bool_t next, Bool_t last)
Enable/disable session buttons.
void SetParentTree(TGListTreeItem *item)
Find parent tree of a clicked item.
TGHorizontalFrame * fBFrame
Definition: TTreeViewer.h:139
TGLabel * fBarLbl2
Definition: TTreeViewer.h:122
Basic string class.
Definition: TString.h:137
void SetTreeName(const char *treeName)
Allow geting the tree from the context menu.
void SetScanMode(Bool_t mode=kTRUE)
Definition: TTreeViewer.h:225
TGPictureButton * fREFR
Definition: TTreeViewer.h:149
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
TGHProgressBar * fProgressBar
Definition: TTreeViewer.h:141
const char * fFilename
Definition: TTreeViewer.h:82
void MapOptions(Long_t parm1)
Scan the selected options from option menu.
TGCheckButton * fBarRec
Definition: TTreeViewer.h:126
Int_t MakeSelector(const char *selector=0)
Get use of TTree::MakeSelector() via the context menu.
const char * EmptyBrackets(const char *name)
Empty the bracket content of a string.
void EditExpression()
Start the expression editor.
void Message(const char *msg)
Send a message on the status bar.
TGLabel * fBarLbl1
Definition: TTreeViewer.h:121
TList * fTreeList
Definition: TTreeViewer.h:92
TGLabel * fBLbl4
Definition: TTreeViewer.h:142
const TGPicture * fPicStop
Definition: TTreeViewer.h:95
TContextMenu * fContextMenu
Definition: TTreeViewer.h:90
TGPopupMenu * fFileMenu
Definition: TTreeViewer.h:109
TGPopupMenu * fOptionsGen
Definition: TTreeViewer.h:113
TGPictureButton * fBGNext
Definition: TTreeViewer.h:155
const char * fSourceFile
Definition: TTreeViewer.h:83
void SetCurrentRecord(Long64_t entry)
Set current record.
TGPopupMenu * fOptionsMenu
Definition: TTreeViewer.h:112
Bool_t SwitchTree(Int_t index)
Makes current the tree at a given index in the list.
void SaveSource(const char *filename="", Option_t *option="")
Save current session as a C++ macro file.
TStopwatch timer
Definition: pirndm.C:37
TGPopupMenu * fEditMenu
Definition: TTreeViewer.h:110
const char * Cut()
Apply Cut.
TGListTree * fLt
Definition: TTreeViewer.h:160
TGComboBox * fCombo
Definition: TTreeViewer.h:151
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t Dimension()
Compute dimension of the histogram.
void ExecuteSpider()
Draw a spider plot for the selected entries.
void DoError(int level, const char *location, const char *fmt, va_list va) const
Put error/warning into TMsgBox and also forward to console.
TList * fWidgets
Definition: TTreeViewer.h:165
Bool_t fCounting
Definition: TTreeViewer.h:100
TTimer * fTimer
Definition: TTreeViewer.h:99
TGToolBar * fToolBar
Definition: TTreeViewer.h:118
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features...
Definition: TTreeViewer.h:60
const char * GetGrOpt()
Get graph option.
Bool_t HandleTimer(TTimer *timer)
This function is called by the fTimer object.
TString fLastOption
Definition: TTreeViewer.h:84
TGCompositeFrame * fListHdr
Definition: TTreeViewer.h:136
Bool_t fVarDraw
Definition: TTreeViewer.h:88
TList * ExpressionList()
Get the list of expression items.
TGTextEntry * fBarOption
Definition: TTreeViewer.h:128
const char * Ez()
Get the expression to be drawn on Z axis.
TGTextEntry * fBarCommand
Definition: TTreeViewer.h:127
void SetTree(TTree *tree)
Assign the fTree member from existing tree, e.g.
A doubly linked list.
Definition: TList.h:47
TGListView * fListView
Definition: TTreeViewer.h:162
void SetFile()
Set file name containing the tree.
TTVLVContainer * fLVContainer
Definition: TTreeViewer.h:163
TGTextButton * fReset
Definition: TTreeViewer.h:157
void SetCutMode(Bool_t enabled=kTRUE)
Definition: TTreeViewer.h:219
TGHorizontalFrame * fHpb
Definition: TTreeViewer.h:140
Long64_t Process(const char *filename, Option_t *option="", Long64_t nentries=TTree::kMaxEntries, Long64_t firstentry=0)
Get use of TTree::Process() via the context menu.
void SetScanFileName(const char *name="")
Set the name of the file where to redirect output.
TTVLVEntry * ExpressionItem(Int_t index)
Get the item from a specific position.
This class represent entries that goes into the TreeViewer listview container.
const TGPicture * fPicX
Definition: TTreeViewer.h:94
Cursor_t fDefaultCursor
Definition: TTreeViewer.h:97
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
void SetSession(TTVSession *session)
Set current session.
TGCanvas * fTreeView
Definition: TTreeViewer.h:159
Bool_t fStopMapping
Definition: TTreeViewer.h:101
void RemoveLastRecord()
Remove the current record.
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
TGPictureButton * fBGLast
Definition: TTreeViewer.h:156
TTree * fMappedTree
Definition: TTreeViewer.h:85
TTreeViewer(const char *treeName=0)
void SetHistogramTitle(const char *title)
Set title of Histogram.
TGLayoutHints * fMenuBarHelpLayout
Definition: TTreeViewer.h:107
Long64_t entry
virtual ~TTreeViewer()
TTreeViewer destructor.
Bool_t IsCutEnabled()
Definition: TTreeViewer.h:207
Int_t fDimension
Definition: TTreeViewer.h:87
void RemoveItem()
Remove the selected item from the list.
void MapBranch(TBranch *branch, const char *prefix="", TGListTreeItem *parent=0, Bool_t listIt=kTRUE)
Map current branch and expand its content in the list view.
const TGPicture * fPicY
Definition: TTreeViewer.h:94
Cursor_t fWatchCursor
Definition: TTreeViewer.h:98
TTree * fTree
Definition: TTreeViewer.h:80
TGPictureButton * fBGFirst
Definition: TTreeViewer.h:152
TGCheckButton * fBarScan
Definition: TTreeViewer.h:125
TGLayoutHints * fMenuBarItemLayout
Definition: TTreeViewer.h:106
long Long_t
Definition: RtypesCore.h:50
TGHorizontalFrame * fHf
Definition: TTreeViewer.h:131
virtual void CloseWindow()
Close the viewer.
TGTextEntry * fBarListOut
Definition: TTreeViewer.h:145
TGTextEntry * fBarHist
Definition: TTreeViewer.h:129
TGVerticalFrame * fV2
Definition: TTreeViewer.h:134
void UpdateRecord(const char *name="new name")
Updates current record to new X, Y, Z items.
const TGPicture * fPicDraw
Definition: TTreeViewer.h:95
TGDoubleVSlider * fSlider
Definition: TTreeViewer.h:132
This class represent a specialized expression editor for TTVLVEntry 'true name' and 'alias' data memb...
int nentries
Definition: THbookFile.cxx:89
TGPopupMenu * fRunMenu
Definition: TTreeViewer.h:111
void AppendTree(TTree *tree)
Allow geting the tree from the context menu.
void BuildInterface()
Create all viewer widgets.
void ExecuteCommand(const char *command, Bool_t fast=kFALSE)
Execute all user commands.
const char * En(Int_t n)
Get the n'th expression.
TGPopupMenu * fOptions2D
Definition: TTreeViewer.h:115
TGLabel * fLbl1
Definition: TTreeViewer.h:137
Bool_t fEnableCut
Definition: TTreeViewer.h:102
#define name(a, b)
Definition: linkTestLib0.cpp:5
void SetGrOpt(const char *option)
Set graph option.
void SetScanRedirect(Bool_t mode)
Set the state of Scan check button.
I/O classes for TreeViewer session handling.
Definition: TTVSession.h:71
Bool_t fScanMode
Definition: TTreeViewer.h:89
const char * Ey()
Get the expression to be drawn on Y axis.
void MapTree(TTree *tree, TGListTreeItem *parent=0, Bool_t listIt=kTRUE)
Map current tree and expand its content (including friends) in the lists.
TGLabel * fBarLbl3
Definition: TTreeViewer.h:123
TGTextEntry * fBarListIn
Definition: TTreeViewer.h:144
TGLayoutHints * fMenuBarLayout
Definition: TTreeViewer.h:105
virtual void Delete(Option_t *)
Delete this object.
Definition: TTreeViewer.h:194
TGPictureButton * fDRAW
Definition: TTreeViewer.h:146
Int_t fTreeIndex
Definition: TTreeViewer.h:93
A TTree object has a header with a name and a title.
Definition: TTree.h:94
TGVerticalFrame * fV1
Definition: TTreeViewer.h:133
void EmptyAll()
Clear the content of all items in the list view.
TGSelectBox * fDialogBox
Definition: TTreeViewer.h:91
const char * ScanList()
returns scanlist
TGCompositeFrame * fTreeHdr
Definition: TTreeViewer.h:135
A TTree is a list of TBranches.
Definition: TBranch.h:58
TGPopupMenu * fHelpMenu
Definition: TTreeViewer.h:116
const Bool_t kTRUE
Definition: Rtypes.h:91
Bool_t IsScanRedirected()
Return kTRUE if scan is redirected.
const TGPicture * fPicZ
Definition: TTreeViewer.h:94
TGStatusBar * fStatusBar
Definition: TTreeViewer.h:150
const Int_t n
Definition: legend1.C:16
TBranch * fMappedBranch
Definition: TTreeViewer.h:86
TGPopupMenu * fOptions1D
Definition: TTreeViewer.h:114
static constexpr Long64_t kMaxEntries
Definition: TTree.h:217
TGLabel * fBLbl5
Definition: TTreeViewer.h:143
This class represent the list view container for the.