-
Notifications
You must be signed in to change notification settings - Fork 456
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
feat(imageIdSpecificStateManager.js): Methods for managing toolState via imageId #1151
feat(imageIdSpecificStateManager.js): Methods for managing toolState via imageId #1151
Conversation
…lState via imageId Expose [get|add|clear]ImageIdToolstate methods which allow managing imageId specific toolState without needing an element with the image loaded. cornerstonejs#1150
Codecov Report
@@ Coverage Diff @@
## master #1151 +/- ##
=======================================
Coverage 18.95% 18.95%
=======================================
Files 282 282
Lines 8422 8422
Branches 1434 1434
=======================================
Hits 1596 1596
Misses 5658 5658
Partials 1168 1168
Continue to review full report at Codecov.
|
This makes a lot of sense to me. I've witnessed too many applications manipulating state directly by drilling down. This feels much safer and less in the weeds. If we want to swap managers, the ID agnostic fields still satisfy the interface -- any state manager not scoped to ID wouldn't use the new methods either. |
🎉 This PR is included in version 4.10.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
function clearElementToolState(element) { | ||
const enabledElement = external.cornerstone.getEnabledElement(element); | ||
|
||
if ( | ||
!enabledElement.image || | ||
toolState.hasOwnProperty(enabledElement.image.imageId) === false | ||
) { | ||
if (!enabledElement.image) { | ||
return; | ||
} | ||
clearImageIdToolState(enabledElement.imageId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there was an error, missing the "image" object
clearImageIdToolState(enabledElement.imageId);
to change:
clearImageIdToolState(enabledElement.image.imageId);
Expose [get|add|clear]ImageIdToolstate methods which allow managing imageId specific toolState without needing an element with the image loaded.
#1150
New feature
What is the current behavior? (You can also link to an open issue here)
What is the new behavior (if this is a feature change)?
3 new methods on the
ImageIdSpecificToolStateManager
for managing toolState without needing an element.The signature for these matches that of the exising
add, get, clear
methods except that the first argument is animageId
instead of an element.No