Hi,
I am trying to have a line drawn at the mouse cursor position when it touches the x-axis. The line needs to be perpendicular to the x-axis. The following code doesnt seem to work. What am I doing wrong?
Cheers
Arindam
[color=#000080][size=85]class TCustomPad : public TPad
{
public:
TCustomPad(const char* name, const char* title, Double_t xlow, Double_t ylow, Double_t xup, Double_t yup, Color_t color = -1, Short_t bordersize = -1, Short_t bordermode = -2)
:TPad(name, title, xlow, ylow, xup, yup, color, bordersize, bordermode)
{}
void ExecuteEventAxis(Int_t event, Int_t px, Int_t py, TAxis *axis)
{
if(event == kMouseMotion)
{
gVirtualX->SetLineColor(5);
gVirtualX->SetLineWidth(3);
Double_t ratio1;
Int_t px1Val, py1minVal, py1maxVal;
if (!strcmp(axis->GetName(),"xaxis")) {
DEBUG((TString("ExecuteEventXAxis px = ")+=px));
DEBUG((TString("ExecuteEventXAxis py = ")+=py));
ratio1 = (AbsPixeltoX(px) - GetUxmin())/(GetUxmax() - GetUxmin());
px1Val = XtoAbsPixel(GetUxmin()+ratio1*(GetUxmax() - GetUxmin()));
py1minVal = YtoAbsPixel(GetUymin());
py1maxVal = YtoAbsPixel(GetUymax());
gVirtualX->DrawLine(px1Val, py1minVal, px1Val, py1maxVal);
//gVirtualX->SetLineColor(-1); //tried with or without this
Modified();
GetMother()->Update();
}
}
TPad::ExecuteEventAxis(event, px, py, axis);
}
ClassDef(TCustomPad, 1);
};[/size][/color]