Skip to content

Commit

Permalink
Hide slider when image dimension is 1 (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanicaSTFC authored Oct 8, 2024
1 parent 1bcf7a3 commit 44c554f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Enhancements:
- Adds methods to CILviewer and CILviewer2D #425

Bugfix:
- Hides the slider when one image dimension is 1 #432
- Differentiate 3D and 2D images in the converter `numpy2vtkImage` #437
- Edit slider min value #420
- Fix extent error when user clicks in the viewer to create a box by clicking outside of the image #425
Expand Down
12 changes: 10 additions & 2 deletions Wrappers/Python/ccpi/viewer/CILViewer2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,11 +1550,18 @@ def installSliceSliderWidgetPipeline(self):
'''Create the pipeline for the slice slider widget
The slider widget and representation are created if not already present.
Currently the slider widget enabled flag is not used.
If present, the slider is updated.
The slider is hidden if any of the dimensions of the visualised image is 1,
else it is shown.
'''
# set slider_hidden
dims = self.img3D.GetDimensions()
slider_hidden = any(dim == 1 for dim in dims)

if self.sliderWidget is not None:
# reset the values to the appropriate ones of the new loaded image
self.sliderCallback.update_orientation(self.style, 'reset')
self.sliderWidget.SetEnabled(not slider_hidden)
return

sr = SliceSliderRepresentation()
Expand All @@ -1567,7 +1574,8 @@ def installSliceSliderWidgetPipeline(self):
sw.SetRepresentation(sr)
sw.SetAnimationModeToAnimate()
sw.EnabledOn()

# enable slider
sw.SetEnabled(not slider_hidden)
cb = SliderCallback(self, sw)

# Add interaction observers
Expand Down

0 comments on commit 44c554f

Please sign in to comment.