Skip to content
Snippets Groups Projects
Commit c96d534a authored by Vojtech Moravec's avatar Vojtech Moravec
Browse files

Receive compressFromMipmap level from server.

Also bunch of files are reformatted since we merged the source of the fork to stay up to date.
parent 93f64136
No related branches found
No related tags found
No related merge requests found
package azgracompress;
public class ViewerCompressionOptions {
private boolean enabled = false;
private int compressFromMipmapLevel = 0;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(final boolean enable) {
this.enabled = enable;
}
public int getCompressFromMipmapLevel() {
return compressFromMipmapLevel;
}
public void setCompressFromMipmapLevel(final int compressFrom) {
this.compressFromMipmapLevel = compressFrom;
}
}
This diff is collapsed.
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
*/ */
package bdv.img.remote; package bdv.img.remote;
import azgracompress.ViewerCompressionOptions;
import azgracompress.cache.ICacheFile; import azgracompress.cache.ICacheFile;
import azgracompress.cache.QuantizationCacheManager; import azgracompress.cache.QuantizationCacheManager;
import azgracompress.compression.ImageDecompressor; import azgracompress.compression.ImageDecompressor;
...@@ -41,6 +40,7 @@ import bdv.img.hdf5.DimsAndExistence; ...@@ -41,6 +40,7 @@ import bdv.img.hdf5.DimsAndExistence;
import bdv.img.hdf5.MipmapInfo; import bdv.img.hdf5.MipmapInfo;
import bdv.img.hdf5.ViewLevelId; import bdv.img.hdf5.ViewLevelId;
import bdv.util.ConstantRandomAccessible; import bdv.util.ConstantRandomAccessible;
import bdv.viewer.ViewerOptions;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import mpicbg.spim.data.generic.sequence.ImgLoaderHint; import mpicbg.spim.data.generic.sequence.ImgLoaderHint;
import net.imglib2.FinalInterval; import net.imglib2.FinalInterval;
...@@ -77,7 +77,7 @@ public class RemoteImageLoader implements ViewerImgLoader { ...@@ -77,7 +77,7 @@ public class RemoteImageLoader implements ViewerImgLoader {
/** /**
* Flag whether we allow the server to send us compressed data. * Flag whether we allow the server to send us compressed data.
*/ */
private ViewerCompressionOptions viewerCompressionOptions; private ViewerOptions.CompressionOptions viewerCompressionOptions;
/** /**
...@@ -131,7 +131,7 @@ public class RemoteImageLoader implements ViewerImgLoader { ...@@ -131,7 +131,7 @@ public class RemoteImageLoader implements ViewerImgLoader {
} }
} }
public void setViewerCompressionOptions(final ViewerCompressionOptions ops) { public void setViewerCompressionOptions(final ViewerOptions.CompressionOptions ops) {
this.viewerCompressionOptions = ops; this.viewerCompressionOptions = ops;
} }
...@@ -146,7 +146,9 @@ public class RemoteImageLoader implements ViewerImgLoader { ...@@ -146,7 +146,9 @@ public class RemoteImageLoader implements ViewerImgLoader {
return; return;
} }
final ArrayList<ICacheFile> cacheFiles = new ArrayList<>(); final ArrayList<ICacheFile> cacheFiles = new ArrayList<>();
int compressFromMipmapLevel = 0;
try (final DataInputStream dis = new DataInputStream(connection.getInputStream())) { try (final DataInputStream dis = new DataInputStream(connection.getInputStream())) {
compressFromMipmapLevel = dis.readByte();
final int codebookCount = dis.readByte(); final int codebookCount = dis.readByte();
for (int cbIndex = 0; cbIndex < codebookCount; cbIndex++) { for (int cbIndex = 0; cbIndex < codebookCount; cbIndex++) {
final ICacheFile readCacheFile = QuantizationCacheManager.readCacheFile(dis); final ICacheFile readCacheFile = QuantizationCacheManager.readCacheFile(dis);
...@@ -160,13 +162,15 @@ public class RemoteImageLoader implements ViewerImgLoader { ...@@ -160,13 +162,15 @@ public class RemoteImageLoader implements ViewerImgLoader {
} }
} }
ColorConsole.fprintf(ColorConsole.Target.stdout, ColorConsole.Color.Yellow, "Received %d cache files.", cacheFiles.size()); ColorConsole.fprintf(ColorConsole.Target.stdout, ColorConsole.Color.Yellow, "Received %d cache files.", cacheFiles.size());
ColorConsole.fprintf(ColorConsole.Target.stdout, ColorConsole.Color.Yellow,
"Decompressing from mipmap level %d.", compressFromMipmapLevel);
final ImageDecompressor[] decompressors = new ImageDecompressor[cacheFiles.size()]; final ImageDecompressor[] decompressors = new ImageDecompressor[cacheFiles.size()];
for (int i = 0; i < cacheFiles.size(); i++) { for (int i = 0; i < cacheFiles.size(); i++) {
decompressors[i] = new ImageDecompressor(cacheFiles.get(i)); decompressors[i] = new ImageDecompressor(cacheFiles.get(i));
} }
shortLoader.setDataDecompressors(decompressors, metadata.maxNumLevels, viewerCompressionOptions.getCompressFromMipmapLevel()); shortLoader.setDataDecompressors(decompressors, metadata.maxNumLevels, compressFromMipmapLevel);
} }
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
*/ */
package bdv.spimdata; package bdv.spimdata;
import azgracompress.ViewerCompressionOptions;
import bdv.img.remote.RemoteImageLoader; import bdv.img.remote.RemoteImageLoader;
import bdv.spimdata.legacy.XmlIoSpimDataMinimalLegacy; import bdv.spimdata.legacy.XmlIoSpimDataMinimalLegacy;
import bdv.viewer.ViewerOptions;
import mpicbg.spim.data.SpimDataException; import mpicbg.spim.data.SpimDataException;
import mpicbg.spim.data.SpimDataIOException; import mpicbg.spim.data.SpimDataIOException;
import mpicbg.spim.data.generic.XmlIoAbstractSpimData; import mpicbg.spim.data.generic.XmlIoAbstractSpimData;
...@@ -49,7 +49,7 @@ import java.io.File; ...@@ -49,7 +49,7 @@ import java.io.File;
import static mpicbg.spim.data.XmlKeys.SPIMDATA_TAG; import static mpicbg.spim.data.XmlKeys.SPIMDATA_TAG;
public class XmlIoSpimDataMinimal extends XmlIoAbstractSpimData<SequenceDescriptionMinimal, SpimDataMinimal> { public class XmlIoSpimDataMinimal extends XmlIoAbstractSpimData<SequenceDescriptionMinimal, SpimDataMinimal> {
private ViewerCompressionOptions compressionOptions; private ViewerOptions.CompressionOptions compressionOptions;
public XmlIoSpimDataMinimal() { public XmlIoSpimDataMinimal() {
super(SpimDataMinimal.class, super(SpimDataMinimal.class,
...@@ -61,7 +61,7 @@ public class XmlIoSpimDataMinimal extends XmlIoAbstractSpimData<SequenceDescript ...@@ -61,7 +61,7 @@ public class XmlIoSpimDataMinimal extends XmlIoAbstractSpimData<SequenceDescript
new XmlIoViewRegistrations()); new XmlIoViewRegistrations());
} }
public void setViewerCompressionOptions(final ViewerCompressionOptions ops) { public void setViewerCompressionOptions(final ViewerOptions.CompressionOptions ops) {
this.compressionOptions = ops; this.compressionOptions = ops;
} }
......
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
* %% * %%
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, * 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation * this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
...@@ -29,285 +29,274 @@ ...@@ -29,285 +29,274 @@
package bdv.viewer; package bdv.viewer;
import bdv.TransformEventHandler3D; import bdv.TransformEventHandler3D;
import java.awt.event.KeyListener; import bdv.TransformEventHandlerFactory;
import org.scijava.ui.behaviour.KeyPressedManager;
import org.scijava.ui.behaviour.io.InputTriggerConfig;
import bdv.viewer.animate.MessageOverlayAnimator; import bdv.viewer.animate.MessageOverlayAnimator;
import bdv.viewer.render.AccumulateProjector; import bdv.viewer.render.AccumulateProjector;
import bdv.viewer.render.AccumulateProjectorARGB; import bdv.viewer.render.AccumulateProjectorARGB;
import bdv.viewer.render.AccumulateProjectorFactory; import bdv.viewer.render.AccumulateProjectorFactory;
import bdv.viewer.render.MultiResolutionRenderer; import bdv.viewer.render.MultiResolutionRenderer;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.ARGBType;
import bdv.TransformEventHandlerFactory; import org.scijava.ui.behaviour.KeyPressedManager;
import org.scijava.ui.behaviour.io.InputTriggerConfig;
import java.awt.event.KeyListener;
/** /**
* Optional parameters for {@link ViewerPanel}. * Optional parameters for {@link ViewerPanel}.
* *
* @author Tobias Pietzsch * @author Tobias Pietzsch
*/ */
public class ViewerOptions public class ViewerOptions {
{ public static class CompressionOptions {
public final Values values = new Values(); private boolean enabled = false;
/** public boolean isEnabled() {
* Create default {@link ViewerOptions}. return enabled;
* @return default {@link ViewerOptions}. }
*/
public static ViewerOptions options() public void setEnabled(final boolean enable) {
{ this.enabled = enable;
return new ViewerOptions(); }
} }
/** public final Values values = new Values();
* Set width of {@link ViewerPanel} canvas.
*/ /**
public ViewerOptions width( final int w ) * Create default {@link ViewerOptions}.
{ *
values.width = w; * @return default {@link ViewerOptions}.
return this; */
} public static ViewerOptions options() {
return new ViewerOptions();
/** }
* Set height of {@link ViewerPanel} canvas.
*/ /**
public ViewerOptions height( final int h ) * Set width of {@link ViewerPanel} canvas.
{ */
values.height = h; public ViewerOptions width(final int w) {
return this; values.width = w;
} return this;
}
/**
* Set the number and scale factors for scaled screen images. public ViewerOptions compressionOptions(final CompressionOptions compressionOptions) {
* values.compressionOptions = compressionOptions;
* @param s return this;
* Scale factors from the viewer canvas to screen images of }
* different resolutions. A scale factor of 1 means 1 pixel in
* the screen image is displayed as 1 pixel on the canvas, a /**
* scale factor of 0.5 means 1 pixel in the screen image is * Set height of {@link ViewerPanel} canvas.
* displayed as 2 pixel on the canvas, etc. */
* @see MultiResolutionRenderer public ViewerOptions height(final int h) {
*/ values.height = h;
public ViewerOptions screenScales( final double[] s ) return this;
{ }
values.screenScales = s;
return this; /**
} * Set the number and scale factors for scaled screen images.
*
/** * @param s Scale factors from the viewer canvas to screen images of
* Set target rendering time in nanoseconds. * different resolutions. A scale factor of 1 means 1 pixel in
* * the screen image is displayed as 1 pixel on the canvas, a
* @param t * scale factor of 0.5 means 1 pixel in the screen image is
* Target rendering time in nanoseconds. The rendering time for * displayed as 2 pixel on the canvas, etc.
* the coarsest rendered scale should be below this threshold. * @see MultiResolutionRenderer
* @see MultiResolutionRenderer */
*/ public ViewerOptions screenScales(final double[] s) {
public ViewerOptions targetRenderNanos( final long t ) values.screenScales = s;
{ return this;
values.targetRenderNanos = t; }
return this;
} /**
* Set target rendering time in nanoseconds.
/** *
* Set how many threads to use for rendering. * @param t Target rendering time in nanoseconds. The rendering time for
* * the coarsest rendered scale should be below this threshold.
* @param n * @see MultiResolutionRenderer
* How many threads to use for rendering. */
* @see MultiResolutionRenderer public ViewerOptions targetRenderNanos(final long t) {
*/ values.targetRenderNanos = t;
public ViewerOptions numRenderingThreads( final int n ) return this;
{ }
values.numRenderingThreads = n;
return this; /**
} * Set how many threads to use for rendering.
*
/** * @param n How many threads to use for rendering.
* Set how many source groups there are initially. * @see MultiResolutionRenderer
* */
* @param n public ViewerOptions numRenderingThreads(final int n) {
* How many source groups to create initially. values.numRenderingThreads = n;
*/ return this;
public ViewerOptions numSourceGroups( final int n ) }
{
values.numSourceGroups = n; /**
return this; * Set how many source groups there are initially.
} *
* @param n How many source groups to create initially.
/** */
* Set whether volatile versions of sources should be used if available. public ViewerOptions numSourceGroups(final int n) {
* values.numSourceGroups = n;
* @param v return this;
* whether volatile versions of sources should be used if }
* available.
* @see MultiResolutionRenderer /**
*/ * Set whether volatile versions of sources should be used if available.
public ViewerOptions useVolatileIfAvailable( final boolean v ) *
{ * @param v whether volatile versions of sources should be used if
values.useVolatileIfAvailable = v; * available.
return this; * @see MultiResolutionRenderer
} */
public ViewerOptions useVolatileIfAvailable(final boolean v) {
public ViewerOptions msgOverlay( final MessageOverlayAnimator o ) values.useVolatileIfAvailable = v;
{ return this;
values.msgOverlay = o; }
return this;
} public ViewerOptions msgOverlay(final MessageOverlayAnimator o) {
values.msgOverlay = o;
public ViewerOptions transformEventHandlerFactory( final TransformEventHandlerFactory f ) return this;
{ }
values.transformEventHandlerFactory = f;
return this; public ViewerOptions transformEventHandlerFactory(final TransformEventHandlerFactory f) {
} values.transformEventHandlerFactory = f;
return this;
/** }
* Set the factory for creating {@link AccumulateProjector}. This can be
* used to customize how sources are combined. /**
* * Set the factory for creating {@link AccumulateProjector}. This can be
* @param f * used to customize how sources are combined.
* factory for creating {@link AccumulateProjector}. *
* @see MultiResolutionRenderer * @param f factory for creating {@link AccumulateProjector}.
*/ * @see MultiResolutionRenderer
public ViewerOptions accumulateProjectorFactory( final AccumulateProjectorFactory< ARGBType > f ) */
{ public ViewerOptions accumulateProjectorFactory(final AccumulateProjectorFactory<ARGBType> f) {
values.accumulateProjectorFactory = f; values.accumulateProjectorFactory = f;
return this; return this;
} }
/** /**
* Set the {@link InputTriggerConfig} from which keyboard and mouse action mapping is loaded. * Set the {@link InputTriggerConfig} from which keyboard and mouse action mapping is loaded.
* *
* @param c the {@link InputTriggerConfig} from which keyboard and mouse action mapping is loaded * @param c the {@link InputTriggerConfig} from which keyboard and mouse action mapping is loaded
*/ */
public ViewerOptions inputTriggerConfig( final InputTriggerConfig c ) public ViewerOptions inputTriggerConfig(final InputTriggerConfig c) {
{ values.inputTriggerConfig = c;
values.inputTriggerConfig = c; return this;
return this; }
}
/**
/** * Set the {@link KeyPressedManager} to share
* Set the {@link KeyPressedManager} to share * {@link KeyListener#keyPressed(java.awt.event.KeyEvent)} events with other
* {@link KeyListener#keyPressed(java.awt.event.KeyEvent)} events with other * ui-behaviour windows.
* ui-behaviour windows. * <p>
* <p> * The goal is to make keyboard click/drag behaviours work like mouse
* The goal is to make keyboard click/drag behaviours work like mouse * click/drag: When a behaviour is initiated with a key press, the window
* click/drag: When a behaviour is initiated with a key press, the window * under the mouse receives focus and the behaviour is handled there.
* under the mouse receives focus and the behaviour is handled there. * </p>
* </p> *
* * @param manager
* @param manager * @return
* @return */
*/ public ViewerOptions shareKeyPressedEvents(final KeyPressedManager manager) {
public ViewerOptions shareKeyPressedEvents( final KeyPressedManager manager ) values.keyPressedManager = manager;
{ return this;
values.keyPressedManager = manager; }
return this;
} /**
* Read-only {@link ViewerOptions} values.
/** */
* Read-only {@link ViewerOptions} values. public static class Values {
*/ private int width = 800;
public static class Values
{ private int height = 600;
private int width = 800;
private double[] screenScales = new double[]{1, 0.75, 0.5, 0.25, 0.125};
private int height = 600;
private long targetRenderNanos = 30 * 1000000l;
private double[] screenScales = new double[] { 1, 0.75, 0.5, 0.25, 0.125 };
private int numRenderingThreads = 3;
private long targetRenderNanos = 30 * 1000000l;
private int numSourceGroups = 10;
private int numRenderingThreads = 3;
private boolean useVolatileIfAvailable = true;
private int numSourceGroups = 10;
private MessageOverlayAnimator msgOverlay = new MessageOverlayAnimator(800);
private boolean useVolatileIfAvailable = true;
private TransformEventHandlerFactory transformEventHandlerFactory = TransformEventHandler3D::new;
private MessageOverlayAnimator msgOverlay = new MessageOverlayAnimator( 800 );
private AccumulateProjectorFactory<ARGBType> accumulateProjectorFactory = AccumulateProjectorARGB.factory;
private TransformEventHandlerFactory transformEventHandlerFactory = TransformEventHandler3D::new;
private InputTriggerConfig inputTriggerConfig = null;
private AccumulateProjectorFactory< ARGBType > accumulateProjectorFactory = AccumulateProjectorARGB.factory;
private KeyPressedManager keyPressedManager = null;
private InputTriggerConfig inputTriggerConfig = null;
private CompressionOptions compressionOptions = new CompressionOptions();
private KeyPressedManager keyPressedManager = null;
public ViewerOptions optionsFromValues() {
public ViewerOptions optionsFromValues() return new ViewerOptions().
{ width(width).
return new ViewerOptions(). height(height).
width( width ). screenScales(screenScales).
height( height ). targetRenderNanos(targetRenderNanos).
screenScales( screenScales ). numRenderingThreads(numRenderingThreads).
targetRenderNanos( targetRenderNanos ). numSourceGroups(numSourceGroups).
numRenderingThreads( numRenderingThreads ). useVolatileIfAvailable(useVolatileIfAvailable).
numSourceGroups( numSourceGroups ). msgOverlay(msgOverlay).
useVolatileIfAvailable( useVolatileIfAvailable ). transformEventHandlerFactory(transformEventHandlerFactory).
msgOverlay( msgOverlay ). accumulateProjectorFactory(accumulateProjectorFactory).
transformEventHandlerFactory( transformEventHandlerFactory ). inputTriggerConfig(inputTriggerConfig).
accumulateProjectorFactory( accumulateProjectorFactory ). compressionOptions(compressionOptions);
inputTriggerConfig( inputTriggerConfig ); }
}
public int getWidth() {
public int getWidth() return width;
{ }
return width;
} public int getHeight() {
return height;
public int getHeight() }
{
return height; public double[] getScreenScales() {
} return screenScales;
}
public double[] getScreenScales()
{ public long getTargetRenderNanos() {
return screenScales; return targetRenderNanos;
} }
public long getTargetRenderNanos() public int getNumRenderingThreads() {
{ return numRenderingThreads;
return targetRenderNanos; }
}
public int getNumSourceGroups() {
public int getNumRenderingThreads() return numSourceGroups;
{ }
return numRenderingThreads;
} public boolean isUseVolatileIfAvailable() {
return useVolatileIfAvailable;
public int getNumSourceGroups() }
{
return numSourceGroups; public MessageOverlayAnimator getMsgOverlay() {
} return msgOverlay;
}
public boolean isUseVolatileIfAvailable()
{ public TransformEventHandlerFactory getTransformEventHandlerFactory() {
return useVolatileIfAvailable; return transformEventHandlerFactory;
} }
public MessageOverlayAnimator getMsgOverlay() public AccumulateProjectorFactory<ARGBType> getAccumulateProjectorFactory() {
{ return accumulateProjectorFactory;
return msgOverlay; }
}
public InputTriggerConfig getInputTriggerConfig() {
public TransformEventHandlerFactory getTransformEventHandlerFactory() return inputTriggerConfig;
{ }
return transformEventHandlerFactory;
} public KeyPressedManager getKeyPressedManager() {
return keyPressedManager;
public AccumulateProjectorFactory< ARGBType > getAccumulateProjectorFactory() }
{
return accumulateProjectorFactory; public CompressionOptions getCompressionOptions() {
} return compressionOptions;
}
public InputTriggerConfig getInputTriggerConfig() }
{
return inputTriggerConfig;
}
public KeyPressedManager getKeyPressedManager()
{
return keyPressedManager;
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment