RF: Reset display space to a sensible value when old reference image is removed

This MR changes FSLeyes so that, when the display space is set to a reference image, and that reference image is removed, the display space is changed to another loaded NIfTI image (the first in the overlay list) instead of being reset to "world".

This change fixes an issue whereby the ortho panel zoom level would increase each time a new image was loaded. The cause of this is quite convoluted, but it is most easily reproduced when (e.g.) viewing T1 images in the file tree panel.

When the user selects the first image in the file tree list, the image is loaded, and is set as the display space reference image. When the user selects the next image in the file tree list, the images are swapped in stages:

  1. The new image is loaded. If the images are slightly rotated with respect to each other, the bounding box surrounding all overlays will increase. The ortho panel has some logic which attempts to preserve the current zoom/pan settings, so internally it will increase the zoom level, although the effective (i.e. visible) zoom will not change.
  2. The old image is removed. This would cause the display space to be automatically reset to "world", which will potentially substantially change the global bounding box, and cause the ortho panel to adjust its zoom settings again.
  3. The display space is manually set to the new image, which again changes the bounding box and triggers the ortho panel zoom preservation logic.

The unnecessary swapping back and forth of the display space setting was causing the ortho panel zoom preservation logic to be disrupted, which would result in it incorrectly increasing the effective zoom level.

The changes in this MR simplify the above process and avoid the zoom increase issue.

  • The file tree manager now swaps the old and new images in a single step
  • The display space is now automatically changed to the next NIfTI image in the overlay list, if the current reference image is removed
  • If the user manually changes the display space to e.g. "world", that choice will be saved, and will be used as the new default.

Merge request reports

Loading