-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #550 from saalfeldlab/fix/1.5.1
fix/1.5.1
- Loading branch information
Showing
15 changed files
with
206 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...lia/saalfeldlab/paintera/stream/HighlightingStreamConverterVolatileLabelMultisetType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.janelia.saalfeldlab.paintera.stream; | ||
|
||
import net.imglib2.type.label.VolatileLabelMultisetType; | ||
import net.imglib2.type.numeric.ARGBType; | ||
|
||
public class HighlightingStreamConverterVolatileLabelMultisetType extends HighlightingStreamConverter<VolatileLabelMultisetType> { | ||
|
||
private final HighlightingStreamConverterLabelMultisetType nonVolatileConverter; | ||
public HighlightingStreamConverterVolatileLabelMultisetType(final AbstractHighlightingARGBStream stream) { | ||
|
||
super(stream); | ||
nonVolatileConverter = new HighlightingStreamConverterLabelMultisetType(stream); | ||
} | ||
|
||
public HighlightingStreamConverterLabelMultisetType getNonVolatileConverter() { | ||
return nonVolatileConverter; | ||
} | ||
|
||
@Override | ||
public void convert(final VolatileLabelMultisetType input, final ARGBType output) { | ||
|
||
final boolean isValid = input.isValid(); | ||
if (!isValid) { | ||
return; | ||
} | ||
nonVolatileConverter.convert(input.get(), output); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/kotlin/org/janelia/saalfeldlab/bdv/fx/viewer/SourceUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.janelia.saalfeldlab.bdv.fx.viewer | ||
|
||
import bdv.viewer.Interpolation | ||
import bdv.viewer.Source | ||
import bdv.viewer.SourceAndConverter | ||
import net.imglib2.converter.Converter | ||
import net.imglib2.realtransform.AffineTransform3D | ||
import net.imglib2.type.numeric.ARGBType | ||
import org.janelia.saalfeldlab.paintera.data.DataSource | ||
import org.janelia.saalfeldlab.paintera.stream.HighlightingStreamConverterVolatileLabelMultisetType | ||
|
||
//FIXME Caleb: These are both private because imho this is a bit of a hack. | ||
// We want to Paintera's DataSource implemenet Source over the volatile type, | ||
// and the corrsponding SourceAndConverter has a convert also over the volatile type | ||
// This makes it not possible get a non-volatile SourceAndConverter over the DataSource. | ||
// So what we do here is manually unwrap, but we still want it to play nicely with the | ||
// volatile renderer, so we need it to "equal" it's volatile version. | ||
// I think SourceAndConverter has a `volatileConverter` that we should instead be using | ||
// when we want volatile (most the time) and support a proper non-volatile version without | ||
// wrapping/unwrapping this way. | ||
private class UnwrappedDataSource<D>(val dataSource : DataSource<D, *>) : Source<D> { | ||
override fun isPresent(t: Int) = dataSource.isPresent(t) | ||
|
||
override fun getSource(t: Int, level: Int) = dataSource.getDataSource(t, level) | ||
|
||
override fun getInterpolatedSource(t: Int, level: Int, method: Interpolation?) = dataSource.getInterpolatedDataSource(t, level, method) | ||
|
||
override fun getSourceTransform(t: Int, level: Int, transform: AffineTransform3D?) { | ||
dataSource.getSourceTransform(t, level, transform) | ||
} | ||
|
||
override fun getType() = dataSource.dataType | ||
|
||
override fun getName() = dataSource.name | ||
|
||
override fun getVoxelDimensions() = dataSource.voxelDimensions | ||
|
||
override fun getNumMipmapLevels() = dataSource.numMipmapLevels | ||
|
||
override fun hashCode() = dataSource.hashCode() | ||
|
||
override fun equals(other: Any?) = dataSource == ((other as? UnwrappedDataSource<*>)?.dataSource ?: other) | ||
} | ||
|
||
|
||
private class WrappedSourceAndConverter<D>(val sourceAndConverter : SourceAndConverter<*>, source : Source<D>, converter : Converter<D, ARGBType>) : SourceAndConverter<D>(source, converter) { | ||
|
||
override fun equals(other: Any?): Boolean { | ||
return sourceAndConverter == ((other as? WrappedSourceAndConverter<*>)?.sourceAndConverter ?: other) | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return sourceAndConverter.hashCode() | ||
} | ||
} | ||
|
||
internal fun <D : Any> getDataSourceAndConverter(sourceAndConverter: SourceAndConverter<*>): SourceAndConverter<*> { | ||
val data = sourceAndConverter.spimSource as? DataSource<D, *> ?: return sourceAndConverter | ||
val unwrappedDataSource = UnwrappedDataSource(data) | ||
|
||
val converter = sourceAndConverter.converter.let { | ||
(it as? HighlightingStreamConverterVolatileLabelMultisetType)?.nonVolatileConverter ?: it | ||
} as Converter<D, ARGBType> | ||
|
||
return WrappedSourceAndConverter(sourceAndConverter, unwrappedDataSource, converter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.