Posted by
Michael Schmid on
Jul 28, 2020; 8:38am
URL: http://imagej.273.s1.nabble.com/RoiManager-tp5023762p5023773.html
Hi Kenneth,
concerning:
> Ordinarily, I would use the Overlay ... It uses the Overlay for
different purposes
I think you can still use the overlay and use names to separate the
different rois in the overlay. Unless you have hundreds of thousands of
overlays, where performance becomes an issue, you can use a single call
to delete all overlays with a given name.
> I already need to keep a separate stack of Roi's (one per slice) for
later processing
Unless you have a huge number of rois (see above), you could also use
the roi names in the overlay to determine which rois serve which
purpose. Then you can iterate over the rois in the overlay and only use
these with the desired name. So you don't need to keep a separate list
(unless that list has some structure that you won't have with roi names,
e.g. a linked list, tree, etc.)
> I may, indeed, use a KeyListener to add a new Roi
Of course, you can also use a nonblocking dialog, e.g. a
NonBlockingGenericDialog where you can add a panel with buttons, or a
PlugInFrame. From the user's point of view, it is usually nicer to use
the keyboard if one has to add lots of rois; but I'd prefer a dialog
with buttons if it is only few clicks (The buttons avoid the need for a
help text telling the user to use a keystroke).
> Using KeyListener would allow multiple Roi editing functions (add,
delete, clear all, ...)
Yes, but you could do the same using a dialog with several buttons.
>...using roi.setPosition(), can I have multiple Roi's in each slice?
Yes. I have done it with hundreds of rois per slice.
Michael
________________________________________________________________
On 27.07.20 20:25, Kenneth Sloan wrote:
> Thanks for the reply.
>
> Ordinarily, I would use the Overlay (and have done that it in similar plugins - but it this case I am trapped by my own ineptitude. The StackWindow involved is part of a code base that supports many plugins (briefly, two StackWindows which are different extensions of StackWindow and which talk to each other and separately manage their own Overlays). It uses the Overlay for different purposes, and when I originally wrote it I had some confusion about how to handle Overlays. As a result, I am loathe to go back to that code to modify it. If memory serves, I first tried to implement the Overlay processing to allow for sharing of the Overlay (using names) - but during debugging I gave up and made that code "greedy" so that it has total control over the Overlay - which it re-establishes on every interaction with the StackWindow. That's on my list of things to fix the next time I do a major re-structuring (which I need to do soon...just not this week!)
>
> I may, indeed, use a KeyListener to add a new Roi - I'm still at the "on paper design stage". The simplest scheme is to have the user click on "OK" (in a wfud box) and then fetch the current Roi. But, I will experiment with using roi.setPosition(). I assume that if I do this for every Roi, then *only* the Roi attached to a particular slice will be displayed? That's what I want, but I was prepared to use an ImageListener to notice when the slice changes, and change the current Roi on the fly.
>
> I already need to keep a separate stack of Roi's (one per slice) for later processing - so this is not all that much extra work. But, if roi.setPositition() works as advertised, perhaps I can eliminate this stack and simply process the Rois at the end by fetching them from the StackWindow.
>
> Using KeyListener would allow multiple Roi editing functions (add, delete, clear all, ...) and I just finished debugging a KeyListener for another plugin. There, I had trouble maintaining "focus". Perhaps this new plugin is a chance to see if I have internalized the lessons learned there.
>
> If it matters, the immediate application is to compute the volume of an object from cross-sections traced by the user, using the Calalieri principle with care taken to handle the "lost cap" issues on either end.
>
> Now...for extra credit...using roi.setPosition(), can I have multiple Roi's in each slice? I don't really need this (now...) and can't quite see how to control which Roi is the "current" Roi while allowing multiple Roi's to be displayed (I just haven't tried this before). But - if this is possible, it makes it more likely that I would use a KeyListener to control this feature.
>
> --
> Kenneth Sloan
>
[hidden email]
> Vision is the art of seeing what is invisible to others.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html