Add / Remove Nodes in FreehandRoi Tool
See original GitHub issuePrerequisites
- Latest
- Are you reporting to the correct repository?
- No related issues, one of them got me no answers.
Description
I would like to know, if there is a possibility to add or remove nodes after the tool has been closed. I am thinking of it as getting the coords from the mouse, and on click, check the tool state and if there is an existing node, remove it (causes error) and re-render the state, and if there is no node, then add it and as well re-render the state.
Expected behavior:
When adding or removing nodes from a rendered tool, be able to add or remove this information from the tool state’s object and re-render the tool state to update the view with/without the selected nodes.
Actual behavior:
After removing or adding a node from the tool state’s object, changing the lines coordinates and re-rendering, after a click or movement the tool crashes stating Undefined is not an object
.
As usual, thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
@dannyrb thanks for your response. What I am currently doing as an example on my project is:
Every time I mark a point with the Freehand tool, I am saving the state of the tool in React’s state. At any moment, I can press ‘cmd + z’ and the last node will get deleted from the state, with the following code:
I am removing the last available node’s lines array as the last node should not have lines, AFAIK. This all works correctly, but after continuing with the marking, the next point I mark makes my application crash and output the following error:
When comparing two objects, the first being an object being generated as I mark lesions, and the second object being the object output after the undo function, they seem exactly the same. I don’t really know if internally there is a points or lines counter on the cornerstoneTools’ object or something that is making this error appear after removing a node from the array.
I am putting here a small vide as an example of the things I described above.
I hope this can make my issue clearer. Thanks again.