[ROOT] problem with gPad->PixeltoY()

From: Ed Oltman (eoltman@imago.com)
Date: Thu Nov 07 2002 - 21:06:15 MET


Hello,
 I have a class derived from TH1F that overrides DistancetoPrimitive().  (I
want
a TH1F that gets selected when ever the mouse is between the histogram line
and
the y=0 axis.) I use gPad->PixeltoX/Y() routines.  The gPad->PixelToX works
fine:
x is what it should be.  The y is totally goofy.  For example, when the
displayed y-range is between 0 and 16000, gPad->PixeltoY returns -20657 when
it
should be 0 and -6242 when it should be 16000. (numbers here are
approximate)

What is going wrong?  When I display the Status Bar, the displayed y-value
is
correct.

I am using root 3.03/9a on win2k.  I use cint and vc++ 6.0 to make my class
into
a dll.

Thanks..

//--------------------------------------------------------------------------
---
Int_t CRange::DistancetoPrimitive(Int_t px,Int_t py)
{
    Int_t dist = 999999;
    double x = gPad->PixeltoX(px);
    double y = gPad->PixeltoY(py);

    // debug print
    printf("x = %f   y = %f  pixx = %d pixy = %d\n",x,y,px,py);


    int bin = FindBin(x);
    if (bin<1 || bin>GetNbinsX()) return dist;
    double yHist = GetBinContent(bin);
    if (yHist>0.)
    {
        if (y<yHist && y>0.) dist = 2;
    }
        else
    {
        if (y>yHist && y<0.) dist = 2;
    }
    return dist;
}



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:16 MET