Restore tool state
See original GitHub issuecornerstone-core - 2.0.0 cornerstone-tools - 2.0.0
Hello.
I am trying to reuse one of the tools for a different purpose so I am unsure if this is possible or if I would have to write a new tool.
The tool in question is the rectangleRoi
The basic idea is to draw a rectangle based on coordinates with the end result being able to highlight for instance the thorax, we already know based on pixel coordinates where the thorax is but can’t draw it as that would require someone interfacing with the mouse.
One of the ideas that came up was getting how the rectangleRoi saves the tool state which we were able to do by cornerstoneTools.getToolState(element, “rectangleRoi”);
cornerstoneTools.getToolState(element, "rectangleRoi");
which returns something like the following
{
"data": [{
"visible": true,
"active": false,
"invalidated": false,
"handles": {
"start": {
"x": 882.0269058295971,
"y": 1500.6502242152467,
"highlight": true,
"active": false
},
"end": {
"x": 2353.6322869955156,
"y": 2430.085201793722,
"highlight": true,
"active": false
},
"textBox": {
"active": false,
"hasMoved": false,
"movesIndependently": false,
"drawnIndependently": true,
"allowedOutsideImage": true,
"hasBoundingBox": true,
"x": 2353.6322869955156,
"y": 1965.3677130044844,
"boundingBox": {
"width": 178,
"height": 25,
"left": 791.5695067264573,
"top": 104.93049327354261
}
}
},
"area": 1367761.5144483089
}]
}
Then based on the know coordinates of the thorax we could build that object but before doing so we need to know if we will actually be able to use it.
So assuming that we were able to build that same object with the above given properties, is there something like this?
cornerstoneTools.setToolState(element, "rectangleRoi", data);
where data equals to the json posted above?
I tried finding it and thought that cornerstoneTools.addToolState would do it but it does not
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (3 by maintainers)
Hi -
I’ve been working on saving and restoring tools to DICOM structured reports so I have some code here that shows how to create a tool state (length tool in this case) and populate it into the cornerstoneTools tool state manager:
https://github.com/OHIF/Viewers/blob/40ae48238b431477787152e1dc6dc92262ce1b58/Packages/ohif-viewerbase/client/lib/handleSR.js#L11-L34
Key call is restoreToolState.
HTH, Steve
@dannyrb
I’ve put up a pull request to add @pieper! 🎉