@@ -16,11 +16,11 @@ import macro from 'vtk.js/Sources/macro'
16
16
const widgets = require ( '@jupyter-widgets/base' )
17
17
18
18
const ANNOTATION_DEFAULT =
19
- '<table style="margin-left: 0;"><tr><td style="margin-left: auto; margin-right: 0;">Index:</td><td>${iIndex},</td><td>${jIndex},</td><td>${kIndex}</td></tr><tr><td style="margin-left: auto; margin-right: 0;">Position:</td><td>${xPosition},</td><td>${yPosition},</td><td>${zPosition}</td></tr><tr><td style="margin-left: auto; margin-right: 0;"">Value:</td><td>${value}</td></tr></table>'
19
+ '<table style="margin-left: 0;"><tr><td style="margin-left: auto; margin-right: 0;">Index:</td><td>${iIndex},</td><td>${jIndex},</td><td>${kIndex}</td></tr><tr><td style="margin-left: auto; margin-right: 0;">Position:</td><td>${xPosition},</td><td>${yPosition},</td><td>${zPosition}</td></tr><tr><td style="margin-left: auto; margin-right: 0;"">Value:</td><td style="text-align:center;" colspan="3" >${value}</td></tr><tr ${annotationLabelStyle}><td style="margin-left: auto; margin-right: 0;">Label:</td><td style="text-align:center;" colspan="3">${annotation }</td></tr></table>'
20
20
const ANNOTATION_CUSTOM_PREFIX =
21
21
'<table style="margin-left: 0;"><tr><td style="margin-left: auto; margin-right: 0;">Scale/Index:</td>'
22
22
const ANNOTATION_CUSTOM_POSTFIX =
23
- '</tr><tr><td style="margin-left: auto; margin-right: 0;">Position:</td><td>${xPosition},</td><td>${yPosition},</td><td>${zPosition}</td></tr><tr><td style="margin-left: auto; margin-right: 0;"">Value:</td><td>${value}</td></tr></table>'
23
+ '</tr><tr><td style="margin-left: auto; margin-right: 0;">Position:</td><td>${xPosition},</td><td>${yPosition},</td><td>${zPosition}</td></tr><tr><td style="margin-left: auto; margin-right: 0;"">Value:</td><td style="text-align:center;" colspan="3" >${value}</td></tr><tr ${annotationLabelStyle}><td style="margin-left: auto; margin-right: 0;">Label:</td><td style="text-align:center;" colspan="3">${annotation }</td></tr></table>'
24
24
25
25
const cores = navigator . hardwareConcurrency ? navigator . hardwareConcurrency : 4
26
26
const numberOfWorkers = cores + Math . floor ( Math . sqrt ( cores ) )
@@ -116,6 +116,7 @@ const ViewerModel = widgets.DOMWidgetModel.extend(
116
116
_view_module_version : '0.27.5' ,
117
117
rendered_image : null ,
118
118
rendered_label_map : null ,
119
+ label_map_names : null ,
119
120
_rendering_image : false ,
120
121
interpolation : true ,
121
122
cmap : 'Viridis (matplotlib)' ,
@@ -719,6 +720,9 @@ const ViewerView = widgets.DOMWidgetView.extend({
719
720
this . select_roi_changed ( )
720
721
this . scale_factors_changed ( )
721
722
}
723
+ if ( rendered_label_map ) {
724
+ this . label_map_names_changed ( )
725
+ }
722
726
723
727
const onUserInterfaceCollapsedToggle = ( collapsed ) => {
724
728
if ( collapsed !== this . model . get ( 'ui_collapsed' ) ) {
@@ -1044,6 +1048,7 @@ const ViewerView = widgets.DOMWidgetView.extend({
1044
1048
this . model . on ( 'change:mode' , this . mode_changed , this )
1045
1049
this . model . on ( 'change:units' , this . units_changed , this )
1046
1050
this . model . on ( 'change:camera' , this . camera_changed , this )
1051
+ this . model . on ( 'change:label_map_names' , this . label_map_names_changed , this )
1047
1052
1048
1053
let toDecompress = [ ]
1049
1054
const rendered_image = this . model . get ( 'rendered_image' )
@@ -1161,6 +1166,14 @@ const ViewerView = widgets.DOMWidgetView.extend({
1161
1166
return Promise . resolve ( null )
1162
1167
} ,
1163
1168
1169
+ label_map_names_changed : function ( ) {
1170
+ const label_map_names = this . model . get ( 'label_map_names' )
1171
+ if ( label_map_names && this . model . hasOwnProperty ( 'itkVtkViewer' ) ) {
1172
+ const labelMapNames = new Map ( label_map_names )
1173
+ this . model . itkVtkViewer . setLabelMapNames ( labelMapNames )
1174
+ }
1175
+ } ,
1176
+
1164
1177
point_sets_changed : function ( ) {
1165
1178
const point_sets = this . model . get ( 'point_sets' )
1166
1179
if ( point_sets && ! ! point_sets . length ) {
@@ -1524,7 +1537,7 @@ const ViewerView = widgets.DOMWidgetView.extend({
1524
1537
scaleFactors [ 1 ] === 1 &&
1525
1538
scaleFactors [ 2 ] === 1
1526
1539
) {
1527
- viewProxy . setCornerAnnotation ( 'se' , `${ ANNOTATION_DEFAULT } ` )
1540
+ viewProxy . setSeCornerAnnotation ( `${ ANNOTATION_DEFAULT } ` )
1528
1541
} else {
1529
1542
let scaleIndex = ''
1530
1543
if ( scaleFactors [ 0 ] === 1 ) {
@@ -1542,8 +1555,7 @@ const ViewerView = widgets.DOMWidgetView.extend({
1542
1555
} else {
1543
1556
scaleIndex = `${ scaleIndex } <td>${ scaleFactors [ 2 ] } X</td>`
1544
1557
}
1545
- viewProxy . setCornerAnnotation (
1546
- 'se' ,
1558
+ viewProxy . setSeCornerAnnotation (
1547
1559
`${ ANNOTATION_CUSTOM_PREFIX } ${ scaleIndex } ${ ANNOTATION_CUSTOM_POSTFIX } `
1548
1560
)
1549
1561
}
0 commit comments