ROOT
master
Reference Guide
Loading...
Searching...
No Matches
gtreeTableTest.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This TableTest class is a simple example of how to use a TGTreeTable.
4
/// TableTest inherits from TGMainFrame to create a top level frame to embed the TGTreeTable in.
5
/// First, the staff.root file is opened to obtain a tree. A TGTreeTable is then created using the tree.
6
/// In the end, the table is added to the TGMainFrame that is the TableTest and the necessary calls to correctly draw
7
/// the window are made. For more information about the use of TGTreeTable, see it's documentation.
8
///
9
/// \macro_code
10
///
11
/// \author Roel Aaij 13/07/2007
12
13
#include <iostream>
14
#include <
TApplication.h
>
15
#include <
TGClient.h
>
16
#include <
TGButton.h
>
17
#include <
TGFrame.h
>
18
#include <
TGWindow.h
>
19
#include <
TString.h
>
20
#include <
TGTreeTable.h
>
21
#include <
TFile.h
>
22
#include <
TNtuple.h
>
23
#include <
TTree.h
>
24
25
// A little class to automatically handle the generation of unique
26
// widget ids.
27
class
IDList {
28
private
:
29
Int_t
nID;
// Generates unique widget IDs.
30
public
:
31
IDList() : nID(0) {}
32
~IDList() {}
33
Int_t
GetUnID(
void
) {
return
++nID; }
34
};
35
36
class
TableTest :
public
TGMainFrame
{
37
38
private
:
39
IDList fIDs;
// Generator for unique widget IDs.
40
UInt_t
fNTableRows;
41
UInt_t
fNTableColumns;
42
TGTreeTable
*fTreeTable;
43
TFile
*fFile;
44
45
public
:
46
TableTest(
const
TGWindow
*
p
,
UInt_t
ntrows,
UInt_t
ntcols,
UInt_t
w
= 100,
UInt_t
h
= 100);
47
~TableTest()
override
;
48
49
void
DoExit();
50
51
TGTreeTable
*GetTable() {
return
fTreeTable; }
52
53
ClassDefOverride
(TableTest, 0)
54
};
55
56
TableTest::TableTest(
const
TGWindow
*
p
,
UInt_t
ntrows,
UInt_t
ntcols,
UInt_t
w
,
UInt_t
h
)
57
:
TGMainFrame
(
p
,
w
,
h
), fNTableRows(ntrows), fNTableColumns(ntcols), fTreeTable(nullptr)
58
{
59
SetCleanup(
kDeepCleanup
);
60
Connect(
"CloseWindow()"
,
"TableTest"
,
this
,
"DoExit()"
);
61
DontCallClose();
62
63
// Open the root file
64
fFile =
new
TFile
(
"cernstaff.root"
);
65
66
if
(!fFile || fFile->IsZombie()) {
67
printf(
"Please run <ROOT location>/tutorials/io/tree/tree500_cernbuild.C first."
);
68
return
;
69
}
70
71
// Get the tree from the file.
72
TTree
*
tree
= (
TTree
*)fFile->Get(
"T"
);
73
74
// Setup the expressions for the columns and the selection of the
75
// interface.
76
TString
varexp =
"px:py:pz:random:sin(px):log(px/py):log(pz)"
;
77
TString
select =
"px>0 && py>0 && pz>0"
;
78
TString
options =
""
;
79
80
// Create the table and add it to the TableTest that is a TGMainFrame
81
fTreeTable =
new
TGTreeTable
(
this
, fIDs.GetUnID(), tree);
82
AddFrame(fTreeTable,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
));
83
84
// Calls to layout and draw the TableTest that is a TGMainFrame.
85
SetWindowName(
"TGTreeTable Test"
);
86
MapSubwindows
();
87
Layout
();
88
Resize(GetDefaultWidth() + 20, 600);
89
MapWindow();
90
};
91
92
TableTest::~TableTest()
93
{
94
// Destructor
95
fFile->Close();
96
Cleanup();
97
}
98
99
void
TableTest::DoExit()
100
{
101
// Exit this application via the Exit button or Window Manager.
102
// Use one of the both lines according to your needs.
103
// Please note to re-run this macro in the same ROOT session,
104
// you have to compile it to get signals/slots 'on place'.
105
106
DeleteWindow();
// to stay in the ROOT session
107
// gApplication->Terminate(); // to exit and close the ROOT session
108
}
109
110
TGTreeTable
*gtreeTableTest(
UInt_t
ntrows = 50,
UInt_t
ntcols = 10)
111
{
112
TableTest *test =
new
TableTest(
nullptr
, ntrows, ntcols, 500, 200);
113
return
test->GetTable();
114
}
h
#define h(i)
Definition
RSha256.hxx:106
Int_t
int Int_t
Definition
RtypesCore.h:45
UInt_t
unsigned int UInt_t
Definition
RtypesCore.h:46
ClassDefOverride
#define ClassDefOverride(name, id)
Definition
Rtypes.h:346
TApplication.h
TFile.h
TGButton.h
TGClient.h
TGFrame.h
kDeepCleanup
@ kDeepCleanup
Definition
TGFrame.h:42
kLHintsExpandY
@ kLHintsExpandY
Definition
TGLayout.h:31
kLHintsExpandX
@ kLHintsExpandX
Definition
TGLayout.h:30
TGTreeTable.h
w
winID w
Definition
TGWin32VirtualGLProxy.cxx:39
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Definition
TGWin32VirtualXProxy.cxx:94
TGWindow.h
TNtuple.h
TString.h
TTree.h
TFile
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition
TFile.h:53
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition
TGLayout.h:50
TGMainFrame
Defines top level windows that interact with the system Window Manager.
Definition
TGFrame.h:397
TGTreeTable
TGTreeTable is a TGTable that owns it's own interface.
Definition
TGTreeTable.h:18
TGWindow
ROOT GUI Window base class.
Definition
TGWindow.h:23
TString
Basic string class.
Definition
TString.h:139
TTree
A TTree represents a columnar dataset.
Definition
TTree.h:79
RooFit::Layout
RooCmdArg Layout(double xmin, double xmax=0.99, double ymin=0.95)
Definition
RooGlobalFunc.cxx:788
TMVA_SOFIE_GNN_Parser.tree
tree
Definition
TMVA_SOFIE_GNN_Parser.py:169
tutorials
visualisation
gui
gtreeTableTest.C
ROOT master - Reference Guide Generated on Thu Dec 19 2024 09:47:24 (GVA Time) using Doxygen 1.9.8