Re: Problems with frame - update

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Nov 04 1997 - 14:51:24 MET


ROHLFS Reiner wrote:

> Hi Rooters,
>
> please have a look to following macro:
>
> {
>   gROOT->Reset();
>
> // Create a new canvas.
>    c1 = new TCanvas("c1","canvas",50,10,600,300);
>
> // create a pad
>    pad = new TPad("p1", "pad", 0.05, 0.05, 0.95, 0.95);
>    pad->SetFillColor(17);
>    pad->Draw();
>
> // draw a frame
>    pad->cd();
>    pad->DrawFrame(0. ,0., 2., 2.);
>
>    pad->Update();
>
>    pad->SetTopMargin(0.2);
>    pad->SetBottomMargin(0.2);
>    pad->SetRightMargin(0.2);
>    pad->SetLeftMargin(0.2);
>
>    pad->Modified();
>    pad->Update();
> }
>
> After the run of this macro there are two frames on the pad. The old one with
> margins of 0.1 without axis and the new one with margins of 0.2.
> After resizing the window, the pad or the new frame the old frame (margin 0.1)
> disappears.
>
> There is no problem without the first call of pad->Modified(). But in my
> application I want to change the margins of the frame after the frame was
> displayed the first time with the old margins.
>
> May be this is the same problem I had with updating TGaxis which have reported
> last Friday?  But I do not have your last development version 1.03/07 to check
> this by myself.
>

TPad::SetTopMargin, etc functions simply set the pad margins.They do not modify
the parameters of an already existing frame.
In your macro above, replace the two last statements
  pad->Modified();
  pad->Update();
by
 pad->DrawFrame(0,0,2,2);  // you draw the frame again

One could, obviously, imagine that the SetTopMargin,etc functions
look if there is an already existing frame in the pad and modify its
parameters. This, however, would have many undesired
side effects.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET