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