Hi Hajo,
You can bypass this problem using the functions:
XtoAbsPixel AbsPixeltoY
YtoAbsPixel AbsPixeltoY
root [0] TCanvas* c = new TCanvas root [1] TH2F* axes = new TH2F("","",10,-5,20,10,-1,2.5) root [2] axes->Draw() root [3] c->XtoAbsPixel(5.0)
These functions take into account the pad position in the canvas. They perform a conversion relatively to the pad position. In your example they gives the same result as XtoPixel, YtoPixel because the pad cover the entire canvas. In the ROOT code PixeltoY is used in several places (at least 19). AbsPixeltoY is used much more (130 places). Despite the relatively low usage of PixeltoY compare to AbsPixeltoY I don't think it would be wise to change it because it is difficult to evaluate how much it is used outside ROOT. I'll try to find a way to document this feature.
Cheers, Olivier
On Sun, 9 Apr 2006, Hajo Molegraaf wrote:
> Hi,
> I have the impression that TPad::PixeltoY returns a wrong answer. Consider the
> following:
>
> root [0] TCanvas* c = new TCanvas
> root [1] TH2F* axes = new TH2F("","",10,-5,20,10,-1,2.5)
> root [2] axes->Draw()
> root [3] c->Draw()
> root [4] c->XtoPixel(5.0)
> (const Int_t)292
> root [5] c->PixeltoX(292)
> (Double_t)4.98563216049116953e+00 // Correct
> root [6] c->YtoPixel(1.0)
> (const Int_t)209
> root [7] c->PixeltoY(209)
> (Double_t)(-3.37473520790611614e+00) // Wrong
> root [8] c->PixeltoY(209 - c->GetWh())
> (Double_t)1.00026483283924716e+00 // Correct !!
>
> I have the impression that YtoPixel uses a positive y-axis that runs from the
> top to the bottom, while YtoPixel uses a positive y-axis that runs from the
> bottom to the top. Or am I doing something wrong?
>
> Hajo.
>
> _________________________________________________________________
> Krijg direct antwoord op je vragen: MSN Messenger
> http://www1.imagine-msn.com/Messenger/Default2.aspx
>
>
-- Org: CERN - European Laboratory for Particle Physics. Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910 E-Mail: Olivier.Couet_at_cern.ch Phone: +41 22 7676522 WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22 7670300Received on Mon Apr 10 2006 - 10:52:50 MEST
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET