Re: [ROOT] How Do we Access a PAD define in one class?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jul 07 2003 - 22:21:26 MEST


Hi Zaldy,

On Tue, 8 Jul 2003, zaldy wrote:

> 
> Dear ROOT Experts,
> 
> I want to understand how ROOT implemets accessing a specific pad which is  
> defined in some class primitives and access at another class methods.
> 
> For instance, I have 3 classes A, B, and C. 
> Say, A defines all that is  necessary for the creation of a Canvases/Pads, 
> while B and C have only methods which dump the information to the 
> active pad via: 
> 
>               gPad->GetThePadNeeded();
> 
> I found this mailing list useful to start with:
> http://root.cern.ch/cgi-bin/print_hit_bold.pl/root/roottalk/roottalk02/4941.html?GetPad#first_hit
> 
> IN MY UNDERSTANDING of THESE LINES,
> 
> //---------------------------------------------------------------<========
> To access a subpad of a pad, eg subpad 4 of pad with name "p1", do:
>   TPad *subpad = (TPad*)pad->GetPrimitive("p1_4");
> 
> To access a subpad N of a pad in general, you can do (eg in a loop):
>   TPad *subpad=(TPad*)pad->GetPrimitive(Form(%s_%d",pad->GetName(),N));
> 
> In the development version in CVS, I have added a new function
>    TVirtualPad  *TVirtualPad::GetPad(Int_t subpadnumber);
> such that you can do
>    TPad *subpad = pad->GetPad(N);
> //-----------------------------------------------------------------<=======
> 
> THE USER HAS CREATED A METHOD THAT DIVIDES THE PAD INTO say, 8 pads LIKE: 
> 
>            TheMostWantedPad->Divide(2,4); 
>            TheMostWantedPad->cd(1);
>            ... 
>            TheMostWantedPad->cd(2);
>            ... 
>            TheMostWantedPad->cd(8);  
> 
>            Then one can access a specific pad, because there is always 
>            this method:    
>            TheMostWantedPad->cd(Pad_Number); 
> 
> THE PAD_NUMBER HERE IS IMPORTATNT AND IS USED TO TIE UP AGAIN THE PREVIOUS 
> (say, the 5th pad) PAD OF INTEREST.
> 
> Is this correct?

Yes, it is correct.

> 
>                   --------------------------
> What if the user do not use the Divide method (like in the "canvas.C" at 
> tutorial section. Just create the pad, then activate it using 
> padWhateverName->cd(), without an integer argument as an ID to this Pad) 
> ), how do we access say the 5th pad if one wants to dump some data 
> coming from another class object?

You can do:
  padWhatEvername->SetNumber(someNumber);
then later, retrieve a pointer to this pad with:
  TPad *pad = parentPad->GetPad(someNumber);

TPad::Divide calls automatically TPad::SetNumber.

Rene Brun

> 
> Thank you very much.
> 
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:13 MET