Logo ROOT   6.21/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 
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
62  kLTNoType = 0,
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
111 // toolbar and hints
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
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();
198  const char *GetGrOpt();
199  TTree *GetTree() {return fTree;}
200  Bool_t HandleTimer(TTimer *timer);
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
TGTextButton * fSPIDER
Definition: TTreeViewer.h:141
TGPictureButton * fBGPrevious
Definition: TTreeViewer.h:147
TGPictureButton * fSTOP
Definition: TTreeViewer.h:142
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:75
void SetNexpressions(Int_t expr)
Change the number of expression widgets.
Int_t fNexpressions
Definition: TTreeViewer.h:97
long long Long64_t
Definition: RtypesCore.h:69
TGCheckButton * fBarH
Definition: TTreeViewer.h:118
TGPictureButton * fBGRecord
Definition: TTreeViewer.h:148
void ExecuteDraw()
Called when the DRAW button is executed.
TGLayoutHints * fBarLayout
Definition: TTreeViewer.h:113
const TGPicture * fPicRefr
Definition: TTreeViewer.h:90
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:199
void PrintEntries()
Print the number of selected entries on status-bar.
TGLabel * fLbl2
Definition: TTreeViewer.h:132
#define BIT(n)
Definition: Rtypes.h:83
Handle_t Cursor_t
Definition: GuiTypes.h:33
TGMenuBar * fMenuBar
Definition: TTreeViewer.h:102
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:133
TGLabel * fBarLbl2
Definition: TTreeViewer.h:116
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:219
TGPictureButton * fREFR
Definition: TTreeViewer.h:143
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGHProgressBar * fProgressBar
Definition: TTreeViewer.h:135
const char * fFilename
Definition: TTreeViewer.h:76
void MapOptions(Long_t parm1)
Scan the selected options from option menu.
TGCheckButton * fBarRec
Definition: TTreeViewer.h:120
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:115
TList * fTreeList
Definition: TTreeViewer.h:86
TGLabel * fBLbl4
Definition: TTreeViewer.h:136
const TGPicture * fPicStop
Definition: TTreeViewer.h:89
TContextMenu * fContextMenu
Definition: TTreeViewer.h:84
TGPopupMenu * fFileMenu
Definition: TTreeViewer.h:103
TGPopupMenu * fOptionsGen
Definition: TTreeViewer.h:107
TGPictureButton * fBGNext
Definition: TTreeViewer.h:149
const char * fSourceFile
Definition: TTreeViewer.h:77
void SetCurrentRecord(Long64_t entry)
Set current record.
TGPopupMenu * fOptionsMenu
Definition: TTreeViewer.h:106
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:104
const char * Cut()
Apply Cut.
TGListTree * fLt
Definition: TTreeViewer.h:154
TGComboBox * fCombo
Definition: TTreeViewer.h:145
#define ClassDef(name, id)
Definition: Rtypes.h:326
Int_t Dimension()
Compute dimension of the histogram.
void ExecuteSpider()
Draw a spider plot for the selected entries.
TList * fWidgets
Definition: TTreeViewer.h:159
Bool_t fCounting
Definition: TTreeViewer.h:94
TTimer * fTimer
Definition: TTreeViewer.h:93
TGToolBar * fToolBar
Definition: TTreeViewer.h:112
A graphic user interface designed to handle ROOT trees and to take advantage of TTree class features...
Definition: TTreeViewer.h:54
const char * GetGrOpt()
Get graph option.
Bool_t HandleTimer(TTimer *timer)
This function is called by the fTimer object.
TString fLastOption
Definition: TTreeViewer.h:78
TGCompositeFrame * fListHdr
Definition: TTreeViewer.h:130
Bool_t fVarDraw
Definition: TTreeViewer.h:82
TList * ExpressionList()
Get the list of expression items.
TGTextEntry * fBarOption
Definition: TTreeViewer.h:122
const char * Ez()
Get the expression to be drawn on Z axis.
TGTextEntry * fBarCommand
Definition: TTreeViewer.h:121
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:156
void SetFile()
Set file name containing the tree.
TTVLVContainer * fLVContainer
Definition: TTreeViewer.h:157
TGTextButton * fReset
Definition: TTreeViewer.h:151
void SetCutMode(Bool_t enabled=kTRUE)
Definition: TTreeViewer.h:213
TGHorizontalFrame * fHpb
Definition: TTreeViewer.h:134
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:88
Cursor_t fDefaultCursor
Definition: TTreeViewer.h:91
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:153
Bool_t fStopMapping
Definition: TTreeViewer.h:95
void RemoveLastRecord()
Remove the current record.
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
TGPictureButton * fBGLast
Definition: TTreeViewer.h:150
TTree * fMappedTree
Definition: TTreeViewer.h:79
TTreeViewer(const char *treeName=0)
TTreeViewer default constructor.
void SetHistogramTitle(const char *title)
Set title of Histogram.
TGLayoutHints * fMenuBarHelpLayout
Definition: TTreeViewer.h:101
virtual ~TTreeViewer()
TTreeViewer destructor.
Bool_t IsCutEnabled()
Definition: TTreeViewer.h:201
Int_t fDimension
Definition: TTreeViewer.h:81
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:88
Cursor_t fWatchCursor
Definition: TTreeViewer.h:92
TTree * fTree
Definition: TTreeViewer.h:74
TGPictureButton * fBGFirst
Definition: TTreeViewer.h:146
const Bool_t kFALSE
Definition: RtypesCore.h:88
TGCheckButton * fBarScan
Definition: TTreeViewer.h:119
TGLayoutHints * fMenuBarItemLayout
Definition: TTreeViewer.h:100
long Long_t
Definition: RtypesCore.h:50
TGHorizontalFrame * fHf
Definition: TTreeViewer.h:125
virtual void CloseWindow()
Close the viewer.
TGTextEntry * fBarListOut
Definition: TTreeViewer.h:139
TGTextEntry * fBarHist
Definition: TTreeViewer.h:123
TGVerticalFrame * fV2
Definition: TTreeViewer.h:128
void UpdateRecord(const char *name="new name")
Updates current record to new X, Y, Z items.
const TGPicture * fPicDraw
Definition: TTreeViewer.h:89
TGDoubleVSlider * fSlider
Definition: TTreeViewer.h:126
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:105
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:109
TGLabel * fLbl1
Definition: TTreeViewer.h:131
Bool_t fEnableCut
Definition: TTreeViewer.h:96
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:70
Bool_t fScanMode
Definition: TTreeViewer.h:83
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:117
TGTextEntry * fBarListIn
Definition: TTreeViewer.h:138
TGLayoutHints * fMenuBarLayout
Definition: TTreeViewer.h:99
Definition: tree.py:1
virtual void Delete(Option_t *)
Delete this object.
Definition: TTreeViewer.h:188
TGPictureButton * fDRAW
Definition: TTreeViewer.h:140
Int_t fTreeIndex
Definition: TTreeViewer.h:87
A TTree represents a columnar dataset.
Definition: TTree.h:72
TGVerticalFrame * fV1
Definition: TTreeViewer.h:127
void EmptyAll()
Clear the content of all items in the list view.
TGSelectBox * fDialogBox
Definition: TTreeViewer.h:85
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:129
A TTree is a list of TBranches.
Definition: TBranch.h:90
TGPopupMenu * fHelpMenu
Definition: TTreeViewer.h:110
Bool_t IsScanRedirected()
Return kTRUE if scan is redirected.
const Bool_t kTRUE
Definition: RtypesCore.h:87
const TGPicture * fPicZ
Definition: TTreeViewer.h:88
TGStatusBar * fStatusBar
Definition: TTreeViewer.h:144
const Int_t n
Definition: legend1.C:16
TBranch * fMappedBranch
Definition: TTreeViewer.h:80
TGPopupMenu * fOptions1D
Definition: TTreeViewer.h:108
static constexpr Long64_t kMaxEntries
Definition: TTree.h:218
TGLabel * fBLbl5
Definition: TTreeViewer.h:137
char name[80]
Definition: TGX11.cxx:109
This class represent the list view container for the.