Skip to content

Commit

Permalink
Merge pull request #551 from saalfeldlab/feat/1.6.0
Browse files Browse the repository at this point in the history
Feat/1.6.0
  • Loading branch information
cmhulbert authored Nov 8, 2024
2 parents 3d5907f + 1ae8945 commit 7875344
Show file tree
Hide file tree
Showing 41 changed files with 647 additions and 438 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Paintera is a general visualization tool for 3D volumetric data and proof-readin

## Installation

The current version release version can be installed from the [Github Releases](https://github.com/saalfeldlab/paintera/releases)
The latest release can be installed from the [Github Releases](https://github.com/saalfeldlab/paintera/releases)

[![GitHub Release](https://img.shields.io/github/v/release/saalfeldlab/paintera)](https://github.com/saalfeldlab/paintera/releases)



Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>paintera</artifactId>
<version>1.5.2-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>

<name>Paintera</name>
<description>New Era Painting and annotation tool</description>
Expand Down Expand Up @@ -58,7 +58,7 @@

<!-- JavaFx Version-->
<javafx.version>22.0.1</javafx.version>
<saalfx.version>2.1.0</saalfx.version>
<saalfx.version>2.2.0</saalfx.version>
<testfx.version>4.0.16-alpha</testfx.version>

<alphanumeric-comparator.version>1.4.1</alphanumeric-comparator.version>
Expand All @@ -68,7 +68,7 @@
<main-class>org.janelia.saalfeldlab.paintera.Paintera</main-class>
<app.name>Paintera</app.name>
<app.package>paintera</app.package>
<app.version>1.5.1</app.version>
<app.version>1.6.0</app.version>

<jvm.modules>javafx.base,javafx.controls,javafx.fxml,javafx.media,javafx.swing,javafx.web,javafx.graphics,java.naming,java.management,java.sql</jvm.modules>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public OrthogonalViewsValueDisplayListener(

public void addHandlers(ViewerPanelFX viewer) {

listeners.putIfAbsent(viewer, new ValueDisplayListener<>(viewer, currentSource, interpolation, submitValue));
if (!listeners.containsKey(viewer)) {
listeners.put(viewer, new ValueDisplayListener<>(viewer, currentSource, interpolation, submitValue));
}

viewer.getDisplay().addEventFilter(MouseEvent.MOUSE_MOVED, listeners.get(viewer));
viewer.addTransformListener(listeners.get(viewer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class AllowedActions {
@Nonnull
public static final AllowedActions VIEW_LABELS = new AllowedActionsBuilder()
.add(NAVIGATION)
.add(LabelActionType.Toggle, LabelActionType.Append, LabelActionType.SelectAll)
.add(LabelActionType.readOnly())
.create();

private final Set<ActionType> actions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,29 @@
import java.util.EnumSet;

public enum LabelActionType implements ActionType {
Toggle,
Toggle(true),
Append,
CreateNew,
Lock,
Lock(true),
Merge,
Split,
SelectAll;
SelectAll(true);

//TODO Caleb: consider moving this to ActionType. Maybe others too
private final boolean readOnly;

LabelActionType() {
this(false);
}

LabelActionType(boolean readOnly) {
this.readOnly = readOnly;
}

public boolean isReadOnly() {

return readOnly;
}

public static EnumSet<LabelActionType> of(final LabelActionType first, final LabelActionType... rest) {

Expand All @@ -21,6 +37,13 @@ public static EnumSet<LabelActionType> all() {
return EnumSet.allOf(LabelActionType.class);
}

public static EnumSet<LabelActionType> readOnly() {

var readOnly = EnumSet.noneOf(LabelActionType.class);
all().stream().filter(LabelActionType::isReadOnly).forEach(readOnly::add);
return readOnly;
}

public static EnumSet<LabelActionType> none() {

return EnumSet.noneOf(LabelActionType.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
public enum MenuActionType implements ActionType {
AddSource,
ChangeActiveSource,
SidePanel,
ToggleSidePanel,
ResizePanel,
ToggleToolBarVisibility,
ToggleMenuBarVisibility,
ToggleMenuBarMode,
ToggleStatusBarVisibility,
ToggleStatusBarMode,
ToggleMaximizeViewer,
ResizeViewers,
OrthoslicesContextMenu,
SaveProject,
CommitCanvas,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public enum PaintActionType implements ActionType {
SetBrushSize,
SetBrushDepth,
ShapeInterpolation,
SegmentAnything;
SegmentAnything,
Smooth;

public static EnumSet<PaintActionType> of(final PaintActionType first, final PaintActionType... rest) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
import net.imglib2.Volatile;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.realtransform.RealViews;
import net.imglib2.type.label.VolatileLabelMultisetType;
import net.imglib2.view.composite.Composite;
import org.janelia.saalfeldlab.bdv.fx.viewer.ViewerPanelFX;
import org.janelia.saalfeldlab.fx.Tasks;
import org.janelia.saalfeldlab.paintera.data.ChannelDataSource;
import org.janelia.saalfeldlab.paintera.data.DataSource;

import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -67,7 +65,7 @@ public ValueDisplayListener(
),
affine
).realRandomAccess();
}, currentSource, viewer.getRenderUnit().getScreenScalesProperty(), viewerTransformChanged
}, currentSource, viewer.getRenderUnit().getScreenScalesProperty(), viewerTransformChanged, viewer.getRenderUnit().getRepaintRequestProperty()
);

this.accessBinding.addListener((obs, old, newAccess) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static long randomTemporaryId() {

static boolean isTemporary(final long id) {

return id > FIRST_TEMPORARY_ID && id < LAST_TEMPORARY_ID;
return id >= FIRST_TEMPORARY_ID && id < LAST_TEMPORARY_ID;
}

class IdServiceNotProvided implements IdService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.janelia.saalfeldlab.paintera.id;

import java.util.Arrays;
import java.util.stream.LongStream;

public class LocalIdService implements IdService {
Expand All @@ -19,15 +20,13 @@ public LocalIdService(final long next) {

@Override public long nextTemporary() {

final var temp = nextTemp;
nextTemp += 1;
return temp;
return IdService.randomTemps.next();
}

@Override public long[] nextTemporary(int n) {

final long[] tempIds = LongStream.range(nextTemp, nextTemp + n).toArray();
nextTemp += n;
final long[] tempIds = new long[n];
Arrays.setAll(tempIds, it -> IdService.randomTemps.next());
return tempIds;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import java.util.Map;

public abstract class HighlightingStreamConverter<T>
implements Converter<T, ARGBType>, SeedProperty, WithAlpha, ColorFromSegmentId, HideLockedSegments,
UserSpecifiedColors {
implements Converter<T, ARGBType>,
SeedProperty, WithAlpha, ColorFromSegmentId, HideLockedSegments, UserSpecifiedColors {

private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

Expand Down Expand Up @@ -132,7 +132,10 @@ public static <T> HighlightingStreamConverter<T> forType(
return (HighlightingStreamConverter<T>)new HighlightingStreamConverterLabelMultisetType(stream);
}
if (t instanceof Volatile<?> && ((Volatile<?>)t).get() instanceof IntegerType<?>) {
return (HighlightingStreamConverter<T>)new HighlightingStreamConverterIntegerType(stream);
return (HighlightingStreamConverter<T>)new HighlightingStreamConverterVolatileIntegerType<>(stream);
}
if (t instanceof IntegerType<?>) {
return (HighlightingStreamConverter<T>)new HighlightingStreamConverterIntegerType<>(stream);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.lang.invoke.MethodHandles;

public class HighlightingStreamConverterIntegerType<I extends IntegerType<I>, V extends Volatile<I>> extends HighlightingStreamConverter<V> {
public class HighlightingStreamConverterIntegerType<I extends IntegerType<I>> extends HighlightingStreamConverter<I> {

private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

Expand All @@ -19,9 +19,9 @@ public HighlightingStreamConverterIntegerType(final AbstractHighlightingARGBStre
}

@Override
public void convert(final V input, final ARGBType output) {
public void convert(final I input, final ARGBType output) {

output.set(stream.argb(input.get().getIntegerLong()));
output.set(stream.argb(input.getIntegerLong()));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.janelia.saalfeldlab.paintera.stream;

import net.imglib2.Volatile;
import net.imglib2.type.numeric.IntegerType;

public class HighlightingStreamConverterVolatileIntegerType<I extends IntegerType<I>, V extends Volatile<I>> extends HighlightingStreamConverterVolatileType<I, V> {

public HighlightingStreamConverterVolatileIntegerType(final AbstractHighlightingARGBStream stream) {

super(stream, new HighlightingStreamConverterIntegerType(stream));
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
package org.janelia.saalfeldlab.paintera.stream;

import net.imglib2.type.label.LabelMultisetType;
import net.imglib2.type.label.VolatileLabelMultisetType;
import net.imglib2.type.numeric.ARGBType;

public class HighlightingStreamConverterVolatileLabelMultisetType extends HighlightingStreamConverter<VolatileLabelMultisetType> {
public class HighlightingStreamConverterVolatileLabelMultisetType extends HighlightingStreamConverterVolatileType<LabelMultisetType, 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);
super(stream, new HighlightingStreamConverterLabelMultisetType(stream));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.janelia.saalfeldlab.paintera.stream;

import net.imglib2.Volatile;
import net.imglib2.type.numeric.ARGBType;

public abstract class HighlightingStreamConverterVolatileType<I, V extends Volatile<I>> extends HighlightingStreamConverter<V> {

protected final HighlightingStreamConverter<I> nonVolatileConverter;

public HighlightingStreamConverterVolatileType(AbstractHighlightingARGBStream stream, HighlightingStreamConverter<I> nonVolatileConverter) {

super(stream);
this.nonVolatileConverter = nonVolatileConverter;
}

public HighlightingStreamConverter<I> getNonVolatileConverter() {

return nonVolatileConverter;
}

@Override public void convert(V input, ARGBType output) {

final boolean isValid = input.isValid();
if (!isValid) {
return;
}
getNonVolatileConverter().convert(input.get(), output);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Scene3DHandler(final Viewer3DFX viewer) {
ActionSet.installActionSet(viewer, additionalCommands);

Paintera.whenPaintable(() -> {
/* These depend on the keyTracker in the PainteraMainWindow, so cannot be installed until the MainWindow is done intializing. */
/* These depend on the keyTracker in the PainteraMainWindow, so cannot be installed until the MainWindow is done initializing. */
final var zoomActionSet = zoom3D();
ActionSet.installActionSet(viewer, zoomActionSet);
});
Expand Down Expand Up @@ -187,16 +187,16 @@ private void drag(MouseEvent event) {

private class Rotate3DView extends DragActionSet {

private double baseSpeed = 1.0;
private double baseSpeed = 0.25;
private double factor = 1.0;

private double speed = baseSpeed * factor;

private final static double SLOW_FACTOR = 0.1;
private final static double SLOW_FACTOR = 0.5;

private final static double NORMAL_FACTOR = 1;

private final static double FAST_FACTOR = 2;
private final static double FAST_FACTOR = 2.0;

private final Affine affineDragStart = new Affine();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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
import org.janelia.saalfeldlab.paintera.stream.HighlightingStreamConverterVolatileType

//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,
Expand Down Expand Up @@ -59,7 +60,7 @@ internal fun <D : Any> getDataSourceAndConverter(sourceAndConverter: SourceAndCo
val unwrappedDataSource = UnwrappedDataSource(data)

val converter = sourceAndConverter.converter.let {
(it as? HighlightingStreamConverterVolatileLabelMultisetType)?.nonVolatileConverter ?: it
(it as? HighlightingStreamConverterVolatileType<*, *>)?.nonVolatileConverter ?: it
} as Converter<D, ARGBType>

return WrappedSourceAndConverter(sourceAndConverter, unwrappedDataSource, converter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.janelia.saalfeldlab.bdv.fx.viewer.ViewerState
import bdv.viewer.Interpolation
import bdv.viewer.Source
import bdv.viewer.render.AccumulateProjectorFactory
import javafx.beans.property.SimpleBooleanProperty
import net.imglib2.parallel.TaskExecutor
import net.imglib2.realtransform.AffineTransform3D
import net.imglib2.type.numeric.ARGBType
Expand Down Expand Up @@ -32,10 +33,36 @@ open class ViewerRenderUnit(
renderingTaskExecutor,
useVolatileIfAvailable = true
) {

val repaintRequestProperty = SimpleBooleanProperty()

override fun paint() {
if (viewerStateSupplier.get()?.isVisible == true)
super.paint()
}

private fun notifyRepaintObservable() = repaintRequestProperty.set(!repaintRequestProperty.value)

override fun requestRepaint() {
super.requestRepaint()
notifyRepaintObservable()
}

override fun requestRepaint(screenScaleIndex: Int) {
super.requestRepaint(screenScaleIndex)
notifyRepaintObservable()
}

override fun requestRepaint(min: LongArray?, max: LongArray?) {
super.requestRepaint(min, max)
notifyRepaintObservable()
}

override fun requestRepaint(screenScaleIndex: Int, min: LongArray?, max: LongArray?) {
super.requestRepaint(screenScaleIndex, min, max)
notifyRepaintObservable()
}

companion object {

private fun Supplier<ViewerState?>.getRenderState() : () -> RenderUnitState? = {
Expand Down
Loading

0 comments on commit 7875344

Please sign in to comment.