(no subject)

Rene Brun (Rene.Brun@cern.ch)
Tue, 02 Mar 1999 16:46:05 +0000


Hi Federico & Marek,

Classes like TF1 or TGraph create TH1 objects durint painting.
Painting is triggered by a new line or a gPad->Update().

However, I agree that in the frequent case of these two classes,
the situtaion could be improved.

I made a first step in adding functionality in both
TF1::GetHistogram and TGraph::GetHistogram
such that if the histogram is not yet created when this function is
called,
I force a pad update and return the pointer to the created histogram.
The gPad->Update will not be required anymore in this case.
The change will appear in 2.21/07

Rene Brun

Federico Carminati wrote:
>
> Rene, Fons,
>
> consider this piece of macro
>
> Double_t expo (Double_t *xx, Double_t *){return TMath::Exp(-(*xx));}
>
> void fca() {
> gROOT->Reset();
> TF1 *fun = new TF1("expo",expo,0,2,0);
> fun->Draw();
> //c1->Update();
> TH1F *hist = fun->GetHistogram();
> hist->Draw("same");
> }
>
> If you do
>
> .L fca.C
>
> and then type the content of the macro everything works as expected. If
> you execute the macro it does not work. If you uncomment the update it
> works.
>
> The reason is simple. The fHistogram is created and filled by the Paint
> method of TF1. This is called either at every return at the keyboard or by
> the Update function of the canvas. But the behaviour is quite unexpected.
> Somehow one would expect simple commands to behave the same way in a macro
> or typed in...
>
> Thanks to M.Kowalski for spotting this.
>