Skip to content

Commit

Permalink
add facility to enable/disable slider
Browse files Browse the repository at this point in the history
  • Loading branch information
paskino committed Sep 15, 2023
1 parent b8897d5 commit f4ece42
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
29 changes: 27 additions & 2 deletions Wrappers/Python/ccpi/viewer/CILViewer2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ class CILViewer2D(CILViewerBase):
IMAGE_WITH_OVERLAY = 0
RECTILINEAR_WIPE = 1

def __init__(self, dimx=600, dimy=600, ren=None, renWin=None, iren=None, debug=True):
def __init__(self, dimx=600, dimy=600, ren=None, renWin=None, iren=None, debug=False, enableSliderWidget=True):
CILViewerBase.__init__(self, dimx=dimx, dimy=dimy, ren=ren, renWin=renWin, iren=iren, debug=debug)

self.setInteractorStyle(CILInteractorStyle(self))
Expand Down Expand Up @@ -1143,6 +1143,7 @@ def __init__(self, dimx=600, dimy=600, ren=None, renWin=None, iren=None, debug=T
# Slider widget
self.sliderProperty = SliderProperties()
self.sliderWidget = None
self._sliderWidgetEnabled = enableSliderWidget

self.__vis_mode = CILViewer2D.IMAGE_WITH_OVERLAY
self.setVisualisationToImageWithOverlay()
Expand Down Expand Up @@ -1316,7 +1317,9 @@ def installPipeline(self):
elif self.vis_mode == CILViewer2D.RECTILINEAR_WIPE:
self.installRectilinearWipePipeline()

self.installSliceSliderWidgetPipeline()
if self.getSliderWidgetEnabled():
self.installSliceSliderWidgetPipeline()

self.ren.ResetCamera()
self.ren.Render()

Expand Down Expand Up @@ -1506,6 +1509,19 @@ def installSliceSliderWidgetPipeline(self):
self.sliderWidget = sw
self.sliderCallback = cb

def uninstallSliderWidget(self):

if self.sliderWidget is not None:
sr = self.sliderWidget.GetRepresentation()
if sr is not None:
sr.RemoveAllObservers()
coll = vtk.vtkPropCollection()
sr.GetActors(coll)
print ("coll", coll)
for actor in coll:
print ("actor", actor)
self.ren.RemoveActor(actor)

def AdjustCamera(self, resetcamera=False):
self.ren.ResetCameraClippingRange()

Expand Down Expand Up @@ -1852,4 +1868,13 @@ def reset(self):
self.uninstallPipeline()
if self.image2 is not None:
self.uninstallPipeline2()
if self.getSliderWidgetEnabled():
self.uninstallSliderWidget()

def getSliderWidgetEnabled(self):
return self._sliderWidgetEnabled
def setSliderWidgetEnabled(self, enable):
if enable:
self._sliderWidgetEnabled = enable


1 change: 1 addition & 0 deletions Wrappers/Python/examples/viewer_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def update_orientation(self, caller, ev):

# # reader.ReadDataSetInfo()
reader2.Update()
v.setSliderWidgetEnabled(False)
v.setInputData(reader2.GetOutput())
v.startRenderLoop()

0 comments on commit f4ece42

Please sign in to comment.