slicer
August 4, 2021, 12:38pm
1
Operating system: Windows 10
Slicer version: 4.11
Is there an event detecting the change of the time in time sequence browser? I want to build my own extension and how can I detect the real-time change of the time value for a sequence file in python?
Hope for your help.
pieper
(Steve Pieper (Isomics, Inc.))
August 4, 2021, 2:47pm
2
You probably want something like this:
sequenceBrowserNodeID = animationNode.GetAttribute('Animator.sequenceBrowserNodeID')
sequenceBrowserNode = slicer.mrmlScene.GetNodeByID(sequenceBrowserNodeID)
sequenceNodeID = animationNode.GetAttribute('Animator.sequenceNodeID')
sequenceNode = slicer.mrmlScene.GetNodeByID(sequenceNodeID)
self.removeSequenceBrowserObserver()
def onBrowserModified(caller, event):
index = sequenceBrowserNode.GetSelectedItemNumber()
scriptTime = float(sequenceNode.GetNthIndexValue(index))
self.logic.act(animationNode, scriptTime)
tag = sequenceBrowserNode.AddObserver(vtk.vtkCommand.ModifiedEvent, onBrowserModified)
self.sequenceBrowserObserverRecord = (sequenceBrowserNode, tag)
self.animatorActionsGUI = AnimatorActionsGUI(animationNode, deleteCallback=self.onSelect)
self.actionsFormLayout.addRow(self.animatorActionsGUI.buildGUI())
self.actionsMenuButton.enabled = animationNode != None
self.exportCollapsibleButton.enabled = animationNode != None
self.sequencePlay.setMRMLSequenceBrowserNode(sequenceBrowserNode)
self.sequenceSeek.setMRMLSequenceBrowserNode(sequenceBrowserNode)
1 Like