#include "TSystem.h" #include "TCanvas.h" #include "TH1F.h" #include "TFormula.h" #include "TF1.h" #include "RQ_OBJECT.h" TH1F *h1f; //______________________________________________________________________________ // // // Helper class used to connect signal-slots. // // class Spy { RQ_OBJECT("Spy") public: Spy() { } ~Spy() { } void ProcessedEvent(Int_t event, Int_t px, Int_t py, TObject *selected); }; //______________________________________________________________________________ void Spy::ProcessedEvent(Int_t event, Int_t px, Int_t py, TObject *selected) { if (event==kKeyPress) { if (px==0 && py==4116) { printf("Next... \n"); h1f->Reset(); h1f->FillRandom("sqroot",10000); gPad->Modified(); gPad->Update(); } else if (px==0 && py==4114) { printf("Previous... \n"); h1f->Reset(); h1f->FillRandom("sqroot",10000); gPad->Modified(); gPad->Update(); } } } //______________________________________________________________________________ void testevent() { Spy *spy = new Spy(); TCanvas *c1 = new TCanvas("c1","Fitting canvas",10,10,900,700); TFormula *form1 = new TFormula("form1","abs(sin(x)/x)"); TF1 *sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10); sqroot->SetParameters(10,4,1,20); h1f = new TH1F("h1f","Test random numbers",200,0,10); h1f->SetFillColor(45); h1f->FillRandom("sqroot",10000); h1f->Draw(); c1->Update(); c1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "Spy", spy, "ProcessedEvent(Int_t,Int_t,Int_t,TObject*)"); }