Zoom out camera automatically to fit in the segment, how?

I am interested if there is some way to zoom in/out so that each segment whether big or small, fits right away into the view covering let’s say 70% of the viewport.

In other words, not to manually zoom in and out each time.

I hope this was not too weirdly expressed, but yeah the zoom should change so that the segment can be seen right away… instead of constantly zooming in and out to show it…

You need to implement a custom action for this (that you can put on the toolbar, in a subject hierarchy right-click menu action, and/or bind to a keyboard shortcut). In the implementation you would need to get the bounds of the segment very similarly how the center is computed in vtkMRMLSegmentationNode::GetSegmentCenter method.

Hm for that I would need programming skills, I will see if someone knows how to do this and could maybe help me in exchange for some money

Hm for that I would need programming skills, I will see if someone knows how to do this and could maybe help me in exchange for some money

I think I can help you with that. I’ll send you a private message

Here I have found bounding box how to get it, is this code useful for me to learn how to do this?

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-size-position-and-orientation-of-each-segment

thank you I have replied in the inbox

Yes, this should be usable, too, to get RAS bounds of segments.

Well I guess I have to figure out three more tasks:

  1. Get slicer to understand the size and the shape of the viewport
  2. Figure out how to call zoom function for red,green and yellow viewports. I found how to do it for the 3d Camera (Zoom in or out via python interactor version 4.8.0 on MAC). Considering the movement of Camera and zoom in/out in 3D world is signitifcantly different, I suppose different view/zoom in and out methods are used for red,green and yellow viewport.
  3. Zoom in/out to get bounds of segment fit the viewport

To get this done correctly, I will have to spend some time

I will be reading more today and tomorrow and in the next week about this, try to figure it out…