@@ -132,6 +132,7 @@ const ViewerModel = widgets.DOMWidgetModel.extend(
132132 z_slice : null ,
133133 clicked_slice_point : null ,
134134 gradient_opacity : 0.2 ,
135+ sample_distance : 0.25 ,
135136 opacity_gaussians : null ,
136137 channels : null ,
137138 blend_mode : 'composite' ,
@@ -733,6 +734,7 @@ const ViewerView = widgets.DOMWidgetView.extend({
733734 if ( rendered_image ) {
734735 this . shadow_changed ( )
735736 this . gradient_opacity_changed ( )
737+ this . sample_distance_changed ( )
736738 this . channels_changed ( )
737739 this . blend_mode_changed ( )
738740 }
@@ -1010,6 +1012,16 @@ const ViewerView = widgets.DOMWidgetView.extend({
10101012 this . model . itkVtkViewer . on ( 'gradientOpacityChanged' ,
10111013 onGradientOpacityChange
10121014 )
1015+
1016+ const onVolumeSampleDistanceChange = ( distance ) => {
1017+ if ( distance !== this . model . get ( 'sample_distance' ) ) {
1018+ this . model . set ( 'sample_distance' , distance )
1019+ this . model . save_changes ( )
1020+ }
1021+ }
1022+ this . model . itkVtkViewer . on ( 'volumeSampleDistanceChanged' ,
1023+ onVolumeSampleDistanceChange
1024+ )
10131025 } // end use2D
10141026
10151027 const onCameraChanged = macro . throttle ( ( ) => {
@@ -1080,6 +1092,11 @@ const ViewerView = widgets.DOMWidgetView.extend({
10801092 this . gradient_opacity_changed ,
10811093 this
10821094 )
1095+ this . model . on (
1096+ 'change:sample_distance' ,
1097+ this . sample_distance_changed ,
1098+ this
1099+ )
10831100 this . model . on ( 'change:blend_mode' , this . blend_mode_changed , this )
10841101 this . model . on ( 'change:select_roi' , this . select_roi_changed , this )
10851102 this . model . on ( 'change:_scale_factors' , this . scale_factors_changed , this )
@@ -1583,6 +1600,13 @@ const ViewerView = widgets.DOMWidgetView.extend({
15831600 }
15841601 } ,
15851602
1603+ sample_distance_changed : function ( ) {
1604+ const sample_distance = this . model . get ( 'sample_distance' )
1605+ if ( this . model . hasOwnProperty ( 'itkVtkViewer' ) && ! this . model . use2D ) {
1606+ this . model . itkVtkViewer . setVolumeSampleDistance ( sample_distance )
1607+ }
1608+ } ,
1609+
15861610 opacity_gaussians_changed : function ( ) {
15871611 const opacity_gaussians = this . model . get ( 'opacity_gaussians' )
15881612 if ( this . model . hasOwnProperty ( 'itkVtkViewer' ) && ! this . model . use2D ) {
0 commit comments