> The class defination "test.h" and its implementation "test.c" is
> followed. The running is like
>
> * aa = new test();
> * aa->Draw();
>
>
> In the code, the implentation "Draw()" is like:
>
> void test::Draw()
> {
> fpx->Draw(); //fpx is a TH1 object
> }
>
> When running like:
>
> aa = new test();
> aa->Draw();
>
> It will produce a Canvas with a histogram in it. After selecting the
> option "Event Status" in TCanvas, I can find three objects:
>
> c1 --> default Canvas
> fpx -->the TH1 object.
> TFrame --> Frame that contains the "fpx"
>
> But can not find "aa". Deleting "aa" will have no effect on the
> existing TCanvas and Histograms. It seems to say that "aa" is not
> in the Canvas.
Everything is Ok.
I found no code to attach very object of "test" to Canvas.
test::Draw() does include the object fpx into TCanvas. But that is
not "test" at all but TH1. And TCanvas calls
fpx->DistansetoPrimitive
and
fpx->ExecuteEvent()
not your "test::aa" but those from TH1::fpx. That's by your desing.
Why did you mix things I mean test and TH1 (the last is a kind of
abstract class thought).
To add very test to TPad you should call
void test::Draw()
{
TObject::Draw();
fpx->Draw(); //fpx is a TH1 object
}
But again I can not find any reason to put
fpx->Draw(); //fpx is a TH1 object
into test::Draw(). This way both objects will be added to TPad
namely your "aa" as well as "fpx" and the methods of the both classes
will be called too. Namely TPad will call
fpx->DistancetoPrimitive( ... )
AND
&aa->DistancetoPrimitive( ... )
and occasionally TPad may select either object.
Hope this helps
Valery