cornerstonejs / cornerstoneTools

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

Help with adding callback to cornerstone tool #1185

Open sinanmb opened 4 years ago

sinanmb commented 4 years ago

Hi,

I would like to add a callback to the Probe tool in order to display a popup after the click on the viewport, (similar to the dialog modal that shows up for the arrowAnnotate tool). I have created a custom cornerstone tool and am looking for pointers on how to setup the callback to open the dialog modal and prompt the user to select a location/description for the measurement.

Thank you

dannyrb commented 4 years ago

Where are you running into issues? What have you tried?

The arrowAnnotateTool does its magic here: https://github.com/cornerstonejs/cornerstoneTools/blob/master/src/tools/annotation/ArrowAnnotateTool.js#L240-L277

Note that, in the moveNewHandle callback, we use getTextCallback. If you follow the callback/stack from there, you should be able to see how things chain together to prompt the user for info, we update the measurement data, and "unlock" the tool.

sinanmb commented 4 years ago

Hi Danny,

Thank you for getting back to me quickly. I have managed to add the callback to the tool. I'm also curious about how to change the tool's marker when hovering over the viewport. Currently the marker is a cross, and I would like to replace it with an arrow. I also would like to display some text data next to the marker.

dannyrb commented 4 years ago

We support "SVG Cursors"

You could also do something similar to dragProbe:

https://github.com/cornerstonejs/cornerstoneTools/blob/e38e2f5c81b0f83cca5a29a03334bee287028a8a/src/tools/DragProbeTool.js