RE: [ROOT] Empty postscript files

From: Valeri Fine (fine@bnl.gov)
Date: Mon Mar 29 2004 - 20:03:48 MEST


Hello Marc,

> 
> Hi,
> 

First of all I could not reproduce your problem.
It works for me properly (Sorry:-)


Anyway I would like to add a my 2 cents.

> The Canvas now remains, but the PS file is still empty,
> unfortunately. Also, in the Plot() macro the postscript
> file is closed before the canvas goes out of existence,
> so I would not expect this to matter.

  It DOES matter (sometimes :-)

1. >    h1->Draw(); 

   appends the "h1"  pointer to the list of attributes of the current
TCanvas

2. TH1F class dtor removes that histogram pointer from the list of
attributes

3. Because the list of attributes of the TCanvas is changed TCanvas
REPAINTs itself ones again and it is EMPTY now because the object was
deleted.

4. But . . .  at this point your Postscript file is already closed and
it must not be   affected by that second repainting. (This is what I did
see and this is why did say I could not reproduce your problem. It
worked for me sorry.)

   My best regards, Valeri


> 
> Cheers,
> 	Marc
> 
> -----Ursprungliche Nachricht-----
> Von: Olivier Couet [mailto:Olivier.Couet@cern.ch]
> Gesendet: Montag, 29. Marz 2004 11:02
> An: Marc de Kamps
> Cc: roottalk@pcroot.cern.ch
> Betreff: Re: [ROOT] Empty postscript files
> 
> 
> 
> Hi,
> 
> I do not see  the problem on linux (PS file is ok) but the Canvas is
> closed immediately after execution. This is because you do not use
> pointers. May be on windows the PS file is not created. Anyway, try
this
> version:
> 
> void DumpCanvas()
> {
>    gROOT->Reset();
>    TCanvas *c1 = new TCanvas("c1","Example",200,10,700,500);
> 
>    TH1F *h1 = new TH1F("h1","wysiwyg",100,0,1);
>    h1->Fill(0.5,1);
>    h1->Draw();
>    c1->Print("Equally_beautiful_histo.ps");
> }
> 
> Cheers,        O.Couet
> 
> 
> On Mon, 29 Mar 2004, Marc de Kamps wrote:
> 
> > Hi,
> >
> > Both macros below create empty ps files.
> > This is 3.10/02 under win2000 (win32gdk version).
> > What to do ?
> >
> > Thanks,
> > 	Marc
> >
> >
> >
> > void Plot()
> > {
> > 	gROOT->Reset();
> >
> > 	TCanvas c1;
> >
> > 	TPostScript ps("Beautiful_histo.ps",111);
> > 	TH1F h1("h1","wysiwyg",100,0,1);
> > 	h1.Fill(0.5,1);
> > 	h1.Draw();
> >
> > 	c1.Update();
> >
> > 	ps.Close();
> > }
> >
> > void DumpCanvas()
> > {
> > 	gROOT->Reset();
> >
> > 	TCanvas c1;
> >
> > 	TH1F h1("h1","wysiwyg",100,0,1);
> > 	h1.Fill(0.5,1);
> > 	h1.Draw();
> >
> > 	c1.Update();
> >
> > 	c1.Print("Equally_beautiful_histo.ps");
> > }
> >
> >
> 
> --
> Org:    CERN - European Laboratory for Particle Physics.
> Mail:   1211 Geneve 23 - Switzerland                     Mailbox:
> J25910
> E-Mail: Olivier.Couet@cern.ch                            Phone:
> +41 22 7676522
> WWW:    http://cern.ch/Olivier.Couet/                    Fax:
> +41 22 7677155



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET