2626import org .scijava .module .MutableModuleItem ;
2727import org .scijava .plugin .Parameter ;
2828import org .scijava .util .ColorRGB ;
29+ import org .scijava .widget .Button ;
2930import org .scijava .widget .ChoiceWidget ;
3031import org .scijava .widget .NumberWidget ;
32+ import sc .fiji .snt .SNTPrefs ;
3133import 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.\n 0 % = 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}
0 commit comments