@@ -122,7 +122,8 @@ const ViewerModel = widgets.DOMWidgetModel.extend(
122
122
_rendering_image : false ,
123
123
interpolation : true ,
124
124
cmap : null ,
125
- _custom_cmap : new Float32Array ( [ 0 , 0 , 0 ] ) ,
125
+ lut : 'glasbey' ,
126
+ _custom_cmap : { array : new Float32Array ( [ 0 , 0 , 0 ] ) , shape : [ 1 , 3 ] } ,
126
127
vmin : null ,
127
128
vmax : null ,
128
129
shadow : true ,
@@ -142,8 +143,9 @@ const ViewerModel = widgets.DOMWidgetModel.extend(
142
143
_scale_factors : new Uint8Array ( [ 1 , 1 , 1 ] ) ,
143
144
units : '' ,
144
145
point_sets : null ,
145
- point_set_colors : new Float32Array ( [ 0 , 0 , 0 ] ) ,
146
- point_set_opacities : new Float32Array ( [ 1.0 ] ) ,
146
+ point_set_colors : { array : new Float32Array ( [ 0 , 0 , 0 ] ) , shape : [ 1 , 3 ] } ,
147
+ point_set_opacities : { array : new Float32Array ( [ 1.0 ] ) , shape : [ 1 ] } ,
148
+ point_set_sizes : { array : new Uint8Array ( [ 3 ] ) , shape : [ 1 ] } ,
147
149
point_set_representations : new Array ( ) ,
148
150
geometries : null ,
149
151
geometry_colors : new Float32Array ( [ 0 , 0 , 0 ] ) ,
@@ -188,6 +190,7 @@ const ViewerModel = widgets.DOMWidgetModel.extend(
188
190
camera : fixed_shape_serialization ( [ 3 , 3 ] ) ,
189
191
point_set_colors : simplearray_serialization ,
190
192
point_set_opacities : simplearray_serialization ,
193
+ point_set_sizes : simplearray_serialization ,
191
194
geometry_colors : simplearray_serialization ,
192
195
geometry_opacities : simplearray_serialization
193
196
} ,
@@ -447,6 +450,7 @@ function replacePointSets (domWidgetView, pointSets) {
447
450
domWidgetView . model . itkVtkViewer . setPointSets ( vtkPointSets )
448
451
domWidgetView . point_set_colors_changed ( )
449
452
domWidgetView . point_set_opacities_changed ( )
453
+ domWidgetView . point_set_sizes_changed ( )
450
454
domWidgetView . point_set_representations_changed ( )
451
455
domWidgetView . model . itkVtkViewer . renderLater ( )
452
456
}
@@ -838,14 +842,15 @@ const ViewerView = widgets.DOMWidgetView.extend({
838
842
this . model . skipOnCroppingPlanesChanged = true
839
843
this . model . set (
840
844
'roi' ,
841
- new Float64Array ( [
842
- bboxCorners [ 0 ] [ 0 ] ,
843
- bboxCorners [ 0 ] [ 1 ] ,
844
- bboxCorners [ 0 ] [ 2 ] ,
845
- bboxCorners [ 7 ] [ 0 ] ,
846
- bboxCorners [ 7 ] [ 1 ] ,
847
- bboxCorners [ 7 ] [ 2 ]
848
- ] )
845
+ { array : new Float64Array ( [
846
+ bboxCorners [ 0 ] [ 0 ] ,
847
+ bboxCorners [ 0 ] [ 1 ] ,
848
+ bboxCorners [ 0 ] [ 2 ] ,
849
+ bboxCorners [ 7 ] [ 0 ] ,
850
+ bboxCorners [ 7 ] [ 1 ] ,
851
+ bboxCorners [ 7 ] [ 2 ]
852
+ ] ) ,
853
+ shape : [ 2 , 3 ] }
849
854
)
850
855
this . model . save_changes ( )
851
856
} else {
@@ -1068,8 +1073,65 @@ const ViewerView = widgets.DOMWidgetView.extend({
1068
1073
if ( point_sets ) {
1069
1074
this . point_set_colors_changed ( )
1070
1075
this . point_set_opacities_changed ( )
1076
+ this . point_set_sizes_changed ( )
1071
1077
this . point_set_representations_changed ( )
1072
1078
}
1079
+
1080
+ const onPointSetColorChanged = ( index , color ) => {
1081
+ const modelColors = this . model . get ( 'point_set_colors' )
1082
+ const modelColor = modelColors . array [ index ]
1083
+ if ( color !== modelColor ) {
1084
+ const newColors = modelColors . array . slice ( )
1085
+ newColors [ index ] = color
1086
+ this . model . set ( 'point_set_colors' , { array : newColors , shape : modelColors . shape } )
1087
+ this . model . save_changes ( )
1088
+ }
1089
+ }
1090
+ this . model . itkVtkViewer . on ( 'pointSetColorChanged' ,
1091
+ onPointSetColorChanged
1092
+ )
1093
+
1094
+ const onPointSetOpacityChanged = ( index , opacity ) => {
1095
+ const modelOpacities = this . model . get ( 'point_set_opacities' )
1096
+ const modelOpacity = modelOpacities . array [ index ]
1097
+ if ( opacity !== modelOpacity ) {
1098
+ const newOpacities = modelOpacities . array . slice ( )
1099
+ newOpacities [ index ] = opacity
1100
+ this . model . set ( 'point_set_opacities' , { array : newOpacities , shape : modelOpacities . shape } )
1101
+ this . model . save_changes ( )
1102
+ }
1103
+ }
1104
+ this . model . itkVtkViewer . on ( 'pointSetOpacityChanged' ,
1105
+ onPointSetOpacityChanged
1106
+ )
1107
+
1108
+ const onPointSetRepresentationChanged = ( index , representation ) => {
1109
+ const modelRepresentations = this . model . get ( 'point_set_representations' )
1110
+ const modelRepresentation = modelRepresentations [ index ]
1111
+ if ( representation !== modelRepresentation ) {
1112
+ modelRepresentations [ index ] = representation
1113
+ this . model . set ( 'point_set_representations' , modelRepresentation )
1114
+ this . model . save_changes ( )
1115
+ }
1116
+ }
1117
+ this . model . itkVtkViewer . on ( 'pointSetRepresentationChanged' ,
1118
+ onPointSetRepresentationChanged
1119
+ )
1120
+
1121
+ const onPointSetSizeChanged = ( index , size ) => {
1122
+ const modelSizes = this . model . get ( 'point_set_sizes' )
1123
+ const modelSize = modelSizes . array [ index ]
1124
+ if ( size !== modelSize ) {
1125
+ const newSize = modelSizes . array . slice ( )
1126
+ newSize [ index ] = size
1127
+ this . model . set ( 'point_set_sizes' , { array : newSize , shape : modelSizes . shape } )
1128
+ this . model . save_changes ( )
1129
+ }
1130
+ }
1131
+ this . model . itkVtkViewer . on ( 'pointSetSizeChanged' ,
1132
+ onPointSetSizeChanged
1133
+ )
1134
+
1073
1135
const geometries = this . model . get ( 'geometries' )
1074
1136
if ( geometries ) {
1075
1137
this . geometry_colors_changed ( )
@@ -1115,6 +1177,11 @@ const ViewerView = widgets.DOMWidgetView.extend({
1115
1177
this . point_set_opacities_changed ,
1116
1178
this
1117
1179
)
1180
+ this . model . on (
1181
+ 'change:point_set_sizes' ,
1182
+ this . point_set_sizes_changed ,
1183
+ this
1184
+ )
1118
1185
this . model . on (
1119
1186
'change:point_set_representations' ,
1120
1187
this . point_set_representations_changed ,
@@ -1308,27 +1375,42 @@ const ViewerView = widgets.DOMWidgetView.extend({
1308
1375
} ,
1309
1376
1310
1377
point_set_colors_changed : function ( ) {
1311
- const point_setColors = this . model . get ( 'point_set_colors' ) . array
1312
1378
if ( this . model . hasOwnProperty ( 'itkVtkViewer' ) ) {
1379
+ const point_set_colors = this . model . get ( 'point_set_colors' ) . array
1313
1380
const point_sets = this . model . get ( 'point_sets' )
1314
1381
if ( point_sets && ! ! point_sets . length ) {
1315
1382
point_sets . forEach ( ( point_set , index ) => {
1316
- const color = point_setColors . slice ( index * 3 , ( index + 1 ) * 3 )
1383
+ const color = point_set_colors . slice ( index * 3 , ( index + 1 ) * 3 )
1317
1384
this . model . itkVtkViewer . setPointSetColor ( index , color )
1318
1385
} )
1319
1386
}
1320
1387
}
1321
1388
} ,
1322
1389
1323
1390
point_set_opacities_changed : function ( ) {
1324
- const point_setOpacities = this . model . get ( 'point_set_opacities' ) . array
1325
1391
if ( this . model . hasOwnProperty ( 'itkVtkViewer' ) ) {
1392
+ const point_set_opacities = this . model . get ( 'point_set_opacities' ) . array
1326
1393
const point_sets = this . model . get ( 'point_sets' )
1327
1394
if ( point_sets && ! ! point_sets . length ) {
1328
1395
point_sets . forEach ( ( point_set , index ) => {
1329
1396
this . model . itkVtkViewer . setPointSetOpacity (
1330
1397
index ,
1331
- point_setOpacities [ index ]
1398
+ point_set_opacities [ index ]
1399
+ )
1400
+ } )
1401
+ }
1402
+ }
1403
+ } ,
1404
+
1405
+ point_set_sizes_changed : function ( ) {
1406
+ if ( this . model . hasOwnProperty ( 'itkVtkViewer' ) ) {
1407
+ const point_set_sizes = this . model . get ( 'point_set_sizes' ) . array
1408
+ const point_sets = this . model . get ( 'point_sets' )
1409
+ if ( point_sets && ! ! point_sets . length ) {
1410
+ point_sets . forEach ( ( point_set , index ) => {
1411
+ this . model . itkVtkViewer . setPointSetSize (
1412
+ index ,
1413
+ point_set_sizes [ index ]
1332
1414
)
1333
1415
} )
1334
1416
}
@@ -1342,6 +1424,7 @@ const ViewerView = widgets.DOMWidgetView.extend({
1342
1424
if ( this . model . hasOwnProperty ( 'itkVtkViewer' ) ) {
1343
1425
const point_sets = this . model . get ( 'point_sets' )
1344
1426
if ( point_sets && ! ! point_sets . length ) {
1427
+ console . log ( point_set_representations )
1345
1428
point_set_representations . forEach ( ( representation , index ) => {
1346
1429
switch ( representation . toLowerCase ( ) ) {
1347
1430
case 'hidden' :
0 commit comments