Problem with TBox and LogY

Hi,

I have some trouble with the TBox and the logY mode. When I am in logY mode, and the box is in a certain range, the TBox cannot anymore been selected by the mouse. Is it a well known problem ?

ex:

TH1F *h = new TH1F("h","h",50,-50,50)
h->FillRandom("gaus")
h->Draw()
TBox *b = new TBox(-20,1200,20,200)
b->Draw()
gPad->SetLogy()

The box cannot anymore be selected by the mouse

Thanks in advance

Jérémie

Yes I see that. The picking in log scale is not implement for several basic graphics object like box arrow ellipse…

Ok I see. And is it possible to manually add it or this is complicated ?

Some mode are needed in TBox::DistancetoPrimitive and TBox::ExecuteEvent

Actually I am not using the TBox but a class which herits from TBox. Do you have an exemple of what I do include in the methods Box::DistancetoPrimitive and TBox::ExecuteEvent to add this possibility for my objects ?

Hi @dudouet - you know what would be even better? You submitting a pull request at https://github.com/root-project/root for the code we don’t currently have, namely TBox::DistanceToPrimitive. You can see what it should look like here: https://root.cern.ch/doc/master/TLine_8cxx_source.html#l00080

Other examples are listed in the doc of TObject::DistanceToPrimitive https://root.cern.ch/doc/master/classTObject.html#a0eb6b52feee3bcdada0e685c0b2fb167 e.g. TPad's https://root.cern.ch/doc/master/TPad_8cxx_source.html#l01087 is likely a good candidate!

Cheers, Axel.

Hi,

I am not sure to understand what you want me to do. For information, I have corrected what was missing: in the method TBox::DistanceToPrimitive, one just need to add :

if(gPad->GetLogx() == true){
    px1 = gPad->XtoAbsPixel(TMath::Log10(GetX1()));
    px2 = gPad->XtoAbsPixel(TMath::Log10(GetX2()));
}
if(gPad->GetLogy() == true){
    py1 = gPad->YtoAbsPixel(TMath::Log10(GetY1()));
    py2 = gPad->YtoAbsPixel(TMath::Log10(GetY2()));
}

after:

px1 = gPad->XtoAbsPixel(fX1);
py1 = gPad->YtoAbsPixel(fY1);
px2 = gPad->XtoAbsPixel(fX2);
py2 = gPad->YtoAbsPixel(fY2);

and the same needs to be done in the method ‘TBox::ExecuteEvent’, in the kMouseMotion case.

Cheers

Jérémie

If you do not want to make a PR can you send me a modified version of TBox working for you ?
So I can test it and do the commit for you.

Hi,

This version of TBox is working fine in log scale for me.

TBox.cxx (27.3 KB)

Cheers

Jérémie

Thanks ! Now in master.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.