Re: [ROOT] TStyle::Copy bug and possible fix

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Tue Jul 30 2002 - 20:26:25 MEST


Fix now in CVS. Thanks.

-- Fons



On Tue, 2002-07-30 at 19:03, Andre Holzner wrote:
> Hello,
> 
> I'm using root of the CVS of today.
> 
> When I do the following:
> 
>   h = new TH1F("","",1,0,1);
>   h->Draw();
>   gPad->SaveAs("test1.eps");
> 
> I get a eps file which looks ok.
> 
> However, if I do (I want to save the current gStyle 
> in order to modify it and go back to the old style
> when returning e.g. from a subroutine):
> 
>   old_style = gStyle;
>   gStyle = new TStyle(*gStyle);
>   h->Draw();
>   gPad->SaveAs("test2.eps");
> 
> I get a broken eps file, i.e. the bounding box is 0 0 0 0.
> 
> I saw that the two fields 
>   TStyle::fPaperSizeX
>   TStyle::fPaperSizeY
> 
> are not copied in TStyle::Copy (in fact, these are the only
> fields I found which are not copied).
> 
> Here's a patch (After which the example works properly):
> 
> ~ROOTSYS > cvs diff -c base/src/TStyle.cxx
> Index: base/src/TStyle.cxx
> ===================================================================
> RCS file: /user/cvs/root/base/src/TStyle.cxx,v
> retrieving revision 1.19
> diff -c -r1.19 TStyle.cxx
> *** TStyle.cxx  2002/05/18 08:43:29     1.19
> --- TStyle.cxx  2002/07/30 17:02:50
> ***************
> *** 273,278 ****
> --- 273,280 ----
>      ((TStyle&)obj).fPadGridY       = fPadGridY;
>      ((TStyle&)obj).fPadTickX       = fPadTickX;
>      ((TStyle&)obj).fPadTickY       = fPadTickY;
> +    ((TStyle&)obj).fPaperSizeX     = fPaperSizeX;
> +    ((TStyle&)obj).fPaperSizeY     = fPaperSizeY;
>      ((TStyle&)obj).fFuncColor      = fFuncColor;
>      ((TStyle&)obj).fFuncStyle      = fFuncStyle;
>      ((TStyle&)obj).fFuncWidth      = fFuncWidth;
> 
> 
> best regards,
> 
> André
> 
> 
> 
> -- 
> ------------------+----------------------------------
> Andre Holzner     | +41 22 76 76750 
> Bureau 32 2-C13   | Building 32     
> CERN              | Office 2-C13    
> CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



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