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

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Mon Feb 05 2001 - 16:42:40 MET


----- Original Message -----
From: Patois Yannick <patois@ganil.fr>
To: ROOT mailing list <roottalk@pcroot.cern.ch>
Sent: 5 февраля 2001 г. 8:01
Subject: [ROOT] LineWidth : in 'pixels' ?


> 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 ?

The class  gwin32pen from the implementation of TVirtualX for Win32
answers your question (for Windows at least).

The line style is defined by CreatePen() method as follows:


gwin32pen:

//______________________________________________________________________________
HPEN TGWin32Pen::CreatePen(){

[ . . . ]
 /*  Set style of the line */

  DWORD dwStyle = fPen.lopnStyle |
                   ((dwWidth == 1) ? PS_COSMETIC
                                   : (PS_GEOMETRIC | PS_INSIDEFRAME) );

[ . . . ]


where the value of fPen.lopnStyle is defined by ROOT SetLineWidth method.

One can see if the width == 1 CreatePen creates so-called "cosmetic" pen otherwise the
"geometric" one.


Win32 docs defines:

cosmetic pen:
    A pen with dimensions specified in device units

geometric pen:
    A pen with dimensions that are specified in world units


In other words under Windows if the user defines the width = 1 he/she defines one pixel
width line (exactly). The real width of such line depends of the real hardware device (monitor, printer).
One monitor prvides 0.25 mm pixel another 0.28 etc.  One printers gives us the 1/600 inch dot size another
one 1/300 inch etc.
If the line width > 1 then the width of the line  is defined by the current Pad coordinate system.  In this case
the width of the line depends of that coordinate system parameters whatever device is used to draw it.
That implementation is a kind of compromise chosen to match its TPad and  X11 counterpart.
Hope Fons can provide some details about X11a and TPad

   Hope this helps.
                                   Valeri



> Exemple:
> <<<<
> file://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