[vtkusers] question about implementing my own image pan
Jim Peterson
jimcp at cox.net
Thu Oct 14 22:08:04 EDT 2010
Jonathan Morra wrote:
>
> Where lastPoint[] is the last point that the mouse was at, and the
> startPoint(e) method updates the lastPoint array. This code does pan
> the image in the direction that the mouse moves, however the amount
> that is panned per mouse movement is wrong, and it seems to be
> affected by the image zoom (ie an image that is zoomed in very far
> pans too fast and an image that is zoomed way out pans too slowly).
> Does anyone have any idea why this is or how to fix it. My guess is
> that I have to multiply the xChange and yChange by some scale factor
> that's a function of the zoom, but I can't seem to figure it out.
>
I think you have the problem, you are using screen coordinates to modify
world coordinates. when you are viewing a large scale object (zoomed
out) the screen coordinates may be insignificant compared to the world
coordinates, when zoomed in, they are very large. you might be able to
factor the adjustment of the camera and focal point to the distance
between camera position and focal point (call that camera distance) to
come up with a reasonable metric, maybe equate this screen width in
pixels to camera distance in world units.
Also, you are assuming your views are always perpendicular to a
coordinate plane, are you allowing scene rotation? if so, your view
plane may not be parallel to one of the coordinate planes.
Just a curiosity, when I hold the shift key down, my window interactor
goes into pan mode. If you need something different then that, maybe
looking at the existing interactor for an example of panning.
HTH,
Jim
More information about the vtkusers
mailing list