# How to put a limit to zoom in?

**URL:** https://discourse.vtk.org/t/how-to-put-a-limit-to-zoom-in/9819
**Category:** Support
**Created:** [November 15, 2022, 6:32am UTC](https://discourse.vtk.org/t/how-to-put-a-limit-to-zoom-in/9819 "2022-11-15T06:32:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![MKRangers](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mkrangers/32/5341_2.png) [@MKRangers](https://discourse.vtk.org/u/MKRangers)
#### Post date: [November 15, 2022, 6:32am UTC](https://discourse.vtk.org/t/how-to-put-a-limit-to-zoom-in/9819/1 "2022-11-15T06:32:20Z")

</div>

Hi everyone,

I have a series of image volumes with different resolutions, and I’m developing a visualization tool with some UI features for the users to navigate different resolutions. I want to set up a limit for `vtkInteractorStyleTrackballCamera::OnMouseWheelForward()`, so that when the user keeps scrolling the wheel, it will eventually change switch to another volume of the same area but with lower resolution.

I notice that there’s `vtkCamera::zoom()` where one can explicitly specify a factor to decide how much to zoom an object. I understand that this factor is probably a relative scaling factor with respect to the current state of the object, so there’s no ‘Get’ method provided for this factor. Is there a way to measure how much an object has been zoomed in or out?

Thank you so much in advanced!

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [November 26, 2022, 9:46pm UTC](https://discourse.vtk.org/t/how-to-put-a-limit-to-zoom-in/9819/2 "2022-11-26T21:46:12Z")

</div>

Hello,

One way to do it is to extend/customize the `vtkInteractorStyleTrackballCamera` classe like this one here: [gammaray/v3dmouseinteractor.h at master · PauloCarvalhoRJ/gammaray · GitHub](https://github.com/PauloCarvalhoRJ/gammaray/blob/master/viewer3d/v3dmouseinteractor.h). That is a modified `vtkInteractorStyleTrackballCamera` to enable probing of mesh values via mouse picking with a probe marker. The probe marker is a small red sphere that must be resized according to the zoom applied so its angular size stays the same. To use a custom interactor style, do like this:

```cpp
    m_myInteractorStyle = vtkSmartPointer<myInteractorStyle>::New();
    m_myInteractorStyle->SetDefaultRenderer( m_renderer );
    m_vtkwidget->renderWindow()->GetInteractor()->SetInteractorStyle( m_myInteractorStyle );

```

In the example above, `m_vtkwidget` is a `QVTKOpenGLNativeWidget`.
