fix(core): re-apply invert after colormap when scrolling a stack#2814
Merged
Conversation
_setPropertiesFromCache runs on every stack scroll and (since #2679) calls setColormap, which rebuilds the RGB transfer function in its default, non-inverted state. The setInvertColor call that follows was then skipped by its no-op guard (setInvertColorGPU only flips the TF when the requested value differs from this.invert) because this.invert still held the carried-over value, so the freshly rebuilt TF stayed non-inverted and the inversion was lost. This surfaced as "invert is lost when scrolling after a reset": resetProperties applies a colormap, so this.colormap becomes defined and is then re-applied on every subsequent scroll, clobbering the inversion. Clear this.invert right after setColormap so the tracked flag matches the rebuilt (non-inverted) TF and setInvertColor actually re-applies the inversion. Colormap preservation from #2679 is retained. Fixes OHIF/Viewers#6153
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesCached inversion restoration
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Regression report: OHIF/Viewers#6153 — "After a reset, Invert is lost when scrolling between slices."
Repro: open a stack study → Invert → Reset → Invert again (the current slice inverts) → scroll to another slice → the invert is gone.
Root cause
Bisected to #2679, which added
setColormap(colormap)(and VOILUTFunction/sharpening/smoothing) toStackViewport._setPropertiesFromCache()— the method that runs on every stack scroll._resetProperties()callssetColormap(matchedColormap), so after a Resetthis.colormapis defined (before any reset it isundefined).setColormap(this.colormap)inside_setPropertiesFromCache, which rebuilds the RGB transfer function in its default, non-inverted state.setInvertColor(invert)that follows is a no-op:setInvertColorGPUonly flips the transfer function when the requested value differs fromthis.invert((!this.invert && invert) || (this.invert && !invert)), andthis.invertstill holds the carried-overtrue. So the freshly rebuilt TF stays non-inverted and the inversion is silently dropped.This is exactly why the loss appears only after a reset (that's what makes the colormap defined), and only did so after #2679 added the colormap re-application on scroll.
Fix
In
_setPropertiesFromCache, clearthis.invertright aftersetColormap(...)so the tracked flag matches the rebuilt (non-inverted) transfer function. The subsequentsetInvertColor(invert)— called with the desired value captured before the mutation — then actually re-applies the inversion instead of being skipped by the no-op guard. #2679's colormap preservation is retained.Testing
Summary by CodeRabbit
resetProperties().