cornerstone3D icon indicating copy to clipboard operation
cornerstone3D copied to clipboard

[Bug] StackViewport.setImageIdIndex should set this.targetImageIdIndex too

Open abustany opened this issue 1 year ago • 2 comments

Describe the Bug

Calling StackViewport.setImageIdIndex on a stack viewport does update this.currentImageIdIndex, but does not update this.targetImageIdIndex. StackViewport.scroll, on the other hand, using this.targetImageIdIndex as a base. As a result, if you scroll with the scroll tool to eg. image 10, then call setImageIdIndex(1), and then use the scroll tool again, the viewport will not scroll to image 2, but to image 11.

Steps to Reproduce

  1. Create a stack viewport
  2. Use the mouse scroll tool to scroll to a given image
  3. Call setImageIdIndex on a different image
  4. Scroll again

The current behavior

Scroll continues from the last image scrolled, instead of continuing from the image set using setImageIdIndex

The expected behavior

Scroll should be continuous even if setImageIdIndex is called.

OS

Linux

Node version

20

Browser

Firefox 128

abustany avatar Jul 15 '24 08:07 abustany

I added the following hack for now, which fixes the issue:

viewport.setImageIdIndex(imageIndex); // will update this.currentImageIdIndex but not this.targetImageIdIndex
(viewport as unknown as {targetImageIdIndex: number}).targetImageIdIndex = imageIndex; // workaround for #1393

abustany avatar Jul 15 '24 08:07 abustany

I have the same issue

cisacpalma avatar Jul 26 '24 18:07 cisacpalma

Can you check the latest OHIF viewer, which now includes Cornerstone 3D 2.0?

Here are the migration guides:

Try OHIF locally: https://viewer-dev.ohif.org/localbasic
Try Cornerstone3D 2.0 locally: https://www.cornerstonejs.org/live-examples/local.html

https://docs.ohif.org/migration-guide/3p8-to-3p9/

sedghi avatar Nov 14 '24 21:11 sedghi

I ran into this bug today and fixed it. Sorry if I didn't understand the issue at first.

sedghi avatar May 01 '25 18:05 sedghi