Re: [ROOT] Number of SubPads in a Pad ?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Feb 15 2002 - 10:58:06 MET


Hi Fred,

With your logic, you must have an infinite loop.
Note that you get a different result with
    gPad->cd(Current_Pad++);
or
    gPad->cd(++Current_Pad);

In your case, you should always use gPad->cd(++Current_Pad) (increment before
the call and not after !).

Rene Brun

Frederic Sarazin wrote:
> 
> Hello,
> 
> I'm looking for the method which would give me the number of
> subpads which are attached to a given pad...
> 
> I tried:
> 
> TCanvas* Current = gPad->GetCanvas(); (From this I get a pointer to the
> Canvas in which my gPad is)
> 
> then:
> 
> int_t Total_Number_of_Pads = ((TList*)
> Current->GetListOfPrimitives())->GetSize();
> 
> This happen to give me a number which is actually the number of pads
> attached to the canvas... however, when
> I take a random Pad in this canvas and divide it into subpads (lets say
> 4 = (2,2)) and with the following
> recursive program I try to put all of the 1D spectra in a LinY scale:
> 
> Linyall()
> {
> 
>   // Auto Lin in Y direction for all Pads belonging
>   // to the canvas in which gPad is active
> 
>   Int_t Current_Pad = 0, Pads = 0;
>   TCanvas* Current = gPad->GetCanvas();
>   Int_t Pad_Number = gPad->GetNumber();
> 
>   Pads = ((TList*) Current->GetListOfPrimitives())->GetSize();
>   Current->cd(Current_Pad);
> 
>   if (Pads==0)
>     {
>       gPad->SetLogy(0);
>       gPad->Modified();
>     }
>   else gPad->cd(Current_Pad++);
> 
>   while (Pads>0)
>     {
>       Pads = 0 ;
>       Pads = ((TList*) gPad->GetListOfPrimitives())->GetSize();
>       if (Pads==0)
>  {
>    gPad->SetLogy(0);
>    gPad->Modified();
>  }
> 
>       else
>  {
>    Current_Pad=0;
>    gPad->cd(Current_Pad++);
>  }
>     }
> 
>   Current->cd(Pad_Number);
>   gPad->Modified();
> }
> 
> The program seems to loop endlessly, the reason is in fact that the
> command:
> 
>  Pads = ((TList*) gPad->GetListOfPrimitives())->GetSize();
> 
>   doesn't give the number of Subpads in the Pads anymore... So, I
> suspect there is
> a method that I missed which return the number of SubPads into a given
> Pad.
> 
> Thanks for any help !
> 
> Fred (TRIUMF - Canada)



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:41 MET