ROOT
master
Reference Guide
Loading...
Searching...
No Matches
simpleTableTest.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 TGSimpleTable that creates and owns it's own
4
/// TGSimpleTableInterface. TableTest inherits from TGMainFrame to create a top level frame to embed the TGTable in.
5
/// First the data needed is created. Then the TGSimpleTable is created using this data.
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 TGSimpleTable 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 <
TGLayout.h
>
19
#include <
TGWindow.h
>
20
#include <
TGLabel.h
>
21
#include <
TGNumberEntry.h
>
22
#include <
TString.h
>
23
#include <
TGButtonGroup.h
>
24
#include <
TGMenu.h
>
25
#include <
TGSimpleTable.h
>
26
27
// A little class to automatically handle the generation of unique
28
// widget ids.
29
class
IDList {
30
private
:
31
Int_t
nID;
// Generates unique widget IDs.
32
public
:
33
IDList() : nID(0) {}
34
~IDList() {}
35
Int_t
GetUnID(
void
) {
return
++nID; }
36
};
37
38
class
TableTest :
public
TGMainFrame
{
39
40
private
:
41
IDList IDs;
// Generator for unique widget IDs.
42
Double_t
**fData;
43
UInt_t
fNDataRows;
44
UInt_t
fNDataColumns;
45
UInt_t
fNTableRows;
46
UInt_t
fNTableColumns;
47
TGSimpleTable
*fSimpleTable;
48
49
public
:
50
TableTest(
const
TGWindow
*
p
,
UInt_t
ndrows,
UInt_t
ndcols,
UInt_t
ntrows,
UInt_t
ntcols,
UInt_t
w
= 100,
51
UInt_t
h
= 100);
52
~TableTest()
override
;
53
54
void
DoExit();
55
56
TGSimpleTable
*GetTable() {
return
fSimpleTable; }
57
58
ClassDefOverride
(TableTest, 0)
59
};
60
61
TableTest::TableTest(
const
TGWindow
*
p
,
UInt_t
ndrows,
UInt_t
ndcols,
UInt_t
ntrows,
UInt_t
ntcols,
UInt_t
w
,
UInt_t
h
)
62
:
TGMainFrame
(
p
,
w
,
h
),
63
fData(nullptr),
64
fNDataRows(ndrows),
65
fNDataColumns(ndcols),
66
fNTableRows(ntrows),
67
fNTableColumns(ntcols),
68
fSimpleTable(nullptr)
69
{
70
SetCleanup(
kDeepCleanup
);
71
Connect(
"CloseWindow()"
,
"TableTest"
,
this
,
"DoExit()"
);
72
DontCallClose();
73
74
// Create the needed data.
75
Int_t
i = 0, j = 0;
76
fData =
new
Double_t
*[fNDataRows];
77
for
(i = 0; i < (
Int_t
)fNDataRows; i++) {
78
fData[i] =
new
Double_t
[fNDataColumns];
79
for
(j = 0; j < (
Int_t
)fNDataColumns; j++) {
80
fData[i][j] = 10 * i + j;
81
}
82
}
83
84
// Create the table and add it to the TableTest that is a TGMainFrame.
85
fSimpleTable =
new
TGSimpleTable
(
this
, IDs.GetUnID(), fData, fNTableRows, fNTableColumns);
86
AddFrame(fSimpleTable,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
));
87
88
// Calls to layout and draw the TableTest that is a TGMainFrame.
89
SetWindowName(
"TGSimpleTable Test"
);
90
MapSubwindows
();
91
Layout
();
92
Resize(GetDefaultWidth() + 20, 600);
93
MapWindow();
94
};
95
96
TableTest::~TableTest()
97
{
98
// Destructor
99
UInt_t
i = 0;
100
for
(i = 0; i < fNDataRows; i++) {
101
delete
[] fData[i];
102
}
103
delete
[] fData;
104
Cleanup();
105
}
106
107
void
TableTest::DoExit()
108
{
109
// Exit this application via the Exit button or Window Manager.
110
// Use one of the both lines according to your needs.
111
// Please note to re-run this macro in the same ROOT session,
112
// you have to compile it to get signals/slots 'on place'.
113
114
DeleteWindow();
// to stay in the ROOT session
115
// gApplication->Terminate(); // to exit and close the ROOT session
116
}
117
118
TGSimpleTable
*simpleTableTest(
UInt_t
ndrows = 500,
UInt_t
ndcols = 20,
UInt_t
ntrows = 50,
UInt_t
ntcols = 10)
119
{
120
TableTest *test =
new
TableTest(
nullptr
, ndrows, ndcols, ntrows, ntcols, 500, 200);
121
return
test->GetTable();
122
}
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
Double_t
double Double_t
Definition
RtypesCore.h:59
ClassDefOverride
#define ClassDefOverride(name, id)
Definition
Rtypes.h:346
TApplication.h
TGButtonGroup.h
TGButton.h
TGClient.h
TGFrame.h
kDeepCleanup
@ kDeepCleanup
Definition
TGFrame.h:42
TGLabel.h
TGLayout.h
kLHintsExpandY
@ kLHintsExpandY
Definition
TGLayout.h:31
kLHintsExpandX
@ kLHintsExpandX
Definition
TGLayout.h:30
TGMenu.h
TGNumberEntry.h
TGSimpleTable.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
TString.h
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
TGSimpleTable
To provide a simple class to visualize an array of doubles, the class TGSimpleTable is provided.
Definition
TGSimpleTable.h:16
TGWindow
ROOT GUI Window base class.
Definition
TGWindow.h:23
RooFit::Layout
RooCmdArg Layout(double xmin, double xmax=0.99, double ymin=0.95)
Definition
RooGlobalFunc.cxx:788
tutorials
visualisation
gui
simpleTableTest.C
ROOT master - Reference Guide Generated on Wed Dec 18 2024 10:10:39 (GVA Time) using Doxygen 1.9.8