Skip to content
/ Slicer Public
forked from Slicer/Slicer

Commit

Permalink
ENH: Update EndoscopyLogic API for retrieving first/previous/next/las…
Browse files Browse the repository at this point in the history
…t indices
  • Loading branch information
jcfr committed Dec 8, 2023
1 parent 083595b commit 9b9cc9f
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions Modules/Scripted/Endoscopy/Endoscopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,34 +411,16 @@ def onDeleteOrientationButtonClicked(self):
self.flyTo(resampledCurvePointIndexToDelete)

def onFirstOrientationButtonClicked(self):
allIndices = self.logic.cameraOrientationResampledCurveIndices
if not allIndices:
return
whereTo = min(allIndices, default=self.frameSlider.minimum)
self.frameSlider.value = whereTo
self.frameSlider.value = self.logic.getFirstControlPointIndex()

def onBackOrientationButtonClicked(self):
allIndices = self.logic.cameraOrientationResampledCurveIndices
allIndices = [x for x in allIndices if x < self.frameSlider.value]
if not allIndices:
return
whereTo = max(allIndices)
self.frameSlider.value = whereTo
self.frameSlider.value = self.logic.getPreviousControlPointIndex(self.frameSlider.value)

def onNextOrientationButtonClicked(self):
allIndices = self.logic.cameraOrientationResampledCurveIndices
allIndices = [x for x in allIndices if x > self.frameSlider.value]
if not allIndices:
return
whereTo = min(allIndices)
self.frameSlider.value = whereTo
self.frameSlider.value = self.logic.getNextControlPointIndex(self.frameSlider.value)

def onLastOrientationButtonClicked(self):
allIndices = self.logic.cameraOrientationResampledCurveIndices
if not allIndices:
return
whereTo = max(allIndices)
self.frameSlider.value = whereTo
self.frameSlider.value = self.logic.getLastControlPointIndex()

def onSaveExportModelButtonClicked(self):
logging.debug("Create Model...")
Expand Down Expand Up @@ -603,6 +585,24 @@ def __init__(self, dl=0.5):
def getNumberOfControlPoints(self):
return self.resampledCurve.GetNumberOfControlPoints()

def getFirstControlPointIndex(self):
allIndices = self.cameraOrientationResampledCurveIndices
return min(allIndices, default=None)

def getPreviousControlPointIndex(self, currentResampledCurvePointIndex):
allIndices = self.cameraOrientationResampledCurveIndices
allIndices = [x for x in allIndices if x < currentResampledCurvePointIndex]
return max(allIndices, default=None)

def getNextControlPointIndex(self, currentResampledCurvePointIndex):
allIndices = self.cameraOrientationResampledCurveIndices
allIndices = [x for x in allIndices if x > currentResampledCurvePointIndex]
return min(allIndices, default=None)

def getLastControlPointIndex(self):
allIndices = self.cameraOrientationResampledCurveIndices
return max(allIndices, default=None)

def setControlPointsByResamplingAndInterpolationFromInputCurve(self, inputCurve) -> None:
if inputCurve is None:
return
Expand Down

0 comments on commit 9b9cc9f

Please sign in to comment.