Re: [ROOT] TCanvas strange behaviour

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Mar 27 2002 - 08:21:03 MET


Hi Henrique,

On Wed, 27 Mar 2002, Henrique de Melo Jorge Barbosa wrote:

> 
> Dear root masters,
> 
> I found something at least peculiar in the behaviour of TCanvas within
> cint interpreter:
> 
> 1) when I create a TCanvas object with:
> 
> 	t = new TCanvas("","",100,100);
> 

Setting both name and title to blank sets the canvas in batch mode. No
window is created on the screen.

> the canvas is not created, but if I type:
> 
> 	t2 = new TCanvas("name","title",100,100);
> 
> the canvas is really created. (it appears on the screen)
> 
> 2) Now suppose I want to divide the canvas t2 into two, without
> space inbetween and both on the same line, then I have to do:
> 
> 	t2->Divide(2,1,0.,0.);
> 
> But then I have no access to the pads:
> 
> 	t2_1->cd();  // or
> 	c1_1->cd();

WRONG! You have named your canvas "name". You must be consistent. Your
pads will be named "name_1", "name_2". Note that (as explained in the doc)
it is more convenient to do:
    t2->cd(1);
    t2->cd(2);

> 
> both commands returns error messages.
> 
> 3) To get tcanvas::divide to work, one must create the canvas with:
> 
> 	t3 = new TCanvas();
>
This is a special case when invoking the default constructor. This is
a typical short command to create a canvas automatically named "c1".
I agree that this may look somehow inconsistent with new
TCanvas("","",100,100), but we assume that if a user sets explicitely
the name and the title to blank, he understands what he does.
 
> and then one have no control over the dimensions (w x h) but the
> TCanvas::Divide works fine. Well, not so fine:
> 
> 4) why the pads are named c1_1 and c1_2.... and not t3_1 and t3_2??
> Naming all divided pads with c1_[index] make it not possible, for 
> exemple, to divide two canvas that exist at the sametime. What
> happens is that the second divided canvas does not respond to c1_1->cd().
> 
already answered above. We give plenty of examples in the tutorials.

Rene Brun

> 
> I know that it is most probably that I am missing something, but I
> could not figure out what. I am using linux redhat 7, and I tried it with
> root3.02/06 and root 3.03. 
> 
> I am sending attached a macro with the commands I have described
> and its result from within the interpreter. I hope it is of some
> help.
> 
> thanks,
> 
> Henrique Barbosa
> --------------------
> Campinas - Brasil
> The Pierre Auger Observatory
> 
> 
> 
> 



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