How to get / set the camera zoom in renderWindow

Hey, In a Generic Render Window, I’m rendering a 3D actor, that we can zoom using mouse scroll,
I need to get and set the zoom property, I tried: GLWindow.getRenderer().getActiveCamera().getDistance()
it doesn’t work, is there a way to get zoom property?

if you are in parallel rendering you should play with parallelScale. Not that there is a convenient zoom() method as well.

1 Like


In perspective projection, the magnification level is mainly governed by the horizontal angle of the camera’s viewing frustum (the smaller the angle, the greater the zoom level). You can call GetViewAngle() on your vtkCamera object to get the current angle. Divide a reference value (e.g. 30º, which is the default angle value) by it to get a relative zoom measure. Examples: if GetViewAngle() gives 15º, then you have a zoom of 2x; if you get 60º, the current zoom level is 0.5x.

Edit.: this is of course a rough approximation. Actual magnification calculation involves some trigonometry.

take care,


1 Like