Closed tischi closed 4 years ago
Not available in BdvFunctions
but in ViewerPanel
, yes. So, it's accessible from BdvHandle
. That's want I wanted to tell you but I wasn't clear enough when I told you to use SourceAndConverter
instead of Source
That's the trick, this function allows to add a SourceAndConverter
:
VolatileViews
because the SourceAndConverter
object has a asVolatile()
method which, if not null, contains the volatile representation of the Source.Converter
stays linked to the initial ConverterSetups
-> if you add two identical SourceAndConverter
, a single ConverterSetup
which has a single slider will control the minmax of these two Sources. This can be positive or negative, depends. But wait for it : here's the magic of Functional interface:
Let's say you want to affine transform a SourceAndConverter
:
This means you need to apply an affineTransform on both the concrete and Volatile source, if present.
So one way is to create an affinetransform action for SourceAndConverter.
Then if you want to warp a Source, it's the same, you write an action for Source
objects but also for SourceAndConverter
objects.
Then if you have an action which applies a Gaussian Blur it's the same.
At the end you have many duplicated Actions, where you do the same things.
But ahah! All these actions on sources (affine, warp, gaussian, whatever) all implement Function<Source,Source>
so what you need to do is just to call an action which will take any of these functions and apply it on a SourceAndConverter
object.
And it's already done: look at:
So -> no duplicated code. Write once for Source, and apply it easily on SourceAndConverter.
All very cool! I like it :-)
One concern about the naming: SourceAndConverterApplySourceFunction
Maybe more correct: ApplySourceFunctionToSourceAndConverter
?
Indeed, still complex but a bit more understandable
Or Applier, since class names are supposed to be nouns
Yes!
@NicoKiaru
Below are the code changes of the PR where I am adding a SourceAndConverter
and getting back a bdvStackSource
. We could see whether we could get the same code running without getting the PR to Bdv-Vistools accepted.
https://github.com/bigdataviewer/bigdataviewer-vistools/pull/40/commits/e1aa24a4f6c2dda9dd81a04c725f4a60446da96c#
Not relevant anymore. See PR https://github.com/bigdataviewer/bigdataviewer-playground/pull/53
@NicoKiaru
Wow.....
https://github.com/haesleinhuepf/bigdataviewer-playground/blob/cdcad0549f9284b2e76f2f86fdd385e4116c5dac/src/main/java/sc/fiji/bdv/sourceAndConverter/add/AddSourceAndConverterToBdv.java#L22
I did not know this function existed for a
SourceAndConverter
!BdvFunctions.show( ... , BdvOptions.options.addTo( ... ) )