Skip to content

Commit c5ecaad

Browse files
committed
misc fixes/improvements
- Fix Bvv axes not visible when scene bounding box is also displayed - Fix Bvv overlay annotations not respecting rendering options at startup - Improve SNT controls tollbar in Bvv
1 parent 06e45d4 commit c5ecaad

3 files changed

Lines changed: 62 additions & 27 deletions

File tree

‎src/main/java/sc/fiji/snt/gui/cmds/BigViewerRenderingOptionsCmd.java‎

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
import org.scijava.module.MutableModuleItem;
2727
import org.scijava.plugin.Parameter;
2828
import org.scijava.util.ColorRGB;
29+
import org.scijava.widget.Button;
2930
import org.scijava.widget.ChoiceWidget;
3031
import org.scijava.widget.NumberWidget;
32+
import sc.fiji.snt.SNTPrefs;
3133
import sc.fiji.snt.viewer.AbstractBigViewer;
3234

3335
/**
@@ -44,42 +46,45 @@ public abstract class BigViewerRenderingOptionsCmd extends DynamicCommand {
4446
protected static final String STYLE_RADII = "Frusta (uses path radii)";
4547

4648
@Parameter(label = "Path rendering style", choices = {STYLE_LINE, STYLE_RADII},
47-
style = ChoiceWidget.RADIO_BUTTON_VERTICAL_STYLE,
49+
style = ChoiceWidget.RADIO_BUTTON_VERTICAL_STYLE, persist = false,
4850
description = "<html>Centerline rendering is recommended for large datasets.<br>"
4951
+ "Frusta (tapered tubes) use per-node radii for a more accurate 3D appearance")
5052
private String renderingStyle;
5153

52-
@Parameter(label = "Use path radii",
53-
description = "Sets whether to use path radius for thickness calculation. "
54+
@Parameter(label = "Use path radii", persist = false,
55+
description = "Sets whether to use path radius for thickness calculation.\n"
5456
+ "Disable for paths with uniform thickness.")
5557
private boolean usePathRadius;
5658

5759
@Parameter(label = "Thickness multiplier", min = "0.1", max = "10.0", stepSize = "0.1",
58-
style = "slider,format:0.00",
59-
description = "Scale factor applied to all path radii. "
60+
style = "slider,format:0.00", persist = false,
61+
description = "Scale factor applied to all path radii.\n"
6062
+ "1.0x = natural size; increase if paths appear too thin.")
6163
private double thicknessMultiplier;
6264

6365
@Parameter(label = "Min. thickness", min = "0.1", max = "20.0", stepSize = "0.1",
64-
style = "slider,format:0.0",
65-
description = "Minimum rendered thickness in physical units. "
66+
style = "slider,format:0.0", persist = false,
67+
description = "Minimum rendered thickness in physical units.\n"
6668
+ "Controls line width in centerline mode and the floor radius in tube mode.")
6769
private double minThickness;
6870

6971
@Parameter(label = "Max. thickness", min = "1", max = "100.0", stepSize = "0.5",
70-
style = "slider,format:0.0",
71-
description = "Maximum rendered thickness in physical units. "
72+
style = "slider,format:0.0", persist = false,
73+
description = "Maximum rendered thickness in physical units.\n"
7274
+ "Controls line width in centerline mode and the ceiling radius in tube mode.")
7375
private double maxThickness;
7476

7577
@Parameter(label = "Transparency (%)", min = "0", max = "100", stepSize = "1",
76-
style = NumberWidget.SLIDER_STYLE,
77-
description = "Opacity of all path overlays. 0% = fully opaque; 100% = fully transparent.")
78+
style = NumberWidget.SLIDER_STYLE, persist = false,
79+
description = "Opacity of all path overlays.\n0% = fully opaque; 100% = fully transparent.")
7880
private double transparency;
7981

8082
@Parameter(required = false, label = "Default color", persist = false)
8183
private ColorRGB defaultColor;
8284

85+
@Parameter(required = false, label = "Reset to Defaults", persist = false, callback = "reset")
86+
private Button reset;
87+
8388
/**
8489
* Returns the viewer instance to configure. Implementations return their
8590
* specific viewer (Bvv or Bdv) injected via a @Parameter field.
@@ -95,9 +100,22 @@ protected void init() {
95100
usePathRadius = opts.isUsePathRadius();
96101
transparency = (1.0 - opts.getTransparency()) * 100; // invert and scale: 0% = opaque, 100% = transparent
97102
defaultColor = new ColorRGB(opts.fallbackColor.getRed(), opts.fallbackColor.getGreen(), opts.fallbackColor.getBlue());
98-
// update widget
99-
final MutableModuleItem<ColorRGB> mi = getInfo().getMutableInput("defaultColor", ColorRGB.class);
100-
mi.setValue(this, defaultColor);
103+
updateColorWidget(defaultColor);
104+
}
105+
106+
private void reset() {
107+
renderingStyle = STYLE_RADII;
108+
thicknessMultiplier = 1.0f;
109+
minThickness = 1.0f;
110+
maxThickness = 100.0f;
111+
usePathRadius = true;
112+
transparency = 0; // inverted: 0% = opaque
113+
defaultColor = new ColorRGB(
114+
SNTPrefs.DEFAULT_DESELECTED_COLOR.getRed(),
115+
SNTPrefs.DEFAULT_DESELECTED_COLOR.getGreen(),
116+
SNTPrefs.DEFAULT_DESELECTED_COLOR.getBlue());
117+
updateColorWidget(defaultColor);
118+
updateOverlay(getViewer());
101119
}
102120

103121
@Override
@@ -111,7 +129,19 @@ public void run() {
111129
opts.setUsePathRadius(usePathRadius);
112130
opts.fallbackColor = new java.awt.Color(defaultColor.getRed(), defaultColor.getGreen(), defaultColor.getBlue());
113131
opts.setTransparency((float) (100 - transparency) / 100);
114-
viewer.setDisplayRadii(STYLE_RADII.equals(renderingStyle)); // invalidates the overlay cache before syncing
115-
viewer.syncOverlays();
132+
updateOverlay(viewer);
133+
}
134+
135+
private void updateColorWidget(final ColorRGB newColor) {
136+
final MutableModuleItem<ColorRGB> mi = getInfo().getMutableInput("defaultColor", ColorRGB.class);
137+
mi.setValue(this, newColor);
116138
}
139+
140+
private void updateOverlay(final AbstractBigViewer viewer) {
141+
if (viewer != null) {
142+
viewer.setDisplayRadii(STYLE_RADII.equals(renderingStyle)); // invalidates the overlay cache before syncing
143+
viewer.syncOverlays();
144+
}
145+
}
146+
117147
}

‎src/main/java/sc/fiji/snt/gui/cmds/BvvRenderingOptionsCmd.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
import sc.fiji.snt.viewer.Bvv;
3030

3131
/**
32-
* Command providing a GUI for configuring {@link AbstractBigViewer.PathRenderingOptions} in
33-
* a {@link Bvv} viewer.
32+
* Command providing a GUI for configuring {@link AbstractBigViewer.PathRenderingOptions} in a {@link Bvv} viewer.
3433
*
3534
* @author Tiago Ferreira
3635
* @see BdvRenderingOptionsCmd

‎src/main/java/sc/fiji/snt/viewer/Bvv.java‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private double[] getClickedPosition(final MouseEvent e) {
202202
*
203203
* @param worldPos calibrated (x,y,z) position to search from
204204
* @return the nearest rendered path, or {@code null} if nothing is currently rendered
205-
* @see {@code Tracer#handleClick}. Mirrors {@code InteractiveTracerCanvas#selectNearestPathToMousePointer},
205+
* @see Tracer#handleClick(MouseEvent) Mirrors {@code InteractiveTracerCanvas#selectNearestPathToMousePointer},
206206
*/
207207
private Path findNearestRenderedPath(final double[] worldPos) {
208208
Path nearest = null;
@@ -1836,6 +1836,11 @@ private JComponent sntToolbar(final BvvActions actions) {
18361836
toolbar.addSeparator();
18371837
toolbar.add(offsetActivate);
18381838
toolbar.addSeparator();
1839+
if (tracer != null) {
1840+
toolbar.add(GuiUtils.Buttons.toolbarButton(actions.syncPathManagerAction(),
1841+
"Sync Path Manager changes"));
1842+
toolbar.addSeparator();
1843+
}
18391844
toolbar.add(Box.createHorizontalGlue());
18401845
toolbar.addSeparator();
18411846

@@ -1867,8 +1872,6 @@ public void componentHidden(java.awt.event.ComponentEvent e) {
18671872
"Set rendering options of annotations"));
18681873

18691874
if (tracer != null) {
1870-
toolbar.add(GuiUtils.Buttons.toolbarButton(actions.syncPathManagerAction(),
1871-
"Sync Path Manager changes"));
18721875
final JPanel panel = new JPanel(new BorderLayout());
18731876
panel.add(toolbar, BorderLayout.NORTH);
18741877
panel.add(tracingStatusRow(), BorderLayout.SOUTH);
@@ -2505,7 +2508,10 @@ private double[] searchPeakAcrossSources(final java.util.Collection<bdv.viewer.S
25052508

25062509
@Override
25072510
public float getDefaultMarkerSize() {
2508-
return renderingOptions.getMinThickness();
2511+
// Clamped to getMaxThickness() as a safety net against extreme multiplier values
2512+
// see OverlayRenderer#recolor/computeScreenData)
2513+
return Math.min(renderingOptions.getMinThickness() * renderingOptions.getThicknessMultiplier(),
2514+
renderingOptions.getMaxThickness());
25092515
}
25102516

25112517
@Override
@@ -3844,9 +3850,7 @@ public void drawOverlays(final java.awt.Graphics g) {
38443850
final double cy = canvasH / 2.0;
38453851

38463852
final java.awt.Graphics2D g2 = (java.awt.Graphics2D) g.create();
3847-
g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING,
3848-
java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
3849-
g2.setStroke(new java.awt.BasicStroke(1.5f));
3853+
g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
38503854

38513855
// World → screen projection (same formula as AnnotationOverlay)
38523856
final java.util.function.Function<double[], double[]> project = world -> {
@@ -3865,12 +3869,14 @@ public void drawOverlays(final java.awt.Graphics g) {
38653869
final double x0 = b[0], y0 = b[1], z0 = b[2], x1 = b[3], y1 = b[4], z1 = b[5];
38663870

38673871
if (showAxes) {
3872+
g2.setStroke(new java.awt.BasicStroke(3f));
38683873
final float axisLen = 0.20f * (float) Math.min(x1 - x0, Math.min(y1 - y0, z1 - z0));
38693874
drawLine3D(g2, project, new double[]{x0, y0, z0}, new double[]{x0 + axisLen, y0, z0}, new java.awt.Color(220, 60, 60));
38703875
drawLine3D(g2, project, new double[]{x0, y0, z0}, new double[]{x0, y0 + axisLen, z0}, new java.awt.Color(60, 200, 60));
38713876
drawLine3D(g2, project, new double[]{x0, y0, z0}, new double[]{x0, y0, z0 + axisLen}, new java.awt.Color(80, 120, 255));
38723877
}
38733878

3879+
g2.setStroke(new java.awt.BasicStroke(1.5f));
38743880
if (showBox) {
38753881
g2.setColor(new java.awt.Color(255, 255, 255, 180));
38763882
// 12 edges of the bounding box
@@ -3942,7 +3948,7 @@ public void drawOverlays(final java.awt.Graphics g) {
39423948

39433949
final java.awt.Color slabColor = new java.awt.Color(40, 90, 160);
39443950
final java.awt.Stroke savedStroke = g2.getStroke();
3945-
g2.setStroke(new java.awt.BasicStroke(1.2f, java.awt.BasicStroke.CAP_BUTT,
3951+
g2.setStroke(new java.awt.BasicStroke(1.5f, java.awt.BasicStroke.CAP_BUTT,
39463952
java.awt.BasicStroke.JOIN_MITER, 4f, new float[]{6f, 4f}, 0f));
39473953
g2.setColor(slabColor);
39483954
final int[][] edges = {
@@ -5859,7 +5865,7 @@ public void actionPerformed(final java.awt.event.ActionEvent e) {
58595865
// Choose the moving source (the one carrying the manual transform)
58605866
final Map<String, BvvMultiSource> choiceMap = multiSourceToChoiceMap(multiSources);
58615867
if (choiceMap.size()==1) {
5862-
getGuiUtils().error("Only one source available.");
5868+
getGuiUtils().error("There is only one source available.");
58635869
return;
58645870
}
58655871
final String[] choiceKeys = choiceMap.keySet().toArray(new String[0]);

0 commit comments

Comments
 (0)