Get end interaction of reformatWidget

Dear everyone,

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!

Cheers,
Pierre

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.

Thank you for the details.
I have implemented a workaround using qt.timer that is working.

sliceNode.AddObserver(vtk.vtkCommand.ModifiedEvent, self.reformatObserverFunction)
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
  print("reformatObserverFunction")
  if self.reformatWidgetTimer:
    # If a time was already on, stop it
    self.reformatWidgetTimer.stop()
    self.reformatWidgetTimer.deleteLater()

  self.reformatWidgetTimer = qt.QTimer()
  self.reformatWidgetTimer.setSingleShot(True)
  self.reformatWidgetTimer.start(500)
  self.reformatWidgetTimer.timeout.connect(self.yourfunction)

Could you give us some details about the new reformat widget? Is it a module for now?

Would the EndSliceNodeInteraction event work? See here Slicer/vtkMRMLThreeDReformatDisplayableManager.cxx at master · Slicer/Slicer · GitHub

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.

Hi Csaba,
Well, we saw that lines in the DisplayableManager/vtkMRMLThreeDReformatDisplayableManager.cxx . But, if I understand the code correctly EndSliceNodeInteraction does not trigger an event.
Pierre

Hm that’s right, it’s not an event, my bad. An event like is what would be helpful in your case.

Do you know where I can find the new reformat widget, just to play around with it.

Based on @lassoan’s comment

within about a year the whole widget will be replaced with a more sophisticated one

the widget will be available in the future.

ok thanks so there is nothing published yet.