Re: One line, two states?

Rene Brun (Rene.Brun@cern.ch)
Fri, 11 Sep 1998 19:09:00 +0200


Patrick Schemitz wrote:
>
> Hi Rooters,
>
> I'm experimenting with ROOT and I noticed something I don't understand.
> The following piece of code creates a window divided in two pads, and a
> line, drawn in both pads.
>
> gROOT->Reset();
>
> TCanvas window ("window","Window Title",100,100,300,300);
> window.SetFillColor(4);
>
> TLine line (0.07,0.07,0.43,0.93);
> line.SetLineColor(12);
>
> window.cd();
> TPad widget1 ("widget1","Lower Part",0.05,0.05,0.95,0.45,6);
> widget1.Draw();
> widget1.cd();
> line.Draw();
>
> window.cd();
> TPad widget2 ("widget2","Upper Part",0.05,0.55,0.95,0.95,6);
> widget2.Draw();
> widget2.cd();
> line.Draw();
>
> The strange thing is, if I right-click the line in the lower pad
> and modify its attributes (say, change the color), the other view
> of the line does _not_ change, even when I iconify and then restore
> the window, thus enforcing a X11 repaint event.
>
> Did I duplicate the line by drawing it in two pads? If yes, what if
> I did this to a _named_ object?

Patrick,
By default, Root will only repaint the current pad. This is
for efficiency reasons. In the vast majority of cases, an object
is drawn in one pad only.
You can force a pad to be repaint by calling pad->Modified().
In an interactive session, clicking on a pad will force the repainting
of this pad.
A simple X event like the one you describe will not force the
repainting of all pads (only pads marked modified).
If you grow/shrink the canvas, then all pads will be updated (obviously)

Rene Brun