bigdataviewer/bigdataviewer-playground

Restore timepoints and source group when using the editor mode

Opened this issue · 8 comments

Restore timepoints and source group when using the editor mode

@tpietzsch just FYI, when BdvOverlay#removeFromBdv is called in a bdv window, there's a lot of things from the bdv state which are changed: the number of timepoints is reset to one, the sources within the groups are reset, and probably some other things.

To go around this issue, I have to save the state snapshot and restore "manually" parts of the state. This is okayish, but it would be better if I could avoid that (see https://github.com/BIOP/bigdataviewer-selector/blob/44321479fc44c35348937b6dae849dfd0bca593b/src/main/java/ch/epfl/biop/bdv/select/SourceSelectorBehaviour.java#L196-L205)

Not that important, but I wanted to mention it to you since it impairs the user experience.

TODO: do a clean issue in bigdataviewer-vistools

Todo fix the SourceGroup workaround in bigdataviewer-selector once bigdataviewer/bigdataviewer-core#177 is fixed

@NicoKiaru I merged your fix for bigdataviewer/bigdataviewer-core#177

Can you explain how you use timepoints?

When BdvOverlay#removeFromBdv is called, vistools recomputes the numTimepoints as the max getNumTimepoints() over all sources (that are left) https://github.com/bigdataviewer/bigdataviewer-core/blob/783b7aee870348f231fdf8c7b214a5fa8a31e9df/src/main/java/bdv/util/BdvHandle.java#L291-L298

So it looks like, either, your overlay had more timepoints than the other sources, or you set the numTimepoints directly in the viewerstate (bypassing vistools BdvSources)?

Most of the time, I build directly the SourceAndConverter object, which, I think, has no convenient way to return a number of timepoints ?

And then each source is added via:

So yes, I'm adding the SourceAndConverter object to the state directly.

Thanks for linking the logic. I'll dig a bit more. ( and thanks for merging the PR )

Yes, right, neither SourceAndConverter nor Source specify number of timepoints.

This only happens on the vistools layer (BdvSource has getNumTimepoints()).
The "problem" here is that you mix vistools and core sources. (BdvOverlaySource is vistools, SourceAndConverter is core).
Maybe an easy way around is to add the SourceAndConverter via vistools BdvFunctions.show(yourSourceAndConverter, numTimepoints, Bdv.options().addTo(bdvh)) https://github.com/bigdataviewer/bigdataviewer-core/blob/783b7aee870348f231fdf8c7b214a5fa8a31e9df/src/main/java/bdv/util/BdvFunctions.java#L251-L255

Of course it would be better to make it more seamless to mix vistools and core. But I don't have a perfect solution at the moment.

Ah yes, thanks, I can try that. I think a minor inconvenience is that I will need to call this for each source in order to specify the timepoints instead of a single call with a List of sources. But maybe that's not a real problem.