@kitware/vtk.js 28.10.1 → 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.
- package/Common/Core/Base64.js +53 -82
- package/Common/Core/CellArray.js +52 -60
- package/Common/Core/ClassHierarchy.js +8 -36
- package/Common/Core/DataArray/Constants.js +6 -6
- package/Common/Core/DataArray.js +185 -270
- package/Common/Core/Endian.js +14 -17
- package/Common/Core/HalfFloat.js +17 -34
- package/Common/Core/ImageHelper.js +17 -25
- package/Common/Core/LookupTable.js +131 -144
- package/Common/Core/Math/Constants.js +8 -8
- package/Common/Core/Math/index.js +778 -903
- package/Common/Core/Math.d.ts +14 -0
- package/Common/Core/Math.js +2 -4
- package/Common/Core/MatrixBuilder.js +99 -151
- package/Common/Core/Points.js +43 -43
- package/Common/Core/PriorityQueue.js +30 -28
- package/Common/Core/ProgressHandler.js +31 -32
- package/Common/Core/ScalarsToColors/Constants.js +4 -4
- package/Common/Core/ScalarsToColors.js +196 -253
- package/Common/Core/StringArray.js +48 -73
- package/Common/Core/URLExtract.js +10 -29
- package/Common/Core/VariantArray.js +48 -73
- package/Common/Core.js +11 -11
- package/Common/DataModel/AbstractPointLocator.js +19 -17
- package/Common/DataModel/BoundingBox.js +322 -490
- package/Common/DataModel/Box.js +46 -63
- package/Common/DataModel/CardinalSpline1D.js +92 -102
- package/Common/DataModel/Cell.js +41 -61
- package/Common/DataModel/CellLinks.js +91 -127
- package/Common/DataModel/CellTypes/Constants.js +7 -6
- package/Common/DataModel/CellTypes.js +55 -74
- package/Common/DataModel/Collection.js +45 -61
- package/Common/DataModel/Cone.js +28 -20
- package/Common/DataModel/Cylinder.js +41 -35
- package/Common/DataModel/DataSet/Constants.js +11 -5
- package/Common/DataModel/DataSet.js +37 -25
- package/Common/DataModel/DataSetAttributes/Constants.js +18 -18
- package/Common/DataModel/DataSetAttributes/FieldData.js +103 -194
- package/Common/DataModel/DataSetAttributes.js +96 -138
- package/Common/DataModel/EdgeLocator.js +45 -70
- package/Common/DataModel/ITKHelper.js +67 -137
- package/Common/DataModel/ImageData.js +115 -172
- package/Common/DataModel/ImplicitBoolean/Constants.js +2 -2
- package/Common/DataModel/ImplicitBoolean.js +66 -96
- package/Common/DataModel/IncrementalOctreeNode.js +201 -231
- package/Common/DataModel/IncrementalOctreePointLocator.js +160 -198
- package/Common/DataModel/KochanekSpline1D.js +78 -81
- package/Common/DataModel/Line/Constants.js +2 -2
- package/Common/DataModel/Line.js +82 -105
- package/Common/DataModel/Locator.js +17 -10
- package/Common/DataModel/Molecule.js +26 -17
- package/Common/DataModel/PiecewiseFunction.js +218 -239
- package/Common/DataModel/Plane.js +90 -113
- package/Common/DataModel/PointSet.js +30 -26
- package/Common/DataModel/PolyData/Constants.js +2 -2
- package/Common/DataModel/PolyData.js +95 -120
- package/Common/DataModel/PolyLine.js +44 -61
- package/Common/DataModel/Polygon/Constants.js +4 -4
- package/Common/DataModel/Polygon.js +128 -169
- package/Common/DataModel/Quad/Constants.js +2 -2
- package/Common/DataModel/Quad.js +61 -100
- package/Common/DataModel/SelectionNode/Constants.js +5 -4
- package/Common/DataModel/SelectionNode.js +25 -21
- package/Common/DataModel/Sphere.js +40 -35
- package/Common/DataModel/Spline1D/Constants.js +3 -2
- package/Common/DataModel/Spline1D.js +34 -18
- package/Common/DataModel/Spline3D/Constants.js +2 -2
- package/Common/DataModel/Spline3D.js +46 -41
- package/Common/DataModel/StructuredData/Constants.js +2 -2
- package/Common/DataModel/StructuredData.js +9 -20
- package/Common/DataModel/Triangle.js +207 -250
- package/Common/DataModel.js +19 -19
- package/Common/System/MobileVR.js +56 -61
- package/Common/System/TimerLog.js +1 -1
- package/Common/System.js +2 -2
- package/Common/Transform/LandmarkTransform/Constants.js +2 -2
- package/Common/Transform/LandmarkTransform.js +133 -117
- package/Common/Transform/Transform.js +42 -57
- package/Common/Transform.js +2 -2
- package/Common/index.js +4 -4
- package/Filters/Core/Cutter.js +134 -146
- package/Filters/Core/PolyDataNormals.js +44 -50
- package/Filters/Core.js +2 -2
- package/Filters/Cornerstone/ImageDataToCornerstoneImage.js +45 -33
- package/Filters/Cornerstone.js +1 -1
- package/Filters/General/AppendPolyData.js +84 -100
- package/Filters/General/Calculator.js +95 -163
- package/Filters/General/ClipClosedSurface/Constants.js +2 -2
- package/Filters/General/ClipClosedSurface.js +341 -416
- package/Filters/General/ClosedPolyLineToSurfaceFilter.js +141 -156
- package/Filters/General/ContourTriangulator/Constants.js +2 -2
- package/Filters/General/ContourTriangulator/helper.js +684 -812
- package/Filters/General/ContourTriangulator.js +92 -89
- package/Filters/General/ImageCropFilter.js +77 -78
- package/Filters/General/ImageDataOutlineFilter.js +42 -36
- package/Filters/General/ImageMarchingCubes/caseTable.js +9 -521
- package/Filters/General/ImageMarchingCubes.js +99 -112
- package/Filters/General/ImageMarchingSquares/caseTable.js +9 -41
- package/Filters/General/ImageMarchingSquares.js +93 -118
- package/Filters/General/ImageOutlineFilter.js +53 -54
- package/Filters/General/ImageSliceFilter.js +39 -30
- package/Filters/General/ImageStreamline.js +107 -124
- package/Filters/General/LineFilter.js +26 -15
- package/Filters/General/MoleculeToRepresentation.js +136 -149
- package/Filters/General/OBBTree/OBBNode.js +36 -34
- package/Filters/General/OBBTree/helper.js +19 -24
- package/Filters/General/OBBTree.js +396 -488
- package/Filters/General/OutlineFilter.js +52 -34
- package/Filters/General/PaintFilter/PaintFilter.worker.js +93 -130
- package/Filters/General/PaintFilter.js +150 -162
- package/Filters/General/ScalarToRGBA.js +38 -33
- package/Filters/General/TriangleFilter.js +65 -62
- package/Filters/General/TubeFilter/Constants.js +4 -4
- package/Filters/General/TubeFilter.js +376 -496
- package/Filters/General/WarpScalar.js +58 -60
- package/Filters/General/WindowedSincPolyDataFilter.js +258 -330
- package/Filters/General.js +21 -21
- package/Filters/Sources/Arrow2DSource/Constants.js +2 -2
- package/Filters/Sources/Arrow2DSource.js +56 -56
- package/Filters/Sources/ArrowSource.js +39 -29
- package/Filters/Sources/CircleSource.js +43 -43
- package/Filters/Sources/ConcentricCylinderSource.js +151 -174
- package/Filters/Sources/ConeSource.js +51 -42
- package/Filters/Sources/CubeSource.js +75 -96
- package/Filters/Sources/Cursor3D.js +94 -109
- package/Filters/Sources/CylinderSource.js +90 -90
- package/Filters/Sources/ImageGridSource.js +43 -43
- package/Filters/Sources/LineSource.js +49 -39
- package/Filters/Sources/PlaneSource.js +97 -104
- package/Filters/Sources/PointSource.js +46 -37
- package/Filters/Sources/RTAnalyticSource.js +50 -48
- package/Filters/Sources/SLICSource.js +63 -73
- package/Filters/Sources/SphereSource.js +88 -78
- package/Filters/Sources/ViewFinderSource.js +26 -23
- package/Filters/Sources.js +14 -14
- package/Filters/Texture/TextureMapToPlane.js +95 -97
- package/Filters/Texture/TextureMapToSphere.js +46 -54
- package/Filters/Texture.js +2 -2
- package/Filters/index.js +5 -5
- package/IO/Core/BinaryHelper.js +12 -18
- package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +43 -59
- package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +76 -113
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +62 -112
- package/IO/Core/DataAccessHelper/LiteHttpDataAccessHelper.js +76 -113
- package/IO/Core/DataAccessHelper.js +6 -6
- package/IO/Core/HttpDataSetReader.js +136 -139
- package/IO/Core/HttpDataSetSeriesReader.js +64 -75
- package/IO/Core/HttpSceneLoader.js +130 -179
- package/IO/Core/ImageStream/DefaultProtocol.js +29 -43
- package/IO/Core/ImageStream/ViewStream.js +100 -103
- package/IO/Core/ImageStream.js +62 -54
- package/IO/Core/ResourceLoader.js +10 -9
- package/IO/Core/Serializer/ArraySerializer.js +40 -40
- package/IO/Core/Serializer/FieldDataSerializer.js +18 -28
- package/IO/Core/Serializer/ImageDataSerializer.js +22 -23
- package/IO/Core/Serializer/PolyDataSerializer.js +17 -21
- package/IO/Core/Serializer.js +6 -13
- package/IO/Core/WSLinkClient.js +90 -76
- package/IO/Core/ZipMultiDataSetReader.js +46 -44
- package/IO/Core/ZipMultiDataSetWriter.js +43 -34
- package/IO/Core.js +7 -7
- package/IO/Geometry/DracoReader.js +118 -121
- package/IO/Geometry/PLYReader.js +163 -223
- package/IO/Geometry/PLYWriter/Constants.js +5 -5
- package/IO/Geometry/PLYWriter.js +139 -154
- package/IO/Geometry/STLReader.js +123 -146
- package/IO/Geometry/STLWriter/Constants.js +2 -2
- package/IO/Geometry/STLWriter.js +83 -82
- package/IO/Geometry.js +5 -5
- package/IO/Legacy/LegacyAsciiParser.js +78 -139
- package/IO/Legacy/PolyDataReader.js +48 -36
- package/IO/Legacy.js +2 -2
- package/IO/Misc/ElevationReader.js +67 -60
- package/IO/Misc/HttpDataSetLODsLoader.js +41 -38
- package/IO/Misc/ITKImageReader.js +58 -45
- package/IO/Misc/ITKPolyDataReader.js +50 -38
- package/IO/Misc/JSONNucleoReader.js +49 -42
- package/IO/Misc/JSONReader.js +38 -33
- package/IO/Misc/MTLReader.js +74 -119
- package/IO/Misc/OBJReader.js +153 -206
- package/IO/Misc/PDBReader.js +70 -68
- package/IO/Misc/SkyboxReader.js +77 -82
- package/IO/Misc.js +9 -9
- package/IO/XML/XMLImageDataReader.js +36 -38
- package/IO/XML/XMLImageDataWriter.js +28 -21
- package/IO/XML/XMLPolyDataReader.js +49 -46
- package/IO/XML/XMLPolyDataWriter.js +43 -42
- package/IO/XML/XMLReader.js +262 -304
- package/IO/XML/XMLWriter/Constants.js +3 -3
- package/IO/XML/XMLWriter.js +70 -84
- package/IO/XML.js +6 -6
- package/IO/index.js +5 -5
- package/Imaging/Core/AbstractImageInterpolator/Constants.js +4 -4
- package/Imaging/Core/AbstractImageInterpolator/InterpolationInfo.js +30 -27
- package/Imaging/Core/AbstractImageInterpolator.js +74 -87
- package/Imaging/Core/ImageInterpolator.js +201 -252
- package/Imaging/Core/ImagePointDataIterator.js +96 -122
- package/Imaging/Core/ImageReslice/Constants.js +2 -2
- package/Imaging/Core/ImageReslice.js +327 -464
- package/Imaging/Core.js +4 -4
- package/Imaging/Hybrid/SampleFunction.js +58 -51
- package/Imaging/Hybrid.js +1 -1
- package/Imaging/index.js +2 -2
- package/Interaction/Animations/TimeStepBasedAnimationHandler.js +39 -54
- package/Interaction/Manipulators/CompositeCameraManipulator.js +22 -13
- package/Interaction/Manipulators/CompositeGestureManipulator.js +31 -43
- package/Interaction/Manipulators/CompositeKeyboardManipulator.js +15 -11
- package/Interaction/Manipulators/CompositeMouseManipulator.js +27 -33
- package/Interaction/Manipulators/CompositeVRManipulator.js +22 -15
- package/Interaction/Manipulators/GestureCameraManipulator.js +54 -36
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +95 -97
- package/Interaction/Manipulators/MouseBoxSelectorManipulator.js +70 -89
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +67 -54
- package/Interaction/Manipulators/MouseCameraSliceManipulator.js +40 -38
- package/Interaction/Manipulators/MouseCameraTrackballFirstPersonManipulator.js +83 -68
- package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.js +32 -28
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +47 -40
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +55 -43
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +56 -46
- package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.js +41 -46
- package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.js +29 -27
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +123 -146
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +144 -166
- package/Interaction/Manipulators/MouseRangeManipulator.js +127 -132
- package/Interaction/Manipulators/VRButtonPanManipulator.js +33 -23
- package/Interaction/Manipulators.js +21 -21
- package/Interaction/Misc/DeviceOrientationToCamera.js +25 -47
- package/Interaction/Misc.js +1 -1
- package/Interaction/Style/InteractorStyleImage.js +101 -121
- package/Interaction/Style/InteractorStyleMPRSlice.js +111 -128
- package/Interaction/Style/InteractorStyleManipulator/Presets.js +9 -17
- package/Interaction/Style/InteractorStyleManipulator.js +254 -329
- package/Interaction/Style/InteractorStyleRemoteMouse.js +195 -180
- package/Interaction/Style/InteractorStyleTrackballCamera.js +154 -157
- package/Interaction/Style/InteractorStyleUnicam.js +30 -38
- package/Interaction/Style.js +5 -5
- package/Interaction/UI/CornerAnnotation/CornerAnnotation.module.css.js +1 -1
- package/Interaction/UI/CornerAnnotation.js +65 -48
- package/Interaction/UI/FPSMonitor.js +104 -105
- package/Interaction/UI/Icons.js +1 -1
- package/Interaction/UI/Slider/Constants.js +2 -2
- package/Interaction/UI/Slider.js +78 -95
- package/Interaction/UI/VolumeController.js +104 -97
- package/Interaction/UI.js +5 -5
- package/Interaction/Widgets/OrientationMarkerWidget/Constants.js +2 -2
- package/Interaction/Widgets/OrientationMarkerWidget.js +90 -135
- package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +381 -498
- package/Interaction/Widgets.js +2 -2
- package/Interaction/index.js +5 -5
- package/Proxy/Animation/AbstractAnimationProxy.js +22 -15
- package/Proxy/Animation/AnimationProxyManager.js +43 -51
- package/Proxy/Animation/TimeStepBasedAnimationHandlerProxy.js +26 -19
- package/Proxy/Core/AbstractRepresentationProxy.js +97 -151
- package/Proxy/Core/LookupTableProxy/Constants.js +4 -4
- package/Proxy/Core/LookupTableProxy.js +49 -52
- package/Proxy/Core/PiecewiseFunctionProxy/Constants.js +4 -4
- package/Proxy/Core/PiecewiseFunctionProxy.js +63 -72
- package/Proxy/Core/ProxyManager/core.js +83 -106
- package/Proxy/Core/ProxyManager/properties.js +53 -76
- package/Proxy/Core/ProxyManager/state.js +100 -110
- package/Proxy/Core/ProxyManager/view.js +45 -55
- package/Proxy/Core/ProxyManager.js +16 -8
- package/Proxy/Core/SourceProxy.js +41 -38
- package/Proxy/Core/View2DProxy.js +143 -199
- package/Proxy/Core/ViewProxy.js +223 -269
- package/Proxy/Core.js +7 -7
- package/Proxy/Representations/GeometryRepresentationProxy.js +34 -20
- package/Proxy/Representations/GlyphRepresentationProxy.js +42 -41
- package/Proxy/Representations/MoleculeRepresentationProxy.js +32 -22
- package/Proxy/Representations/ResliceRepresentationProxy.js +48 -32
- package/Proxy/Representations/SkyboxRepresentationProxy.js +30 -29
- package/Proxy/Representations/SliceRepresentationProxy.js +93 -112
- package/Proxy/Representations/SlicedGeometryRepresentationProxy.js +46 -42
- package/Proxy/Representations/VolumeRepresentationProxy.js +108 -133
- package/Proxy/Representations.js +7 -7
- package/Proxy/index.js +2 -2
- package/Rendering/Core/AbstractImageMapper/helper.js +44 -49
- package/Rendering/Core/AbstractImageMapper.js +18 -19
- package/Rendering/Core/AbstractMapper.js +39 -55
- package/Rendering/Core/AbstractMapper3D.js +26 -31
- package/Rendering/Core/AbstractPicker.js +25 -21
- package/Rendering/Core/Actor.js +71 -93
- package/Rendering/Core/Actor2D.js +64 -78
- package/Rendering/Core/AnnotatedCubeActor/Presets.js +5 -11
- package/Rendering/Core/AnnotatedCubeActor.js +94 -79
- package/Rendering/Core/AxesActor.js +65 -87
- package/Rendering/Core/Camera.js +246 -271
- package/Rendering/Core/CellPicker.js +125 -148
- package/Rendering/Core/ColorTransferFunction/ColorMaps.js +20 -21
- package/Rendering/Core/ColorTransferFunction/ColorMapsLite.js +20 -21
- package/Rendering/Core/ColorTransferFunction/Constants.js +4 -4
- package/Rendering/Core/ColorTransferFunction.js +460 -546
- package/Rendering/Core/Coordinate/Constants.js +2 -2
- package/Rendering/Core/Coordinate.js +119 -198
- package/Rendering/Core/CubeAxesActor.js +294 -320
- package/Rendering/Core/Follower.js +46 -45
- package/Rendering/Core/Glyph3DMapper/Constants.js +4 -4
- package/Rendering/Core/Glyph3DMapper.js +96 -148
- package/Rendering/Core/HardwareSelector.js +36 -69
- package/Rendering/Core/ImageArrayMapper.js +87 -126
- package/Rendering/Core/ImageCPRMapper.js +134 -209
- package/Rendering/Core/ImageMapper/Constants.js +2 -2
- package/Rendering/Core/ImageMapper.js +92 -170
- package/Rendering/Core/ImageProperty/Constants.js +2 -2
- package/Rendering/Core/ImageProperty.js +66 -81
- package/Rendering/Core/ImageResliceMapper/Constants.js +2 -2
- package/Rendering/Core/ImageResliceMapper.js +36 -29
- package/Rendering/Core/ImageSlice.js +85 -127
- package/Rendering/Core/InteractorObserver.js +82 -73
- package/Rendering/Core/InteractorStyle/Constants.js +2 -2
- package/Rendering/Core/InteractorStyle.js +56 -58
- package/Rendering/Core/Light.js +43 -49
- package/Rendering/Core/Mapper/CoincidentTopologyHelper.js +37 -48
- package/Rendering/Core/Mapper/Constants.js +6 -6
- package/Rendering/Core/Mapper/Static.js +15 -12
- package/Rendering/Core/Mapper.js +194 -259
- package/Rendering/Core/Mapper2D.js +61 -100
- package/Rendering/Core/Picker.js +124 -143
- package/Rendering/Core/PixelSpaceCallbackMapper.js +40 -37
- package/Rendering/Core/PointPicker.js +68 -79
- package/Rendering/Core/Prop/Constants.js +2 -2
- package/Rendering/Core/Prop.js +58 -106
- package/Rendering/Core/Prop3D.js +54 -83
- package/Rendering/Core/Property/Constants.js +6 -6
- package/Rendering/Core/Property.js +45 -74
- package/Rendering/Core/Property2D/Constants.js +2 -2
- package/Rendering/Core/Property2D.js +33 -42
- package/Rendering/Core/RenderWindow.js +70 -82
- package/Rendering/Core/RenderWindowInteractor/Constants.js +7 -7
- package/Rendering/Core/RenderWindowInteractor.js +324 -439
- package/Rendering/Core/Renderer.js +193 -257
- package/Rendering/Core/ScalarBarActor.js +267 -272
- package/Rendering/Core/Skybox.js +26 -24
- package/Rendering/Core/SphereMapper.js +22 -12
- package/Rendering/Core/StickMapper.js +22 -12
- package/Rendering/Core/SurfaceLICInterface/Constants.js +6 -6
- package/Rendering/Core/SurfaceLICInterface.js +13 -9
- package/Rendering/Core/SurfaceLICMapper.js +23 -15
- package/Rendering/Core/Texture.js +99 -141
- package/Rendering/Core/Viewport.js +60 -88
- package/Rendering/Core/Volume.js +55 -77
- package/Rendering/Core/VolumeMapper/Constants.js +4 -4
- package/Rendering/Core/VolumeMapper.js +59 -91
- package/Rendering/Core/VolumeProperty/Constants.js +4 -4
- package/Rendering/Core/VolumeProperty.js +78 -115
- package/Rendering/Core.js +47 -49
- package/Rendering/Misc/CanvasView.js +62 -61
- package/Rendering/Misc/FullScreenRenderWindow.js +60 -62
- package/Rendering/Misc/GenericRenderWindow.js +48 -37
- package/Rendering/Misc/RemoteView.js +86 -80
- package/Rendering/Misc/RenderWindowWithControlBar.js +54 -48
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +43 -51
- package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +52 -82
- package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +258 -308
- package/Rendering/Misc/SynchronizableRenderWindow.js +133 -163
- package/Rendering/Misc/TextureLODsDownloader.js +72 -74
- package/Rendering/Misc.js +7 -7
- package/Rendering/OpenGL/Actor.js +57 -68
- package/Rendering/OpenGL/Actor2D.js +56 -56
- package/Rendering/OpenGL/BufferObject/Constants.js +2 -2
- package/Rendering/OpenGL/BufferObject.js +50 -65
- package/Rendering/OpenGL/Camera.js +35 -29
- package/Rendering/OpenGL/CellArrayBufferObject.js +119 -149
- package/Rendering/OpenGL/Convolution2DPass.js +87 -81
- package/Rendering/OpenGL/CubeAxesActor.js +28 -21
- package/Rendering/OpenGL/ForwardPass.js +53 -64
- package/Rendering/OpenGL/Framebuffer.js +61 -101
- package/Rendering/OpenGL/Glyph3DMapper.js +165 -196
- package/Rendering/OpenGL/HardwareSelector/Constants.js +2 -2
- package/Rendering/OpenGL/HardwareSelector.js +272 -397
- package/Rendering/OpenGL/Helper.js +58 -73
- package/Rendering/OpenGL/ImageCPRMapper.js +339 -421
- package/Rendering/OpenGL/ImageMapper.js +268 -361
- package/Rendering/OpenGL/ImageResliceMapper.js +306 -438
- package/Rendering/OpenGL/ImageSlice.js +48 -54
- package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +102 -84
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +43 -42
- package/Rendering/OpenGL/PolyDataMapper.js +358 -492
- package/Rendering/OpenGL/PolyDataMapper2D.js +153 -205
- package/Rendering/OpenGL/RadialDistortionPass.js +86 -89
- package/Rendering/OpenGL/RenderWindow/Constants.js +2 -2
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +20 -29
- package/Rendering/OpenGL/RenderWindow.js +356 -510
- package/Rendering/OpenGL/Renderer.js +77 -89
- package/Rendering/OpenGL/ReplacementShaderMapper.js +28 -46
- package/Rendering/OpenGL/ScalarBarActor.js +28 -21
- package/Rendering/OpenGL/Shader.js +37 -31
- package/Rendering/OpenGL/ShaderCache.js +67 -74
- package/Rendering/OpenGL/ShaderProgram.js +136 -248
- package/Rendering/OpenGL/Skybox.js +99 -60
- package/Rendering/OpenGL/SphereMapper.js +94 -108
- package/Rendering/OpenGL/StickMapper.js +110 -114
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +91 -157
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +142 -151
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +142 -216
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +79 -100
- package/Rendering/OpenGL/SurfaceLIC.js +2 -2
- package/Rendering/OpenGL/Texture/Constants.js +4 -4
- package/Rendering/OpenGL/Texture.js +444 -609
- package/Rendering/OpenGL/TextureUnitManager.js +47 -43
- package/Rendering/OpenGL/VertexArrayObject.js +92 -131
- package/Rendering/OpenGL/ViewNodeFactory.js +25 -13
- package/Rendering/OpenGL/Volume.js +38 -34
- package/Rendering/OpenGL/VolumeMapper.js +437 -547
- package/Rendering/OpenGL.js +28 -28
- package/Rendering/SceneGraph/RenderPass.js +34 -31
- package/Rendering/SceneGraph/RenderWindowViewNode.js +68 -94
- package/Rendering/SceneGraph/ViewNode.js +82 -111
- package/Rendering/SceneGraph/ViewNodeFactory.js +31 -26
- package/Rendering/SceneGraph.js +4 -4
- package/Rendering/WebGPU/Actor.js +49 -49
- package/Rendering/WebGPU/Actor2D.js +45 -44
- package/Rendering/WebGPU/BindGroup.js +43 -50
- package/Rendering/WebGPU/Buffer.js +41 -50
- package/Rendering/WebGPU/BufferManager/Constants.js +4 -4
- package/Rendering/WebGPU/BufferManager.js +111 -141
- package/Rendering/WebGPU/Camera.js +65 -67
- package/Rendering/WebGPU/CellArrayMapper.js +621 -388
- package/Rendering/WebGPU/CubeAxesActor.js +28 -19
- package/Rendering/WebGPU/Device.js +78 -133
- package/Rendering/WebGPU/ForwardPass.js +75 -72
- package/Rendering/WebGPU/FullScreenQuad.js +25 -18
- package/Rendering/WebGPU/Glyph3DMapper.js +62 -74
- package/Rendering/WebGPU/HardwareSelectionPass.js +45 -38
- package/Rendering/WebGPU/HardwareSelector.js +200 -276
- package/Rendering/WebGPU/ImageMapper.js +180 -171
- package/Rendering/WebGPU/ImageSlice.js +45 -44
- package/Rendering/WebGPU/IndexBuffer.js +166 -200
- package/Rendering/WebGPU/OpaquePass.js +37 -36
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +72 -45
- package/Rendering/WebGPU/Pipeline.js +37 -51
- package/Rendering/WebGPU/PixelSpaceCallbackMapper.js +27 -19
- package/Rendering/WebGPU/PolyDataMapper.js +50 -53
- package/Rendering/WebGPU/PolyDataMapper2D.js +39 -39
- package/Rendering/WebGPU/RenderEncoder.js +68 -88
- package/Rendering/WebGPU/RenderWindow.js +262 -376
- package/Rendering/WebGPU/Renderer.js +224 -208
- package/Rendering/WebGPU/Sampler.js +27 -21
- package/Rendering/WebGPU/ScalarBarActor.js +28 -19
- package/Rendering/WebGPU/ShaderCache.js +43 -41
- package/Rendering/WebGPU/ShaderDescription.js +52 -59
- package/Rendering/WebGPU/ShaderModule.js +26 -17
- package/Rendering/WebGPU/SimpleMapper.js +185 -121
- package/Rendering/WebGPU/SphereMapper.js +200 -130
- package/Rendering/WebGPU/StickMapper.js +289 -152
- package/Rendering/WebGPU/StorageBuffer.js +100 -115
- package/Rendering/WebGPU/Texture.js +79 -99
- package/Rendering/WebGPU/TextureManager.js +52 -54
- package/Rendering/WebGPU/TextureView.js +40 -43
- package/Rendering/WebGPU/Types.js +53 -70
- package/Rendering/WebGPU/UniformBuffer.js +158 -184
- package/Rendering/WebGPU/VertexInput.js +64 -90
- package/Rendering/WebGPU/ViewNodeFactory.js +25 -13
- package/Rendering/WebGPU/Volume.js +52 -51
- package/Rendering/WebGPU/VolumePass.js +218 -239
- package/Rendering/WebGPU/VolumePassFSQ.js +625 -306
- package/Rendering/WebGPU.js +1 -1
- package/Rendering/index.js +5 -5
- package/Widgets/Core/AbstractWidget/Constants.js +2 -2
- package/Widgets/Core/AbstractWidget.js +49 -58
- package/Widgets/Core/AbstractWidgetFactory.js +101 -122
- package/Widgets/Core/StateBuilder/boundsMixin.js +23 -28
- package/Widgets/Core/StateBuilder/color3Mixin.js +10 -7
- package/Widgets/Core/StateBuilder/colorMixin.js +10 -6
- package/Widgets/Core/StateBuilder/cornerMixin.js +16 -15
- package/Widgets/Core/StateBuilder/directionMixin.js +20 -18
- package/Widgets/Core/StateBuilder/manipulatorMixin.js +26 -18
- package/Widgets/Core/StateBuilder/nameMixin.js +10 -6
- package/Widgets/Core/StateBuilder/orientationMixin.js +19 -16
- package/Widgets/Core/StateBuilder/originMixin.js +25 -32
- package/Widgets/Core/StateBuilder/scale1Mixin.js +10 -6
- package/Widgets/Core/StateBuilder/scale3Mixin.js +10 -6
- package/Widgets/Core/StateBuilder/shapeMixin.js +12 -6
- package/Widgets/Core/StateBuilder/textMixin.js +10 -6
- package/Widgets/Core/StateBuilder/visibleMixin.js +10 -6
- package/Widgets/Core/StateBuilder.js +120 -149
- package/Widgets/Core/WidgetManager/Constants.js +7 -7
- package/Widgets/Core/WidgetManager.js +249 -421
- package/Widgets/Core/WidgetState.js +48 -57
- package/Widgets/Core.js +5 -5
- package/Widgets/Manipulators/AbstractManipulator.js +20 -14
- package/Widgets/Manipulators/CPRManipulator.js +55 -71
- package/Widgets/Manipulators/LineManipulator.js +31 -28
- package/Widgets/Manipulators/PickerManipulator.d.ts +48 -0
- package/Widgets/Manipulators/PickerManipulator.js +65 -0
- package/Widgets/Manipulators/PlaneManipulator.js +26 -23
- package/Widgets/Manipulators/TrackballManipulator.js +39 -35
- package/Widgets/Manipulators.js +4 -2
- package/Widgets/Representations/ArrowHandleRepresentation.js +148 -162
- package/Widgets/Representations/CircleContextRepresentation.js +44 -38
- package/Widgets/Representations/ContextRepresentation.js +17 -14
- package/Widgets/Representations/ConvexFaceContextRepresentation.js +50 -47
- package/Widgets/Representations/CroppingOutlineRepresentation.js +38 -27
- package/Widgets/Representations/CubeHandleRepresentation.js +21 -18
- package/Widgets/Representations/GlyphRepresentation.js +107 -152
- package/Widgets/Representations/HandleRepresentation.js +17 -14
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +97 -91
- package/Widgets/Representations/LineHandleRepresentation.js +44 -41
- package/Widgets/Representations/OutlineContextRepresentation.js +42 -36
- package/Widgets/Representations/PolyLineRepresentation.js +60 -75
- package/Widgets/Representations/RectangleContextRepresentation.js +42 -37
- package/Widgets/Representations/SphereContextRepresentation.js +19 -27
- package/Widgets/Representations/SphereHandleRepresentation.js +31 -27
- package/Widgets/Representations/SplineContextRepresentation.js +46 -70
- package/Widgets/Representations/WidgetRepresentation/Constants.js +2 -2
- package/Widgets/Representations/WidgetRepresentation.js +99 -134
- package/Widgets/Representations.js +13 -13
- package/Widgets/Widgets3D/AngleWidget/behavior.js +41 -63
- package/Widgets/Widgets3D/AngleWidget.js +41 -39
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +40 -61
- package/Widgets/Widgets3D/DistanceWidget.js +38 -36
- package/Widgets/Widgets3D/EllipseWidget/behavior.js +14 -19
- package/Widgets/Widgets3D/EllipseWidget/state.js +4 -2
- package/Widgets/Widgets3D/EllipseWidget.js +37 -26
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +26 -56
- package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +14 -17
- package/Widgets/Widgets3D/ImageCroppingWidget/state.js +20 -16
- package/Widgets/Widgets3D/ImageCroppingWidget.js +80 -98
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +55 -77
- package/Widgets/Widgets3D/InteractiveOrientationWidget/behavior.js +17 -18
- package/Widgets/Widgets3D/InteractiveOrientationWidget/state.js +15 -7
- package/Widgets/Widgets3D/InteractiveOrientationWidget.js +30 -29
- package/Widgets/Widgets3D/LabelWidget/behavior.js +37 -62
- package/Widgets/Widgets3D/LabelWidget.js +31 -25
- package/Widgets/Widgets3D/LineWidget/Constants.js +8 -8
- package/Widgets/Widgets3D/LineWidget/behavior.js +77 -114
- package/Widgets/Widgets3D/LineWidget/helpers.js +13 -20
- package/Widgets/Widgets3D/LineWidget/state.js +2 -1
- package/Widgets/Widgets3D/LineWidget.js +39 -35
- package/Widgets/Widgets3D/PaintWidget/behavior.js +24 -59
- package/Widgets/Widgets3D/PaintWidget.js +39 -37
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +44 -68
- package/Widgets/Widgets3D/PolyLineWidget.js +36 -31
- package/Widgets/Widgets3D/RectangleWidget/behavior.js +6 -11
- package/Widgets/Widgets3D/RectangleWidget/state.js +4 -2
- package/Widgets/Widgets3D/RectangleWidget.js +37 -25
- package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +35 -21
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +134 -210
- package/Widgets/Widgets3D/ResliceCursorWidget/cprBehavior.js +26 -41
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +90 -117
- package/Widgets/Widgets3D/ResliceCursorWidget/state.js +33 -40
- package/Widgets/Widgets3D/ResliceCursorWidget.js +186 -227
- package/Widgets/Widgets3D/SeedWidget/behavior.js +82 -0
- package/Widgets/Widgets3D/SeedWidget/state.js +18 -0
- package/Widgets/Widgets3D/SeedWidget.d.ts +44 -0
- package/Widgets/Widgets3D/SeedWidget.js +43 -0
- package/Widgets/Widgets3D/ShapeWidget/Constants.js +19 -19
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +150 -252
- package/Widgets/Widgets3D/ShapeWidget.js +24 -27
- package/Widgets/Widgets3D/SphereWidget/behavior.js +35 -69
- package/Widgets/Widgets3D/SphereWidget/state.js +9 -5
- package/Widgets/Widgets3D/SphereWidget.js +34 -44
- package/Widgets/Widgets3D/SplineWidget/behavior.js +85 -120
- package/Widgets/Widgets3D/SplineWidget.js +43 -39
- package/Widgets/Widgets3D.js +15 -15
- package/Widgets/index.js +4 -4
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +95 -207
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +0 -3
- package/favicon.js +5 -6
- package/index.d.ts +4 -2
- package/index.js +4 -3
- package/macros.js +4 -1931
- package/macros2.js +1684 -0
- package/package.json +6 -6
- package/vtk.js +18 -31
|
@@ -1,82 +1,86 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
18
|
-
|
|
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
|
-
|
|
20
|
+
const TOUCH_CLICK = [];
|
|
21
|
+
|
|
22
|
+
// ----------------------------------------------------------------------------
|
|
26
23
|
// Global methods
|
|
27
24
|
// ----------------------------------------------------------------------------
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
adjustPosition
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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;
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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
|
-
|
|
89
|
-
|
|
93
|
+
// The opacity did not changed
|
|
90
94
|
return false;
|
|
91
95
|
}
|
|
92
|
-
};
|
|
96
|
+
};
|
|
93
97
|
|
|
94
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
for (
|
|
113
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
}
|
|
144
|
+
}
|
|
142
145
|
|
|
146
|
+
// center around 0 and normalize to -1,1
|
|
147
|
+
const x1 = (x0 - position) / correctedWidth;
|
|
143
148
|
|
|
144
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
|
183
|
-
y
|
|
184
|
-
midpoint
|
|
185
|
-
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
|
-
|
|
196
|
+
let style = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
195
197
|
lineWidth: 1,
|
|
196
198
|
strokeStyle: '#000'
|
|
197
199
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
226
|
+
const workCanvas = canvas || document.createElement('canvas');
|
|
229
227
|
workCanvas.setAttribute('width', width);
|
|
230
228
|
workCanvas.setAttribute('height', 256);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
240
|
-
|
|
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
|
-
|
|
247
|
+
const workCanvas = canvas || document.createElement('canvas');
|
|
253
248
|
workCanvas.setAttribute('width', width);
|
|
254
249
|
workCanvas.setAttribute('height', 256);
|
|
255
|
-
|
|
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
|
-
|
|
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
|
-
|
|
269
|
-
|
|
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
|
-
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
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
|
|
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(
|
|
311
|
-
|
|
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
|
|
309
|
+
callback.action(...touchHandle.singleTouche);
|
|
316
310
|
}
|
|
317
|
-
});
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
|
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
|
|
378
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
458
|
-
height
|
|
459
|
-
width
|
|
460
|
-
xBias
|
|
461
|
-
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
|
-
|
|
488
|
-
|
|
460
|
+
publicAPI.updateStyle = style => {
|
|
461
|
+
model.style = {
|
|
462
|
+
...model.style,
|
|
463
|
+
...style
|
|
464
|
+
};
|
|
489
465
|
publicAPI.modified();
|
|
490
|
-
};
|
|
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
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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
|
-
|
|
512
|
-
|
|
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
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
487
|
+
let arrayIndex = 0;
|
|
488
|
+
const workerChunks = [];
|
|
489
|
+
const workers = [];
|
|
522
490
|
while (arrayIndex < array.length) {
|
|
523
|
-
|
|
491
|
+
const worker = new WorkerFactory();
|
|
524
492
|
workers.push(worker);
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
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
|
|
532
|
-
numberOfComponents
|
|
533
|
-
min
|
|
534
|
-
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
|
-
|
|
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(
|
|
547
|
-
for (
|
|
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
|
-
|
|
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
|
-
|
|
567
|
-
|
|
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
|
-
|
|
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
|
-
|
|
589
|
-
|
|
590
|
-
|
|
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
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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;
|
|
557
|
+
model.selectedGaussian = gaussianIdx;
|
|
608
558
|
|
|
609
|
-
|
|
559
|
+
// Fake active action
|
|
560
|
+
macro.setImmediate(() => {
|
|
610
561
|
publicAPI.onDown(x, y);
|
|
611
562
|
model.dragAction = {
|
|
612
563
|
originalXY: [0, 0],
|
|
613
|
-
action
|
|
614
|
-
gaussian
|
|
615
|
-
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
|
-
|
|
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
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
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
|
-
|
|
668
|
-
|
|
604
|
+
const gaussian = model.gaussians[newActive];
|
|
669
605
|
if (model.enableRangeZoom && xNormalizedAbs >= 0 && y < model.graphArea[1] - 6 // circle radius
|
|
670
606
|
) {
|
|
671
|
-
|
|
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
|
-
|
|
685
|
-
|
|
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
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
642
|
+
const action = ACTIONS[actionName];
|
|
643
|
+
const originalGaussian = {
|
|
644
|
+
...gaussian
|
|
645
|
+
};
|
|
714
646
|
model.dragAction = {
|
|
715
647
|
originalXY: [xNormalized, yNormalized],
|
|
716
|
-
action
|
|
717
|
-
gaussian
|
|
718
|
-
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
|
-
|
|
737
|
-
|
|
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
|
-
|
|
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
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
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
|
|
765
|
-
publicAPI
|
|
766
|
-
|
|
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
|
-
|
|
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
|
-
|
|
808
|
-
|
|
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
|
-
|
|
821
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
866
|
-
var ctx = model.canvas.getContext('2d');
|
|
767
|
+
publicAPI.render = () => {
|
|
768
|
+
const ctx = model.canvas.getContext('2d');
|
|
867
769
|
ctx.imageSmoothingEnabled = true;
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
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
|
-
|
|
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
|
|
888
|
-
|
|
784
|
+
ctx.fillRect(...graphArea);
|
|
889
785
|
if (model.style.iconSize > 1) {
|
|
890
786
|
// Draw icons
|
|
891
787
|
// +
|
|
892
|
-
|
|
893
|
-
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
});
|
|
836
|
+
});
|
|
941
837
|
|
|
838
|
+
// Draw color function if any
|
|
942
839
|
if (model.colorTransferFunction && model.colorTransferFunction.getSize()) {
|
|
943
|
-
|
|
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
|
-
});
|
|
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
|
-
}
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
-
});
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
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();
|
|
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();
|
|
1018
|
-
|
|
1019
|
-
|
|
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();
|
|
1025
|
-
|
|
1026
|
-
|
|
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
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
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
|
|
1045
|
-
y
|
|
1046
|
-
midpoint
|
|
1047
|
-
sharpness
|
|
934
|
+
x,
|
|
935
|
+
y,
|
|
936
|
+
midpoint,
|
|
937
|
+
sharpness
|
|
1048
938
|
});
|
|
1049
939
|
}
|
|
1050
|
-
|
|
1051
940
|
return nodes;
|
|
1052
941
|
};
|
|
1053
|
-
|
|
1054
|
-
|
|
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
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1095
|
-
|
|
972
|
+
const change = rangeZoom(...arguments);
|
|
1096
973
|
if (change) {
|
|
1097
974
|
model.colorCanvasMTime = 0;
|
|
1098
975
|
}
|
|
1099
|
-
|
|
1100
976
|
return change;
|
|
1101
|
-
};
|
|
977
|
+
};
|
|
1102
978
|
|
|
979
|
+
// Trigger rendering for any modified event
|
|
980
|
+
publicAPI.onModified(() => publicAPI.render());
|
|
981
|
+
publicAPI.setSize(...model.size);
|
|
982
|
+
}
|
|
1103
983
|
|
|
1104
|
-
|
|
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
|
-
|
|
1152
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
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');
|
|
1037
|
+
macro.event(publicAPI, model, 'zoomChange');
|
|
1161
1038
|
|
|
1039
|
+
// Object specific methods
|
|
1162
1040
|
vtkPiecewiseGaussianWidget(publicAPI, model);
|
|
1163
|
-
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// ----------------------------------------------------------------------------
|
|
1164
1044
|
|
|
1165
|
-
|
|
1045
|
+
const newInstance = macro.newInstance(extend, 'vtkPiecewiseGaussianWidget');
|
|
1166
1046
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
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 };
|