ROOT
Version master
v6.34
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
exec3.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// Example of using signal/slot in TCanvas/TPad to get feedback about processed events.
4
/// Note that slots can be either functions or class methods.
5
/// Compare this with tutorials $ROOTSYS/tutorials/hist/hist057_TExec_th1.C and
6
/// $ROOTSYS/tutorials/hist/hist058_TExec_th2.C.
7
///
8
/// \macro_code
9
///
10
/// \author Ilka Antcheva
11
12
#include <
TH1.h
>
13
#include <
TCanvas.h
>
14
#include <
TQObject.h
>
15
#include "
TROOT.h
"
16
17
void
exec3
()
18
{
19
// Temporary work around the lack of automatic refresh of the list
20
// when a script is reloaded.
21
gROOT
->GetListOfGlobalFunctions()->Delete();
22
23
TH1F
*
h
=
new
TH1F
(
"h"
,
"h"
, 100, -3, 3);
24
h
->FillRandom(
"gaus"
, 1000);
25
TCanvas
*
c1
=
new
TCanvas
(
"c1"
);
26
h
->Draw();
27
c1
->Update();
28
c1
->Connect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)"
,
nullptr
,
nullptr
,
29
"exec3event(Int_t,Int_t,Int_t,TObject*)"
);
30
}
31
32
void
exec3event
(
Int_t
event,
Int_t
x
,
Int_t
y
,
TObject
*
selected
)
33
{
34
TCanvas
*
c
= (
TCanvas
*)
gTQSender
;
35
printf
(
"Canvas %s: event=%d, x=%d, y=%d, selected=%s\n"
,
c
->GetName(), event,
x
,
y
,
selected
->IsA()->GetName());
36
}
c
#define c(i)
Definition
RSha256.hxx:101
h
#define h(i)
Definition
RSha256.hxx:106
Int_t
int Int_t
Definition
RtypesCore.h:45
TCanvas.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
TH1.h
TQObject.h
gTQSender
R__EXTERN void * gTQSender
Definition
TQObject.h:46
TROOT.h
gROOT
#define gROOT
Definition
TROOT.h:406
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:650
TObject
Mother of all ROOT objects.
Definition
TObject.h:41
y
Double_t y[n]
Definition
legend1.C:17
c1
return c1
Definition
legend1.C:41
x
Double_t x[n]
Definition
legend1.C:17
tutorials
visualisation
gui
exec3.C
ROOT master - Reference Guide Generated on Tue Apr 8 2025 06:21:59 (GVA Time) using Doxygen 1.10.0