cornerstonejs / cornerstoneTools

A framework for tools built on top of Cornerstone.
https://tools.cornerstonejs.org/
MIT License
579 stars 455 forks source link

How to reset/wipe away ww wl values or tool changes on an image? #1175

Closed kuehlc closed 4 years ago

kuehlc commented 4 years ago

Prerequisites

Description

I want to be able to reset an image/dicom to original state (before any wwwc changes or tool edits).

dannyrb commented 4 years ago

https://docs.cornerstonejs.org/api.html#reset

cornerstone.reset(enabledDomElement)

Resets viewport properties; would not clear annotations

kuehlc commented 4 years ago

@dannyrb Thanks! Don't know how I missed that in the docs.

ryanyr commented 4 years ago

@dannyrb is there a fuc to clear all annotations?

dannyrb commented 4 years ago

@ryanyr , you could clear toolState for a specific imageId, or "restoreToolstate" to a clean slate:

https://github.com/cornerstonejs/cornerstoneTools/blob/master/src/stateManagement/imageIdSpecificStateManager.js#L115

If you're depending on measurementmodified events, I don't think this would emit them. This would only apply to imageIdSpecific managers, so it's possible you'd have some stack, frameOfReference, etc. Manager still holding on to state.

ryanyr commented 4 years ago

@ryanyr , you could clear toolState for a specific imageId, or "restoreToolstate" to a clean slate:

https://github.com/cornerstonejs/cornerstoneTools/blob/master/src/stateManagement/imageIdSpecificStateManager.js#L115

If you're depending on measurementmodified events, I don't think this would emit them. This would only apply to imageIdSpecific managers, so it's possible you'd have some stack, frameOfReference, etc. Manager still holding on to state.

Thanks, it works!