Skip to content

Commit

Permalink
ENH: Improve Endoscopy usability updating status of keyframe navigati…
Browse files Browse the repository at this point in the history
…on buttons

(cherry picked from commit 51d73db)
  • Loading branch information
jcfr committed Dec 11, 2023
1 parent 9f93fcc commit c427b52
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Modules/Scripted/Endoscopy/Endoscopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,28 @@ def setupFlythroughUI(self):
firstOrientationButton.enabled = True
firstOrientationButton.connect("clicked()", self.onFirstOrientationButtonClicked)
flythroughOrientationLayout.addWidget(firstOrientationButton)
self.firstOrientationButton = firstOrientationButton

backOrientationButton = qt.QPushButton(_("Back"))
backOrientationButton.toolTip = _("Go to the previous user-supplied keyframe.")
backOrientationButton.enabled = True
backOrientationButton.connect("clicked()", self.onBackOrientationButtonClicked)
flythroughOrientationLayout.addWidget(backOrientationButton)
self.backOrientationButton = backOrientationButton

nextOrientationButton = qt.QPushButton(_("Next"))
nextOrientationButton.toolTip = _("Go to the next user-supplied keyframe.")
nextOrientationButton.enabled = True
nextOrientationButton.connect("clicked()", self.onNextOrientationButtonClicked)
flythroughOrientationLayout.addWidget(nextOrientationButton)
self.nextOrientationButton = nextOrientationButton

lastOrientationButton = qt.QPushButton(_("Last"))
lastOrientationButton.toolTip = _("Go to the last user-supplied keyframe.")
lastOrientationButton.enabled = True
lastOrientationButton.connect("clicked()", self.onLastOrientationButtonClicked)
flythroughOrientationLayout.addWidget(lastOrientationButton)
self.lastOrientationButton = lastOrientationButton

flythroughFormLayout.addRow(flythroughOrientationLayout)

Expand Down Expand Up @@ -352,6 +356,21 @@ def updateWidgetFromMRML(self, *_unused):
_("Update Keyframe Orientation") if deletable else _("Save Keyframe Orientation")
)

# Update keyframe navigation buttons
firstResampledCurvePointIndex = self.logic.getFirstControlPointIndex()
lastResampledCurvePointIndex = self.logic.getLastControlPointIndex()
(
self.firstOrientationButton.enabled,
self.backOrientationButton.enabled,
self.nextOrientationButton.enabled,
self.lastOrientationButton.enabled,
) = (
firstResampledCurvePointIndex is not None and firstResampledCurvePointIndex != resampledCurvePointIndex,
self.logic.getPreviousControlPointIndex(resampledCurvePointIndex) is not None,
self.logic.getNextControlPointIndex(resampledCurvePointIndex) is not None,
lastResampledCurvePointIndex is not None and lastResampledCurvePointIndex != resampledCurvePointIndex,
)

# If there is no input curve available (e.g scene close), stop playblack
if not self.inputCurve:
self.setPlaybackEnabled(False)
Expand Down

0 comments on commit c427b52

Please sign in to comment.