Re: canvas

Rene Brun (Rene.Brun@cern.ch)
Tue, 07 Apr 1998 12:44:07 +0200


Jens Berger wrote:
>
> Hi Rene,
>
> I created a canvas with a histogram in it and saved it to a file. After
> reading the file, is it possible to draw the saved canvas in an pad,
> created with Canvas->Divide(1,2,0,0) of a new Canvas?
>

This can be of general interest. I forward the answer to roottalk.

Yes, this is possible. Suppose that in a first session, you have
a canvas (say c1) with one or more histograms. You can save this
canvas in two ways:
1- Select the SavesAs canvas.root" item in the canvas menu.
this will create the file c1.root.
2- or type the command:
c1.Print("c1.root");

Now, in the next session, you create a new canvas (say c2)
that you divide in 2 pads. You can then connect the c1.root file,
get the c1 object in memory and draw the list of primitives
in c1 in (for example )pad2. This suite of commands is illustrated
in the following session:
TCanvas c2("c2");
c2.Divide(1,2);
TFile oldcanvas("c1.root");
TCanvas *c1 = (TCanvas*)oldcanvas.Get("c1");
TList *list = c1->GetListOfPrimitives();
c2.cd(2);
list->Draw();

Rene Brun