Re: [ROOT] LineWidth : in 'pixels' ?

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Feb 05 2001 - 17:07:48 MET


Hi Yannick,
I agree that the current algorithm is unsatisfactory with your example.
When drawing histograms/functions, the line width is scaled by the ratio
of the pad height to the canvas height. This happens in THistPainter::PaintHist.
Without this scaling, ugly pictures are generated when the canvas is resized.
I have just played with variants of the current algorithm and have found
one that gives always better results. The line width is scaled to the absolute
canvas size taken as reference an "average" canvas size of 800 pixels in height.
The new statement in THistPainter::PaintHist is
   //Width_t lw = Width_t(fH->GetLineWidth()*gPad->GetAbsHNDC() + 0.5); //old
   Width_t lw = Width_t(fH->GetLineWidth()*gPad->GetWh()/800. + 0.5);   //new

Note that the scaling has nothing to do with an interpretation in TGX11 or
TGWin32. It is simply an algorithm local to THistPainter::PaintHist.

If somebody has a better idea, let me know.

Rene Brun

Patois Yannick wrote:
> 
> Hello rooters,
> 
> In the doc for the class TAttFill, I read:
> *-*  Line attributes are taking from the argument list
> [...]
> *-*    width : expressed in pixel units
> 
> What is this 'pixel' ?
> If I give the same value in different condition, I obtain very different
> visual output (and certainly not the same number of screen pixels).
> How is the computation of the actual width done ?
> 
> Exemple:
> <<<<
> //File test.C
> {
>   TCanvas cnv1("toto","LineWidth size",2);
>   TH1D *h1=new TH1D("h1","h1",100,-10,10);
>   h1->FillRandom("gaus");
>   TF1 *f1=new TF1("f1","gaus");
>   f1->SetLineWidth(5);
>   h1->Fit("f1");
> 
>   TCanvas cnv2("toto2","LineWidth size2",2);
>   cnv2->Divide(1,2);
>   toto2_1->cd();
>   h1->Draw();
>   toto2_2->cd();
>   h1->Draw();
> 
> }
> >>>>
> 
> On my system (ix86 Linux with ROOT v3.00.02) the line width is very
> different between the 2 pads, and if it could be near 5 pixels on cnv1
> it's at the most 2 or 3 on cnv2.
> 
> I understand that a scaling has to be done, but I would like to know the
> rules that are applied to do it...
> 
>         Yannick
> 
> PS1: On my system, the previous test break CINT at second invocation
> (did I made an obvious mistake?):
>   *   Version   3.00/02   18 January 2001   *
> root [0] .x test.C
> (fits vals) OK
> root [1] .x test.C
> Warning in <TH1::Build>: Replacing existing histogram: h1
> (fits val)
>  *** Break *** segmentation violation
> 
> PS2: The HTML presentation of the class is very useful and clever,
> nicely presented, full of coments and hyperlinks, but why cant it be the
> same for the .h files ? If I have the bad luck to seek for informations
> related to an inline method, I'm send to an ugly looking file without
> any fontification, neither comments or help of any kind. Is there a good
> reason for it ?



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:35 MET