Re: gPad->XtoPad() not working, why?

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Fri, 10 Aug 2007 16:55:07 +0200


Hans,

XtoPad does not convert user coordinates to NDC !! (it takes care only of lin/log user coordinates
to pad coordinates. If linear coordinates   double x = pad->XtoPad(y); returns y otherwise it returns log(y). To convert from user coordinates to NDC, to, eg

   Double_t dpx  = gPad->GetX2() - gPad->GetX1();
   Double_t dpy  = gPad->GetY2() - gPad->GetY1();
   Double_t xp1  = gPad->GetX1();
   Double_t yp1  = gPad->GetY1();

  Double_t xndc = (x-xp1)/dpx
  Double_t yndc = (y-yp1)/dpy

Rene Brun

Hans Dembinski wrote:
> Dear Root Users/Developers,
>
> I have a script which works like this:
>
> 1) Draw a frame histogram, just something to define the axes and the user
> coordinate system, so that we can nicely overlay our real data on it.
>
> After this step, NDC and user coordinates should be defined!
>
> 2) I draw my data into the pad with the frame.
>
> 3) I call gPad->Draw(), ->Update(), ->Modified(), whatever and also the
> TCanvas versions. I tried them all.
>
> Now, the Pad should know its contents!
>
> 4) After doing all that, I now need to convert some user coordinates inside
> the pad into NDC coordinates. I use
>
> my_value_ndc = gPad->XtoPad(my_value);
>
> and it does not work. I just get my old value, so my_value_ndc equals
> my_value.
>
> Can someone help me understand why this is not working? Or is it a bug?
>
> Best regards,
> Hans
>
>
Received on Fri Aug 10 2007 - 16:55:12 CEST

This archive was generated by hypermail 2.2.0 : Fri Aug 10 2007 - 17:50:02 CEST