Skip to content

Commit 43756c4

Browse files
authored
Merge pull request #235 from thewtex/scale-bar-updates
Scale bar updates
2 parents 55eb344 + 4b14cd0 commit 43756c4

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

itkwidgets/widget_viewer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class Viewer(ViewerParent):
143143
help="We are downsampling the image to meet the size limits.").tag(sync=True)
144144
_reset_crop_requested = CBool(default_value=False,
145145
help="The user requested a reset of the roi.").tag(sync=True)
146+
units = Unicode('', help="Units to display in the scale bar.").tag(sync=True)
147+
point_set_representations = List(trait=Unicode(), default_value=[], help="Point set representation").tag(sync=True)
146148
point_sets = PointSetList(default_value=None, allow_none=True, help="Point sets to visualize").tag(sync=True, **polydata_list_serialization)
147149
point_set_colors = NDArray(dtype=np.float32, default_value=np.zeros((0, 3), dtype=np.float32),
148150
help="RGB colors for the points sets")\
@@ -574,6 +576,9 @@ def view(image=None,
574576
Other Parameters
575577
----------------
576578
579+
units: string, optional, default: ''
580+
Units to display in the scale bar.
581+
577582
actors: vtkActor, vtkAssembly, vtkVolume, optional, default: None
578583
List of standard vtk objects, colors are extracted from their properties
579584

js/lib/viewer.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const ViewerModel = widgets.DOMWidgetModel.extend({
7777
select_roi: false,
7878
_reset_crop_requested: false,
7979
_scale_factors: new Uint8Array([1, 1, 1]),
80+
units: '',
8081
point_sets: null,
8182
point_set_colors: new Float32Array([0., 0., 0.]),
8283
point_set_opacities: new Float32Array([1.0]),
@@ -667,6 +668,8 @@ const ViewerView = widgets.DOMWidgetView.extend({
667668
this.geometry_opacities_changed()
668669
}
669670
this.mode_changed()
671+
672+
this.units_changed()
670673
},
671674

672675
render: function() {
@@ -691,6 +694,7 @@ const ViewerView = widgets.DOMWidgetView.extend({
691694
this.model.on('change:rotate', this.rotate_changed, this)
692695
this.model.on('change:annotations', this.annotations_changed, this)
693696
this.model.on('change:mode', this.mode_changed, this)
697+
this.model.on('change:units', this.units_changed, this)
694698
this.model.on('change:camera', this.camera_changed, this)
695699

696700
let toDecompress = []
@@ -924,6 +928,15 @@ const ViewerView = widgets.DOMWidgetView.extend({
924928
}
925929
},
926930

931+
units_changed: function() {
932+
const units = this.model.get('units')
933+
if (this.model.hasOwnProperty('itkVtkViewer')) {
934+
console.log(`Units: ${units}`)
935+
const viewProxy = this.model.itkVtkViewer.getViewProxy()
936+
viewProxy.setUnits(units)
937+
}
938+
},
939+
927940
camera_changed: function() {
928941
const camera = this.model.get('camera')
929942
if (this.model.hasOwnProperty('itkVtkViewer')) {

js/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"copy-webpack-plugin": "^4.5.1",
6262
"css-element-queries": "^1.0.2",
6363
"itk": "^10.2.0",
64-
"itk-vtk-viewer": "^9.10.1",
64+
"itk-vtk-viewer": "^9.10.3",
6565
"jupyter-dataserializers": "^2.1.0",
6666
"mobx": "^5.13.0",
6767
"vtk.js": "^13.0.0"

0 commit comments

Comments
 (0)