Skip to content

Commit

Permalink
Merge pull request #737 from PaulHax/vtkjs-upgrade
Browse files Browse the repository at this point in the history
Update vtk.js to 29.4.6
  • Loading branch information
thewtex authored Feb 19, 2024
2 parents 3622a93 + 938c503 commit ffd4c4c
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 701 deletions.
130 changes: 93 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
"main": "./dist/itkVtkViewer.js",
"types": "./src/index.d.ts",
"dependencies": {
"@kitware/vtk.js": "^26.9.15",
"@kitware/vtk.js": "^29.4.6",
"@material/web": "^1.0.1",
"@thewtex/iconselect.js": "^2.1.2",
"@xstate/inspect": "^0.4.1",
"axios": "^1.6.0",
"commander": "^2.20.3",
"core-js": "^3.36.0",
"css-element-queries": "^1.2.3",
"curry": "^1.2.0",
"eventemitter3": "^4.0.7",
Expand All @@ -53,7 +54,7 @@
"promise-file-reader": "^1.0.3",
"promise.any": "^2.0.2",
"regenerator-runtime": "^0.13.7",
"vtk.js": "^26.9.15",
"vtk.js": "^29.4.6",
"webworker-promise": "^0.4.2",
"xstate": "^4.37.0"
},
Expand Down
3 changes: 2 additions & 1 deletion src/IO/ndarrayToPointSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ function ndarrayToPointSet(array) {
verts[i] = 1
verts[i + 1] = i / 2
}
const size = array._rshape.reduce((a, b) => a * b, 1)
return vtk({
vtkClass: 'vtkPolyData',
points: {
vtkClass: 'vtkPoints',
name: '_points',
numberOfComponents: 3,
dataType: arrayType.name,
size: array._rshape[0],
size,
values: new arrayType(array._rvalue),
},
verts: {
Expand Down
44 changes: 5 additions & 39 deletions src/Rendering/VTKJS/Widgets/DistanceWidget/DistanceWidget.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import macro from 'vtk.js/Sources/macros'
import vtkSphereHandleRepresentation from 'vtk.js/Sources/Widgets/Representations/SphereHandleRepresentation'
import vtkDistanceWidget from 'vtk.js/Sources/Widgets/Widgets3D/DistanceWidget'
import vtkDistanceWidgetBehavoir from 'vtk.js/Sources/Widgets/Widgets3D/DistanceWidget/behavior'
import vtkPolyLineRepresentation from 'vtk.js/Sources/Widgets/Representations/PolyLineRepresentation'

import stateGenerator from './state'

import { ViewTypes } from 'vtk.js/Sources/Widgets/Core/WidgetManager/Constants'
import vtkLineWidget from 'vtk.js/Sources/Widgets/Widgets3D/LineWidget'
import vtkLineWidgetBehavior from 'vtk.js/Sources/Widgets/Widgets3D/LineWidget/behavior'
import stateGenerator from 'vtk.js/Sources/Widgets/Widgets3D/LineWidget/state'

// ----------------------------------------------------------------------------
// Factory
Expand All @@ -25,37 +20,8 @@ function DistanceWidget(publicAPI, model) {
'text',
'textStateIndex',
]
model.behavior = vtkDistanceWidgetBehavoir
model.behavior = vtkLineWidgetBehavior
model.widgetState = stateGenerator()
publicAPI.getRepresentationsForViewType = viewType => {
switch (viewType) {
case ViewTypes.DEFAULT:
case ViewTypes.GEOMETRY:
case ViewTypes.SLICE:
case ViewTypes.VOLUME:
default:
return [
{
builder: vtkSphereHandleRepresentation,
labels: ['handles'],
initialValues: {
scaleInPixels: true,
},
},
{
builder: vtkSphereHandleRepresentation,
labels: ['moveHandle'],
initialValues: {
scaleInPixels: true,
},
},
{
builder: vtkPolyLineRepresentation,
labels: ['handles', 'moveHandle'],
},
]
}
}
}

// ----------------------------------------------------------------------------
Expand All @@ -67,7 +33,7 @@ const DEFAULT_VALUES = {}
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues)

vtkDistanceWidget.extend(publicAPI, model, {
vtkLineWidget.extend(publicAPI, model, {
...initialValues,
useCameraFocalPoint: true,
})
Expand Down
Loading

0 comments on commit ffd4c4c

Please sign in to comment.