@kitware/vtk.js 28.10.2 → 28.11.0

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 (565) hide show
  1. package/Common/Core/Base64.js +53 -82
  2. package/Common/Core/CellArray.js +52 -60
  3. package/Common/Core/ClassHierarchy.js +8 -36
  4. package/Common/Core/DataArray/Constants.js +6 -6
  5. package/Common/Core/DataArray.js +185 -270
  6. package/Common/Core/Endian.js +14 -17
  7. package/Common/Core/HalfFloat.js +17 -34
  8. package/Common/Core/ImageHelper.js +17 -25
  9. package/Common/Core/LookupTable.js +131 -144
  10. package/Common/Core/Math/Constants.js +8 -8
  11. package/Common/Core/Math/index.js +754 -942
  12. package/Common/Core/Math.js +2 -4
  13. package/Common/Core/MatrixBuilder.js +99 -151
  14. package/Common/Core/Points.js +43 -43
  15. package/Common/Core/PriorityQueue.js +30 -28
  16. package/Common/Core/ProgressHandler.js +31 -32
  17. package/Common/Core/ScalarsToColors/Constants.js +4 -4
  18. package/Common/Core/ScalarsToColors.js +196 -253
  19. package/Common/Core/StringArray.js +48 -73
  20. package/Common/Core/URLExtract.js +10 -29
  21. package/Common/Core/VariantArray.js +48 -73
  22. package/Common/Core.js +11 -11
  23. package/Common/DataModel/AbstractPointLocator.js +19 -17
  24. package/Common/DataModel/BoundingBox.js +322 -490
  25. package/Common/DataModel/Box.js +46 -63
  26. package/Common/DataModel/CardinalSpline1D.js +92 -102
  27. package/Common/DataModel/Cell.js +41 -61
  28. package/Common/DataModel/CellLinks.js +91 -127
  29. package/Common/DataModel/CellTypes/Constants.js +7 -6
  30. package/Common/DataModel/CellTypes.js +55 -74
  31. package/Common/DataModel/Collection.js +45 -61
  32. package/Common/DataModel/Cone.js +28 -20
  33. package/Common/DataModel/Cylinder.js +41 -35
  34. package/Common/DataModel/DataSet/Constants.js +11 -5
  35. package/Common/DataModel/DataSet.js +37 -25
  36. package/Common/DataModel/DataSetAttributes/Constants.js +18 -18
  37. package/Common/DataModel/DataSetAttributes/FieldData.js +103 -194
  38. package/Common/DataModel/DataSetAttributes.js +96 -138
  39. package/Common/DataModel/EdgeLocator.js +45 -70
  40. package/Common/DataModel/ITKHelper.js +67 -137
  41. package/Common/DataModel/ImageData.js +115 -172
  42. package/Common/DataModel/ImplicitBoolean/Constants.js +2 -2
  43. package/Common/DataModel/ImplicitBoolean.js +66 -96
  44. package/Common/DataModel/IncrementalOctreeNode.js +201 -231
  45. package/Common/DataModel/IncrementalOctreePointLocator.js +160 -198
  46. package/Common/DataModel/KochanekSpline1D.js +78 -81
  47. package/Common/DataModel/Line/Constants.js +2 -2
  48. package/Common/DataModel/Line.js +82 -105
  49. package/Common/DataModel/Locator.js +17 -10
  50. package/Common/DataModel/Molecule.js +26 -17
  51. package/Common/DataModel/PiecewiseFunction.js +218 -239
  52. package/Common/DataModel/Plane.js +90 -113
  53. package/Common/DataModel/PointSet.js +30 -26
  54. package/Common/DataModel/PolyData/Constants.js +2 -2
  55. package/Common/DataModel/PolyData.js +95 -120
  56. package/Common/DataModel/PolyLine.js +44 -61
  57. package/Common/DataModel/Polygon/Constants.js +4 -4
  58. package/Common/DataModel/Polygon.js +128 -169
  59. package/Common/DataModel/Quad/Constants.js +2 -2
  60. package/Common/DataModel/Quad.js +61 -100
  61. package/Common/DataModel/SelectionNode/Constants.js +5 -4
  62. package/Common/DataModel/SelectionNode.js +25 -21
  63. package/Common/DataModel/Sphere.js +40 -35
  64. package/Common/DataModel/Spline1D/Constants.js +3 -2
  65. package/Common/DataModel/Spline1D.js +34 -18
  66. package/Common/DataModel/Spline3D/Constants.js +2 -2
  67. package/Common/DataModel/Spline3D.js +46 -41
  68. package/Common/DataModel/StructuredData/Constants.js +2 -2
  69. package/Common/DataModel/StructuredData.js +9 -20
  70. package/Common/DataModel/Triangle.js +207 -250
  71. package/Common/DataModel.js +19 -19
  72. package/Common/System/MobileVR.js +56 -61
  73. package/Common/System/TimerLog.js +1 -1
  74. package/Common/System.js +2 -2
  75. package/Common/Transform/LandmarkTransform/Constants.js +2 -2
  76. package/Common/Transform/LandmarkTransform.js +133 -117
  77. package/Common/Transform/Transform.js +42 -57
  78. package/Common/Transform.js +2 -2
  79. package/Common/index.js +4 -4
  80. package/Filters/Core/Cutter.js +134 -146
  81. package/Filters/Core/PolyDataNormals.js +44 -50
  82. package/Filters/Core.js +2 -2
  83. package/Filters/Cornerstone/ImageDataToCornerstoneImage.js +45 -33
  84. package/Filters/Cornerstone.js +1 -1
  85. package/Filters/General/AppendPolyData.js +84 -100
  86. package/Filters/General/Calculator.js +95 -163
  87. package/Filters/General/ClipClosedSurface/Constants.js +2 -2
  88. package/Filters/General/ClipClosedSurface.js +341 -416
  89. package/Filters/General/ClosedPolyLineToSurfaceFilter.js +141 -156
  90. package/Filters/General/ContourTriangulator/Constants.js +2 -2
  91. package/Filters/General/ContourTriangulator/helper.js +684 -812
  92. package/Filters/General/ContourTriangulator.js +92 -89
  93. package/Filters/General/ImageCropFilter.js +77 -78
  94. package/Filters/General/ImageDataOutlineFilter.js +42 -36
  95. package/Filters/General/ImageMarchingCubes/caseTable.js +9 -521
  96. package/Filters/General/ImageMarchingCubes.js +99 -112
  97. package/Filters/General/ImageMarchingSquares/caseTable.js +9 -41
  98. package/Filters/General/ImageMarchingSquares.js +93 -118
  99. package/Filters/General/ImageOutlineFilter.js +53 -54
  100. package/Filters/General/ImageSliceFilter.js +39 -30
  101. package/Filters/General/ImageStreamline.js +107 -124
  102. package/Filters/General/LineFilter.js +26 -15
  103. package/Filters/General/MoleculeToRepresentation.js +136 -149
  104. package/Filters/General/OBBTree/OBBNode.js +36 -34
  105. package/Filters/General/OBBTree/helper.js +19 -24
  106. package/Filters/General/OBBTree.js +396 -488
  107. package/Filters/General/OutlineFilter.js +52 -34
  108. package/Filters/General/PaintFilter/PaintFilter.worker.js +93 -130
  109. package/Filters/General/PaintFilter.js +150 -162
  110. package/Filters/General/ScalarToRGBA.js +38 -33
  111. package/Filters/General/TriangleFilter.js +65 -62
  112. package/Filters/General/TubeFilter/Constants.js +4 -4
  113. package/Filters/General/TubeFilter.js +376 -496
  114. package/Filters/General/WarpScalar.js +58 -60
  115. package/Filters/General/WindowedSincPolyDataFilter.js +258 -330
  116. package/Filters/General.js +21 -21
  117. package/Filters/Sources/Arrow2DSource/Constants.js +2 -2
  118. package/Filters/Sources/Arrow2DSource.js +56 -56
  119. package/Filters/Sources/ArrowSource.js +39 -29
  120. package/Filters/Sources/CircleSource.js +43 -43
  121. package/Filters/Sources/ConcentricCylinderSource.js +151 -174
  122. package/Filters/Sources/ConeSource.js +51 -42
  123. package/Filters/Sources/CubeSource.js +75 -96
  124. package/Filters/Sources/Cursor3D.js +94 -109
  125. package/Filters/Sources/CylinderSource.js +90 -90
  126. package/Filters/Sources/ImageGridSource.js +43 -43
  127. package/Filters/Sources/LineSource.js +49 -39
  128. package/Filters/Sources/PlaneSource.js +97 -104
  129. package/Filters/Sources/PointSource.js +46 -37
  130. package/Filters/Sources/RTAnalyticSource.js +50 -48
  131. package/Filters/Sources/SLICSource.js +63 -73
  132. package/Filters/Sources/SphereSource.js +88 -78
  133. package/Filters/Sources/ViewFinderSource.js +26 -23
  134. package/Filters/Sources.js +14 -14
  135. package/Filters/Texture/TextureMapToPlane.js +95 -97
  136. package/Filters/Texture/TextureMapToSphere.js +46 -54
  137. package/Filters/Texture.js +2 -2
  138. package/Filters/index.js +5 -5
  139. package/IO/Core/BinaryHelper.js +12 -18
  140. package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +43 -59
  141. package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +76 -113
  142. package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +62 -112
  143. package/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js +76 -113
  144. package/IO/Core/DataAccessHelper.js +6 -6
  145. package/IO/Core/HttpDataSetReader.js +136 -139
  146. package/IO/Core/HttpDataSetSeriesReader.js +64 -75
  147. package/IO/Core/HttpSceneLoader.js +130 -179
  148. package/IO/Core/ImageStream/DefaultProtocol.js +29 -43
  149. package/IO/Core/ImageStream/ViewStream.js +100 -103
  150. package/IO/Core/ImageStream.js +62 -54
  151. package/IO/Core/ResourceLoader.js +10 -9
  152. package/IO/Core/Serializer/ArraySerializer.js +40 -40
  153. package/IO/Core/Serializer/FieldDataSerializer.js +18 -28
  154. package/IO/Core/Serializer/ImageDataSerializer.js +22 -23
  155. package/IO/Core/Serializer/PolyDataSerializer.js +17 -21
  156. package/IO/Core/Serializer.js +6 -13
  157. package/IO/Core/WSLinkClient.js +90 -76
  158. package/IO/Core/ZipMultiDataSetReader.js +46 -44
  159. package/IO/Core/ZipMultiDataSetWriter.js +43 -34
  160. package/IO/Core.js +7 -7
  161. package/IO/Geometry/DracoReader.js +118 -121
  162. package/IO/Geometry/PLYReader.js +163 -223
  163. package/IO/Geometry/PLYWriter/Constants.js +5 -5
  164. package/IO/Geometry/PLYWriter.js +139 -154
  165. package/IO/Geometry/STLReader.js +123 -146
  166. package/IO/Geometry/STLWriter/Constants.js +2 -2
  167. package/IO/Geometry/STLWriter.js +83 -82
  168. package/IO/Geometry.js +5 -5
  169. package/IO/Legacy/LegacyAsciiParser.js +78 -139
  170. package/IO/Legacy/PolyDataReader.js +48 -36
  171. package/IO/Legacy.js +2 -2
  172. package/IO/Misc/ElevationReader.js +67 -60
  173. package/IO/Misc/HttpDataSetLODsLoader.js +41 -38
  174. package/IO/Misc/ITKImageReader.js +58 -45
  175. package/IO/Misc/ITKPolyDataReader.js +50 -38
  176. package/IO/Misc/JSONNucleoReader.js +49 -42
  177. package/IO/Misc/JSONReader.js +38 -33
  178. package/IO/Misc/MTLReader.js +74 -119
  179. package/IO/Misc/OBJReader.js +153 -206
  180. package/IO/Misc/PDBReader.js +70 -68
  181. package/IO/Misc/SkyboxReader.js +77 -82
  182. package/IO/Misc.js +9 -9
  183. package/IO/XML/XMLImageDataReader.js +36 -38
  184. package/IO/XML/XMLImageDataWriter.js +28 -21
  185. package/IO/XML/XMLPolyDataReader.js +49 -46
  186. package/IO/XML/XMLPolyDataWriter.js +43 -42
  187. package/IO/XML/XMLReader.js +262 -304
  188. package/IO/XML/XMLWriter/Constants.js +3 -3
  189. package/IO/XML/XMLWriter.js +70 -84
  190. package/IO/XML.js +6 -6
  191. package/IO/index.js +5 -5
  192. package/Imaging/Core/AbstractImageInterpolator/Constants.js +4 -4
  193. package/Imaging/Core/AbstractImageInterpolator/InterpolationInfo.js +30 -27
  194. package/Imaging/Core/AbstractImageInterpolator.js +74 -87
  195. package/Imaging/Core/ImageInterpolator.js +201 -252
  196. package/Imaging/Core/ImagePointDataIterator.js +96 -122
  197. package/Imaging/Core/ImageReslice/Constants.js +2 -2
  198. package/Imaging/Core/ImageReslice.js +327 -464
  199. package/Imaging/Core.js +4 -4
  200. package/Imaging/Hybrid/SampleFunction.js +58 -51
  201. package/Imaging/Hybrid.js +1 -1
  202. package/Imaging/index.js +2 -2
  203. package/Interaction/Animations/TimeStepBasedAnimationHandler.js +39 -54
  204. package/Interaction/Manipulators/CompositeCameraManipulator.js +22 -13
  205. package/Interaction/Manipulators/CompositeGestureManipulator.js +31 -43
  206. package/Interaction/Manipulators/CompositeKeyboardManipulator.js +15 -11
  207. package/Interaction/Manipulators/CompositeMouseManipulator.js +27 -33
  208. package/Interaction/Manipulators/CompositeVRManipulator.js +22 -15
  209. package/Interaction/Manipulators/GestureCameraManipulator.js +54 -36
  210. package/Interaction/Manipulators/KeyboardCameraManipulator.js +95 -97
  211. package/Interaction/Manipulators/MouseBoxSelectorManipulator.js +70 -89
  212. package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +67 -54
  213. package/Interaction/Manipulators/MouseCameraSliceManipulator.js +40 -38
  214. package/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator.js +83 -68
  215. package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +32 -28
  216. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +47 -40
  217. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +55 -43
  218. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +56 -46
  219. package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +41 -46
  220. package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.js +29 -27
  221. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +123 -146
  222. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +144 -166
  223. package/Interaction/Manipulators/MouseRangeManipulator.js +127 -132
  224. package/Interaction/Manipulators/VRButtonPanManipulator.js +33 -23
  225. package/Interaction/Manipulators.js +21 -21
  226. package/Interaction/Misc/DeviceOrientationToCamera.js +25 -47
  227. package/Interaction/Misc.js +1 -1
  228. package/Interaction/Style/InteractorStyleImage.js +101 -121
  229. package/Interaction/Style/InteractorStyleMPRSlice.js +111 -128
  230. package/Interaction/Style/InteractorStyleManipulator/Presets.js +9 -17
  231. package/Interaction/Style/InteractorStyleManipulator.js +254 -329
  232. package/Interaction/Style/InteractorStyleRemoteMouse.js +195 -180
  233. package/Interaction/Style/InteractorStyleTrackballCamera.js +154 -157
  234. package/Interaction/Style/InteractorStyleUnicam.js +30 -38
  235. package/Interaction/Style.js +5 -5
  236. package/Interaction/UI/CornerAnnotation/CornerAnnotation.module.css.js +1 -1
  237. package/Interaction/UI/CornerAnnotation.js +65 -48
  238. package/Interaction/UI/FPSMonitor.js +104 -105
  239. package/Interaction/UI/Icons.js +1 -1
  240. package/Interaction/UI/Slider/Constants.js +2 -2
  241. package/Interaction/UI/Slider.js +78 -95
  242. package/Interaction/UI/VolumeController.js +104 -97
  243. package/Interaction/UI.js +5 -5
  244. package/Interaction/Widgets/OrientationMarkerWidget/Constants.js +2 -2
  245. package/Interaction/Widgets/OrientationMarkerWidget.js +90 -135
  246. package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
  247. package/Interaction/Widgets/PiecewiseGaussianWidget.js +381 -498
  248. package/Interaction/Widgets.js +2 -2
  249. package/Interaction/index.js +5 -5
  250. package/Proxy/Animation/AbstractAnimationProxy.js +22 -15
  251. package/Proxy/Animation/AnimationProxyManager.js +43 -51
  252. package/Proxy/Animation/TimeStepBasedAnimationHandlerProxy.js +26 -19
  253. package/Proxy/Core/AbstractRepresentationProxy.js +97 -151
  254. package/Proxy/Core/LookupTableProxy/Constants.js +4 -4
  255. package/Proxy/Core/LookupTableProxy.js +49 -52
  256. package/Proxy/Core/PiecewiseFunctionProxy/Constants.js +4 -4
  257. package/Proxy/Core/PiecewiseFunctionProxy.js +63 -72
  258. package/Proxy/Core/ProxyManager/core.js +83 -106
  259. package/Proxy/Core/ProxyManager/properties.js +53 -76
  260. package/Proxy/Core/ProxyManager/state.js +100 -110
  261. package/Proxy/Core/ProxyManager/view.js +45 -55
  262. package/Proxy/Core/ProxyManager.js +16 -8
  263. package/Proxy/Core/SourceProxy.js +41 -38
  264. package/Proxy/Core/View2DProxy.js +143 -199
  265. package/Proxy/Core/ViewProxy.js +223 -269
  266. package/Proxy/Core.js +7 -7
  267. package/Proxy/Representations/GeometryRepresentationProxy.js +34 -20
  268. package/Proxy/Representations/GlyphRepresentationProxy.js +42 -41
  269. package/Proxy/Representations/MoleculeRepresentationProxy.js +32 -22
  270. package/Proxy/Representations/ResliceRepresentationProxy.js +48 -32
  271. package/Proxy/Representations/SkyboxRepresentationProxy.js +30 -29
  272. package/Proxy/Representations/SliceRepresentationProxy.js +93 -112
  273. package/Proxy/Representations/SlicedGeometryRepresentationProxy.js +46 -42
  274. package/Proxy/Representations/VolumeRepresentationProxy.js +108 -133
  275. package/Proxy/Representations.js +7 -7
  276. package/Proxy/index.js +2 -2
  277. package/Rendering/Core/AbstractImageMapper/helper.js +44 -49
  278. package/Rendering/Core/AbstractImageMapper.js +18 -19
  279. package/Rendering/Core/AbstractMapper.js +39 -55
  280. package/Rendering/Core/AbstractMapper3D.js +26 -31
  281. package/Rendering/Core/AbstractPicker.js +25 -21
  282. package/Rendering/Core/Actor.js +71 -93
  283. package/Rendering/Core/Actor2D.js +64 -78
  284. package/Rendering/Core/AnnotatedCubeActor/Presets.js +5 -11
  285. package/Rendering/Core/AnnotatedCubeActor.js +94 -79
  286. package/Rendering/Core/AxesActor.js +65 -87
  287. package/Rendering/Core/Camera.js +246 -271
  288. package/Rendering/Core/CellPicker.js +125 -148
  289. package/Rendering/Core/ColorTransferFunction/ColorMaps.js +20 -21
  290. package/Rendering/Core/ColorTransferFunction/ColorMapsLite.js +20 -21
  291. package/Rendering/Core/ColorTransferFunction/Constants.js +4 -4
  292. package/Rendering/Core/ColorTransferFunction.js +460 -546
  293. package/Rendering/Core/Coordinate/Constants.js +2 -2
  294. package/Rendering/Core/Coordinate.js +119 -198
  295. package/Rendering/Core/CubeAxesActor.js +294 -320
  296. package/Rendering/Core/Follower.js +46 -45
  297. package/Rendering/Core/Glyph3DMapper/Constants.js +4 -4
  298. package/Rendering/Core/Glyph3DMapper.js +96 -148
  299. package/Rendering/Core/HardwareSelector.js +36 -69
  300. package/Rendering/Core/ImageArrayMapper.js +87 -126
  301. package/Rendering/Core/ImageCPRMapper.js +134 -209
  302. package/Rendering/Core/ImageMapper/Constants.js +2 -2
  303. package/Rendering/Core/ImageMapper.js +85 -144
  304. package/Rendering/Core/ImageProperty/Constants.js +2 -2
  305. package/Rendering/Core/ImageProperty.js +66 -81
  306. package/Rendering/Core/ImageResliceMapper/Constants.js +2 -2
  307. package/Rendering/Core/ImageResliceMapper.js +36 -29
  308. package/Rendering/Core/ImageSlice.js +85 -127
  309. package/Rendering/Core/InteractorObserver.js +82 -73
  310. package/Rendering/Core/InteractorStyle/Constants.js +2 -2
  311. package/Rendering/Core/InteractorStyle.js +56 -58
  312. package/Rendering/Core/Light.js +43 -49
  313. package/Rendering/Core/Mapper/CoincidentTopologyHelper.js +37 -48
  314. package/Rendering/Core/Mapper/Constants.js +6 -6
  315. package/Rendering/Core/Mapper/Static.js +15 -12
  316. package/Rendering/Core/Mapper.js +194 -259
  317. package/Rendering/Core/Mapper2D.js +61 -100
  318. package/Rendering/Core/Picker.js +124 -143
  319. package/Rendering/Core/PixelSpaceCallbackMapper.js +40 -37
  320. package/Rendering/Core/PointPicker.js +68 -79
  321. package/Rendering/Core/Prop/Constants.js +2 -2
  322. package/Rendering/Core/Prop.js +58 -106
  323. package/Rendering/Core/Prop3D.js +54 -83
  324. package/Rendering/Core/Property/Constants.js +6 -6
  325. package/Rendering/Core/Property.js +45 -74
  326. package/Rendering/Core/Property2D/Constants.js +2 -2
  327. package/Rendering/Core/Property2D.js +33 -42
  328. package/Rendering/Core/RenderWindow.js +70 -82
  329. package/Rendering/Core/RenderWindowInteractor/Constants.js +7 -7
  330. package/Rendering/Core/RenderWindowInteractor.js +324 -439
  331. package/Rendering/Core/Renderer.js +192 -256
  332. package/Rendering/Core/ScalarBarActor.js +267 -272
  333. package/Rendering/Core/Skybox.js +26 -24
  334. package/Rendering/Core/SphereMapper.js +22 -12
  335. package/Rendering/Core/StickMapper.js +22 -12
  336. package/Rendering/Core/SurfaceLICInterface/Constants.js +6 -6
  337. package/Rendering/Core/SurfaceLICInterface.js +13 -9
  338. package/Rendering/Core/SurfaceLICMapper.js +23 -15
  339. package/Rendering/Core/Texture.js +99 -141
  340. package/Rendering/Core/Viewport.js +60 -88
  341. package/Rendering/Core/Volume.js +55 -77
  342. package/Rendering/Core/VolumeMapper/Constants.js +4 -4
  343. package/Rendering/Core/VolumeMapper.js +59 -91
  344. package/Rendering/Core/VolumeProperty/Constants.js +4 -4
  345. package/Rendering/Core/VolumeProperty.js +78 -115
  346. package/Rendering/Core.js +47 -49
  347. package/Rendering/Misc/CanvasView.js +62 -61
  348. package/Rendering/Misc/FullScreenRenderWindow.js +60 -62
  349. package/Rendering/Misc/GenericRenderWindow.js +48 -37
  350. package/Rendering/Misc/RemoteView.js +86 -80
  351. package/Rendering/Misc/RenderWindowWithControlBar.js +54 -48
  352. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +43 -51
  353. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +52 -82
  354. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +258 -308
  355. package/Rendering/Misc/SynchronizableRenderWindow.js +133 -163
  356. package/Rendering/Misc/TextureLODsDownloader.js +72 -74
  357. package/Rendering/Misc.js +7 -7
  358. package/Rendering/OpenGL/Actor.js +57 -68
  359. package/Rendering/OpenGL/Actor2D.js +56 -56
  360. package/Rendering/OpenGL/BufferObject/Constants.js +2 -2
  361. package/Rendering/OpenGL/BufferObject.js +50 -65
  362. package/Rendering/OpenGL/Camera.js +35 -29
  363. package/Rendering/OpenGL/CellArrayBufferObject.js +119 -149
  364. package/Rendering/OpenGL/Convolution2DPass.js +87 -81
  365. package/Rendering/OpenGL/CubeAxesActor.js +28 -21
  366. package/Rendering/OpenGL/ForwardPass.js +53 -64
  367. package/Rendering/OpenGL/Framebuffer.js +61 -101
  368. package/Rendering/OpenGL/Glyph3DMapper.js +165 -196
  369. package/Rendering/OpenGL/HardwareSelector/Constants.js +2 -2
  370. package/Rendering/OpenGL/HardwareSelector.js +272 -397
  371. package/Rendering/OpenGL/Helper.js +58 -73
  372. package/Rendering/OpenGL/ImageCPRMapper.js +339 -421
  373. package/Rendering/OpenGL/ImageMapper.js +268 -361
  374. package/Rendering/OpenGL/ImageResliceMapper.js +306 -438
  375. package/Rendering/OpenGL/ImageSlice.js +48 -54
  376. package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +102 -84
  377. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +43 -42
  378. package/Rendering/OpenGL/PolyDataMapper.js +358 -492
  379. package/Rendering/OpenGL/PolyDataMapper2D.js +153 -205
  380. package/Rendering/OpenGL/RadialDistortionPass.js +86 -89
  381. package/Rendering/OpenGL/RenderWindow/Constants.js +2 -2
  382. package/Rendering/OpenGL/RenderWindow/ContextProxy.js +20 -29
  383. package/Rendering/OpenGL/RenderWindow.js +356 -510
  384. package/Rendering/OpenGL/Renderer.js +77 -89
  385. package/Rendering/OpenGL/ReplacementShaderMapper.js +28 -46
  386. package/Rendering/OpenGL/ScalarBarActor.js +28 -21
  387. package/Rendering/OpenGL/Shader.js +37 -31
  388. package/Rendering/OpenGL/ShaderCache.js +67 -74
  389. package/Rendering/OpenGL/ShaderProgram.js +136 -248
  390. package/Rendering/OpenGL/Skybox.js +99 -60
  391. package/Rendering/OpenGL/SphereMapper.js +94 -108
  392. package/Rendering/OpenGL/StickMapper.js +110 -114
  393. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +91 -157
  394. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +142 -151
  395. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +142 -216
  396. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +79 -100
  397. package/Rendering/OpenGL/SurfaceLIC.js +2 -2
  398. package/Rendering/OpenGL/Texture/Constants.js +4 -4
  399. package/Rendering/OpenGL/Texture.js +443 -608
  400. package/Rendering/OpenGL/TextureUnitManager.js +47 -43
  401. package/Rendering/OpenGL/VertexArrayObject.js +92 -131
  402. package/Rendering/OpenGL/ViewNodeFactory.js +25 -13
  403. package/Rendering/OpenGL/Volume.js +38 -34
  404. package/Rendering/OpenGL/VolumeMapper.js +437 -547
  405. package/Rendering/OpenGL.js +28 -28
  406. package/Rendering/SceneGraph/RenderPass.js +34 -31
  407. package/Rendering/SceneGraph/RenderWindowViewNode.js +68 -94
  408. package/Rendering/SceneGraph/ViewNode.js +82 -111
  409. package/Rendering/SceneGraph/ViewNodeFactory.js +31 -26
  410. package/Rendering/SceneGraph.js +4 -4
  411. package/Rendering/WebGPU/Actor.js +49 -49
  412. package/Rendering/WebGPU/Actor2D.js +45 -44
  413. package/Rendering/WebGPU/BindGroup.js +43 -50
  414. package/Rendering/WebGPU/Buffer.js +41 -50
  415. package/Rendering/WebGPU/BufferManager/Constants.js +4 -4
  416. package/Rendering/WebGPU/BufferManager.js +111 -141
  417. package/Rendering/WebGPU/Camera.js +65 -67
  418. package/Rendering/WebGPU/CellArrayMapper.js +621 -388
  419. package/Rendering/WebGPU/CubeAxesActor.js +28 -19
  420. package/Rendering/WebGPU/Device.js +78 -133
  421. package/Rendering/WebGPU/ForwardPass.js +75 -72
  422. package/Rendering/WebGPU/FullScreenQuad.js +25 -18
  423. package/Rendering/WebGPU/Glyph3DMapper.js +62 -74
  424. package/Rendering/WebGPU/HardwareSelectionPass.js +45 -38
  425. package/Rendering/WebGPU/HardwareSelector.js +200 -276
  426. package/Rendering/WebGPU/ImageMapper.js +180 -171
  427. package/Rendering/WebGPU/ImageSlice.js +45 -44
  428. package/Rendering/WebGPU/IndexBuffer.js +166 -200
  429. package/Rendering/WebGPU/OpaquePass.js +37 -36
  430. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +72 -45
  431. package/Rendering/WebGPU/Pipeline.js +37 -51
  432. package/Rendering/WebGPU/PixelSpaceCallbackMapper.js +27 -19
  433. package/Rendering/WebGPU/PolyDataMapper.js +50 -53
  434. package/Rendering/WebGPU/PolyDataMapper2D.js +39 -39
  435. package/Rendering/WebGPU/RenderEncoder.js +68 -88
  436. package/Rendering/WebGPU/RenderWindow.js +262 -376
  437. package/Rendering/WebGPU/Renderer.js +224 -208
  438. package/Rendering/WebGPU/Sampler.js +27 -21
  439. package/Rendering/WebGPU/ScalarBarActor.js +28 -19
  440. package/Rendering/WebGPU/ShaderCache.js +43 -41
  441. package/Rendering/WebGPU/ShaderDescription.js +52 -59
  442. package/Rendering/WebGPU/ShaderModule.js +26 -17
  443. package/Rendering/WebGPU/SimpleMapper.js +185 -121
  444. package/Rendering/WebGPU/SphereMapper.js +200 -130
  445. package/Rendering/WebGPU/StickMapper.js +289 -152
  446. package/Rendering/WebGPU/StorageBuffer.js +100 -115
  447. package/Rendering/WebGPU/Texture.js +79 -99
  448. package/Rendering/WebGPU/TextureManager.js +52 -54
  449. package/Rendering/WebGPU/TextureView.js +40 -43
  450. package/Rendering/WebGPU/Types.js +53 -70
  451. package/Rendering/WebGPU/UniformBuffer.js +158 -184
  452. package/Rendering/WebGPU/VertexInput.js +64 -90
  453. package/Rendering/WebGPU/ViewNodeFactory.js +25 -13
  454. package/Rendering/WebGPU/Volume.js +52 -51
  455. package/Rendering/WebGPU/VolumePass.js +218 -239
  456. package/Rendering/WebGPU/VolumePassFSQ.js +625 -306
  457. package/Rendering/WebGPU.js +1 -1
  458. package/Rendering/index.js +5 -5
  459. package/Widgets/Core/AbstractWidget/Constants.js +2 -2
  460. package/Widgets/Core/AbstractWidget.js +49 -58
  461. package/Widgets/Core/AbstractWidgetFactory.js +101 -122
  462. package/Widgets/Core/StateBuilder/boundsMixin.js +23 -28
  463. package/Widgets/Core/StateBuilder/color3Mixin.js +10 -7
  464. package/Widgets/Core/StateBuilder/colorMixin.js +10 -6
  465. package/Widgets/Core/StateBuilder/cornerMixin.js +16 -15
  466. package/Widgets/Core/StateBuilder/directionMixin.js +20 -18
  467. package/Widgets/Core/StateBuilder/manipulatorMixin.js +26 -18
  468. package/Widgets/Core/StateBuilder/nameMixin.js +10 -6
  469. package/Widgets/Core/StateBuilder/orientationMixin.js +19 -16
  470. package/Widgets/Core/StateBuilder/originMixin.js +25 -32
  471. package/Widgets/Core/StateBuilder/scale1Mixin.js +10 -6
  472. package/Widgets/Core/StateBuilder/scale3Mixin.js +10 -6
  473. package/Widgets/Core/StateBuilder/shapeMixin.js +12 -6
  474. package/Widgets/Core/StateBuilder/textMixin.js +10 -6
  475. package/Widgets/Core/StateBuilder/visibleMixin.js +10 -6
  476. package/Widgets/Core/StateBuilder.js +120 -149
  477. package/Widgets/Core/WidgetManager/Constants.js +7 -7
  478. package/Widgets/Core/WidgetManager.js +249 -421
  479. package/Widgets/Core/WidgetState.js +48 -57
  480. package/Widgets/Core.js +5 -5
  481. package/Widgets/Manipulators/AbstractManipulator.js +20 -14
  482. package/Widgets/Manipulators/CPRManipulator.js +55 -71
  483. package/Widgets/Manipulators/LineManipulator.js +31 -28
  484. package/Widgets/Manipulators/PickerManipulator.d.ts +48 -0
  485. package/Widgets/Manipulators/PickerManipulator.js +65 -0
  486. package/Widgets/Manipulators/PlaneManipulator.js +26 -23
  487. package/Widgets/Manipulators/TrackballManipulator.js +39 -35
  488. package/Widgets/Manipulators.js +4 -2
  489. package/Widgets/Representations/ArrowHandleRepresentation.js +148 -162
  490. package/Widgets/Representations/CircleContextRepresentation.js +44 -38
  491. package/Widgets/Representations/ContextRepresentation.js +17 -14
  492. package/Widgets/Representations/ConvexFaceContextRepresentation.js +50 -47
  493. package/Widgets/Representations/CroppingOutlineRepresentation.js +38 -27
  494. package/Widgets/Representations/CubeHandleRepresentation.js +21 -18
  495. package/Widgets/Representations/GlyphRepresentation.js +107 -152
  496. package/Widgets/Representations/HandleRepresentation.js +17 -14
  497. package/Widgets/Representations/ImplicitPlaneRepresentation.js +97 -91
  498. package/Widgets/Representations/LineHandleRepresentation.js +44 -41
  499. package/Widgets/Representations/OutlineContextRepresentation.js +42 -36
  500. package/Widgets/Representations/PolyLineRepresentation.js +60 -75
  501. package/Widgets/Representations/RectangleContextRepresentation.js +42 -37
  502. package/Widgets/Representations/SphereContextRepresentation.js +19 -27
  503. package/Widgets/Representations/SphereHandleRepresentation.js +31 -27
  504. package/Widgets/Representations/SplineContextRepresentation.js +46 -70
  505. package/Widgets/Representations/WidgetRepresentation/Constants.js +2 -2
  506. package/Widgets/Representations/WidgetRepresentation.js +99 -134
  507. package/Widgets/Representations.js +13 -13
  508. package/Widgets/Widgets3D/AngleWidget/behavior.js +41 -63
  509. package/Widgets/Widgets3D/AngleWidget.js +40 -38
  510. package/Widgets/Widgets3D/DistanceWidget/behavior.js +40 -61
  511. package/Widgets/Widgets3D/DistanceWidget.js +38 -36
  512. package/Widgets/Widgets3D/EllipseWidget/behavior.js +14 -19
  513. package/Widgets/Widgets3D/EllipseWidget/state.js +4 -2
  514. package/Widgets/Widgets3D/EllipseWidget.js +37 -26
  515. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +26 -56
  516. package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +14 -17
  517. package/Widgets/Widgets3D/ImageCroppingWidget/state.js +20 -16
  518. package/Widgets/Widgets3D/ImageCroppingWidget.js +80 -98
  519. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +55 -77
  520. package/Widgets/Widgets3D/InteractiveOrientationWidget/behavior.js +17 -18
  521. package/Widgets/Widgets3D/InteractiveOrientationWidget/state.js +15 -7
  522. package/Widgets/Widgets3D/InteractiveOrientationWidget.js +30 -29
  523. package/Widgets/Widgets3D/LabelWidget/behavior.js +37 -62
  524. package/Widgets/Widgets3D/LabelWidget.js +31 -25
  525. package/Widgets/Widgets3D/LineWidget/Constants.js +8 -8
  526. package/Widgets/Widgets3D/LineWidget/behavior.js +77 -114
  527. package/Widgets/Widgets3D/LineWidget/helpers.js +13 -20
  528. package/Widgets/Widgets3D/LineWidget/state.js +2 -1
  529. package/Widgets/Widgets3D/LineWidget.js +39 -35
  530. package/Widgets/Widgets3D/PaintWidget/behavior.js +24 -59
  531. package/Widgets/Widgets3D/PaintWidget.js +39 -37
  532. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +44 -68
  533. package/Widgets/Widgets3D/PolyLineWidget.js +36 -31
  534. package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -11
  535. package/Widgets/Widgets3D/RectangleWidget/state.js +4 -2
  536. package/Widgets/Widgets3D/RectangleWidget.js +37 -25
  537. package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +35 -21
  538. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +133 -209
  539. package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
  540. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +89 -116
  541. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +33 -40
  542. package/Widgets/Widgets3D/ResliceCursorWidget.js +186 -227
  543. package/Widgets/Widgets3D/SeedWidget/behavior.js +82 -0
  544. package/Widgets/Widgets3D/SeedWidget/state.js +18 -0
  545. package/Widgets/Widgets3D/SeedWidget.d.ts +44 -0
  546. package/Widgets/Widgets3D/SeedWidget.js +43 -0
  547. package/Widgets/Widgets3D/ShapeWidget/Constants.js +19 -19
  548. package/Widgets/Widgets3D/ShapeWidget/behavior.js +150 -252
  549. package/Widgets/Widgets3D/ShapeWidget.js +24 -27
  550. package/Widgets/Widgets3D/SphereWidget/behavior.js +35 -69
  551. package/Widgets/Widgets3D/SphereWidget/state.js +9 -5
  552. package/Widgets/Widgets3D/SphereWidget.js +34 -44
  553. package/Widgets/Widgets3D/SplineWidget/behavior.js +85 -120
  554. package/Widgets/Widgets3D/SplineWidget.js +43 -39
  555. package/Widgets/Widgets3D.js +15 -15
  556. package/Widgets/index.js +4 -4
  557. package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +95 -207
  558. package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
  559. package/favicon.js +5 -6
  560. package/index.d.ts +4 -2
  561. package/index.js +4 -3
  562. package/macros.js +4 -1931
  563. package/macros2.js +1684 -0
  564. package/package.json +6 -6
  565. package/vtk.js +18 -31
@@ -1,82 +1,86 @@
1
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
- import macro from '../../macros.js';
1
+ import { m as macro } from '../../macros2.js';
5
2
  import { D as arrayRange } from '../../Common/Core/Math/index.js';
6
3
  import WebworkerPromise from 'webworker-promise';
7
4
  import { W as WorkerFactory } from '../../_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js';
8
5
 
9
- 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; }
10
-
11
- 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; }
12
6
  /* eslint-disable no-continue */
7
+
13
8
  // ----------------------------------------------------------------------------
14
9
  // Global structures
15
10
  // ----------------------------------------------------------------------------
16
11
 
17
- var MIN_GAUSSIAN_WIDTH = 0.001;
18
- var ACTION_TO_CURSOR = {
12
+ const MIN_GAUSSIAN_WIDTH = 0.001;
13
+ const ACTION_TO_CURSOR = {
19
14
  adjustPosition: '-webkit-grab',
20
15
  adjustHeight: 'row-resize',
21
16
  adjustBias: 'crosshair',
22
17
  adjustWidth: 'col-resize',
23
18
  adjustZoom: 'col-resize'
24
19
  };
25
- var TOUCH_CLICK = []; // ----------------------------------------------------------------------------
20
+ const TOUCH_CLICK = [];
21
+
22
+ // ----------------------------------------------------------------------------
26
23
  // Global methods
27
24
  // ----------------------------------------------------------------------------
28
25
 
29
- var ACTIONS = {
30
- adjustPosition: function adjustPosition(x, y, _ref) {
31
- var originalXY = _ref.originalXY,
32
- gaussian = _ref.gaussian,
33
- originalGaussian = _ref.originalGaussian;
34
- var xOffset = originalGaussian.position - originalXY[0];
26
+ const ACTIONS = {
27
+ adjustPosition(x, y, _ref) {
28
+ let {
29
+ originalXY,
30
+ gaussian,
31
+ originalGaussian
32
+ } = _ref;
33
+ const xOffset = originalGaussian.position - originalXY[0];
35
34
  gaussian.position = x + xOffset;
36
35
  return true;
37
36
  },
38
- adjustHeight: function adjustHeight(x, y, _ref2) {
39
- var model = _ref2.model,
40
- gaussian = _ref2.gaussian;
37
+ adjustHeight(x, y, _ref2) {
38
+ let {
39
+ model,
40
+ gaussian
41
+ } = _ref2;
41
42
  gaussian.height = 1 - y;
42
43
  gaussian.height = Math.min(1, Math.max(model.gaussianMinimumHeight, gaussian.height));
43
44
  return true;
44
45
  },
45
- adjustBias: function adjustBias(x, y, _ref3) {
46
- var originalXY = _ref3.originalXY,
47
- gaussian = _ref3.gaussian,
48
- originalGaussian = _ref3.originalGaussian;
46
+ adjustBias(x, y, _ref3) {
47
+ let {
48
+ originalXY,
49
+ gaussian,
50
+ originalGaussian
51
+ } = _ref3;
49
52
  gaussian.xBias = originalGaussian.xBias - (originalXY[0] - x) / gaussian.height;
50
- gaussian.yBias = originalGaussian.yBias + 4 * (originalXY[1] - y) / gaussian.height; // Clamps
51
-
53
+ gaussian.yBias = originalGaussian.yBias + 4 * (originalXY[1] - y) / gaussian.height;
54
+ // Clamps
52
55
  gaussian.xBias = Math.max(-1, Math.min(1, gaussian.xBias));
53
56
  gaussian.yBias = Math.max(0, Math.min(2, gaussian.yBias));
54
57
  return true;
55
58
  },
56
- adjustWidth: function adjustWidth(x, y, _ref4) {
57
- var originalXY = _ref4.originalXY,
58
- gaussian = _ref4.gaussian,
59
- originalGaussian = _ref4.originalGaussian,
60
- gaussianSide = _ref4.gaussianSide;
59
+ adjustWidth(x, y, _ref4) {
60
+ let {
61
+ originalXY,
62
+ gaussian,
63
+ originalGaussian,
64
+ gaussianSide
65
+ } = _ref4;
61
66
  gaussian.width = gaussianSide < 0 ? originalGaussian.width - (originalXY[0] - x) : originalGaussian.width + (originalXY[0] - x);
62
-
63
67
  if (gaussian.width < MIN_GAUSSIAN_WIDTH) {
64
68
  gaussian.width = MIN_GAUSSIAN_WIDTH;
65
69
  }
66
-
67
70
  return true;
68
71
  },
69
- adjustZoom: function adjustZoom(x, y, _ref5) {
70
- var rangeZoom = _ref5.rangeZoom,
71
- publicAPI = _ref5.publicAPI;
72
- var delta = rangeZoom[1] - rangeZoom[0];
73
- var absNormX = (x - rangeZoom[0]) / delta;
74
- var minDelta = Math.abs(absNormX - rangeZoom[0]);
75
- var maxDelta = Math.abs(absNormX - rangeZoom[1]);
76
- var meanDelta = Math.abs(absNormX - 0.5 * (rangeZoom[0] + rangeZoom[1]));
77
-
72
+ adjustZoom(x, y, _ref5) {
73
+ let {
74
+ rangeZoom,
75
+ publicAPI
76
+ } = _ref5;
77
+ const delta = rangeZoom[1] - rangeZoom[0];
78
+ const absNormX = (x - rangeZoom[0]) / delta;
79
+ const minDelta = Math.abs(absNormX - rangeZoom[0]);
80
+ const maxDelta = Math.abs(absNormX - rangeZoom[1]);
81
+ const meanDelta = Math.abs(absNormX - 0.5 * (rangeZoom[0] + rangeZoom[1]));
78
82
  if (meanDelta < Math.min(minDelta, maxDelta)) {
79
- var halfDelta = delta * 0.5;
83
+ const halfDelta = delta * 0.5;
80
84
  rangeZoom[0] = Math.min(Math.max(absNormX - halfDelta, 0), rangeZoom[1] - 0.1);
81
85
  rangeZoom[1] = Math.max(Math.min(absNormX + halfDelta, 1), rangeZoom[0] + 0.1);
82
86
  } else if (minDelta < maxDelta) {
@@ -84,47 +88,46 @@ var ACTIONS = {
84
88
  } else {
85
89
  rangeZoom[1] = Math.max(Math.min(absNormX, 1), rangeZoom[0] + 0.1);
86
90
  }
91
+ publicAPI.invokeZoomChange(rangeZoom);
87
92
 
88
- publicAPI.invokeZoomChange(rangeZoom); // The opacity did not changed
89
-
93
+ // The opacity did not changed
90
94
  return false;
91
95
  }
92
- }; // ----------------------------------------------------------------------------
96
+ };
93
97
 
94
- function computeOpacities(gaussians) {
95
- var sampling = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 256;
96
- var opacities = [];
98
+ // ----------------------------------------------------------------------------
97
99
 
100
+ function computeOpacities(gaussians) {
101
+ let sampling = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 256;
102
+ const opacities = [];
98
103
  while (opacities.length < sampling) {
99
104
  opacities.push(0);
100
105
  }
101
-
102
- var count = gaussians.length;
103
-
106
+ let count = gaussians.length;
104
107
  while (count--) {
105
- var _gaussians$count = gaussians[count],
106
- position = _gaussians$count.position,
107
- height = _gaussians$count.height,
108
- width = _gaussians$count.width,
109
- xBias = _gaussians$count.xBias,
110
- yBias = _gaussians$count.yBias;
111
-
112
- for (var i = 0; i < sampling; i++) {
113
- var x = i / (sampling - 1); // clamp non-zero values to pos +/- width
114
-
108
+ const {
109
+ position,
110
+ height,
111
+ width,
112
+ xBias,
113
+ yBias
114
+ } = gaussians[count];
115
+ for (let i = 0; i < sampling; i++) {
116
+ const x = i / (sampling - 1);
117
+
118
+ // clamp non-zero values to pos +/- width
115
119
  if (x > position + width || x < position - width) {
116
120
  if (opacities[i] < 0.0) {
117
121
  opacities[i] = 0.0;
118
122
  }
119
-
120
123
  continue;
121
- } // non-zero width
122
-
123
-
124
- var correctedWidth = width < MIN_GAUSSIAN_WIDTH ? MIN_GAUSSIAN_WIDTH : width; // translate the original x to a new x based on the xbias
124
+ }
125
125
 
126
- var x0 = 0;
126
+ // non-zero width
127
+ const correctedWidth = width < MIN_GAUSSIAN_WIDTH ? MIN_GAUSSIAN_WIDTH : width;
127
128
 
129
+ // translate the original x to a new x based on the xbias
130
+ let x0 = 0;
128
131
  if (xBias === 0 || x === position + xBias) {
129
132
  x0 = x;
130
133
  } else if (x > position + xBias) {
@@ -138,206 +141,192 @@ function computeOpacities(gaussians) {
138
141
  x0 = position;
139
142
  } else {
140
143
  x0 = position - (x - position - xBias) * (correctedWidth / (correctedWidth + xBias));
141
- } // center around 0 and normalize to -1,1
144
+ }
142
145
 
146
+ // center around 0 and normalize to -1,1
147
+ const x1 = (x0 - position) / correctedWidth;
143
148
 
144
- var x1 = (x0 - position) / correctedWidth; // do a linear interpolation between:
149
+ // do a linear interpolation between:
145
150
  // a gaussian and a parabola if 0 < yBias <1
146
151
  // a parabola and a step function if 1 < yBias <2
147
-
148
- var h0a = Math.exp(-(4 * x1 * x1));
149
- var h0b = 1.0 - x1 * x1;
150
- var h0c = 1.0;
151
- var h1 = void 0;
152
-
152
+ const h0a = Math.exp(-(4 * x1 * x1));
153
+ const h0b = 1.0 - x1 * x1;
154
+ const h0c = 1.0;
155
+ let h1;
153
156
  if (yBias < 1) {
154
157
  h1 = yBias * h0b + (1 - yBias) * h0a;
155
158
  } else {
156
159
  h1 = (2 - yBias) * h0b + (yBias - 1) * h0c;
157
160
  }
161
+ const h2 = height * h1;
158
162
 
159
- var h2 = height * h1; // perform the MAX over different gaussians, not the sum
160
-
163
+ // perform the MAX over different gaussians, not the sum
161
164
  if (h2 > opacities[i]) {
162
165
  opacities[i] = h2;
163
166
  }
164
167
  }
165
168
  }
166
-
167
169
  return opacities;
168
- } // ----------------------------------------------------------------------------
170
+ }
169
171
 
172
+ // ----------------------------------------------------------------------------
170
173
 
171
174
  function applyGaussianToPiecewiseFunction(gaussians, sampling, rangeToUse, piecewiseFunction) {
172
- var opacities = computeOpacities(gaussians, sampling);
173
- var nodes = [];
174
- var delta = (rangeToUse[1] - rangeToUse[0]) / (opacities.length - 1);
175
- var midpoint = 0.5;
176
- var sharpness = 0;
177
-
178
- for (var index = 0; index < opacities.length; index++) {
179
- var x = rangeToUse[0] + delta * index;
180
- var y = opacities[index];
175
+ const opacities = computeOpacities(gaussians, sampling);
176
+ const nodes = [];
177
+ const delta = (rangeToUse[1] - rangeToUse[0]) / (opacities.length - 1);
178
+ const midpoint = 0.5;
179
+ const sharpness = 0;
180
+ for (let index = 0; index < opacities.length; index++) {
181
+ const x = rangeToUse[0] + delta * index;
182
+ const y = opacities[index];
181
183
  nodes.push({
182
- x: x,
183
- y: y,
184
- midpoint: midpoint,
185
- sharpness: sharpness
184
+ x,
185
+ y,
186
+ midpoint,
187
+ sharpness
186
188
  });
187
189
  }
188
-
189
190
  piecewiseFunction.setNodes(nodes);
190
- } // ----------------------------------------------------------------------------
191
+ }
191
192
 
193
+ // ----------------------------------------------------------------------------
192
194
 
193
195
  function drawChart(ctx, area, values) {
194
- var style = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
196
+ let style = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
195
197
  lineWidth: 1,
196
198
  strokeStyle: '#000'
197
199
  };
198
- var verticalScale = area[3];
199
- var horizontalScale = area[2] / (values.length - 1);
200
- var fill = !!style.fillStyle;
201
- var offset = verticalScale + area[1];
200
+ const verticalScale = area[3];
201
+ const horizontalScale = area[2] / (values.length - 1);
202
+ const fill = !!style.fillStyle;
203
+ const offset = verticalScale + area[1];
202
204
  ctx.lineWidth = style.lineWidth;
203
205
  ctx.strokeStyle = style.strokeStyle;
204
206
  ctx.beginPath();
205
207
  ctx.moveTo(area[0], area[1] + area[3]);
206
-
207
- for (var index = 0; index < values.length; index++) {
208
+ for (let index = 0; index < values.length; index++) {
208
209
  ctx.lineTo(area[0] + index * horizontalScale, Math.max(area[1], offset - values[index] * verticalScale));
209
210
  }
210
-
211
211
  if (fill) {
212
212
  ctx.fillStyle = style.fillStyle;
213
213
  ctx.lineTo(area[0] + area[2], area[1] + area[3]);
214
-
215
214
  if (style.clip) {
216
215
  ctx.clip();
217
216
  return;
218
217
  }
219
-
220
218
  ctx.fill();
221
219
  }
222
-
223
220
  ctx.stroke();
224
- } // ----------------------------------------------------------------------------
221
+ }
225
222
 
223
+ // ----------------------------------------------------------------------------
226
224
 
227
225
  function updateColorCanvas(colorTransferFunction, width, rangeToUse, canvas) {
228
- var workCanvas = canvas || document.createElement('canvas');
226
+ const workCanvas = canvas || document.createElement('canvas');
229
227
  workCanvas.setAttribute('width', width);
230
228
  workCanvas.setAttribute('height', 256);
231
- var ctx = workCanvas.getContext('2d');
232
- var rgba = colorTransferFunction.getUint8Table(rangeToUse[0], rangeToUse[1], width, 4);
233
- var pixelsArea = ctx.getImageData(0, 0, width, 256);
234
-
235
- for (var lineIdx = 0; lineIdx < 256; lineIdx++) {
229
+ const ctx = workCanvas.getContext('2d');
230
+ const rgba = colorTransferFunction.getUint8Table(rangeToUse[0], rangeToUse[1], width, 4);
231
+ const pixelsArea = ctx.getImageData(0, 0, width, 256);
232
+ for (let lineIdx = 0; lineIdx < 256; lineIdx++) {
236
233
  pixelsArea.data.set(rgba, lineIdx * 4 * width);
237
234
  }
238
-
239
- var nbValues = 256 * width * 4;
240
- var lineSize = width * 4;
241
-
242
- for (var i = 3; i < nbValues; i += 4) {
235
+ const nbValues = 256 * width * 4;
236
+ const lineSize = width * 4;
237
+ for (let i = 3; i < nbValues; i += 4) {
243
238
  pixelsArea.data[i] = 255 - Math.floor(i / lineSize);
244
239
  }
245
-
246
240
  ctx.putImageData(pixelsArea, 0, 0);
247
241
  return workCanvas;
248
- } // ----------------------------------------------------------------------------
242
+ }
249
243
 
244
+ // ----------------------------------------------------------------------------
250
245
 
251
246
  function updateColorCanvasFromImage(img, width, canvas) {
252
- var workCanvas = canvas || document.createElement('canvas');
247
+ const workCanvas = canvas || document.createElement('canvas');
253
248
  workCanvas.setAttribute('width', width);
254
249
  workCanvas.setAttribute('height', 256);
255
- var ctx = workCanvas.getContext('2d');
250
+ const ctx = workCanvas.getContext('2d');
256
251
  ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, width, 256);
257
252
  return workCanvas;
258
- } // ----------------------------------------------------------------------------
253
+ }
259
254
 
255
+ // ----------------------------------------------------------------------------
260
256
 
261
257
  function normalizeCoordinates(x, y, subRectangeArea) {
262
- var zoomRange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [0, 1];
258
+ let zoomRange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [0, 1];
263
259
  return [zoomRange[0] + (x - subRectangeArea[0]) / subRectangeArea[2] * (zoomRange[1] - zoomRange[0]), (y - subRectangeArea[1]) / subRectangeArea[3]];
264
- } // ----------------------------------------------------------------------------
260
+ }
265
261
 
262
+ // ----------------------------------------------------------------------------
266
263
 
267
264
  function findGaussian(x, gaussians) {
268
- var distances = gaussians.map(function (g) {
269
- return Math.abs(g.position - x);
270
- });
271
- var min = Math.min.apply(Math, _toConsumableArray(distances));
265
+ const distances = gaussians.map(g => Math.abs(g.position - x));
266
+ const min = Math.min(...distances);
272
267
  return distances.indexOf(min);
273
- } // ----------------------------------------------------------------------------
268
+ }
274
269
 
270
+ // ----------------------------------------------------------------------------
275
271
 
276
272
  function createListener(callback) {
277
- var preventDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
278
- return function (e) {
279
- var offsetX = e.offsetX,
280
- offsetY = e.offsetY;
281
-
273
+ let preventDefault = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
274
+ return e => {
275
+ const {
276
+ offsetX,
277
+ offsetY
278
+ } = e;
282
279
  if (preventDefault) {
283
280
  e.preventDefault();
284
281
  }
285
-
286
282
  callback(offsetX, offsetY);
287
283
  };
288
- } // ----------------------------------------------------------------------------
284
+ }
289
285
 
286
+ // ----------------------------------------------------------------------------
290
287
 
291
288
  function createTouchClickListener() {
292
- var id = TOUCH_CLICK.length;
293
-
289
+ const id = TOUCH_CLICK.length;
294
290
  for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
295
291
  callbacks[_key] = arguments[_key];
296
292
  }
297
-
298
293
  TOUCH_CLICK.push({
299
- callbacks: callbacks,
294
+ callbacks,
300
295
  timeout: 0,
301
296
  deltaT: 200,
302
297
  count: 0,
303
298
  ready: false
304
299
  });
305
300
  return id;
306
- } // ----------------------------------------------------------------------------
301
+ }
307
302
 
303
+ // ----------------------------------------------------------------------------
308
304
 
309
305
  function processTouchClicks() {
310
- TOUCH_CLICK.filter(function (t) {
311
- return t.ready;
312
- }).forEach(function (touchHandle) {
313
- touchHandle.callbacks.forEach(function (callback) {
306
+ TOUCH_CLICK.filter(t => t.ready).forEach(touchHandle => {
307
+ touchHandle.callbacks.forEach(callback => {
314
308
  if (callback.touches === touchHandle.touches && callback.clicks === touchHandle.count) {
315
- callback.action.apply(callback, _toConsumableArray(touchHandle.singleTouche));
309
+ callback.action(...touchHandle.singleTouche);
316
310
  }
317
- }); // Clear state
311
+ });
318
312
 
313
+ // Clear state
319
314
  touchHandle.ts = 0;
320
315
  touchHandle.count = 0;
321
316
  touchHandle.touches = 0;
322
317
  touchHandle.ready = false;
323
318
  });
324
- } // ----------------------------------------------------------------------------
319
+ }
325
320
 
321
+ // ----------------------------------------------------------------------------
326
322
 
327
323
  function createTouchListener(id, callback) {
328
- var nbTouches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
329
- var preventDefault = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
330
- return function (e) {
331
- var targetBounds = e.target.getBoundingClientRect();
332
- var relativeTouches = Array.prototype.map.call(e.touches, function (t) {
333
- return [t.pageX - targetBounds.left, t.pageY - targetBounds.top];
334
- });
335
- var singleTouche = relativeTouches.reduce(function (a, b) {
336
- return [a[0] + b[0], a[1] + b[1]];
337
- }, [0, 0]).map(function (v) {
338
- return v / e.touches.length;
339
- });
340
-
324
+ let nbTouches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
325
+ let preventDefault = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
326
+ return e => {
327
+ const targetBounds = e.target.getBoundingClientRect();
328
+ const relativeTouches = Array.prototype.map.call(e.touches, t => [t.pageX - targetBounds.left, t.pageY - targetBounds.top]);
329
+ const singleTouche = relativeTouches.reduce((a, b) => [a[0] + b[0], a[1] + b[1]], [0, 0]).map(v => v / e.touches.length);
341
330
  if (e.type === 'touchstart') {
342
331
  clearTimeout(TOUCH_CLICK[id].timeout);
343
332
  TOUCH_CLICK[id].ts = e.timeStamp;
@@ -351,282 +340,241 @@ function createTouchListener(id, callback) {
351
340
  if (e.timeStamp - TOUCH_CLICK[id].ts < TOUCH_CLICK[id].deltaT) {
352
341
  TOUCH_CLICK[id].count += 1;
353
342
  TOUCH_CLICK[id].ready = true;
354
-
355
343
  if (preventDefault) {
356
344
  e.preventDefault();
357
345
  }
358
-
359
346
  TOUCH_CLICK[id].timeout = setTimeout(processTouchClicks, TOUCH_CLICK[id].deltaT);
360
347
  } else {
361
348
  TOUCH_CLICK[id].ready = false;
362
349
  }
363
350
  }
364
-
365
351
  if (e.touches.length === nbTouches) {
366
- callback.apply(void 0, _toConsumableArray(singleTouche));
367
-
352
+ callback(...singleTouche);
368
353
  if (preventDefault) {
369
354
  e.preventDefault();
370
355
  }
371
356
  }
372
357
  };
373
- } // ----------------------------------------------------------------------------
358
+ }
374
359
 
360
+ // ----------------------------------------------------------------------------
375
361
 
376
362
  function listenerSelector(condition, ok, ko) {
377
- return function (e) {
378
- return condition() ? ok(e) : ko(e);
379
- };
380
- } // ----------------------------------------------------------------------------
363
+ return e => condition() ? ok(e) : ko(e);
364
+ }
381
365
 
366
+ // ----------------------------------------------------------------------------
382
367
 
383
368
  function rescaleArray(array, focusArea) {
384
369
  if (!focusArea) {
385
370
  return array;
386
371
  }
387
-
388
- var maxIdx = array.length - 1;
389
- var idxRange = focusArea.map(function (v) {
390
- return Math.round(v * maxIdx);
391
- });
372
+ const maxIdx = array.length - 1;
373
+ const idxRange = focusArea.map(v => Math.round(v * maxIdx));
392
374
  return array.slice(idxRange[0], idxRange[1] + 1);
393
- } // ----------------------------------------------------------------------------
375
+ }
394
376
 
377
+ // ----------------------------------------------------------------------------
395
378
 
396
379
  function rescaleValue(value, focusArea) {
397
380
  if (!focusArea) {
398
381
  return value;
399
382
  }
400
-
401
383
  return (value - focusArea[0]) / (focusArea[1] - focusArea[0]);
402
- } // ----------------------------------------------------------------------------
384
+ }
385
+
386
+ // ----------------------------------------------------------------------------
403
387
  // Static API
404
388
  // ----------------------------------------------------------------------------
405
389
 
390
+ const STATIC = {
391
+ applyGaussianToPiecewiseFunction,
392
+ computeOpacities,
393
+ createListener,
394
+ drawChart,
395
+ findGaussian,
396
+ listenerSelector,
397
+ normalizeCoordinates
398
+ };
406
399
 
407
- var STATIC = {
408
- applyGaussianToPiecewiseFunction: applyGaussianToPiecewiseFunction,
409
- computeOpacities: computeOpacities,
410
- createListener: createListener,
411
- drawChart: drawChart,
412
- findGaussian: findGaussian,
413
- listenerSelector: listenerSelector,
414
- normalizeCoordinates: normalizeCoordinates
415
- }; // ----------------------------------------------------------------------------
400
+ // ----------------------------------------------------------------------------
416
401
  // vtkPiecewiseGaussianWidget methods
417
402
  // ----------------------------------------------------------------------------
418
403
 
419
404
  function vtkPiecewiseGaussianWidget(publicAPI, model) {
420
405
  // Set our className
421
406
  model.classHierarchy.push('vtkPiecewiseGaussianWidget');
422
-
423
407
  if (!model.canvas) {
424
408
  model.canvas = document.createElement('canvas');
425
409
  }
426
-
427
- publicAPI.setContainer = function (el) {
410
+ publicAPI.setContainer = el => {
428
411
  if (model.container && model.container !== el) {
429
412
  model.container.removeChild(model.canvas);
430
413
  }
431
-
432
414
  if (model.container !== el) {
433
415
  model.container = el;
434
-
435
416
  if (model.container) {
436
417
  model.container.appendChild(model.canvas);
437
418
  }
438
-
439
419
  publicAPI.modified();
440
420
  }
441
421
  };
442
-
443
- publicAPI.setGaussians = function (gaussians) {
422
+ publicAPI.setGaussians = gaussians => {
444
423
  if (model.gaussians === gaussians) {
445
424
  return;
446
425
  }
447
-
448
426
  model.gaussians = gaussians;
449
427
  model.opacities = computeOpacities(model.gaussians, model.piecewiseSize);
450
428
  publicAPI.invokeOpacityChange(publicAPI);
451
429
  publicAPI.modified();
452
430
  };
453
-
454
- publicAPI.addGaussian = function (position, height, width, xBias, yBias) {
455
- var nextIndex = model.gaussians.length;
431
+ publicAPI.addGaussian = (position, height, width, xBias, yBias) => {
432
+ const nextIndex = model.gaussians.length;
456
433
  model.gaussians.push({
457
- position: position,
458
- height: height,
459
- width: width,
460
- xBias: xBias,
461
- yBias: yBias
434
+ position,
435
+ height,
436
+ width,
437
+ xBias,
438
+ yBias
462
439
  });
463
440
  model.opacities = computeOpacities(model.gaussians, model.piecewiseSize);
464
441
  publicAPI.invokeOpacityChange(publicAPI);
465
442
  publicAPI.modified();
466
443
  return nextIndex;
467
444
  };
468
-
469
- publicAPI.removeGaussian = function (index) {
445
+ publicAPI.removeGaussian = index => {
470
446
  model.gaussians.splice(index, 1);
471
447
  model.opacities = computeOpacities(model.gaussians, model.piecewiseSize);
472
448
  publicAPI.invokeOpacityChange(publicAPI);
473
449
  publicAPI.modified();
474
450
  };
475
-
476
- publicAPI.setSize = function (width, height) {
451
+ publicAPI.setSize = (width, height) => {
477
452
  model.canvas.setAttribute('width', width);
478
453
  model.canvas.setAttribute('height', height);
479
-
480
454
  if (model.size[0] !== width || model.size[1] !== height) {
481
455
  model.size = [width, height];
482
456
  model.colorCanvasMTime = 0;
483
457
  publicAPI.modified();
484
458
  }
485
459
  };
486
-
487
- publicAPI.updateStyle = function (style) {
488
- model.style = _objectSpread(_objectSpread({}, model.style), style);
460
+ publicAPI.updateStyle = style => {
461
+ model.style = {
462
+ ...model.style,
463
+ ...style
464
+ };
489
465
  publicAPI.modified();
490
- }; // Method used to compute and show data distribution in the background.
466
+ };
467
+
468
+ // Method used to compute and show data distribution in the background.
491
469
  // When an array with many components is used, you can provide additional
492
470
  // information to choose which component you want to extract the histogram
493
471
  // from.
494
472
 
495
-
496
473
  publicAPI.setDataArray = function (array) {
497
- var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
498
- _ref6$numberOfBinToCo = _ref6.numberOfBinToConsiders,
499
- numberOfBinToConsiders = _ref6$numberOfBinToCo === void 0 ? 1 : _ref6$numberOfBinToCo,
500
- _ref6$numberOfBinsToS = _ref6.numberOfBinsToSkip,
501
- numberOfBinsToSkip = _ref6$numberOfBinsToS === void 0 ? 1 : _ref6$numberOfBinsToS,
502
- _ref6$numberOfCompone = _ref6.numberOfComponents,
503
- numberOfComponents = _ref6$numberOfCompone === void 0 ? 1 : _ref6$numberOfCompone,
504
- _ref6$component = _ref6.component,
505
- component = _ref6$component === void 0 ? 0 : _ref6$component;
506
-
474
+ let {
475
+ numberOfBinToConsiders = 1,
476
+ numberOfBinsToSkip = 1,
477
+ numberOfComponents = 1,
478
+ component = 0
479
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
507
480
  model.histogram = null;
508
481
  model.histogramArray = array;
509
482
  model.dataRange = arrayRange(array, component, numberOfComponents);
510
-
511
- var _model$dataRange = _slicedToArray(model.dataRange, 2),
512
- min = _model$dataRange[0],
513
- max = _model$dataRange[1];
514
-
515
- var maxNumberOfWorkers = 4;
516
- var arrayStride = Math.floor(array.length / maxNumberOfWorkers) || 1;
483
+ const [min, max] = model.dataRange;
484
+ const maxNumberOfWorkers = 4;
485
+ let arrayStride = Math.floor(array.length / maxNumberOfWorkers) || 1;
517
486
  arrayStride += arrayStride % numberOfComponents;
518
- var arrayIndex = 0;
519
- var workerChunks = [];
520
- var workers = [];
521
-
487
+ let arrayIndex = 0;
488
+ const workerChunks = [];
489
+ const workers = [];
522
490
  while (arrayIndex < array.length) {
523
- var worker = new WorkerFactory();
491
+ const worker = new WorkerFactory();
524
492
  workers.push(worker);
525
- var workerPromise = new WebworkerPromise(worker);
526
- var arrayStart = arrayIndex;
527
- var arrayEnd = Math.min(arrayIndex + arrayStride, array.length - 1);
528
- var subArray = new array.constructor(array.slice(arrayStart, arrayEnd + 1));
493
+ const workerPromise = new WebworkerPromise(worker);
494
+ const arrayStart = arrayIndex;
495
+ const arrayEnd = Math.min(arrayIndex + arrayStride, array.length - 1);
496
+ const subArray = new array.constructor(array.slice(arrayStart, arrayEnd + 1));
529
497
  workerChunks.push(workerPromise.postMessage({
530
498
  array: subArray,
531
- component: component,
532
- numberOfComponents: numberOfComponents,
533
- min: min,
534
- max: max,
499
+ component,
500
+ numberOfComponents,
501
+ min,
502
+ max,
535
503
  numberOfBins: model.numberOfBins
536
504
  }, [subArray.buffer]));
537
505
  arrayIndex += arrayStride;
538
506
  }
539
-
540
- Promise.all(workerChunks).then(function (subHistograms) {
541
- workers.forEach(function (worker) {
542
- return worker.terminate();
543
- });
507
+ Promise.all(workerChunks).then(subHistograms => {
508
+ workers.forEach(worker => worker.terminate());
544
509
  model.histogram = new Float32Array(model.numberOfBins);
545
510
  model.histogram.fill(0);
546
- subHistograms.forEach(function (subHistogram) {
547
- for (var i = 0, len = subHistogram.length; i < len; ++i) {
511
+ subHistograms.forEach(subHistogram => {
512
+ for (let i = 0, len = subHistogram.length; i < len; ++i) {
548
513
  model.histogram[i] += subHistogram[i];
549
514
  }
550
- }); // Smart Rescale Histogram
551
-
552
- var sampleSize = Math.min(numberOfBinToConsiders, model.histogram.length - numberOfBinsToSkip);
553
- var sortedArray = Array.from(model.histogram);
554
- sortedArray.sort(function (a, b) {
555
- return Number(a) - Number(b);
556
515
  });
557
516
 
558
- for (var i = 0; i < numberOfBinsToSkip; i++) {
517
+ // Smart Rescale Histogram
518
+ const sampleSize = Math.min(numberOfBinToConsiders, model.histogram.length - numberOfBinsToSkip);
519
+ const sortedArray = Array.from(model.histogram);
520
+ sortedArray.sort((a, b) => Number(a) - Number(b));
521
+ for (let i = 0; i < numberOfBinsToSkip; i++) {
559
522
  sortedArray.pop();
560
523
  }
561
-
562
524
  while (sortedArray.length > sampleSize) {
563
525
  sortedArray.shift();
564
526
  }
565
-
566
- var mean = sortedArray.reduce(function (a, b) {
567
- return a + b;
568
- }, 0) / sampleSize;
569
-
570
- for (var _i = 0, len = model.histogram.length; _i < len; ++_i) {
571
- model.histogram[_i] /= mean;
527
+ const mean = sortedArray.reduce((a, b) => a + b, 0) / sampleSize;
528
+ for (let i = 0, len = model.histogram.length; i < len; ++i) {
529
+ model.histogram[i] /= mean;
572
530
  }
573
-
574
531
  publicAPI.modified();
575
532
  setTimeout(publicAPI.render, 0);
576
533
  });
577
534
  publicAPI.modified();
578
535
  };
579
-
580
- publicAPI.onClick = function (x, y) {
581
- var _normalizeCoordinates = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null),
582
- _normalizeCoordinates2 = _slicedToArray(_normalizeCoordinates, 2),
583
- xNormalized = _normalizeCoordinates2[0],
584
- yNormalized = _normalizeCoordinates2[1];
585
-
536
+ publicAPI.onClick = (x, y) => {
537
+ const [xNormalized, yNormalized] = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null);
586
538
  if (xNormalized < 0 && model.style.iconSize > 1) {
587
539
  // Control buttons
588
- var delta = model.style.iconSize + model.style.padding;
589
- var offset = delta;
590
- var buttonIdx = 0;
591
-
540
+ const delta = model.style.iconSize + model.style.padding;
541
+ let offset = delta;
542
+ let buttonIdx = 0;
592
543
  while (y > offset) {
593
544
  buttonIdx += 1;
594
545
  offset += delta;
595
546
  }
596
-
597
547
  switch (buttonIdx) {
598
548
  case 0:
599
549
  {
600
- var gaussianIdx = publicAPI.addGaussian(0, 1, 0.1, 0, 0);
601
- var gaussian = model.gaussians[gaussianIdx];
602
-
603
- var originalGaussian = _objectSpread({}, gaussian);
604
-
605
- var action = ACTIONS.adjustPosition;
550
+ const gaussianIdx = publicAPI.addGaussian(0, 1, 0.1, 0, 0);
551
+ const gaussian = model.gaussians[gaussianIdx];
552
+ const originalGaussian = {
553
+ ...gaussian
554
+ };
555
+ const action = ACTIONS.adjustPosition;
606
556
  model.activeGaussian = gaussianIdx;
607
- model.selectedGaussian = gaussianIdx; // Fake active action
557
+ model.selectedGaussian = gaussianIdx;
608
558
 
609
- macro.setImmediate(function () {
559
+ // Fake active action
560
+ macro.setImmediate(() => {
610
561
  publicAPI.onDown(x, y);
611
562
  model.dragAction = {
612
563
  originalXY: [0, 0],
613
- action: action,
614
- gaussian: gaussian,
615
- originalGaussian: originalGaussian
564
+ action,
565
+ gaussian,
566
+ originalGaussian
616
567
  };
617
568
  });
618
569
  break;
619
570
  }
620
-
621
571
  case 1:
622
572
  {
623
573
  if (model.selectedGaussian !== -1) {
624
574
  publicAPI.removeGaussian(model.selectedGaussian);
625
575
  }
626
-
627
576
  break;
628
577
  }
629
-
630
578
  default:
631
579
  {
632
580
  model.selectedGaussian = -1;
@@ -637,53 +585,38 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) {
637
585
  model.selectedGaussian = -1;
638
586
  model.dragAction = null;
639
587
  } else {
640
- var newSelected = findGaussian(xNormalized, model.gaussians);
641
-
588
+ const newSelected = findGaussian(xNormalized, model.gaussians);
642
589
  if (newSelected !== model.selectedGaussian) {
643
590
  model.selectedGaussian = newSelected;
644
591
  publicAPI.modified();
645
592
  }
646
593
  }
647
-
648
594
  return true;
649
595
  };
650
-
651
- publicAPI.onHover = function (x, y) {
596
+ publicAPI.onHover = (x, y) => {
652
597
  // Determines the interaction region size for adjusting the Gaussian's
653
598
  // height.
654
- var tolerance = 20 / model.canvas.height;
655
-
656
- var _normalizeCoordinates3 = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null),
657
- _normalizeCoordinates4 = _slicedToArray(_normalizeCoordinates3, 2),
658
- xNormalized = _normalizeCoordinates4[0],
659
- yNormalized = _normalizeCoordinates4[1];
660
-
661
- var _normalizeCoordinates5 = normalizeCoordinates(x, y, model.graphArea),
662
- _normalizeCoordinates6 = _slicedToArray(_normalizeCoordinates5, 1),
663
- xNormalizedAbs = _normalizeCoordinates6[0];
664
-
665
- var newActive = xNormalized < 0 ? model.selectedGaussian : findGaussian(xNormalized, model.gaussians);
599
+ const tolerance = 20 / model.canvas.height;
600
+ const [xNormalized, yNormalized] = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null);
601
+ const [xNormalizedAbs] = normalizeCoordinates(x, y, model.graphArea);
602
+ const newActive = xNormalized < 0 ? model.selectedGaussian : findGaussian(xNormalized, model.gaussians);
666
603
  model.canvas.style.cursor = 'default';
667
- var gaussian = model.gaussians[newActive];
668
-
604
+ const gaussian = model.gaussians[newActive];
669
605
  if (model.enableRangeZoom && xNormalizedAbs >= 0 && y < model.graphArea[1] - 6 // circle radius
670
606
  ) {
671
- var thirdDelta = (model.rangeZoom[1] - model.rangeZoom[0]) / 3;
672
-
607
+ const thirdDelta = (model.rangeZoom[1] - model.rangeZoom[0]) / 3;
673
608
  if (xNormalizedAbs < model.rangeZoom[0] + thirdDelta || xNormalizedAbs > model.rangeZoom[1] - thirdDelta) {
674
609
  model.canvas.style.cursor = ACTION_TO_CURSOR.adjustZoom;
675
610
  } else {
676
611
  model.canvas.style.cursor = ACTION_TO_CURSOR.adjustPosition;
677
612
  }
678
-
679
613
  model.dragAction = {
680
614
  rangeZoom: model.rangeZoom,
681
615
  action: ACTIONS.adjustZoom
682
616
  };
683
617
  } else if (gaussian && xNormalizedAbs >= 0) {
684
- var invY = 1 - yNormalized;
685
- var actionName = null;
686
-
618
+ const invY = 1 - yNormalized;
619
+ let actionName = null;
687
620
  if (invY > gaussian.height + tolerance) {
688
621
  actionName = 'adjustPosition';
689
622
  } else if (invY > gaussian.height - tolerance) {
@@ -705,123 +638,94 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) {
705
638
  } else {
706
639
  actionName = 'adjustWidth';
707
640
  }
708
-
709
641
  model.canvas.style.cursor = ACTION_TO_CURSOR[actionName];
710
- var action = ACTIONS[actionName];
711
-
712
- var originalGaussian = _objectSpread({}, gaussian);
713
-
642
+ const action = ACTIONS[actionName];
643
+ const originalGaussian = {
644
+ ...gaussian
645
+ };
714
646
  model.dragAction = {
715
647
  originalXY: [xNormalized, yNormalized],
716
- action: action,
717
- gaussian: gaussian,
718
- originalGaussian: originalGaussian
648
+ action,
649
+ gaussian,
650
+ originalGaussian
719
651
  };
720
652
  }
721
-
722
653
  if (newActive !== model.activeGaussian) {
723
654
  model.activeGaussian = newActive;
724
655
  publicAPI.modified();
725
656
  }
726
-
727
657
  return true;
728
658
  };
729
-
730
- publicAPI.onDown = function (x, y) {
659
+ publicAPI.onDown = (x, y) => {
731
660
  if (!model.mouseIsDown) {
732
661
  publicAPI.invokeAnimation(true);
733
662
  }
734
-
735
663
  model.mouseIsDown = true;
736
- var xNormalized = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null)[0];
737
- var newSelected = findGaussian(xNormalized, model.gaussians);
664
+ const xNormalized = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null)[0];
665
+ const newSelected = findGaussian(xNormalized, model.gaussians);
738
666
  model.gaussianSide = 0;
739
- var gaussian = model.gaussians[newSelected];
740
-
667
+ const gaussian = model.gaussians[newSelected];
741
668
  if (gaussian) {
742
669
  model.gaussianSide = gaussian.position - xNormalized;
743
670
  }
744
-
745
671
  if (newSelected !== model.selectedGaussian && xNormalized > 0) {
746
672
  model.selectedGaussian = newSelected;
747
673
  publicAPI.modified();
748
674
  }
749
-
750
675
  return true;
751
676
  };
752
-
753
- publicAPI.onDrag = function (x, y) {
677
+ publicAPI.onDrag = (x, y) => {
754
678
  if (model.dragAction) {
755
- var _normalizeCoordinates7 = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null),
756
- _normalizeCoordinates8 = _slicedToArray(_normalizeCoordinates7, 2),
757
- xNormalized = _normalizeCoordinates8[0],
758
- yNormalized = _normalizeCoordinates8[1];
759
-
760
- var action = model.dragAction.action;
761
-
762
- if (action(xNormalized, yNormalized, _objectSpread({
679
+ const [xNormalized, yNormalized] = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null);
680
+ const {
681
+ action
682
+ } = model.dragAction;
683
+ if (action(xNormalized, yNormalized, {
763
684
  gaussianSide: model.gaussianSide,
764
- model: model,
765
- publicAPI: publicAPI
766
- }, model.dragAction))) {
685
+ model,
686
+ publicAPI,
687
+ ...model.dragAction
688
+ })) {
767
689
  model.opacities = computeOpacities(model.gaussians, model.piecewiseSize);
768
690
  publicAPI.invokeOpacityChange(publicAPI, true);
769
691
  }
770
-
771
692
  publicAPI.modified();
772
693
  }
773
-
774
694
  return true;
775
695
  };
776
-
777
- publicAPI.onUp = function (x, y) {
696
+ publicAPI.onUp = (x, y) => {
778
697
  if (model.mouseIsDown) {
779
698
  publicAPI.invokeAnimation(false);
780
699
  }
781
-
782
700
  model.mouseIsDown = false;
783
701
  return true;
784
702
  };
785
-
786
- publicAPI.onLeave = function (x, y) {
703
+ publicAPI.onLeave = (x, y) => {
787
704
  publicAPI.onUp(x, y);
788
705
  model.canvas.style.cursor = 'default';
789
706
  model.activeGaussian = -1;
790
707
  publicAPI.modified();
791
708
  return true;
792
709
  };
793
-
794
- publicAPI.onAddGaussian = function (x, y) {
795
- var _normalizeCoordinates9 = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null),
796
- _normalizeCoordinates10 = _slicedToArray(_normalizeCoordinates9, 2),
797
- xNormalized = _normalizeCoordinates10[0],
798
- yNormalized = _normalizeCoordinates10[1];
799
-
710
+ publicAPI.onAddGaussian = (x, y) => {
711
+ const [xNormalized, yNormalized] = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null);
800
712
  if (xNormalized >= 0) {
801
713
  publicAPI.addGaussian(xNormalized, 1 - yNormalized, 0.1, 0, 0);
802
714
  }
803
-
804
715
  return true;
805
716
  };
806
-
807
- publicAPI.onRemoveGaussian = function (x, y) {
808
- var xNormalized = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null)[0];
809
- var newSelected = findGaussian(xNormalized, model.gaussians);
810
-
717
+ publicAPI.onRemoveGaussian = (x, y) => {
718
+ const xNormalized = normalizeCoordinates(x, y, model.graphArea, model.enableRangeZoom ? model.rangeZoom : null)[0];
719
+ const newSelected = findGaussian(xNormalized, model.gaussians);
811
720
  if (xNormalized >= 0 && newSelected !== -1) {
812
721
  publicAPI.removeGaussian(newSelected);
813
722
  }
814
-
815
723
  return true;
816
724
  };
817
-
818
- publicAPI.bindMouseListeners = function () {
725
+ publicAPI.bindMouseListeners = () => {
819
726
  if (!model.listeners) {
820
- var isDown = function isDown() {
821
- return !!model.mouseIsDown;
822
- };
823
-
824
- var touchId = createTouchClickListener({
727
+ const isDown = () => !!model.mouseIsDown;
728
+ const touchId = createTouchClickListener({
825
729
  clicks: 1,
826
730
  touches: 1,
827
731
  action: publicAPI.onClick
@@ -845,52 +749,44 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) {
845
749
  touchstart: createTouchListener(touchId, macro.chain(publicAPI.onHover, publicAPI.onDown)),
846
750
  touchmove: listenerSelector(isDown, createTouchListener(touchId, publicAPI.onDrag), createTouchListener(touchId, publicAPI.onHover)),
847
751
  touchend: createTouchListener(touchId, publicAPI.onUp, 0) // touchend have 0 touch event...
848
-
849
752
  };
850
- Object.keys(model.listeners).forEach(function (eventType) {
753
+
754
+ Object.keys(model.listeners).forEach(eventType => {
851
755
  model.canvas.addEventListener(eventType, model.listeners[eventType], false);
852
756
  });
853
757
  }
854
758
  };
855
-
856
- publicAPI.unbindMouseListeners = function () {
759
+ publicAPI.unbindMouseListeners = () => {
857
760
  if (model.listeners) {
858
- Object.keys(model.listeners).forEach(function (eventType) {
761
+ Object.keys(model.listeners).forEach(eventType => {
859
762
  model.canvas.removeEventListener(eventType, model.listeners[eventType]);
860
763
  });
861
764
  delete model.listeners;
862
765
  }
863
766
  };
864
-
865
- publicAPI.render = function () {
866
- var ctx = model.canvas.getContext('2d');
767
+ publicAPI.render = () => {
768
+ const ctx = model.canvas.getContext('2d');
867
769
  ctx.imageSmoothingEnabled = true;
868
-
869
- var _model$size = _slicedToArray(model.size, 2),
870
- width = _model$size[0],
871
- height = _model$size[1];
872
-
873
- var offset = model.style.padding;
874
- var graphArea = [Math.floor(model.style.iconSize + offset), Math.floor(offset), Math.ceil(width - 2 * offset - model.style.iconSize), Math.ceil(height - 2 * offset)];
875
- var zoomControlHeight = model.style.zoomControlHeight;
876
-
770
+ const [width, height] = model.size;
771
+ const offset = model.style.padding;
772
+ const graphArea = [Math.floor(model.style.iconSize + offset), Math.floor(offset), Math.ceil(width - 2 * offset - model.style.iconSize), Math.ceil(height - 2 * offset)];
773
+ const zoomControlHeight = model.style.zoomControlHeight;
877
774
  if (model.enableRangeZoom) {
878
775
  graphArea[1] += Math.floor(zoomControlHeight);
879
776
  graphArea[3] -= Math.floor(zoomControlHeight);
880
777
  }
778
+ model.graphArea = graphArea;
881
779
 
882
- model.graphArea = graphArea; // Clear canvas
883
-
780
+ // Clear canvas
884
781
  ctx.clearRect(0, 0, width, height);
885
782
  ctx.lineJoin = 'round';
886
783
  ctx.fillStyle = model.style.backgroundColor;
887
- ctx.fillRect.apply(ctx, graphArea);
888
-
784
+ ctx.fillRect(...graphArea);
889
785
  if (model.style.iconSize > 1) {
890
786
  // Draw icons
891
787
  // +
892
- var halfSize = Math.round(model.style.iconSize / 2 - model.style.strokeWidth);
893
- var center = Math.round(halfSize + offset + model.style.strokeWidth);
788
+ const halfSize = Math.round(model.style.iconSize / 2 - model.style.strokeWidth);
789
+ const center = Math.round(halfSize + offset + model.style.strokeWidth);
894
790
  ctx.beginPath();
895
791
  ctx.lineWidth = model.style.buttonStrokeWidth;
896
792
  ctx.strokeStyle = model.style.buttonStrokeColor;
@@ -903,8 +799,9 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) {
903
799
  ctx.stroke();
904
800
  ctx.moveTo(center - offset / 2, center - halfSize + model.style.strokeWidth + 2);
905
801
  ctx.lineTo(center - offset / 2, center + halfSize - model.style.strokeWidth - 2);
906
- ctx.stroke(); // -
802
+ ctx.stroke();
907
803
 
804
+ // -
908
805
  if (model.selectedGaussian === -1) {
909
806
  ctx.fillStyle = model.style.buttonDisableFillColor;
910
807
  ctx.lineWidth = model.style.buttonDisableStrokeWidth;
@@ -914,7 +811,6 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) {
914
811
  ctx.lineWidth = model.style.buttonStrokeWidth;
915
812
  ctx.strokeStyle = model.style.buttonStrokeColor;
916
813
  }
917
-
918
814
  ctx.beginPath();
919
815
  ctx.arc(center - offset / 2, center + offset / 2 + model.style.iconSize, halfSize, 0, 2 * Math.PI, false);
920
816
  ctx.fill();
@@ -922,45 +818,44 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) {
922
818
  ctx.moveTo(center - halfSize + model.style.strokeWidth + 2 - offset / 2, center + offset / 2 + model.style.iconSize);
923
819
  ctx.lineTo(center + halfSize - model.style.strokeWidth - 2 - offset / 2, center + offset / 2 + model.style.iconSize);
924
820
  ctx.stroke();
925
- } // Draw histogram
926
-
821
+ }
927
822
 
823
+ // Draw histogram
928
824
  if (model.histogram) {
929
825
  drawChart(ctx, graphArea, rescaleArray(model.histogram, model.rangeZoom), {
930
826
  lineWidth: 1,
931
827
  strokeStyle: model.style.histogramColor,
932
828
  fillStyle: model.style.histogramColor
933
829
  });
934
- } // Draw gaussians
935
-
830
+ }
936
831
 
832
+ // Draw gaussians
937
833
  drawChart(ctx, graphArea, rescaleArray(model.opacities, model.enableRangeZoom && model.rangeZoom), {
938
834
  lineWidth: model.style.strokeWidth,
939
835
  strokeStyle: model.style.strokeColor
940
- }); // Draw color function if any
836
+ });
941
837
 
838
+ // Draw color function if any
942
839
  if (model.colorTransferFunction && model.colorTransferFunction.getSize()) {
943
- var rangeToUse = model.dataRange || model.colorTransferFunction.getMappingRange();
944
-
840
+ const rangeToUse = model.dataRange || model.colorTransferFunction.getMappingRange();
945
841
  if (!model.colorCanvas || model.colorCanvasMTime !== model.colorTransferFunction.getMTime()) {
946
842
  model.colorCanvasMTime = model.colorTransferFunction.getMTime();
947
843
  model.colorCanvas = updateColorCanvas(model.colorTransferFunction, graphArea[2], rangeToUse, model.colorCanvas);
948
844
  }
949
-
950
845
  ctx.save();
951
846
  drawChart(ctx, graphArea, rescaleArray(model.opacities, model.enableRangeZoom && model.rangeZoom), {
952
847
  lineWidth: 1,
953
848
  strokeStyle: 'rgba(0,0,0,0)',
954
849
  fillStyle: 'rgba(0,0,0,1)',
955
850
  clip: true
956
- }); // Draw the correct portion of the color BG image
851
+ });
957
852
 
853
+ // Draw the correct portion of the color BG image
958
854
  if (model.enableRangeZoom) {
959
855
  ctx.drawImage(model.colorCanvas, model.rangeZoom[0] * graphArea[2], 0, graphArea[2], graphArea[3], graphArea[0], graphArea[1], graphArea[2] / (model.rangeZoom[1] - model.rangeZoom[0]), graphArea[3]);
960
856
  } else {
961
857
  ctx.drawImage(model.colorCanvas, graphArea[0], graphArea[1]);
962
858
  }
963
-
964
859
  ctx.restore();
965
860
  } else if (model.backgroundImage) {
966
861
  model.colorCanvas = updateColorCanvasFromImage(model.backgroundImage, graphArea[2], model.colorCanvas);
@@ -973,144 +868,124 @@ function vtkPiecewiseGaussianWidget(publicAPI, model) {
973
868
  });
974
869
  ctx.drawImage(model.colorCanvas, graphArea[0], graphArea[1]);
975
870
  ctx.restore();
976
- } // Draw zoomed area
977
-
871
+ }
978
872
 
873
+ // Draw zoomed area
979
874
  if (model.enableRangeZoom) {
980
875
  ctx.fillStyle = model.style.zoomControlColor;
981
876
  ctx.beginPath();
982
877
  ctx.rect(graphArea[0] + model.rangeZoom[0] * graphArea[2], 0, (model.rangeZoom[1] - model.rangeZoom[0]) * graphArea[2], zoomControlHeight);
983
878
  ctx.fill();
984
- } // Draw active gaussian
985
-
986
-
987
- var activeGaussian = model.gaussians[model.activeGaussian] || model.gaussians[model.selectedGaussian];
879
+ }
988
880
 
881
+ // Draw active gaussian
882
+ const activeGaussian = model.gaussians[model.activeGaussian] || model.gaussians[model.selectedGaussian];
989
883
  if (activeGaussian) {
990
- var activeOpacities = computeOpacities([activeGaussian], graphArea[2]);
884
+ const activeOpacities = computeOpacities([activeGaussian], graphArea[2]);
991
885
  drawChart(ctx, graphArea, rescaleArray(activeOpacities, model.enableRangeZoom && model.rangeZoom), {
992
886
  lineWidth: model.style.activeStrokeWidth,
993
887
  strokeStyle: model.style.activeColor
994
- }); // Draw controls
995
-
996
- var xCenter = graphArea[0] + rescaleValue(activeGaussian.position, model.enableRangeZoom && model.rangeZoom) * graphArea[2];
997
- var yTop = graphArea[1] + (1 - activeGaussian.height) * graphArea[3];
998
- var yMiddle = graphArea[1] + (1 - 0.5 * activeGaussian.height) * graphArea[3];
999
- var yBottom = graphArea[1] + graphArea[3];
1000
- var widthInPixel = activeGaussian.width * graphArea[2];
1001
-
888
+ });
889
+ // Draw controls
890
+ const xCenter = graphArea[0] + rescaleValue(activeGaussian.position, model.enableRangeZoom && model.rangeZoom) * graphArea[2];
891
+ const yTop = graphArea[1] + (1 - activeGaussian.height) * graphArea[3];
892
+ const yMiddle = graphArea[1] + (1 - 0.5 * activeGaussian.height) * graphArea[3];
893
+ const yBottom = graphArea[1] + graphArea[3];
894
+ let widthInPixel = activeGaussian.width * graphArea[2];
1002
895
  if (model.enableRangeZoom) {
1003
896
  widthInPixel /= model.rangeZoom[1] - model.rangeZoom[0];
1004
897
  }
1005
-
1006
898
  ctx.lineWidth = model.style.handleWidth;
1007
899
  ctx.strokeStyle = model.style.handleColor;
1008
900
  ctx.fillStyle = model.style.backgroundColor;
1009
901
  ctx.beginPath();
1010
902
  ctx.moveTo(xCenter, graphArea[1] + (1 - activeGaussian.height) * graphArea[3]);
1011
903
  ctx.lineTo(xCenter, graphArea[1] + graphArea[3]);
1012
- ctx.stroke(); // Height
1013
-
904
+ ctx.stroke();
905
+ // Height
1014
906
  ctx.beginPath();
1015
907
  ctx.arc(xCenter, yTop, 6, 0, 2 * Math.PI);
1016
908
  ctx.fill();
1017
- ctx.stroke(); // Bias
1018
-
1019
- var radius = Math.min(widthInPixel * 0.1, activeGaussian.height * graphArea[3] * 0.2);
909
+ ctx.stroke();
910
+ // Bias
911
+ const radius = Math.min(widthInPixel * 0.1, activeGaussian.height * graphArea[3] * 0.2);
1020
912
  ctx.beginPath();
1021
913
  ctx.rect(xCenter - radius, yMiddle - radius, radius * 2, radius * 2);
1022
914
  ctx.fill();
1023
915
  ctx.stroke();
1024
- ctx.beginPath(); // Width
1025
-
1026
- var sliderWidth = widthInPixel * 0.8;
916
+ ctx.beginPath();
917
+ // Width
918
+ const sliderWidth = widthInPixel * 0.8;
1027
919
  ctx.rect(xCenter - sliderWidth, yBottom - 5, 2 * sliderWidth, 10);
1028
920
  ctx.fill();
1029
921
  ctx.stroke();
1030
922
  }
1031
923
  };
1032
-
1033
- publicAPI.getOpacityNodes = function (dataRange) {
1034
- var rangeToUse = dataRange || model.dataRange;
1035
- var delta = (rangeToUse[1] - rangeToUse[0]) / (model.opacities.length - 1);
1036
- var nodes = [];
1037
- var midpoint = 0.5;
1038
- var sharpness = 0;
1039
-
1040
- for (var index = 0; index < model.opacities.length; index++) {
1041
- var x = rangeToUse[0] + delta * index;
1042
- var y = model.opacities[index];
924
+ publicAPI.getOpacityNodes = dataRange => {
925
+ const rangeToUse = dataRange || model.dataRange;
926
+ const delta = (rangeToUse[1] - rangeToUse[0]) / (model.opacities.length - 1);
927
+ const nodes = [];
928
+ const midpoint = 0.5;
929
+ const sharpness = 0;
930
+ for (let index = 0; index < model.opacities.length; index++) {
931
+ const x = rangeToUse[0] + delta * index;
932
+ const y = model.opacities[index];
1043
933
  nodes.push({
1044
- x: x,
1045
- y: y,
1046
- midpoint: midpoint,
1047
- sharpness: sharpness
934
+ x,
935
+ y,
936
+ midpoint,
937
+ sharpness
1048
938
  });
1049
939
  }
1050
-
1051
940
  return nodes;
1052
941
  };
1053
-
1054
- publicAPI.applyOpacity = function (piecewiseFunction, dataRange) {
1055
- var nodes = publicAPI.getOpacityNodes(dataRange);
942
+ publicAPI.applyOpacity = (piecewiseFunction, dataRange) => {
943
+ const nodes = publicAPI.getOpacityNodes(dataRange);
1056
944
  piecewiseFunction.setNodes(nodes);
1057
945
  };
1058
-
1059
- publicAPI.getOpacityRange = function (dataRange) {
1060
- var rangeToUse = dataRange || model.dataRange;
1061
- var delta = (rangeToUse[1] - rangeToUse[0]) / (model.opacities.length - 1);
1062
- var minIndex = model.opacities.length - 1;
1063
- var maxIndex = 0;
1064
-
1065
- for (var index = 0; index < model.opacities.length; index++) {
946
+ publicAPI.getOpacityRange = dataRange => {
947
+ const rangeToUse = dataRange || model.dataRange;
948
+ const delta = (rangeToUse[1] - rangeToUse[0]) / (model.opacities.length - 1);
949
+ let minIndex = model.opacities.length - 1;
950
+ let maxIndex = 0;
951
+ for (let index = 0; index < model.opacities.length; index++) {
1066
952
  if (model.opacities[index] > 0) {
1067
953
  minIndex = Math.min(minIndex, index);
1068
954
  }
1069
-
1070
955
  if (model.opacities[index] > 0) {
1071
956
  maxIndex = Math.max(maxIndex, index);
1072
957
  }
1073
958
  }
1074
-
1075
959
  return [rangeToUse[0] + minIndex * delta, rangeToUse[0] + maxIndex * delta];
1076
960
  };
1077
-
1078
- var enableZoom = publicAPI.setEnableRangeZoom;
1079
-
1080
- publicAPI.setEnableRangeZoom = function (v) {
1081
- var change = enableZoom(v);
1082
-
961
+ const enableZoom = publicAPI.setEnableRangeZoom;
962
+ publicAPI.setEnableRangeZoom = v => {
963
+ const change = enableZoom(v);
1083
964
  if (change) {
1084
965
  model.colorCanvasMTime = 0;
1085
966
  model.rangeZoom = [0, 1];
1086
967
  }
1087
-
1088
968
  return change;
1089
969
  };
1090
-
1091
- var rangeZoom = publicAPI.setRangeZoom;
1092
-
970
+ const rangeZoom = publicAPI.setRangeZoom;
1093
971
  publicAPI.setRangeZoom = function () {
1094
- var change = rangeZoom.apply(void 0, arguments);
1095
-
972
+ const change = rangeZoom(...arguments);
1096
973
  if (change) {
1097
974
  model.colorCanvasMTime = 0;
1098
975
  }
1099
-
1100
976
  return change;
1101
- }; // Trigger rendering for any modified event
977
+ };
1102
978
 
979
+ // Trigger rendering for any modified event
980
+ publicAPI.onModified(() => publicAPI.render());
981
+ publicAPI.setSize(...model.size);
982
+ }
1103
983
 
1104
- publicAPI.onModified(function () {
1105
- return publicAPI.render();
1106
- });
1107
- publicAPI.setSize.apply(publicAPI, _toConsumableArray(model.size));
1108
- } // ----------------------------------------------------------------------------
984
+ // ----------------------------------------------------------------------------
1109
985
  // Object factory
1110
986
  // ----------------------------------------------------------------------------
1111
987
 
1112
-
1113
- var DEFAULT_VALUES = {
988
+ const DEFAULT_VALUES = {
1114
989
  histogram: [],
1115
990
  numberOfBins: 256,
1116
991
  histogramArray: null,
@@ -1144,29 +1019,37 @@ var DEFAULT_VALUES = {
1144
1019
  selectedGaussian: -1,
1145
1020
  enableRangeZoom: true,
1146
1021
  rangeZoom: [0, 1] // normalized value
1022
+ };
1147
1023
 
1148
- }; // ----------------------------------------------------------------------------
1024
+ // ----------------------------------------------------------------------------
1149
1025
 
1150
1026
  function extend(publicAPI, model) {
1151
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1152
- Object.assign(model, DEFAULT_VALUES, initialValues); // Object methods
1027
+ let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1028
+ Object.assign(model, DEFAULT_VALUES, initialValues);
1153
1029
 
1030
+ // Object methods
1154
1031
  macro.obj(publicAPI, model);
1155
1032
  macro.setGet(publicAPI, model, ['piecewiseSize', 'numberOfBins', 'colorTransferFunction', 'backgroundImage', 'enableRangeZoom', 'gaussianMinimumHeight']);
1156
1033
  macro.setGetArray(publicAPI, model, ['rangeZoom'], 2);
1157
1034
  macro.get(publicAPI, model, ['size', 'canvas', 'gaussians']);
1158
1035
  macro.event(publicAPI, model, 'opacityChange');
1159
1036
  macro.event(publicAPI, model, 'animation');
1160
- macro.event(publicAPI, model, 'zoomChange'); // Object specific methods
1037
+ macro.event(publicAPI, model, 'zoomChange');
1161
1038
 
1039
+ // Object specific methods
1162
1040
  vtkPiecewiseGaussianWidget(publicAPI, model);
1163
- } // ----------------------------------------------------------------------------
1041
+ }
1042
+
1043
+ // ----------------------------------------------------------------------------
1164
1044
 
1165
- var newInstance = macro.newInstance(extend, 'vtkPiecewiseGaussianWidget'); // ----------------------------------------------------------------------------
1045
+ const newInstance = macro.newInstance(extend, 'vtkPiecewiseGaussianWidget');
1166
1046
 
1167
- var vtkPiecewiseGaussianWidget$1 = _objectSpread({
1168
- newInstance: newInstance,
1169
- extend: extend
1170
- }, STATIC);
1047
+ // ----------------------------------------------------------------------------
1048
+
1049
+ var vtkPiecewiseGaussianWidget$1 = {
1050
+ newInstance,
1051
+ extend,
1052
+ ...STATIC
1053
+ };
1171
1054
 
1172
1055
  export { STATIC, vtkPiecewiseGaussianWidget$1 as default, extend, newInstance };