Problem with TBox and LogY


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 ?


TH1F *h = new TH1F("h","h",50,-50,50)
TBox *b = new TBox(-20,1200,20,200)

The box cannot anymore be selected by the mouse

Thanks in advance


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 for the code we don’t currently have, namely TBox::DistanceToPrimitive. You can see what it should look like here:

Other examples are listed in the doc of TObject::DistanceToPrimitive e.g. TPad's is likely a good candidate!

Cheers, Axel.


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()));


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.



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.


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

TBox.cxx (27.3 KB)



Thanks ! Now in master.

1 Like

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