15 void HighlightZoom(TVirtualPad *pad, TObject *obj, Int_t xhb, Int_t yhb);
22 auto Canvas1 =
new TCanvas(
"Canvas1",
"", 0, 0, 600, 400);
23 auto f1 =
new TF1(
"f1",
"x*gaus(0) + [3]*abs(sin(x)/x)", -50.0, 50.0);
24 f1->SetParameters(20.0, 4.0, 1.0, 20.0);
25 auto h1 =
new TH1F(
"h1",
"Test random numbers", 200, -50.0, 50.0);
26 h1->FillRandom(
"f1", 100000);
29 gStyle->SetGridColor(kGray);
32 info =
new TText(0.0, h1->GetMaximum()*0.7,
"please move the mouse over the frame");
33 info->SetTextSize(0.04);
34 info->SetTextAlign(22);
35 info->SetTextColor(kRed-1);
36 info->SetBit(kCannotPick);
41 Canvas1->HighlightConnect(
"HighlightZoom(TVirtualPad*,TObject*,Int_t,Int_t)");
45 void HighlightZoom(TVirtualPad *pad, TObject *obj, Int_t xhb, Int_t yhb)
50 auto Canvas2 = (TCanvas *)gROOT->GetListOfCanvases()->FindObject(
"Canvas2");
52 if (!h->IsHighlight()) {
53 if (Canvas2)
delete Canvas2;
54 if (hz) {
delete hz; hz = 0; }
61 Canvas2 =
new TCanvas(
"Canvas2",
"Canvas2", 605, 0, 400, 400);
66 hz = (TH1 *)h->Clone(
"hz");
67 hz->SetTitle(TString::Format(
"%s (zoomed)", hz->GetTitle()));
71 hz->SetHighlight(kFALSE);
74 Int_t zf = hz->GetNbinsX()*0.05;
75 hz->GetXaxis()->SetRange(xhb-zf, xhb+zf);