Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] StackViewport selected index is out of sync with StackScrollTool when used with StackViewport.setImageIdIndex() #1727

Open
mcullifer opened this issue Dec 23, 2024 · 0 comments

Comments

@mcullifer
Copy link

mcullifer commented Dec 23, 2024

Describe the Bug

I have a stack viewport to display frames of an OCT image. One of the controls I have on the viewer is a range slider which lets the user select the frame to view using viewport.setImageIdIndex(rangeSliderValue). I am also using the StackScrollTool on the viewport. There's some UX reasons why I have both the StackScrollTool as well as a range slider to set the selected frame. Either way if you set the selected frame with the range slider viewport.setImageIdIndex() then use the stack scroll tool (I have the tool binding set to Ctrl + MouseWheel) the selected frame jumps to the initial frame the StackViewport was set to with viewport.setStack(imageIds, initialIndex).

Potential Fix

After some digging I found out that the StackViewport has 2 separate properties:

  1. currentImageIdIndex
  2. targetImageIdIndex

The StackScrollTool references targetImageIdIndex, which is set when calling viewport.setStack() and viewport.scroll(). It appears that the StackScrollTool ends up calling viewport.scroll(). However, when calling viewport.setImageIdIndex() it appears that only currentImageIdIndex is updated. I believe this is the source of the problem. The setImageIdIndex()/_setImageIdIndex() method should also update targetImageIdIndex after successfully setting the new currentImageIdIndex. This way when using viewport.scroll() or StackScrollTool in combination with manual viewport.setImageIdIndex() the referenced image id index will stay in sync with each other.

Steps to Reproduce

  1. Set the StackViewport selected index to something other than the index it was initialized with using viewport.setImageIdIndex()
  2. Use the StackScrollTool to scroll to the next/previous image
  3. The frame will jump to the initial viewport index state

Example

  • Set default stack index to 0
  • Call viewport.setImageIdIndex(60) or some other value that is not 0
  • Scroll using StackScrollTool
  • The selected viewport image will jump to 0 + delta instead of 60 + delta

The current behavior

The index that the StackScrollTool thinks the viewport is on is not the same as what the viewport is actually on.

The expected behavior

The selected index of the StackViewport should be the same as the index the StackScrollTool references.

OS

Windows 11

Node version

v20.18.0

Browser

Chromium 131.0.6778.205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant