Possible regression in events triggered by plane and ROI markups

Hi all,

I am encountering an inconsistent behavior regarding the handling of events for plane and ROI markups in the latest preview version of Slicer, comparing to the stable release (slicer 5.6.2)

It seems that in the cases detailed below, some events are missing.

Here is the detailed behaviour :

Reproduction:
OS = Windows 11
Slicer version = 5.7.0 (revision 33134, built 2024-12-01) compared to slicer 5.6.2 (both installed from binaries)

  1. Create the markups (plane or ROI) using the markups module
  2. use the following snippet to get the node and connect the observers
# retrieve the node using its name (default is P for plane, R for ROI)
node = getNode("P")
# connect callbacks 
node.AddObserver(slicer.vtkMRMLMarkupsROINode.PointStartInteractionEvent, lambda *_: print("start"))
node.AddObserver(slicer.vtkMRMLMarkupsROINode.PointModifiedEvent, lambda *_: print("modified"))
node.AddObserver(slicer.vtkMRMLMarkupsROINode.PointEndInteractionEvent, lambda *_: print("end"))
  1. observe the console logs while click and dragging either the center point, or the corner (or side) handles

Results:
Here are the events triggered depending on the use cases

Use case Slicer 5.6.2 Slicer 5.7.2 2024-12-01
Dragging center of ROI startInteraction, modified, endInteraction modified
Dragging corner of ROI startInteraction, modified, endInteraction modified
Draging center of plane markup startInteraction, modified, endInteraction startInteraction, modifiedEvents, endInteraction
Dragging corner of plane markup StartInteraction, endInteraction* No event

*The first time a corner of the plane is moved in 5.6.2, a single modifiedEvent is triggered between the start and end events

To me it seems like a regression, unless I have missed an API change regarding the events of these markups. I didn’t notice any change in other markups (fiducial, line, angle…) but I haven’t tried all of them.

I would be grateful if you have any insight on what could be causing these changes.

Control point modifications still invoke PointStartInterActionEvent, PointModifiedEvent, PointEndInteractionEvent events. However, plane and ROI position and sizes are not defined by control points but mostly by the new vtkMRMLInteractionWidget, which does not emit start/end interaction events. It may be still possible to add these events to the interaction widget before we release Slicer-5.8. To make sure we try to include this, please add an issue at https://issues.slicer.org.

Can you write about your use case? How do you use these interaction events?

Thank you for the clarification.

Here is the link to the corresponding issue I created.

We often use markups as handles for controlling 3D assets and rely on those events to update their properties.

You can control 3D assets using node modified events. It is only necessary to know about interaction (when the user depresses and releases the mouse button) in very rare, special cases, such as you cannot de real-time updates continuouslt. What is your special use case?

Are you aware that transforms have now widgets in 2D and 3D (so you don’t need to use ROIs or planes for positioning, rotating, and scaling them)?

Start- and End- interaction events are used for undo / redo logic.

Real time updates also pose a problem when performance is an issue (e.g when the event is triggering a processing pipeline on the data). Sometimes it makes more sense to let the user do the positioning and re-run the pipeline only once on mouse release than to do it real time with too much lag.

I understand that there are options around it, but none of them are painless. And from a developer perspective, I think it would be valuable to keep the API consistent for all markups types. Having some markups not trigger the same events as others adds a bit of complexity, since it is not immediately obvious why they would have a different behavior. So I think it could be worth adding these events back.

We will try to get this done before releasing Slicer-5.8 within a few weeks.

1 Like