fury
fury copied to clipboard
Reset camera tight does not keep the camera point of view
Description
The scene.reset_camera
method is expected to "reset the camera so the content fit tightly within the window."
The self-contained example below shows that the call does not have an effect on the displayed scene, whatever the value of the margin_factor
is: i.e. contents are not fit within the window more or less tightly.
I ignore if the call should be combined with a call to scene.zoom()
with the appropriate factor, but I would expect the method to do that from the description. I would also expect the point of view of the camera to remain the same (i.e. not to reset to the default view), although this would be a minor issue if it can be solved by setting it to the desired point of view (e.g. scene.roll(90)
) once the contents fit tightly within the window.
Way to reproduce
A self-contained script to reproduce the issue and the generated images have been posted in: https://gist.github.com/jhlegarreta/1cd2d674e130f3643058761d4dda83d8
As said, contents are not fit within the window more or less tightly regardless of the margin_factor
value (more extreme values have been tried).
Environment:
'fury_version': '0.7.0.post51+g2e7971a',
commit_hash': '2e7971a176c2540e10a9a6da861097583d08cb4a'
'sys_version': '3.8.10 (default, Jun 2 2021, 10:49:15) \n[GCC 9.4.0]'
'sys_platform': 'linux'
'numpy_version': '1.21.1'
'scipy_version': '1.7.0'
'vtk_version': '9.0.3'
'matplotlib_version': '3.4.2'
'dipy_version': '1.4.1'
I think this is present in earlier versions of FURY
, regardless of the VTK
version, though.
- [X] Code example
- [X] Relevant images (if any)
- [X] Operating system and versions (run
python -c "from fury import get_info; print(get_info())"
)
Thanks.
Hi @jhlegarreta,
It seems that reset_camera_tight
is working correctly.
You just need to pay attention when you call window.show()
. This function has a parameter named reset_camera
default to True
. So you have to set it up to False if you call reset_camera_tight
before.
e.g: window.show(scene, size=size, reset_camera=False)
.
Sorry for the late answer and I hope this helps. closing this issue
@skoudoro thanks for caring about this.
You just need to pay attention when you call window.show(). This function has a parameter named reset_camera default to True. So you have to set it up to False if you call reset_camera_tight before. e.g: window.show(scene, size=size, reset_camera=False).
Although I confirm that this is right (i.e. the camera is tightened around the contents), the point of view is not kept:
I would also expect the point of view of the camera to remain the same (i.e. not to reset to the default view), ~although this would be a minor issue if it can be solved by setting it to the desired point of view (e.g. scene.roll(90)) once the contents fit tightly within the window.~
Once the contents fit tightly, changing the point of view has no effect.
Unless I'm doing something wrong, this can be easily seen slightly modifying the posted snippet: i) we can remove any camera resetting by window.show
commenting it; ii) then we set the camera to snapshot a e.g. sagittal view; iii) tightening the camera around the contents makes the viewpoint to be reset
scene.yaw(90)
scene.roll(-90)
scene.reset_camera() # unless this is called, the above camera movements do not take effect
# Try to tighten around the contents
margin_factor = 0.7
scene.reset_camera_tight(margin_factor=margin_factor) # makes the camera to disregard the yaw and roll angles; sets it to its default position. Commenting this statement records a sagittal snapshot below.
size = (900, 900)
# window.show(scene, size=size, reset_camera=False)
filename = "scene_snapshot_tighten1.png"
window.snapshot(scene, fname=filename, size=size)
I do not have permissions to re-open the issue, but I'd say that the above is not the expected behavior. Thanks.
ok, thank you for the feedback, the issue is more clear now and I confirm it. I will look into it