Zoom individual pads of a canvas in a GUI

Hi,

I want to be able to zoom individual pads to see objects in individual pads better.
When it is just a single canvas no sub psds, i.e. only one figure instead of 6, I use the
ProcessedEvent(Int_t event,Int_t ix, Int_t iy, TObject* selected) of the TCanvas, where
using ix and and iy of kButton1Down and kButton1Up and the c->GetRange(x_0, y_0, x_1, y_1), the frame range is modified accordingly.

However I am not sure what is the best way of doing this with multiple pads.
For example in this plot I divided the canvas into 6 pads, but then realized that
pad doesn’t have “ProcessedEvent” method.

Could you advise, if I should necessarily make a separate embedded canvas for each figure (which I want to avoid), or somehow I can do the “Zoom” using the pad.

In this figure drawn objects are TArc and TLine.

ROOT Version: 6.16/00
Platform: Not Provided
Compiler: gcc 7.5.0


The expert on this is @couet, but he will probably be quite busy the next few days.

In the mean time, I would try to zoom the histogram that’s displayed on the pad in question. Something like

hist->GetXaxis()->SetRange[User](...);

Maybe you have to tell the pad that it has been modified after the zooming of the axis using thePad->Modified();

Thank you @StephanH for the replay,

It is actually just a frame, not histogram nor graph.
I just draw TArc and TLine on it.

Though my issue is, how to get coordinates in the local pad frame.
from ProcessedEvent method of the canvas I can get coordinates in the global canvas,
frame, but not of the pad on which that mouse operated.

Ok, we better wait for @couet to have a look at this.

Thanks @StephanH !!, sure No rush.

I do not understand why you need to use ProcessedEvent to perform zooming.
Interactive Zooming is already implemented … there is no code to write … just zoom with the mouse.
I guess you are doing something special. Can you provide a piece of code reproducing what you are doing ?

Thank you for the replay.

I just uploaded a slightly modified version of exec3.C from the root tutorials.
So on the right pad I draw a frame, and on that frame I draw to TArcs.
In my case the mouse zoom doesn’t work. It will work if I zoom individual axises separately, when I hover the mouse in the vicinity of axises, but what I want is to zoom, like how it is done in TH2

exec3_Rafo.C (1.3 KB)

DrawFrame produces and empty TH1F… You need a TH2F. Instead of using DrawFrame create an empty TH2F and Draw it.

Thank you!

Yes With TH2 it worked!
This mostly satisfies my needs.

Ont thing that I was envisioning is to keep the aspect ratio fixed, even, if user mouse zoom is changing the AR, I would like it keep the aspect ratio using the largest side.
Is any option is available, that would allow me to do this?

Thanks,
Rafo

great !

No, not directly. You will need to implement something.

1 Like