Handle IJ1's in place manipulations of ImagePluses

Description

Our code to display Datasets will need to be smart about some of the changes IJ1 makes to data. If pixels are changed in place this is likely handled already. But imagine a IJ1 plugin that deletes a slice from an ImagePlus's stack. IJ2 will think the ImagePlus is the same and the Display code may not work right. Or a new Dataset will get hatched. Must somehow support things so the internals of the Dataset change and the Dataset is correctly displayed in IJ2.

Change History

Defined a macro in IJ1 that deletes the last slice from a image stack. When loading T1 Head sample image and running macro in IJ1 stack is correctly changed. In IJ2 it is not. I have been able to run IJ1 macros in IJ2 with success before. Failure is also apparent via menu command Delete Slice.

We need to put a check somewhere that notices that a plugin has changed an ImagePlus in place. This is somewhat tricky because some plugins are all side effects and do not return a Dataset as an output.

Curtis thinks we can piggyback on calls to updateAndDraw() and check for changed status there. May need to use CodeHacker on more fine grained pieces of code.

Changes to ImagePluses worth noting:

one or more slices are added or removed to the ImagePlus' ImageStack

a ImagePlus' ImageStack slices are reordered

a whole new ImageStack replaces an existing ImageStack within an ImagePlus

If we get more fine grained we may have to create something like a map between ImagePluses and ImageStacks. Thus we can catch ImageStack.deleteLastSlice(), find which ImagePlus is affected, update it's associated Dataset, and publish a DatasetChanged event.

Debugged Delete Slice plugin to see what is happening. IJ1 calls setStack() with a new stack. We aren't catching that. Then I think it bypasses updateAndDraw() with draw() (not yet confirmed on this). We're not firing any LegacyImageChanged events. Started playing with messing with the LegacyManager via CodeHacker to handle setStack() but ran into some manager initialization issues afterwords. I'll look into this further soon.