Logo ROOT   6.14/05
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 
25 class TTreeViewer;
26 class TTVLVContainer;
27 class TTVLVEntry;
28 class TTVSession;
29 class TGSelectBox;
30 class TTree;
31 class TBranch;
32 class TContextMenu;
33 class TList;
34 class TGPicture;
35 class TTimer;
36 class TGLayoutHints;
37 class TGMenuBar;
38 class TGPopupMenu;
39 class TGToolBar;
40 class TGLabel;
41 class TGCheckButton;
42 class TGComboBox;
43 class TGTextButton;
44 class TGTextEntry;
45 class TGDoubleVSlider;
46 class TGPictureButton;
47 class TGStatusBar;
48 class TGCanvas;
49 class TGListTree;
50 class TGListTreeItem;
51 class TGListView;
52 class TGHProgressBar;
53 class TGButton;
54 
55 
56 class TTreeViewer : public TGMainFrame {
57 
58 friend class TGClient;
59 friend class TGButton;
60 
61 public:
62  //---- item types used as user data
64  kLTNoType = 0,
73  };
74 
75 private:
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 
163 private:
164 // private methods
165  void BuildInterface();
166  const char *Cut();
167  Int_t Dimension();
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 
181 public:
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
TGTextButton * fSPIDER
Definition: TTreeViewer.h:143
TGPictureButton * fBGPrevious
Definition: TTreeViewer.h:149
TGPictureButton * fSTOP
Definition: TTreeViewer.h:144
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:77
void SetNexpressions(Int_t expr)
Change the number of expression widgets.
Int_t fNexpressions
Definition: TTreeViewer.h:99
long long Long64_t
Definition: RtypesCore.h:69
TGCheckButton * fBarH
Definition: TTreeViewer.h:120
TGPictureButton * fBGRecord
Definition: TTreeViewer.h:150
void ExecuteDraw()
Called when the DRAW button is executed.
TGLayoutHints * fBarLayout
Definition: TTreeViewer.h:115
const TGPicture * fPicRefr
Definition: TTreeViewer.h:92
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:201
void PrintEntries()
Print the number of selected entries on status-bar.
TGLabel * fLbl2
Definition: TTreeViewer.h:134
#define BIT(n)
Definition: Rtypes.h:78
Handle_t Cursor_t
Definition: GuiTypes.h:33
TGMenuBar * fMenuBar
Definition: TTreeViewer.h:104
void SetUserCode(const char *code, Bool_t autoexec=kTRUE)
user defined command for current record
void UpdateCombo()
Updates combo box to current session entries.
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:135
TGLabel * fBarLbl2
Definition: TTreeViewer.h:118
Basic string class.
Definition: TString.h:131
void SetTreeName(const char *treeName)
Allow geting the tree from the context menu.
void SetScanMode(Bool_t mode=kTRUE)
Definition: TTreeViewer.h:221
TGPictureButton * fREFR
Definition: TTreeViewer.h:145
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGHProgressBar * fProgressBar
Definition: TTreeViewer.h:137
const char * fFilename
Definition: TTreeViewer.h:78
void MapOptions(Long_t parm1)
Scan the selected options from option menu.
TGCheckButton * fBarRec
Definition: TTreeViewer.h:122
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:117
TList * fTreeList
Definition: TTreeViewer.h:88
TGLabel * fBLbl4
Definition: TTreeViewer.h:138
const TGPicture * fPicStop
Definition: TTreeViewer.h:91
TContextMenu * fContextMenu
Definition: TTreeViewer.h:86
TGPopupMenu * fFileMenu
Definition: TTreeViewer.h:105
TGPopupMenu * fOptionsGen
Definition: TTreeViewer.h:109
TGPictureButton * fBGNext
Definition: TTreeViewer.h:151
const char * fSourceFile
Definition: TTreeViewer.h:79
void SetCurrentRecord(Long64_t entry)
Set current record.
TGPopupMenu * fOptionsMenu
Definition: TTreeViewer.h:108
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.
TGPopupMenu * fEditMenu
Definition: TTreeViewer.h:106
const char * Cut()
Apply Cut.
TGListTree * fLt
Definition: TTreeViewer.h:156
TGComboBox * fCombo
Definition: TTreeViewer.h:147
#define ClassDef(name, id)
Definition: Rtypes.h:320
Int_t Dimension()
Compute dimension of the histogram.
void ExecuteSpider()
Draw a spider plot for the selected entries.
TList * fWidgets
Definition: TTreeViewer.h:161
Bool_t fCounting
Definition: TTreeViewer.h:96
TTimer * fTimer
Definition: TTreeViewer.h:95
TGToolBar * fToolBar
Definition: TTreeViewer.h:114
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features...
Definition: TTreeViewer.h:56
const char * GetGrOpt()
Get graph option.
Bool_t HandleTimer(TTimer *timer)
This function is called by the fTimer object.
TString fLastOption
Definition: TTreeViewer.h:80
TGCompositeFrame * fListHdr
Definition: TTreeViewer.h:132
Bool_t fVarDraw
Definition: TTreeViewer.h:84
TList * ExpressionList()
Get the list of expression items.
TGTextEntry * fBarOption
Definition: TTreeViewer.h:124
const char * Ez()
Get the expression to be drawn on Z axis.
TGTextEntry * fBarCommand
Definition: TTreeViewer.h:123
void SetTree(TTree *tree)
Assign the fTree member from existing tree, e.g.
A doubly linked list.
Definition: TList.h:44
TGListView * fListView
Definition: TTreeViewer.h:158
void SetFile()
Set file name containing the tree.
TTVLVContainer * fLVContainer
Definition: TTreeViewer.h:159
TGTextButton * fReset
Definition: TTreeViewer.h:153
void SetCutMode(Bool_t enabled=kTRUE)
Definition: TTreeViewer.h:215
TGHorizontalFrame * fHpb
Definition: TTreeViewer.h:136
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 <Scan> 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:90
Cursor_t fDefaultCursor
Definition: TTreeViewer.h:93
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:40
void SetSession(TTVSession *session)
Set current session.
TGCanvas * fTreeView
Definition: TTreeViewer.h:155
Bool_t fStopMapping
Definition: TTreeViewer.h:97
void RemoveLastRecord()
Remove the current record.
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
TGPictureButton * fBGLast
Definition: TTreeViewer.h:152
TTree * fMappedTree
Definition: TTreeViewer.h:81
TTreeViewer(const char *treeName=0)
TTreeViewer default constructor.
void SetHistogramTitle(const char *title)
Set title of Histogram.
TGLayoutHints * fMenuBarHelpLayout
Definition: TTreeViewer.h:103
virtual ~TTreeViewer()
TTreeViewer destructor.
Bool_t IsCutEnabled()
Definition: TTreeViewer.h:203
Int_t fDimension
Definition: TTreeViewer.h:83
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:90
Cursor_t fWatchCursor
Definition: TTreeViewer.h:94
TTree * fTree
Definition: TTreeViewer.h:76
TGPictureButton * fBGFirst
Definition: TTreeViewer.h:148
const Bool_t kFALSE
Definition: RtypesCore.h:88
TGCheckButton * fBarScan
Definition: TTreeViewer.h:121
TGLayoutHints * fMenuBarItemLayout
Definition: TTreeViewer.h:102
long Long_t
Definition: RtypesCore.h:50
TGHorizontalFrame * fHf
Definition: TTreeViewer.h:127
virtual void CloseWindow()
Close the viewer.
TGTextEntry * fBarListOut
Definition: TTreeViewer.h:141
TGTextEntry * fBarHist
Definition: TTreeViewer.h:125
TGVerticalFrame * fV2
Definition: TTreeViewer.h:130
void UpdateRecord(const char *name="new name")
Updates current record to new X, Y, Z items.
const TGPicture * fPicDraw
Definition: TTreeViewer.h:91
TGDoubleVSlider * fSlider
Definition: TTreeViewer.h:128
This class represent a specialized expression editor for TTVLVEntry &#39;true name&#39; and &#39;alias&#39; data memb...
int nentries
Definition: THbookFile.cxx:89
TGPopupMenu * fRunMenu
Definition: TTreeViewer.h:107
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&#39;th expression.
TGPopupMenu * fOptions2D
Definition: TTreeViewer.h:111
TGLabel * fLbl1
Definition: TTreeViewer.h:133
Bool_t fEnableCut
Definition: TTreeViewer.h:98
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:69
Bool_t fScanMode
Definition: TTreeViewer.h:85
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:119
TGTextEntry * fBarListIn
Definition: TTreeViewer.h:140
TGLayoutHints * fMenuBarLayout
Definition: TTreeViewer.h:101
Definition: tree.py:1
virtual void Delete(Option_t *)
Delete this object.
Definition: TTreeViewer.h:190
TGPictureButton * fDRAW
Definition: TTreeViewer.h:142
Int_t fTreeIndex
Definition: TTreeViewer.h:89
A TTree object has a header with a name and a title.
Definition: TTree.h:70
TGVerticalFrame * fV1
Definition: TTreeViewer.h:129
void EmptyAll()
Clear the content of all items in the list view.
TGSelectBox * fDialogBox
Definition: TTreeViewer.h:87
void DoError(int level, const char *location, const char *fmt, va_list va) const
Put error/warning into TMsgBox and also forward to console.
Definition: first.py:1
const char * ScanList()
returns scanlist
TGCompositeFrame * fTreeHdr
Definition: TTreeViewer.h:131
A TTree is a list of TBranches.
Definition: TBranch.h:62
TGPopupMenu * fHelpMenu
Definition: TTreeViewer.h:112
Bool_t IsScanRedirected()
Return kTRUE if scan is redirected.
const Bool_t kTRUE
Definition: RtypesCore.h:87
const TGPicture * fPicZ
Definition: TTreeViewer.h:90
TGStatusBar * fStatusBar
Definition: TTreeViewer.h:146
const Int_t n
Definition: legend1.C:16
TBranch * fMappedBranch
Definition: TTreeViewer.h:82
TGPopupMenu * fOptions1D
Definition: TTreeViewer.h:110
static constexpr Long64_t kMaxEntries
Definition: TTree.h:207
TGLabel * fBLbl5
Definition: TTreeViewer.h:139
char name[80]
Definition: TGX11.cxx:109
This class represent the list view container for the.