cornerstone3D icon indicating copy to clipboard operation
cornerstone3D copied to clipboard

[Bug] CircleROITool fires unnecessary `ANNOTATION_MODIFIED` events when any part of the annotation is outside the image

Open ScottShingler opened this issue 5 months ago • 0 comments

Describe the Bug

Positioning a CircleROITool annotation partially or fully outside the image (i.e. in the black border area) in a StackViewport will cause extraneous ANNOTATION_MODIFIED events to be triggered. This can be observed by setting up an event listener that logs to console:

eventTarget.addEventListener(
    csToolsEnums.Events.ANNOTATION_MODIFIED,
    (event) => {
        console.log(`ANNOTATION_MODIFIED: ${event.detail.viewportId} ${event.detail.annotation.annotationUID} ${event.detail.changeType}`);
    }
);

The extraneous events have been observed to fire when any part of the annotation is outside the image and any of the following occur:

  • Moving the annotation
  • Resizing the annotation
  • Moving the mouse over the annotation

This becomes a crippling issue when you have multiple viewports and need to force the other viewports to render so that the annotation is updated. Because of the extraneous ANNOTATION_MODIFIED event, it ends up causing an infinite feedback loop. I have created a repro that demonstrates this: cornerstone-annotation-spam-repro

Steps to Reproduce

  1. Draw a circle annotation in a StackViewport
  2. Move the circle partially or fully outside the image

The current behavior

Extra ANNOTATION_MODIFIED events are triggered when the annotation is outside the image.

The extraneous events have been observed to fire when any part of the annotation is outside the image and any of the following occur:

  • Moving the annotation
  • Resizing the annotation
  • Moving the mouse over the annotation

The expected behavior

The ANNOTATION_MODIFIED triggering behaviour when the annotation is outside the image should be the same as how it is when the annotation is completely contained within the image. To put it another way, it should behave more like the EllipticalROITool, which doesn't suffer from this issue.

OS

Windows 11

Node version

18.20.3

Browser

Edge 129.0.2792.52 (Official build) (64-bit)

ScottShingler avatar Oct 02 '24 21:10 ScottShingler