Changing multipoint tool behavior

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing multipoint tool behavior

David Kysela
My plugin generates multipoint selections that require interactive adjustment by the user. Currently, I simply let the user select the default multipoint tool and drag around the points. However, if a user inadvertently clicks just outside of a point, a new point selection is created and the existing multipoint selection is lost.

Is there a way to basically clone the multipoint tool in such a way that its behavior is limited to dragging existing points? I've dug around a bit, but honestly I just can't wrap my head around how the multipoint tool is implemented. I did find info on extending the PlugInTool class, but it seems prudent to try extending the multipoint tool itself and simply overriding undesirable behaviors. Or at least if I have a better understanding of the multipoint tool, I may be able to develop my own PlugInTool to do what I've described.

Along similar lines, is there a way to automatically activate such a tool via my plugin, then revert to the previously selected ImageJ tool upon exiting my plugin?

Thanks,
Dave

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Changing multipoint tool behavior

Wayne Rasband-2
> On May 21, 2018, at 6:27 PM, David Kysela <[hidden email]> wrote:
>
> My plugin generates multipoint selections that require interactive adjustment by the user. Currently, I simply let the user select the default multipoint tool and drag around the points. However, if a user inadvertently clicks just outside of a point, a new point selection is created and the existing multipoint selection is lost.

The latest ImageJ daily build (1.52d2) adds a PointRoi.promptBeforeDeleting(boolean) method that causes ImageJ to display a dialog before deleting multi-point selections. Here is a JavaScript example:

 img = IJ.createImage("Untitled", "8-bit black", 400, 400, 1);
 xpoints = [112, 247, 325, 310, 188, 60];
 ypoints = [75, 45, 150, 260, 260, 240];
 points = new PointRoi(xpoints, ypoints);
 points.setShowLabels(true);
 points.setPointType(2);
 points.setSize(4);
 points.promptBeforeDeleting(true);
 img.setRoi(points);
 img.show();
 IJ.setTool("rectangleā€¯);

-wayne


> Is there a way to basically clone the multipoint tool in such a way that its behavior is limited to dragging existing points? I've dug around a bit, but honestly I just can't wrap my head around how the multipoint tool is implemented. I did find info on extending the PlugInTool class, but it seems prudent to try extending the multipoint tool itself and simply overriding undesirable behaviors. Or at least if I have a better understanding of the multipoint tool, I may be able to develop my own PlugInTool to do what I've described.
>
> Along similar lines, is there a way to automatically activate such a tool via my plugin, then revert to the previously selected ImageJ tool upon exiting my plugin?
>
> Thanks,
> Dave

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html