Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
exec3.C File Reference

Detailed Description

Example of using signal/slot in TCanvas/TPad to get feedback about processed events.

Note that slots can be either functions or class methods. Compare this with tutorials $ROOTSYS/tutorials/hist/hist057_TExec_th1.C and $ROOTSYS/tutorials/hist/hist058_TExec_th2.C.

#include <TH1.h>
#include <TCanvas.h>
#include <TQObject.h>
#include "TROOT.h"
void exec3()
{
// Temporary work around the lack of automatic refresh of the list
// when a script is reloaded.
gROOT->GetListOfGlobalFunctions()->Delete();
TH1F *h = new TH1F("h", "h", 100, -3, 3);
h->FillRandom("gaus", 1000);
TCanvas *c1 = new TCanvas("c1");
h->Draw();
c1->Update();
c1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", nullptr, nullptr,
"exec3event(Int_t,Int_t,Int_t,TObject*)");
}
{
printf("Canvas %s: event=%d, x=%d, y=%d, selected=%s\n", c->GetName(), event, x, y, selected->IsA()->GetName());
}
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN void * gTQSender
Definition TQObject.h:46
#define gROOT
Definition TROOT.h:414
The Canvas class.
Definition TCanvas.h:23
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:877
Mother of all ROOT objects.
Definition TObject.h:41
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
Author
Ilka Antcheva

Definition in file exec3.C.