@@ -824,27 +824,27 @@ const ViewerView = widgets.DOMWidgetView.extend({
824824 }
825825 this . model . itkVtkViewer . on ( 'selectLookupTable' , onSelectLookupTable )
826826
827- const onChangeColorRange = ( component , colorRange ) => {
828- const vmin = this . model . get ( 'vmin' )
827+ const onColorRangesChanged = ( colorRanges ) => {
828+ let vmin = this . model . get ( 'vmin' )
829829 if ( vmin === null ) {
830830 vmin = [ ]
831831 }
832- if ( colorRange [ 0 ] !== vmin [ component ] ) {
833- vmin [ component ] = colorRange [ 0 ]
834- this . model . set ( 'vmin' , vmin )
835- this . model . save_changes ( )
836- }
837- const vmax = this . model . get ( 'vmax' )
832+ let vmax = this . model . get ( 'vmax' )
838833 if ( vmax === null ) {
839834 vmax = [ ]
840835 }
841- if ( colorRange [ 1 ] !== vmax [ component ] ) {
836+ const rendered_image = this . model . get ( 'rendered_image' )
837+ const components = rendered_image . imageType . components
838+ for ( let component = 0 ; component < components ; component ++ ) {
839+ const colorRange = colorRanges [ component ]
840+ vmin [ component ] = colorRange [ 0 ]
842841 vmax [ component ] = colorRange [ 1 ]
843- this . model . set ( 'vmax' , vmax )
844- this . model . save_changes ( )
845842 }
843+ this . model . set ( 'vmax' , vmax )
844+ this . model . set ( 'vmin' , vmin )
845+ this . model . save_changes ( )
846846 }
847- this . model . itkVtkViewer . on ( 'changeColorRange ' , onChangeColorRange )
847+ this . model . itkVtkViewer . on ( 'colorRangesChanged ' , onColorRangesChanged )
848848
849849 const onCroppingPlanesChanged = ( planes , bboxCorners ) => {
850850 if (
0 commit comments