ROOT
Version v6.34
master
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
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 the window are made.
7
/// 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
,
47
UInt_t
w
= 100,
UInt_t
h
= 100);
48
~TableTest
()
override
;
49
50
void
DoExit() ;
51
52
TGTreeTable
*GetTable() {
return
fTreeTable
; }
53
54
ClassDefOverride
(
TableTest
, 0)
55
};
56
57
TableTest::TableTest(
const
TGWindow
*
p
,
UInt_t
ntrows
,
UInt_t
ntcols
,
58
UInt_t
w
,
UInt_t
h
)
59
:
TGMainFrame
(
p
,
w
,
h
),
fNTableRows
(
ntrows
),
fNTableColumns
(
ntcols
),
60
fTreeTable
(nullptr)
61
{
62
SetCleanup(
kDeepCleanup
) ;
63
Connect(
"CloseWindow()"
,
"TableTest"
,
this
,
"DoExit()"
) ;
64
DontCallClose() ;
65
66
// Open the root file
67
fFile =
new
TFile
(
"cernstaff.root"
);
68
69
if
(!fFile || fFile->IsZombie()) {
70
printf
(
"Please run <ROOT location>/tutorials/tree/cernbuild.C first."
);
71
return
;
72
}
73
74
// Get the tree from the file.
75
TTree
*
tree
= (
TTree
*)fFile->Get(
"T"
);
76
77
// Setup the expressions for the columns and the selection of the
78
// interface.
79
TString
varexp
=
"px:py:pz:random:sin(px):log(px/py):log(pz)"
;
80
TString
select
=
"px>0 && py>0 && pz>0"
;
81
TString
options =
""
;
82
83
// Create the table and add it to the TableTest that is a TGMainFrame
84
fTreeTable
=
new
TGTreeTable
(
this
, fIDs.GetUnID(), tree);
85
AddFrame(
fTreeTable
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
));
86
87
// Calls to layout and draw the TableTest that is a TGMainFrame.
88
SetWindowName(
"TGTreeTable Test"
) ;
89
MapSubwindows
() ;
90
Layout
();
91
Resize(GetDefaultWidth()+20, 600) ;
92
MapWindow() ;
93
94
} ;
95
96
TableTest::~TableTest()
97
{
98
// Destructor
99
fFile->Close();
100
Cleanup() ;
101
}
102
103
void
TableTest::DoExit()
104
{
105
// Exit this application via the Exit button or Window Manager.
106
// Use one of the both lines according to your needs.
107
// Please note to re-run this macro in the same ROOT session,
108
// you have to compile it to get signals/slots 'on place'.
109
110
DeleteWindow();
// to stay in the ROOT session
111
// gApplication->Terminate(); // to exit and close the ROOT session
112
}
113
114
TGTreeTable
*
gtreeTableTest
(
UInt_t
ntrows
= 50,
UInt_t
ntcols
= 10) {
115
TableTest
*
test
=
new
TableTest
(
nullptr
,
ntrows
,
ntcols
, 500, 200);
116
return
test
->GetTable();
117
}
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
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
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
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
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:783
TMVA_SOFIE_GNN_Parser.tree
tree
Definition
TMVA_SOFIE_GNN_Parser.py:169
tutorials
gui
gtreeTableTest.C
ROOT v6-34 - Reference Guide Generated on Sun Apr 6 2025 15:42:54 (GVA Time) using Doxygen 1.10.0