I am trying to observe the end interaction event of the reformat widget.
To do that I have tried to observe the Interaction node of the vtkMRMLThreeDReformatDisplayableManager using slicer.vtkMRMLInteractionNode.EndPlacementEvent.
Unfortunately, I was not able to get signals.
Is it the right way to do this? Any advice would be great!
I don’t think this widget event is exposed in MRML now. You could probably inspect the VTK renderer and find the widget and add an observer to the event, but it would not be very clean and within about a year the whole widget will be replaced with a more sophisticated one (developed specifically for image slices, with thickness adjustment, right-click menu, etc.).
What would you like to achieve? Maybe there are other events in the MRML scene that you could observe.
def reformatObserverFunction(self, sliceNodeCaller, event):
Start/reset a 500ms timer each time we receive user MultiplanarReformatFlag. ParameterNode update is triggered at trigger timeout
if sliceNodeCaller.GetInteractionFlags() == sliceNodeCaller.MultiplanarReformatFlag: # Pass signals coming from the reformatWidget
# If a time was already on, stop it
self.reformatWidgetTimer = qt.QTimer()
Could you give us some details about the new reformat widget? Is it a module for now?
Although the workaround may work, I strongly suggest not relying on such mechanics for handling events. QTimer should only be used as a last resort. As a comment about the implementation of the workaround, I’d suggest not deleting and re-creating the timer, there is no apparent reason to do so, and deleteLater is not a reliable way to delete an object in Qt, so should not be relied on either.
Well, we saw that lines in the DisplayableManager/vtkMRMLThreeDReformatDisplayableManager.cxx . But, if I understand the code correctly EndSliceNodeInteraction does not trigger an event.