Re: [ROOT] bug in gPad->PixeltoY()?

From: Dirk Dodt (dodt@mail.desy.de)
Date: Thu Jun 24 2004 - 13:58:27 MEST


Thanks a lot, you already mentioned it...

It's never a bug :)

kind regards
       dirk


Rene Brun wrote:
> Dirk,
> 
> Instead of PixeltoY(-y) use AbsPixeltoY(y)
> 
> Rene Brun
> 
> Dirk Dodt wrote:
> 
>>Ok Here it is. I'm using just a single Pad on the Canvas, The Output
>>generated when moving the mouse over the pad is:
>>* Pixel Coordinates,
>>* User Coordinates passed back from Pixelto?() [already "corrected" by
>>calling -can->PixeltoY(-y)!]
>>* and the User Coordinates calculated the way which I understood from
>>the root manual they should work.
>>
>>The "corrected" coordinates seem to be right, but when you click the
>>left mouse button the User Coordinate Range is changed and from there on
>>the ouput from my defines is different from the -PixeltoY(-y) result.
>>(which one is correct now :)?)
>>
>>kind regards
>>   dirk
>>
>>Rene Brun wrote:
>>
>>>Dirk,
>>>
>>>Could you send a simple script showing your problem?
>>>
>>>It could be that you are using PixeltoX where you should use AbsPixeltoX.
>>>There is a difference if you have a canvas divided into subpads.
>>>
>>>Rene brun
>>>
>>>Dirk Dodt wrote:
>>>
>>>
>>>>I have the feeling the TPad::PixeltoX Method Or Rather the underlying
>>>>method whichs sets the needed Coefficients might be buggy.
>>>>
>>>>The mistake (if any) can sometimes(!) be corrected by using
>>>>-1*..->PixeltoY(-y).
>>>>
>>>>Maybe I have not fully understand everything concerning the different
>>>>coordinate systems, but if someone else is having similar problems it
>>>>might be worth looking into it. (For my own case I already have found a
>>>>workaround.)
>>>>
>>>>For Completeness:
>>>>I'm using a TRootEmbeddedCanvas in Root 3.10_03 (Suse 7.3/=Desy linux 4)
>>>>inside a QT Gui to Display some Detector Information.
>>>>
>>>>In order to do a Zoom into the Detector, I Connected the
>>>>ProcessedEvent(Int_t,Int_t,Int_t,TObject*) Slot with my code, that uses
>>>>PixeltoX and PixeltoY to transform the x,y[pixel] provided by the signal
>>>>into user coordinates and set a new ...->Range(x1,y1,x2,y2) for the Pad.
>>>
>>>
>>  --------------------------------------------------------------------------------
>>TCanvas *can;
>>void PixeltoY()
>>{
>>can = new TCanvas("test","test",500,500);
>>can->Range(-85,-85,85,85);
>>can->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, "", "DisplayGetCoordinates(Int_t, Int_t, Int_t, TObject *)");
>>}
>>#define PIXELTOX(x) ((x2-x1)*x/can->GetWw()+x1)
>>#define PIXELTOY(y) ((y2-y1)*(-y)/can->GetWh()+y2)
>>
>>void DisplayGetCoordinates(Int_t event, Int_t x, Int_t y, TObject *selected)
>>{
>>        Double_t x1,x2,y1,y2;
>>        can->GetRange(x1,y1,x2,y2);
>>        printf("Event %d: at (%3d, %3d)=(%4.1f, %4.1f)=(%3.1f, %3.1f)\n", event,x,y, can->PixeltoX(x), -can->PixeltoY(-y), PIXELTOX(x), PIXELTOY(y));//=(%3.1f, %3.1f)
>>        switch (event) {
>>                case 1://ButtonDown
>>                can->Range(0,0,85,85);
>>                break;
>>        }
>>}
> 
> 
> 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET