sciapp / gr

GR framework: a graphics library for visualisation applications
Other
328 stars 54 forks source link

fix centering of `gr_panzoom` #90

Closed heliosdrm closed 4 years ago

heliosdrm commented 4 years ago

Make the center of the calculated coordinates consistent with the displacement indicated by x, y, regardless of the value of xzoom or yzoom

heliosdrm commented 4 years ago

Nonsense: It was just the same.

heliosdrm commented 4 years ago

Sorry for the confusion. It's only the same if x and y is 0, so I reopen it.

IngoMeyer441 commented 4 years ago

Thanks for your pull request! We tested your code and unfortunately it breaks existing applications for us. Currently, x and y are used as a fixed focus point (if xzoom and yzoom are unequal 0), so gr_panzoom can be used in GUI applications to zoom onto a given mouse position for example. Your patch causes the zoom box to be centered around the given x and y coordinates which leads to a shift of the focus point. What exactly do you want to achieve?

heliosdrm commented 4 years ago

As it is now, if xzoom == 1 and yzoom == 1, then gr_panzoom returns the coordinates of the current window without modification, whatever x and y you pass. I had thought that it had to return the coordinates of a window whose center is displaced (x, y) from the current center, thus the change in the PR.

Thanks for the explanation.

heliosdrm commented 4 years ago

Hi, I now understand that it works like this:

gr_panzoom

I had thought that "panzoom" meant a two-step action: (1) pan, and then (2) zoom. But this makes sense, so I close the PR.

IngoMeyer441 commented 4 years ago

You can use gr_panzoom for panning when passing xzoom = 0 and yzoom = 0. In this case x and y are an offset for the pan operation.