Skip to content

Commit

Permalink
Merge pull request #273 from saalfeldlab/update-picocli-dependency
Browse files Browse the repository at this point in the history
Add --add-n5-container option to Paintera main class
  • Loading branch information
hanslovsky committed Aug 5, 2019
2 parents d5da29e + 914cbf9 commit 7525eef
Show file tree
Hide file tree
Showing 31 changed files with 1,447 additions and 1,126 deletions.
146 changes: 118 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,45 +144,135 @@ We recommend setting these JVM options:
The following assumes that Paintera was installed through [conda](#conda) or [pip](#pip) and the `paintera` command is available on the command line. Replace `paintera` with an appropriate substitute if executed in a different way, e.g. through [jgo](#jgo).
```shell
$ paintera --help
Usage: Paintera [-h] [--default-to-temp-directory] [--print-error-codes]
Usage: Paintera [--add-n5-container=<container>...
[--add-n5-container=<container>...]... (-d=DATASET...
[-d=DATASET...]... [-r=RESOLUTION] [-r=RESOLUTION]...
[-o=OFFSET] [-o=OFFSET]... [-R] [--min=MIN] [--max=MAX]
[--channel-dimension=CHANNEL_DIMENSION]
[--channels=CHANNELS...] [--channels=CHANNELS...]...
[--name=NAME] [--name=NAME]...
[--id-service-fallback=ID_SERVICE_FALLBACK]
[--label-block-lookup-fallback=LABEL_BLOCK_LOOKUP_FALLBACK]
[--entire-container] [--exclude=EXCLUDE...]
[--exclude=EXCLUDE...]... [--include=INCLUDE...]
[--include=INCLUDE...]... [--only-explicitly-included])]...
[-h] [--default-to-temp-directory] [--print-error-codes]
[--version] [--height=HEIGHT]
[--highest-screen-scale=HIGHEST_SCREEN_SCALE]
[--num-screen-scales=NUM_SCREEN_SCALES]
[--screen-scale-factor=SCREEN_SCALE_FACTOR] [--width=WIDTH]
[--screen-scales=SCREEN_SCALES[,SCREEN_SCALES...]...]...
[PROJECT]
[PROJECT] Optional project N5 root (N5 or FileSystem).
[PROJECT] Optional project N5 root (N5 or FileSystem).
--add-n5-container=<container>...
Container of dataset(s) to be added. If none is
provided, default to Paintera project (if any).
Currently N5 file system and HDF5 containers are
supported.
--channel-dimension=CHANNEL_DIMENSION
Defines the dimension of a 4D dataset to be
interpreted as channel axis. 0 <=
CHANNEL_DIMENSION <= 3
Default: 3
--channels=CHANNELS... Use only this subset of channels for channel (4D)
data. Multiple subsets can be specified. If no
channels are specified, use all channels.
-d, --dataset=DATASET... Dataset(s) within CONTAINER to be added. TODO: If
no datasets are specified, all datasets will be
added (or use a separate option for this).
--default-to-temp-directory
Default to temporary directory instead of showing
dialog when PROJECT is not specified.
-h, --help Display this help message.
--height=HEIGHT Initial height of viewer. Defaults to 600.
Overrides height stored in project.
Default to temporary directory instead of showing
dialog when PROJECT is not specified.
--entire-container If set to true, discover all datasets (Paintera
format, multi-scale group, and N5 dataset)
inside CONTAINER and add to Paintera. The -d,
--dataset and --name options will be ignored if
ENTIRE_CONTAINER is set. Datasets can be
excluded through the --exclude option. The
--include option overrides any exclusions.
--exclude=EXCLUDE... Exclude any data set that matches any of EXCLUDE
regex patterns.
-h, --help Display this help message.
--height=HEIGHT Initial height of viewer. Defaults to 600.
Overrides height stored in project.
Default: -1
--highest-screen-scale=HIGHEST_SCREEN_SCALE
Highest screen scale, restricted to the interval
(0,1], defaults to 1. If no scale option is
specified, scales default to [1.0, 0.5, 0.25,
0.125, 0.0625].
Highest screen scale, restricted to the interval
(0,1], defaults to 1. If no scale option is
specified, scales default to [1.0, 0.5, 0.25,
0.125, 0.0625].
--id-service-fallback=ID_SERVICE_FALLBACK
Set a fallback id service for scenarios in which
an id service is not provided by the data
backend, e.g. when no `maxId' attribute is
specified in an N5 dataset. Valid options are
(case insensitive): from-data — infer the max id
and id service from the dataset (may take a long
time for large datasets), none — do not use an
id service (requesting new ids will not be
possible), and ask — show a dialog to choose
between those two options
Default: ask
--include=INCLUDE... Include any data set that matches any of INCLUDE
regex patterns. Takes precedence over EXCLUDE.
--label-block-lookup-fallback=LABEL_BLOCK_LOOKUP_FALLBACK
Set a fallback label block lookup for scenarios in
which a label block lookup is not provided by
the data backend. The label block lookup is used
to process only relevant data during on-the-fly
mesh generation. Valid options are: `complete'
always process the entire dataset (slow for
large data), `none' — do not process at all (no
3D representations/meshes available), and `ask'
— show a dialog to choose between those two
options
Default: ask
--max=MAX Maximum value of contrast range for raw and
channel data.
--min=MIN Minimum value of contrast range for raw and
channel data.
--name=NAME Specify name for dataset(s). The names are
assigned to datasets in the same order as
specified. If more datasets than names are
specified, the remaining dataset names will
default to the last segment of the dataset path.
--num-screen-scales=NUM_SCREEN_SCALES
Number of screen scales, defaults to 3. If no scale
option is specified, scales default to [1.0, 0.5,
0.25, 0.125, 0.0625].
--print-error-codes List all error codes and exit.
Number of screen scales, defaults to 3. If no
scale option is specified, scales default to
[1.0, 0.5, 0.25, 0.125, 0.0625].
-o, --offset=OFFSET Spatial offset for all dataset(s) specified by
DATASET. Takes meta-data over resolution
specified in meta data of DATASET
--only-explicitly-included
When this option is set, use only data sets that
were explicitly included via INCLUDE. Equivalent
to --exclude '.*'
--print-error-codes List all error codes and exit.
-r, --resolution=RESOLUTION
Spatial resolution for all dataset(s) specified by
DATASET. Takes meta-data over resolution
specified in meta data of DATASET
-R, --revert-array-attributes
Revert array attributes found in meta data of
attributes of DATASET. Does not affect any array
attributes set explicitly through the RESOLUTION
or OFFSET options.
--screen-scale-factor=SCREEN_SCALE_FACTOR
Scalar value from the open interval (0,1) that
defines how screen scales diminish in each
dimension. Defaults to 0.5. If no scale option is
specified, scales default to [1.0, 0.5, 0.25,
0.125, 0.0625].
Scalar value from the open interval (0,1) that
defines how screen scales diminish in each
dimension. Defaults to 0.5. If no scale option
is specified, scales default to [1.0, 0.5, 0.25,
0.125, 0.0625].
--screen-scales=SCREEN_SCALES[,SCREEN_SCALES...]...
Explicitly set screen scales. Must be strictly
monotonically decreasing values in from the
interval (0,1]. Overrides all other screen scale
options. If no scale option is specified, scales
default to [1.0, 0.5, 0.25, 0.125, 0.0625].
--version Print version string and exit
--width=WIDTH Initial width of viewer. Defaults to 800. Overrides
width stored in project.
Explicitly set screen scales. Must be strictly
monotonically decreasing values in from the
interval (0,1]. Overrides all other screen scale
options. If no scale option is specified, scales
default to [1.0, 0.5, 0.25, 0.125, 0.0625].
--version Print version string and exit
--width=WIDTH Initial width of viewer. Defaults to 800.
Overrides width stored in project.
Default: -1
```
## Usage
Expand Down
14 changes: 14 additions & 0 deletions generate-bash-completion.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env kscript

@file:KotlinOpts("-classpath /usr/lib/jvm/java-8-openjdk/jre/lib/ext/jfxrt.jar")
@file:DependsOn("org.janelia.saalfeldlab:paintera:0.17.0")
@file:DependsOn("org.slf4j:slf4j-simple:1.7.25")

import picocli.AutoComplete

AutoComplete.main(
"-n",
"paintera",
"org.janelia.saalfeldlab.paintera.PainteraCommandLineArgs",
"--force")

6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

<!-- NB: Deploy releases to the SciJava Maven repository. -->
<releaseProfiles>deploy-to-scijava</releaseProfiles>

<picocli.version>4.0.1</picocli.version>
</properties>


Expand Down Expand Up @@ -135,9 +137,9 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>pl.touk</groupId>
<groupId>com.pivovarit</groupId>
<artifactId>throwing-function</artifactId>
<version>1.3</version>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.snakeyaml</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package bdv.fx.viewer.render;

import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import com.pivovarit.function.ThrowingRunnable;
import com.sun.javafx.tk.PlatformImage;
import javafx.scene.image.Image;
import javafx.scene.image.WritableImage;
Expand All @@ -15,7 +11,11 @@
import net.imglib2.type.numeric.ARGBType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pl.touk.throwing.ThrowingRunnable;

import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class BufferExposingWritableImage extends WritableImage
{
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/org/janelia/saalfeldlab/paintera/Paintera.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import bdv.viewer.ViewerOptions;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.pivovarit.function.ThrowingFunction;
import com.pivovarit.function.ThrowingSupplier;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.ListChangeListener;
Expand Down Expand Up @@ -38,8 +40,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import picocli.CommandLine;
import pl.touk.throwing.ThrowingFunction;
import pl.touk.throwing.ThrowingSupplier;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -190,8 +190,7 @@ public void startImpl(final Stage stage) throws Exception
true,
() -> projectDir,
indexToState,
gridConstraintsManager
)))
gridConstraintsManager)))
.orElse(new Properties(baseView, gridConstraintsManager));

paneWithStatus.crosshairConfigNode().bind(properties.crosshairConfig);
Expand Down Expand Up @@ -315,8 +314,7 @@ public void startImpl(final Stage stage) throws Exception
properties,
GsonHelpers.builderWithAllRequiredSerializers(
baseView,
() -> projectDir
).setPrettyPrinting()
() -> projectDir).setPrettyPrinting()
);
} catch (final IOException e1)
{
Expand All @@ -326,8 +324,7 @@ public void startImpl(final Stage stage) throws Exception
LOG.error("Project undefined");
}
},
e -> keyTracker.areOnlyTheseKeysDown(KeyCode.CONTROL, KeyCode.S)
).installInto(paneWithStatus.getPane());
e -> keyTracker.areOnlyTheseKeysDown(KeyCode.CONTROL, KeyCode.S)).installInto(paneWithStatus.getPane());

EventFX.KEY_PRESSED("commit", e -> {
LOG.debug("Showing commit dialog");
Expand All @@ -343,8 +340,7 @@ public void startImpl(final Stage stage) throws Exception
LOG.error("Unable to persist fragment-segment-assignment: {}", e1.getMessage());
}
},
e -> baseView.allowedActionsProperty().get().isAllowed(MenuActionType.CommitCanvas) && keyTracker.areOnlyTheseKeysDown(KeyCode.CONTROL, KeyCode.C)
).installInto(paneWithStatus.getPane());
e -> baseView.allowedActionsProperty().get().isAllowed(MenuActionType.CommitCanvas) && keyTracker.areOnlyTheseKeysDown(KeyCode.CONTROL, KeyCode.C)).installInto(paneWithStatus.getPane());

keyTracker.installInto(scene);
scene.addEventFilter(MouseEvent.ANY, mouseTracker);
Expand All @@ -355,6 +351,8 @@ public void startImpl(final Stage stage) throws Exception
properties.windowProperties.heightProperty.bind(stage.heightProperty());
properties.setGlobalTransformClean();

painteraArgs.addToViewer(baseView, projectDir);

stage.show();
}

Expand Down
Loading

0 comments on commit 7525eef

Please sign in to comment.