@kitware/vtk.js 25.10.0 → 26.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/Common/Core/CellArray.d.ts +0 -6
  2. package/Common/Core/CellArray.js +21 -12
  3. package/Common/Core/ClassHierarchy.js +11 -6
  4. package/Common/Core/DataArray.d.ts +20 -0
  5. package/Common/Core/DataArray.js +21 -4
  6. package/Proxy/Core/ViewProxy.js +17 -9
  7. package/Rendering/Core/ColorTransferFunction.d.ts +0 -20
  8. package/Rendering/Core/ColorTransferFunction.js +0 -63
  9. package/Rendering/Core/Prop3D.js +1 -6
  10. package/Rendering/Core/RenderWindow.js +9 -6
  11. package/Rendering/Core/VolumeProperty.js +2 -3
  12. package/Rendering/Misc/CanvasView.js +6 -5
  13. package/Rendering/Misc/GenericRenderWindow.js +12 -7
  14. package/Rendering/OpenGL/Actor.js +4 -4
  15. package/Rendering/OpenGL/Actor2D.js +4 -4
  16. package/Rendering/OpenGL/Camera.js +7 -4
  17. package/Rendering/OpenGL/CubeAxesActor.js +7 -5
  18. package/Rendering/OpenGL/ForwardPass.js +1 -1
  19. package/Rendering/OpenGL/Glyph3DMapper.js +4 -4
  20. package/Rendering/OpenGL/ImageMapper.js +9 -5
  21. package/Rendering/OpenGL/ImageSlice.js +3 -3
  22. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +9 -5
  23. package/Rendering/OpenGL/PolyDataMapper.js +27 -21
  24. package/Rendering/OpenGL/PolyDataMapper2D.js +17 -10
  25. package/Rendering/OpenGL/ScalarBarActor.js +6 -4
  26. package/Rendering/OpenGL/Skybox.js +10 -6
  27. package/Rendering/OpenGL/Texture.js +6 -5
  28. package/Rendering/OpenGL/Volume.js +2 -2
  29. package/Rendering/OpenGL/VolumeMapper.js +11 -11
  30. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  31. package/Rendering/SceneGraph/RenderPass.js +3 -2
  32. package/Rendering/WebGPU/ForwardPass.js +1 -1
  33. package/Rendering/WebGPU/HardwareSelectionPass.js +1 -1
  34. package/Rendering/WebGPU/HardwareSelector.js +14 -13
  35. package/Rendering/WebGPU/OpaquePass.js +1 -1
  36. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
  37. package/Rendering/WebGPU/VolumePass.js +1 -1
  38. package/Utilities/config/rules-tests.js +28 -0
  39. package/Widgets/Core/AbstractWidgetFactory.js +1 -0
  40. package/Widgets/Core/StateBuilder/color3Mixin.js +22 -0
  41. package/Widgets/Core/StateBuilder/colorMixin.js +7 -0
  42. package/Widgets/Core/StateBuilder.js +2 -0
  43. package/Widgets/Core/WidgetManager.js +21 -256
  44. package/Widgets/Representations/ArrowHandleRepresentation.js +28 -110
  45. package/Widgets/Representations/CircleContextRepresentation.js +43 -165
  46. package/Widgets/Representations/ContextRepresentation.js +0 -3
  47. package/Widgets/Representations/ConvexFaceContextRepresentation.js +11 -11
  48. package/Widgets/Representations/CroppingOutlineRepresentation.js +5 -12
  49. package/Widgets/Representations/CubeHandleRepresentation.js +15 -104
  50. package/Widgets/Representations/GlyphRepresentation.js +320 -0
  51. package/Widgets/Representations/HandleRepresentation.js +0 -5
  52. package/Widgets/Representations/ImplicitPlaneRepresentation.js +68 -49
  53. package/Widgets/Representations/LineHandleRepresentation.js +116 -0
  54. package/Widgets/Representations/PolyLineRepresentation.js +52 -49
  55. package/Widgets/Representations/RectangleContextRepresentation.js +16 -21
  56. package/Widgets/Representations/SphereContextRepresentation.js +30 -109
  57. package/Widgets/Representations/SphereHandleRepresentation.js +13 -110
  58. package/Widgets/Representations/SplineContextRepresentation.js +53 -36
  59. package/Widgets/Representations/WidgetRepresentation.d.ts +52 -1
  60. package/Widgets/Representations/WidgetRepresentation.js +140 -78
  61. package/Widgets/Representations.js +6 -0
  62. package/Widgets/Widgets3D/AngleWidget.js +1 -4
  63. package/Widgets/Widgets3D/EllipseWidget/state.js +1 -1
  64. package/Widgets/Widgets3D/EllipseWidget.js +0 -7
  65. package/Widgets/Widgets3D/LabelWidget/behavior.js +0 -7
  66. package/Widgets/Widgets3D/LabelWidget.js +1 -18
  67. package/Widgets/Widgets3D/LineWidget/behavior.js +0 -44
  68. package/Widgets/Widgets3D/LineWidget.js +0 -11
  69. package/Widgets/Widgets3D/PolyLineWidget.js +0 -10
  70. package/Widgets/Widgets3D/RectangleWidget.js +0 -7
  71. package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +15 -3
  72. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +93 -36
  73. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +75 -82
  74. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +49 -170
  75. package/Widgets/Widgets3D/ResliceCursorWidget.js +61 -23
  76. package/Widgets/Widgets3D/ShapeWidget.js +1 -1
  77. package/index.d.ts +0 -1
  78. package/macros.d.ts +3 -5
  79. package/macros.js +4 -35
  80. package/package.json +3 -2
  81. package/Widgets/Core/WidgetManager/vdom.js +0 -172
  82. package/Widgets/Representations/ResliceCursorContextRepresentation/Constants.js +0 -12
  83. package/Widgets/Representations/ResliceCursorContextRepresentation.d.ts +0 -54
  84. package/Widgets/Representations/ResliceCursorContextRepresentation.js +0 -357
  85. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +0 -28
  86. package/Widgets/SVG/SVGLandmarkRepresentation.js +0 -179
  87. package/Widgets/SVG/SVGRepresentation.js +0 -163
  88. package/_vendor/available-typed-arrays/index.js_commonjs-proxy.js +0 -1
  89. package/_vendor/call-bind/callBound.js_commonjs-proxy.js +0 -1
  90. package/_vendor/call-bind/index.js_commonjs-module.js +0 -3
  91. package/_vendor/call-bind/index.js_commonjs-proxy.js +0 -1
  92. package/_vendor/deep-equal/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
  93. package/_vendor/define-properties/index.js_commonjs-proxy.js +0 -1
  94. package/_vendor/es-abstract/helpers/getOwnPropertyDescriptor.js_commonjs-proxy.js +0 -1
  95. package/_vendor/es-get-iterator/index.js_commonjs-module.js +0 -3
  96. package/_vendor/es-get-iterator/index.js_commonjs-proxy.js +0 -1
  97. package/_vendor/es-get-iterator/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
  98. package/_vendor/foreach/index.js_commonjs-proxy.js +0 -1
  99. package/_vendor/function-bind/implementation.js_commonjs-proxy.js +0 -1
  100. package/_vendor/function-bind/index.js_commonjs-proxy.js +0 -1
  101. package/_vendor/get-intrinsic/index.js_commonjs-proxy.js +0 -1
  102. package/_vendor/has/src/index.js_commonjs-proxy.js +0 -1
  103. package/_vendor/has-bigints/index.js_commonjs-proxy.js +0 -1
  104. package/_vendor/has-symbols/index.js_commonjs-proxy.js +0 -1
  105. package/_vendor/has-symbols/shams.js_commonjs-proxy.js +0 -1
  106. package/_vendor/has-tostringtag/shams.js_commonjs-proxy.js +0 -1
  107. package/_vendor/is-arguments/index.js_commonjs-proxy.js +0 -1
  108. package/_vendor/is-bigint/index.js_commonjs-module.js +0 -3
  109. package/_vendor/is-bigint/index.js_commonjs-proxy.js +0 -1
  110. package/_vendor/is-boolean-object/index.js_commonjs-proxy.js +0 -1
  111. package/_vendor/is-date-object/index.js_commonjs-proxy.js +0 -1
  112. package/_vendor/is-map/index.js_commonjs-proxy.js +0 -1
  113. package/_vendor/is-number-object/index.js_commonjs-proxy.js +0 -1
  114. package/_vendor/is-regex/index.js_commonjs-proxy.js +0 -1
  115. package/_vendor/is-set/index.js_commonjs-proxy.js +0 -1
  116. package/_vendor/is-string/index.js_commonjs-proxy.js +0 -1
  117. package/_vendor/is-symbol/index.js_commonjs-module.js +0 -3
  118. package/_vendor/is-symbol/index.js_commonjs-proxy.js +0 -1
  119. package/_vendor/is-typed-array/index.js_commonjs-proxy.js +0 -1
  120. package/_vendor/is-weakmap/index.js_commonjs-proxy.js +0 -1
  121. package/_vendor/is-weakset/index.js_commonjs-proxy.js +0 -1
  122. package/_vendor/object-inspect/index.js_commonjs-proxy.js +0 -1
  123. package/_vendor/object-is/implementation.js_commonjs-proxy.js +0 -1
  124. package/_vendor/object-is/index.js_commonjs-proxy.js +0 -1
  125. package/_vendor/object-is/polyfill.js_commonjs-proxy.js +0 -1
  126. package/_vendor/object-is/shim.js_commonjs-proxy.js +0 -1
  127. package/_vendor/object-keys/implementation.js_commonjs-proxy.js +0 -1
  128. package/_vendor/object-keys/index.js_commonjs-proxy.js +0 -1
  129. package/_vendor/object-keys/isArguments.js_commonjs-proxy.js +0 -1
  130. package/_vendor/object.assign/implementation.js_commonjs-proxy.js +0 -1
  131. package/_vendor/object.assign/index.js_commonjs-proxy.js +0 -1
  132. package/_vendor/object.assign/polyfill.js_commonjs-proxy.js +0 -1
  133. package/_vendor/object.assign/shim.js_commonjs-proxy.js +0 -2
  134. package/_vendor/regexp.prototype.flags/implementation.js_commonjs-proxy.js +0 -1
  135. package/_vendor/regexp.prototype.flags/index.js_commonjs-proxy.js +0 -1
  136. package/_vendor/regexp.prototype.flags/polyfill.js_commonjs-proxy.js +0 -1
  137. package/_vendor/regexp.prototype.flags/shim.js_commonjs-proxy.js +0 -1
  138. package/_vendor/side-channel/index.js_commonjs-proxy.js +0 -1
  139. package/_vendor/which-boxed-primitive/index.js_commonjs-proxy.js +0 -5
  140. package/_vendor/which-collection/index.js_commonjs-proxy.js +0 -4
  141. package/_vendor/which-typed-array/index.js_commonjs-proxy.js +0 -1
  142. package/_virtual/_node-resolve_empty.js_commonjs-proxy.js +0 -6
  143. package/_virtual/commonjsHelpers.js +0 -18
  144. package/_virtual/node-resolve_empty.js +0 -8
  145. package/_virtual/polyfill-node.global.js +0 -5
  146. package/_virtual/polyfill-node.process.js +0 -225
  147. package/vendor/available-typed-arrays/index.js +0 -29
  148. package/vendor/call-bind/callBound.js +0 -19
  149. package/vendor/call-bind/index.js +0 -52
  150. package/vendor/deep-equal/index.js +0 -379
  151. package/vendor/deep-equal/node_modules/isarray/index.js +0 -7
  152. package/vendor/define-properties/index.js +0 -60
  153. package/vendor/es-abstract/helpers/getOwnPropertyDescriptor.js +0 -17
  154. package/vendor/es-get-iterator/index.js +0 -217
  155. package/vendor/es-get-iterator/node_modules/isarray/index.js +0 -7
  156. package/vendor/foreach/index.js +0 -22
  157. package/vendor/function-bind/implementation.js +0 -52
  158. package/vendor/function-bind/index.js +0 -7
  159. package/vendor/get-intrinsic/index.js +0 -334
  160. package/vendor/has/src/index.js +0 -7
  161. package/vendor/has-bigints/index.js +0 -12
  162. package/vendor/has-symbols/index.js +0 -15
  163. package/vendor/has-symbols/shams.js +0 -42
  164. package/vendor/has-tostringtag/shams.js +0 -9
  165. package/vendor/is-arguments/index.js +0 -36
  166. package/vendor/is-bigint/index.js +0 -39
  167. package/vendor/is-boolean-object/index.js +0 -29
  168. package/vendor/is-date-object/index.js +0 -22
  169. package/vendor/is-map/index.js +0 -42
  170. package/vendor/is-number-object/index.js +0 -26
  171. package/vendor/is-regex/index.js +0 -61
  172. package/vendor/is-set/index.js +0 -42
  173. package/vendor/is-string/index.js +0 -26
  174. package/vendor/is-symbol/index.js +0 -36
  175. package/vendor/is-typed-array/index.js +0 -67
  176. package/vendor/is-weakmap/index.js +0 -42
  177. package/vendor/is-weakset/index.js +0 -42
  178. package/vendor/object-inspect/index.js +0 -515
  179. package/vendor/object-is/implementation.js +0 -18
  180. package/vendor/object-is/index.js +0 -25
  181. package/vendor/object-is/polyfill.js +0 -9
  182. package/vendor/object-is/shim.js +0 -17
  183. package/vendor/object-keys/implementation.js +0 -124
  184. package/vendor/object-keys/index.js +0 -35
  185. package/vendor/object-keys/isArguments.js +0 -17
  186. package/vendor/object.assign/implementation.js +0 -46
  187. package/vendor/object.assign/index.js +0 -29
  188. package/vendor/object.assign/polyfill.js +0 -57
  189. package/vendor/object.assign/shim.js +0 -17
  190. package/vendor/regexp.prototype.flags/implementation.js +0 -30
  191. package/vendor/regexp.prototype.flags/index.js +0 -25
  192. package/vendor/regexp.prototype.flags/polyfill.js +0 -23
  193. package/vendor/regexp.prototype.flags/shim.js +0 -29
  194. package/vendor/side-channel/index.js +0 -128
  195. package/vendor/which-boxed-primitive/index.js +0 -38
  196. package/vendor/which-collection/index.js +0 -29
  197. package/vendor/which-typed-array/index.js +0 -63
package/macros.js CHANGED
@@ -3,7 +3,6 @@ import _typeof from '@babel/runtime/helpers/typeof';
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
5
5
  import _construct from '@babel/runtime/helpers/construct';
6
- import { d as deepEqual } from './vendor/deep-equal/index.js';
7
6
  import vtk, { vtkGlobal } from './vtk.js';
8
7
  import ClassHierarchy from './Common/Core/ClassHierarchy.js';
9
8
 
@@ -234,13 +233,7 @@ function obj() {
234
233
  if (!('classHierarchy' in model)) {
235
234
  model.classHierarchy = new ClassHierarchy('vtkObject');
236
235
  } else if (!(model.classHierarchy instanceof ClassHierarchy)) {
237
- var hierarchy = new ClassHierarchy();
238
-
239
- for (var i = 0; i < model.classHierarchy.length; i++) {
240
- hierarchy.push(model.classHierarchy[i]);
241
- }
242
-
243
- model.classHierarchy = hierarchy;
236
+ model.classHierarchy = ClassHierarchy.from(model.classHierarchy);
244
237
  }
245
238
 
246
239
  function off(index) {
@@ -444,25 +437,12 @@ function obj() {
444
437
  // getXXX: add getters
445
438
  // ----------------------------------------------------------------------------
446
439
 
447
- var objectGetterMap = {
448
- object: function object(publicAPI, model, field) {
449
- return function getter() {
450
- return _objectSpread({}, model[field.name]);
451
- };
452
- }
453
- };
454
440
  function get(publicAPI, model, fieldNames) {
455
441
  fieldNames.forEach(function (field) {
456
442
  if (_typeof(field) === 'object') {
457
- var getter = objectGetterMap[field.type];
458
-
459
- if (getter) {
460
- publicAPI["get".concat(_capitalize(field.name))] = getter(publicAPI, model, field);
461
- } else {
462
- publicAPI["get".concat(_capitalize(field.name))] = function () {
463
- return model[field.name];
464
- };
465
- }
443
+ publicAPI["get".concat(_capitalize(field.name))] = function () {
444
+ return model[field.name];
445
+ };
466
446
  } else {
467
447
  publicAPI["get".concat(_capitalize(field))] = function () {
468
448
  return model[field];
@@ -511,17 +491,6 @@ var objectSetterMap = {
511
491
  vtkErrorMacro("Set Enum with invalid argument (String/Number) ".concat(field, ", ").concat(value));
512
492
  throw new TypeError('Set Enum with invalid argument (String/Number)');
513
493
  };
514
- },
515
- object: function object(publicAPI, model, field) {
516
- return function (value) {
517
- if (!deepEqual(model[field.name], value)) {
518
- model[field.name] = value;
519
- publicAPI.modified();
520
- return true;
521
- }
522
-
523
- return false;
524
- };
525
494
  }
526
495
  };
527
496
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "25.10.0",
3
+ "version": "26.0.0-beta.2",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",
@@ -112,6 +112,7 @@
112
112
  "rollup-plugin-svgo": "1.1.0",
113
113
  "rollup-plugin-web-worker-loader": "1.6.1",
114
114
  "semantic-release": "19.0.3",
115
+ "snabbdom": "^3.5.1",
115
116
  "string-replace-loader": "3.1.0",
116
117
  "style-loader": "3.3.1",
117
118
  "tape": "5.5.3",
@@ -149,7 +150,7 @@
149
150
  "release:create-packages": "node ./Utilities/ci/build-npm-package.js",
150
151
  "test": "karma start ./karma.conf.js",
151
152
  "test:headless": "karma start ./karma.conf.js --browsers ChromeHeadlessNoSandbox --single-run",
152
- "test:debug": "karma start ./karma.conf.js --no-single-run",
153
+ "test:debug": "karma start ./karma.conf.js --log-level debug --no-single-run",
153
154
  "test:firefox": "karma start ./karma.conf.js --browsers Firefox",
154
155
  "test:webgpu": "cross-env WEBGPU=1 NO_WEBGL=1 karma start ./karma.conf.js --browsers ChromeWebGPU --no-single-run",
155
156
  "test:firefox-debug": "karma start ./karma.conf.js --browsers Firefox --no-single-run",
@@ -1,172 +0,0 @@
1
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
-
3
- var SVG_XMLNS = 'http://www.w3.org/2000/svg';
4
-
5
- function attrDelta(oldObj, newObj) {
6
- var set = [];
7
- var remove = [];
8
- var oldKeysArray = Object.keys(oldObj);
9
- var newKeysArray = Object.keys(newObj);
10
- var oldKeys = new Set(oldKeysArray);
11
- var newKeys = new Set(newKeysArray);
12
-
13
- for (var i = 0; i < oldKeysArray.length; i++) {
14
- var key = oldKeysArray[i];
15
-
16
- if (newKeys.has(key)) {
17
- if (oldObj[key] !== newObj[key]) {
18
- set.push([key, newObj[key]]);
19
- }
20
- } else {
21
- remove.push(key);
22
- }
23
- }
24
-
25
- for (var _i = 0; _i < newKeysArray.length; _i++) {
26
- var _key = newKeysArray[_i];
27
-
28
- if (!oldKeys.has(_key)) {
29
- set.push([_key, newObj[_key]]);
30
- }
31
- }
32
-
33
- return [set, remove];
34
- }
35
-
36
- function render(vnode) {
37
- var node = document.createElementNS(SVG_XMLNS, vnode.name);
38
- var keys = Object.keys(vnode.attrs);
39
-
40
- for (var i = 0; i < keys.length; i++) {
41
- var key = keys[i];
42
- node.setAttribute(key, vnode.attrs[key]);
43
- } // TODO: support removing event listener (e.g. use snabbdom)
44
-
45
-
46
- Object.keys(vnode.eventListeners).forEach(function (key) {
47
- node.addEventListener(key, vnode.eventListeners[key]);
48
- });
49
-
50
- if (vnode.textContent) {
51
- node.textContent = vnode.textContent;
52
- } else {
53
- for (var _i2 = 0; _i2 < vnode.children.length; _i2++) {
54
- node.appendChild(render(vnode.children[_i2]));
55
- }
56
- }
57
-
58
- return node;
59
- }
60
- /**
61
- * Returns a set of patch functions to be applied to a document node.
62
- *
63
- * Patch functions must return the effective result node.
64
- */
65
-
66
- function diff(oldVTree, newVTree) {
67
- if (newVTree.textContent !== null && newVTree.children.length) {
68
- throw new Error('Tree cannot have both children and textContent!');
69
- }
70
-
71
- if (!oldVTree) {
72
- return [function () {
73
- return render(newVTree);
74
- }];
75
- }
76
-
77
- if (!newVTree) {
78
- return [function (node) {
79
- return node.remove();
80
- }];
81
- }
82
-
83
- if (oldVTree.name !== newVTree.name) {
84
- return [function (node) {
85
- var newNode = render(newVTree);
86
- node.replaceWith(newNode);
87
- return newNode;
88
- }];
89
- }
90
-
91
- var patchFns = [];
92
-
93
- var _attrDelta = attrDelta(oldVTree.attrs, newVTree.attrs),
94
- _attrDelta2 = _slicedToArray(_attrDelta, 2),
95
- attrsSet = _attrDelta2[0],
96
- attrsRemove = _attrDelta2[1];
97
-
98
- if (attrsSet.length || attrsRemove.length) {
99
- patchFns.push(function (node) {
100
- for (var i = 0; i < attrsSet.length; i++) {
101
- var _attrsSet$i = _slicedToArray(attrsSet[i], 2),
102
- name = _attrsSet$i[0],
103
- value = _attrsSet$i[1];
104
-
105
- node.setAttribute(name, value);
106
- }
107
-
108
- for (var _i3 = 0; _i3 < attrsRemove.length; _i3++) {
109
- var _name = attrsRemove[_i3];
110
- node.removeAttribute(_name);
111
- }
112
-
113
- return node;
114
- });
115
- }
116
-
117
- if (oldVTree.textContent !== newVTree.textContent && newVTree.textContent !== null) {
118
- patchFns.push(function (node) {
119
- node.textContent = newVTree.textContent;
120
- return node;
121
- });
122
- }
123
-
124
- if (newVTree.textContent === null) {
125
- var min = Math.min(oldVTree.children.length, newVTree.children.length);
126
-
127
- var _loop = function _loop(i) {
128
- var childPatches = diff(oldVTree.children[i], newVTree.children[i]);
129
- patchFns.push(function (node) {
130
- for (var p = 0; p < childPatches.length; p++) {
131
- childPatches[p](node.children[i]);
132
- }
133
-
134
- return node;
135
- });
136
- };
137
-
138
- for (var i = 0; i < min; i++) {
139
- _loop(i);
140
- }
141
-
142
- if (oldVTree.children.length < newVTree.children.length) {
143
- var _loop2 = function _loop2(_i4) {
144
- patchFns.push(function (node) {
145
- node.appendChild(render(newVTree.children[_i4]));
146
- return node;
147
- });
148
- };
149
-
150
- for (var _i4 = min; _i4 < newVTree.children.length; _i4++) {
151
- _loop2(_i4);
152
- }
153
- } else {
154
- var _loop3 = function _loop3(_i5) {
155
- patchFns.push(function (node) {
156
- node.children[_i5].remove();
157
-
158
- return node;
159
- });
160
- };
161
-
162
- // always delete nodes in reverse
163
- for (var _i5 = oldVTree.children.length - 1; _i5 >= min; _i5--) {
164
- _loop3(_i5);
165
- }
166
- }
167
- }
168
-
169
- return patchFns;
170
- }
171
-
172
- export { diff, render };
@@ -1,12 +0,0 @@
1
- var PlaneNormal = {
2
- X: [1, 0, 0],
3
- Y: [0, -1, 0],
4
- Z: [0, 0, 1]
5
- };
6
- var PlaneOrientation = {
7
- X: 0,
8
- Y: 1,
9
- Z: 2
10
- };
11
-
12
- export { PlaneNormal, PlaneOrientation };
@@ -1,54 +0,0 @@
1
- import {vtkWidgetRepresentation, IWidgetRepresentationInitialValues} from './WidgetRepresentation';
2
-
3
- export interface IResliceCursorContextRepresentationInitialValues extends IWidgetRepresentationInitialValues {
4
- axis1Name?: string,
5
- axis2Name?: string,
6
- rotationEnabled?: boolean,
7
- rotationHandlePosition?: number,
8
- scaleInPixels?: boolean,
9
- viewType: any,
10
- coincidentTopologyParameters: object,
11
- }
12
-
13
- export interface vtkResliceCursorContextRepresentation extends vtkWidgetRepresentation {
14
-
15
- /**
16
- * Returns the ratio applied on the smallest view side (width or height)
17
- * used to compute the position of the rotation handles.
18
- * 1 to place the handles on the edge of the smallest view side, 0.5 to
19
- * place the handles half way between the center of the reslice cursor
20
- * and the edge of the smallest view side.
21
- * 0.5 by default
22
- */
23
- getRotationHandlePosition(): number;
24
-
25
- /**
26
- * Sets the ratio applied on the smallest view side (width or height) used to
27
- * compute the position of the rotation handles
28
- * @param {number} ratio a positive floating percent of the smallest view side
29
- * @returns true if modified, false otherwise
30
- * @see getRotationHandlePosition()
31
- */
32
- setRotationHandlePosition(ratio: number): boolean;
33
- }
34
-
35
- /**
36
- * Method use to decorate a given object (publicAPI+model) with vtkResliceCursorContextRepresentation characteristics.
37
- *
38
- * @param publicAPI object on which methods will be bounds (public)
39
- * @param model object on which data structure will be bounds (protected)
40
- * @param {IResliceCursorContextRepresentationInitialValues} [initialValues] (default: {})
41
- */
42
- export function extend(publicAPI: object, model: object, initialValues?: IResliceCursorContextRepresentationInitialValues): void;
43
-
44
- /**
45
- * Method use to create a new instance of vtkResliceCursorContextRepresentation
46
- * @param {IResliceCursorContextRepresentationInitialValues} [initialValues] for pre-setting some of its content
47
- */
48
- export function newInstance(initialValues?: IResliceCursorContextRepresentationInitialValues): vtkResliceCursorContextRepresentation;
49
-
50
- export declare const vtkResliceCursorContextRepresentation: {
51
- newInstance: typeof newInstance;
52
- extend: typeof extend;
53
- }
54
- export default vtkResliceCursorContextRepresentation;
@@ -1,357 +0,0 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
- import macro from '../../macros.js';
4
- import { s as subtract, o as multiplyAccumulate, m as normalize, k as cross } from '../../Common/Core/Math/index.js';
5
- import vtkActor from '../../Rendering/Core/Actor.js';
6
- import vtkCylinderSource from '../../Filters/Sources/CylinderSource.js';
7
- import vtkMapper from '../../Rendering/Core/Mapper.js';
8
- import vtkPolyData from '../../Common/DataModel/PolyData.js';
9
- import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
10
- import vtkWidgetRepresentation from './WidgetRepresentation.js';
11
- import { RenderingTypes } from '../Core/WidgetManager/Constants.js';
12
- import { InteractionMethodsName } from '../Widgets3D/ResliceCursorWidget/Constants.js';
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
- // vtkResliceCursorContextRepresentation methods
18
- // ----------------------------------------------------------------------------
19
-
20
- function vtkResliceCursorContextRepresentation(publicAPI, model) {
21
- // Set our className
22
- model.classHierarchy.push('vtkResliceCursorContextRepresentation'); // --------------------------------------------------------------------------
23
- // Generic rendering pipeline
24
- // --------------------------------------------------------------------------
25
-
26
- model.mapper = vtkMapper.newInstance();
27
- model.actor = vtkActor.newInstance({
28
- parentProp: publicAPI
29
- });
30
- model.mapper.setInputConnection(publicAPI.getOutputPort());
31
- model.actor.setMapper(model.mapper);
32
- publicAPI.addActor(model.actor);
33
- model.pipelines = {};
34
- model.pipelines.center = {
35
- source: vtkSphereSource.newInstance(),
36
- mapper: vtkMapper.newInstance(),
37
- actor: vtkActor.newInstance({
38
- parentProp: publicAPI
39
- })
40
- };
41
- model.pipelines.axes = [];
42
- var squarishCylinderProperties = {
43
- initAngle: Math.PI / 4,
44
- otherRadius: 0,
45
- resolution: 4
46
- }; // Create axis 1
47
-
48
- var axis1 = {};
49
- axis1.line = {
50
- source: vtkCylinderSource.newInstance(squarishCylinderProperties),
51
- mapper: vtkMapper.newInstance(),
52
- actor: vtkActor.newInstance({
53
- pickable: true,
54
- _parentProp: publicAPI
55
- })
56
- };
57
- axis1.rotation1 = {
58
- source: vtkSphereSource.newInstance(),
59
- mapper: vtkMapper.newInstance(),
60
- actor: vtkActor.newInstance({
61
- pickable: true,
62
- _parentProp: publicAPI
63
- })
64
- };
65
- axis1.rotation2 = {
66
- source: vtkSphereSource.newInstance(),
67
- mapper: vtkMapper.newInstance(),
68
- actor: vtkActor.newInstance({
69
- pickable: true,
70
- _parentProp: publicAPI
71
- })
72
- }; // Create axis 2
73
-
74
- var axis2 = {};
75
- axis2.line = {
76
- source: vtkCylinderSource.newInstance(squarishCylinderProperties),
77
- mapper: vtkMapper.newInstance(),
78
- actor: vtkActor.newInstance({
79
- pickable: true,
80
- _parentProp: publicAPI
81
- })
82
- };
83
- axis2.rotation1 = {
84
- source: vtkSphereSource.newInstance(),
85
- mapper: vtkMapper.newInstance(),
86
- actor: vtkActor.newInstance({
87
- pickable: true,
88
- _parentProp: publicAPI
89
- })
90
- };
91
- axis2.rotation2 = {
92
- source: vtkSphereSource.newInstance(),
93
- mapper: vtkMapper.newInstance(),
94
- actor: vtkActor.newInstance({
95
- pickable: true,
96
- _parentProp: publicAPI
97
- })
98
- };
99
- model.pipelines.axes.push(axis1);
100
- model.pipelines.axes.push(axis2); // Improve actors rendering
101
-
102
- model.pipelines.center.actor.getProperty().setAmbient(1, 1, 1);
103
- model.pipelines.center.actor.getProperty().setDiffuse(0, 0, 0);
104
- model.pipelines.center.actor.getProperty().setBackfaceCulling(true);
105
- model.pipelines.axes.forEach(function (axis) {
106
- Object.values(axis).forEach(function (lineOrRotationHandle) {
107
- vtkWidgetRepresentation.connectPipeline(lineOrRotationHandle);
108
- var actor = lineOrRotationHandle.actor;
109
- actor.getProperty().setAmbient(1, 1, 1);
110
- actor.getProperty().setDiffuse(0, 0, 0);
111
- actor.getProperty().setBackfaceCulling(true);
112
- publicAPI.addActor(actor);
113
- });
114
- });
115
- vtkWidgetRepresentation.connectPipeline(model.pipelines.center);
116
- publicAPI.addActor(model.pipelines.center.actor);
117
-
118
- publicAPI.setLineThickness = function (lineThickness) {
119
- var scaledLineThickness = lineThickness;
120
-
121
- if (publicAPI.getScaleInPixels()) {
122
- var centerCoords = model.pipelines.center.source.getCenter();
123
- scaledLineThickness *= publicAPI.getPixelWorldHeightAtCoord(centerCoords);
124
- }
125
-
126
- model.pipelines.axes[0].line.source.setRadius(scaledLineThickness);
127
- model.pipelines.axes[1].line.source.setRadius(scaledLineThickness);
128
- };
129
-
130
- publicAPI.setSphereRadius = function (radius) {
131
- publicAPI.setSphereRadiusOnSphere(radius, model.pipelines.center.source);
132
- publicAPI.setSphereRadiusOnSphere(radius, model.pipelines.axes[0].rotation1.source);
133
- publicAPI.setSphereRadiusOnSphere(radius, model.pipelines.axes[0].rotation2.source);
134
- publicAPI.setSphereRadiusOnSphere(radius, model.pipelines.axes[1].rotation1.source);
135
- publicAPI.setSphereRadiusOnSphere(radius, model.pipelines.axes[1].rotation2.source);
136
- };
137
-
138
- publicAPI.setSphereRadiusOnSphere = function (radius, source) {
139
- var scaledRadius = radius;
140
-
141
- if (publicAPI.getScaleInPixels()) {
142
- var centerCoords = source.getCenter();
143
- scaledRadius *= publicAPI.getPixelWorldHeightAtCoord(centerCoords);
144
- }
145
-
146
- source.setRadius(scaledRadius);
147
- };
148
-
149
- publicAPI.setSphereRadius(7);
150
-
151
- function updateRender(state, axis) {
152
- var color = state.getColor();
153
- axis.line.actor.getProperty().setColor(color);
154
- axis.rotation1.actor.getProperty().setColor(color);
155
- axis.rotation2.actor.getProperty().setColor(color);
156
- var vector = [0, 0, 0];
157
- subtract(state.getPoint2(), state.getPoint1(), vector);
158
- var center = [0, 0, 0];
159
- multiplyAccumulate(state.getPoint1(), vector, 0.5, center);
160
- var length = normalize(vector);
161
- axis.line.source.setHeight(20 * length); // make it an infinite line
162
- // Rotate the cylinder to be along vector
163
-
164
- var viewNormal = model.inputData[0].getPlanes()[state.getInViewType()].normal;
165
- var x = cross(vector, viewNormal, []);
166
- var mat = [].concat(_toConsumableArray(x), [0], vector, [0], _toConsumableArray(viewNormal), [0], center, [1]);
167
- axis.line.actor.setUserMatrix(mat); // Rotation handles
168
-
169
- var distance = 0;
170
-
171
- if (publicAPI.getScaleInPixels()) {
172
- var pixelWorldHeight = publicAPI.getPixelWorldHeightAtCoord(center);
173
- var rendererPixelDims = model.displayScaleParams.rendererPixelDims;
174
- var totalSize = Math.min(rendererPixelDims[0], rendererPixelDims[1]) / 2;
175
- distance = publicAPI.getRotationHandlePosition() * pixelWorldHeight * totalSize;
176
- } else {
177
- distance = publicAPI.getRotationHandlePosition() * length / 2;
178
- }
179
-
180
- var rotationHandlePosition = [];
181
- multiplyAccumulate(center, vector, distance, rotationHandlePosition);
182
- axis.rotation1.source.setCenter(rotationHandlePosition);
183
- multiplyAccumulate(center, vector, -distance, rotationHandlePosition);
184
- axis.rotation2.source.setCenter(rotationHandlePosition);
185
- }
186
- /**
187
- * Returns the line actors in charge of translating the views.
188
- */
189
-
190
-
191
- publicAPI.getTranslationActors = function () {
192
- return [model.pipelines.axes[0].line.actor, model.pipelines.axes[1].line.actor];
193
- };
194
-
195
- publicAPI.getRotationActors = function () {
196
- return [model.pipelines.axes[0].rotation1.actor, model.pipelines.axes[0].rotation2.actor, model.pipelines.axes[1].rotation1.actor, model.pipelines.axes[1].rotation2.actor];
197
- };
198
-
199
- publicAPI.requestData = function (inData, outData) {
200
- var state = inData[0];
201
- var origin = state.getCenter();
202
- model.pipelines.center.source.setCenter(origin);
203
- var getAxis1 = "get".concat(model.axis1Name);
204
- var getAxis2 = "get".concat(model.axis2Name);
205
- var axis1State = state[getAxis1]();
206
- var axis2State = state[getAxis2]();
207
- updateRender(axis1State, model.pipelines.axes[0]);
208
- updateRender(axis2State, model.pipelines.axes[1]);
209
- publicAPI.setLineThickness(state.getLineThickness());
210
- publicAPI.setSphereRadius(state.getSphereRadius()); // TODO: return meaningful polydata (e.g. appended lines)
211
-
212
- outData[0] = vtkPolyData.newInstance();
213
- };
214
-
215
- publicAPI.updateActorVisibility = function (renderingType, ctxVisible, hVisible) {
216
- var state = model.inputData[0];
217
- var visibility = hVisible || renderingType === RenderingTypes.PICKING_BUFFER;
218
- publicAPI.getActors().forEach(function (actor) {
219
- actor.getProperty().setOpacity(state.getOpacity());
220
- var actorVisibility = visibility; // Conditionally display rotation handles
221
-
222
- if (publicAPI.getRotationActors().includes(actor)) {
223
- actorVisibility = actorVisibility && state.getEnableRotation();
224
- } // Conditionally display center handle but always show it for picking
225
-
226
-
227
- if (!state.getShowCenter() && actor === model.pipelines.center.actor) {
228
- actorVisibility = actorVisibility && renderingType === RenderingTypes.PICKING_BUFFER;
229
- }
230
-
231
- actor.setVisibility(actorVisibility); // Conditionally pick lines
232
-
233
- if (publicAPI.getTranslationActors().includes(actor)) {
234
- actor.setPickable(state.getEnableTranslation());
235
- }
236
- });
237
- var lineThickness = state.getLineThickness();
238
-
239
- if (renderingType === RenderingTypes.PICKING_BUFFER) {
240
- lineThickness = Math.max(3, lineThickness);
241
- }
242
-
243
- publicAPI.setLineThickness(lineThickness);
244
- var radius = state.getSphereRadius();
245
-
246
- if (renderingType === RenderingTypes.PICKING_BUFFER) {
247
- radius += 1;
248
- }
249
-
250
- publicAPI.setSphereRadius(radius);
251
- };
252
-
253
- publicAPI.getSelectedState = function (prop, compositeID) {
254
- var state = model.inputData[0];
255
- state.setActiveViewType(model.viewType);
256
- var getAxis1 = "get".concat(model.axis1Name);
257
- var getAxis2 = "get".concat(model.axis2Name);
258
- var axis1State = state[getAxis1]();
259
- var axis2State = state[getAxis2]();
260
- var activeLineState = null;
261
- var activeRotationPointName = '';
262
- var methodName = '';
263
-
264
- switch (prop) {
265
- case model.pipelines.axes[0].line.actor:
266
- activeLineState = axis1State;
267
- methodName = InteractionMethodsName.TranslateAxis;
268
- break;
269
-
270
- case model.pipelines.axes[1].line.actor:
271
- activeLineState = axis2State;
272
- methodName = InteractionMethodsName.TranslateAxis;
273
- break;
274
-
275
- case model.pipelines.axes[0].rotation1.actor:
276
- activeLineState = axis1State;
277
- activeRotationPointName = 'point1';
278
- methodName = InteractionMethodsName.RotateLine;
279
- break;
280
-
281
- case model.pipelines.axes[0].rotation2.actor:
282
- activeLineState = axis1State;
283
- activeRotationPointName = 'point2';
284
- methodName = InteractionMethodsName.RotateLine;
285
- break;
286
-
287
- case model.pipelines.axes[1].rotation1.actor:
288
- activeLineState = axis2State;
289
- activeRotationPointName = 'point1';
290
- methodName = InteractionMethodsName.RotateLine;
291
- break;
292
-
293
- case model.pipelines.axes[1].rotation2.actor:
294
- activeLineState = axis2State;
295
- activeRotationPointName = 'point2';
296
- methodName = InteractionMethodsName.RotateLine;
297
- break;
298
-
299
- default:
300
- methodName = InteractionMethodsName.TranslateCenter;
301
- break;
302
- }
303
-
304
- state.setActiveLineState(activeLineState);
305
- state.setActiveRotationPointName(activeRotationPointName);
306
- state.setUpdateMethodName(methodName);
307
- return state;
308
- };
309
- } // ----------------------------------------------------------------------------
310
- // Object factory
311
- // ----------------------------------------------------------------------------
312
-
313
-
314
- function defaultValues(initialValues) {
315
- return _objectSpread(_objectSpread({
316
- axis1Name: '',
317
- axis2Name: '',
318
- rotationEnabled: true,
319
- rotationHandlePosition: 0.5,
320
- scaleInPixels: true,
321
- viewType: null
322
- }, initialValues), {}, {
323
- coincidentTopologyParameters: _objectSpread({
324
- Point: {
325
- factor: -1.0,
326
- offset: -1.0
327
- },
328
- Line: {
329
- factor: -1.5,
330
- offset: -1.5
331
- },
332
- Polygon: {
333
- factor: -2.0,
334
- offset: -2.0
335
- }
336
- }, initialValues.coincidentTopologyParameters)
337
- });
338
- } // ----------------------------------------------------------------------------
339
-
340
-
341
- function extend(publicAPI, model) {
342
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
343
- Object.assign(model, defaultValues(initialValues));
344
- vtkWidgetRepresentation.extend(publicAPI, model, initialValues);
345
- macro.setGet(publicAPI, model, ['rotationHandlePosition']); // Object specific methods
346
-
347
- vtkResliceCursorContextRepresentation(publicAPI, model);
348
- } // ----------------------------------------------------------------------------
349
-
350
- var newInstance = macro.newInstance(extend, 'vtkResliceCursorContextRepresentation'); // ----------------------------------------------------------------------------
351
-
352
- var vtkResliceCursorContextRepresentation$1 = {
353
- newInstance: newInstance,
354
- extend: extend
355
- };
356
-
357
- export { vtkResliceCursorContextRepresentation$1 as default, extend, newInstance };