Re: [ROOT] gROOT->GetSelectedPad()

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Dec 19 2000 - 12:38:54 MET


Andre,

The SelectedPad is set when you click with the mouse in a pad.
You should not use the selected pad in your example, but the CURRENT PAD.
The current pad is always available via the global gPad.
Simply replace the line:
   pad->DrawFrame(105,-8,120,8);
by
   gPad->DrawFrame(105,-8,120,8);

Rene Brun


Andre Holzner wrote:
> 
> Hello,
> 
> Rene Brun wrote:
> >
> > Andre,
> > Add the line
> >   c5->Update();
> > after the line
> >   c5->Divide(3,2);
> >
> > Otherwise, when you call gROOT->GetSelectedPad, there is no canvas
> > "Paint" at this time.
> 
> Thanks, this works.
> However, I see the axes only on the last pad (while as it was before,
> I get [after the second run] axes on all pads). Is there any solution
> to this ?
> 
> many thanks,
> 
> Andre
> 
> >
> > Rene Brun
> >
> > Andre Holzner wrote:
> > >
> > > Hello,
> > >
> > > what am I doing wrong with this macro ?
> > > The first time I run it, it produces an empty canvas
> > > (and I see the complaint messages). Running it again,
> > > I get a new canvas with all the frames in it (as I
> > > want them). Can anybody reproduce the problem ?
> > >
> > > void test()
> > > {
> > >   TCanvas *c5 = new TCanvas;
> > >   c5->cd();
> > >   c5->Divide(3,2);
> > >
> > >   int i;
> > >   for (i=0; i<6; ++i)
> > >     {
> > >       c5->cd(i+1);
> > >
> > >       TPad *pad = gROOT->GetSelectedPad();
> > >       if (pad == NULL)
> > >         cout << "GetSelectedPad() returns NULL" << endl;
> > >       else
> > >         pad->DrawFrame(105,-8,120,8);
> > >     }
> > > }
> > >
> > > thanks for looking at it,
> > >
> > > Andre
> > >
> > > --
> > > ------------------+----------------------------------
> > > Andre Holzner     | +41 22 76 76750
> > > Bureau 32 2-C13   | Building 32
> > > CERN              | Office 2-C13
> > > CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/
> 
> --
> ------------------+----------------------------------
> Andre Holzner     | +41 22 76 76750
> Bureau 32 2-C13   | Building 32
> CERN              | Office 2-C13
> CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/
> 
>   --------------------------------------------------------------------------------
> 
>                   Name: root.jpg
>    root.jpg       Type: JPEG Image (image/jpeg)
>               Encoding: base64



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:40 MET