@cornerstonejs/tools 2.0.0-beta.29 → 2.0.0-beta.30
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/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js +1 -1
- package/dist/esm/store/ToolGroupManager/createToolGroup.d.ts +1 -1
- package/dist/esm/store/ToolGroupManager/createToolGroup.js +3 -3
- package/dist/esm/tools/StackScrollTool.d.ts +0 -2
- package/dist/esm/tools/StackScrollTool.js +2 -84
- package/dist/esm/tools/VolumeRotateMouseWheelTool.d.ts +10 -0
- package/dist/esm/tools/VolumeRotateMouseWheelTool.js +52 -0
- package/dist/esm/tools/displayTools/Contour/contourHandler/utils.js +1 -1
- package/dist/esm/tools/index.d.ts +2 -1
- package/dist/esm/tools/index.js +2 -1
- package/dist/esm/tools/segmentation/BrushTool.js +1 -1
- package/dist/esm/utilities/planarFreehandROITool/smoothAnnotation.d.ts +5 -2
- package/dist/esm/utilities/planarFreehandROITool/smoothAnnotation.js +43 -26
- package/dist/esm/utilities/scroll.js +10 -0
- package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.d.ts +1 -1
- package/dist/esm/utilities/stackPrefetch/stackPrefetchUtils.js +1 -1
- package/package.json +3 -3
package/dist/esm/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import * as cursors from './cursors';
|
|
|
9
9
|
import * as Types from './types';
|
|
10
10
|
import * as annotation from './stateManagement/annotation';
|
|
11
11
|
import * as segmentation from './stateManagement/segmentation';
|
|
12
|
-
import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool } from './tools';
|
|
12
|
+
import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateMouseWheelTool } from './tools';
|
|
13
13
|
import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
|
|
14
14
|
import * as Enums from './enums';
|
|
15
|
-
export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, };
|
|
15
|
+
export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateMouseWheelTool, };
|
package/dist/esm/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import * as cursors from './cursors';
|
|
|
9
9
|
import * as Types from './types';
|
|
10
10
|
import * as annotation from './stateManagement/annotation';
|
|
11
11
|
import * as segmentation from './stateManagement/segmentation';
|
|
12
|
-
import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, } from './tools';
|
|
12
|
+
import { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, KeyImageTool, CrosshairsTool, ReferenceLinesTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, OverlayGridTool, SegmentationIntersectionTool, EraserTool, SculptorTool, SegmentSelectTool, WindowLevelRegionTool, VolumeRotateMouseWheelTool, } from './tools';
|
|
13
13
|
import VideoRedactionTool from './tools/annotation/VideoRedactionTool';
|
|
14
14
|
import * as Enums from './enums';
|
|
15
|
-
export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, };
|
|
15
|
+
export { VideoRedactionTool, init, destroy, addTool, removeTool, cancelActiveManipulations, BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, ZoomTool, StackScrollTool, PlanarRotateTool, MIPJumpToClickTool, LengthTool, HeightTool, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, SplineContourSegmentationTool, BidirectionalTool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, MagnifyTool, AdvancedMagnifyTool, ReferenceCursors, ScaleOverlayTool, SculptorTool, EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, BrushTool, OrientationMarkerTool, SegmentSelectTool, synchronizers, Synchronizer, SynchronizerManager, PaintFillTool, Types, state, ToolGroupManager, Enums, CONSTANTS, drawing, annotation, segmentation, utilities, cursors, VolumeRotateMouseWheelTool, };
|
package/dist/esm/stateManagement/segmentation/polySeg/Surface/createAndCacheSurfacesFromRaw.js
CHANGED
|
@@ -23,7 +23,7 @@ export async function createAndCacheSurfacesFromRaw(segmentationId, rawSurfacesD
|
|
|
23
23
|
const geometryId = closedSurface.id;
|
|
24
24
|
geometryIds.set(segmentIndex, geometryId);
|
|
25
25
|
return geometryLoader.createAndCacheGeometry(geometryId, {
|
|
26
|
-
type: Enums.GeometryType.
|
|
26
|
+
type: Enums.GeometryType.SURFACE,
|
|
27
27
|
geometryData: closedSurface,
|
|
28
28
|
});
|
|
29
29
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { state } from '../state';
|
|
2
2
|
import ToolGroup from './ToolGroup';
|
|
3
3
|
function createToolGroup(toolGroupId) {
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
4
|
+
const toolGroupWithIdExists = state.toolGroups.some((tg) => tg.id === toolGroupId);
|
|
5
|
+
if (toolGroupWithIdExists) {
|
|
6
6
|
console.warn(`'${toolGroupId}' already exists.`);
|
|
7
|
-
return
|
|
7
|
+
return;
|
|
8
8
|
}
|
|
9
9
|
const toolGroup = new ToolGroup(toolGroupId);
|
|
10
10
|
state.toolGroups.push(toolGroup);
|
|
@@ -8,9 +8,7 @@ declare class StackScrollTool extends BaseTool {
|
|
|
8
8
|
mouseDragCallback(evt: EventTypes.InteractionEventType): void;
|
|
9
9
|
touchDragCallback(evt: EventTypes.InteractionEventType): void;
|
|
10
10
|
_dragCallback(evt: EventTypes.InteractionEventType): void;
|
|
11
|
-
_rotateDrag(evt: EventTypes.InteractionEventType): void;
|
|
12
11
|
_scrollDrag(evt: EventTypes.InteractionEventType): void;
|
|
13
|
-
_rotate(evt: any): void;
|
|
14
12
|
_scroll(evt: EventTypes.MouseWheelEventType): void;
|
|
15
13
|
_getPixelPerImage(viewport: any): number;
|
|
16
14
|
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { getEnabledElementByIds, getEnabledElement, VolumeViewport, BaseVolumeViewport, } from '@cornerstonejs/core';
|
|
2
2
|
import { BaseTool } from './base';
|
|
3
3
|
import { scroll } from '../utilities';
|
|
4
|
-
import { mat4, vec3 } from 'gl-matrix';
|
|
5
|
-
const DIRECTIONS = {
|
|
6
|
-
X: [1, 0, 0],
|
|
7
|
-
Y: [0, 1, 0],
|
|
8
|
-
Z: [0, 0, 1],
|
|
9
|
-
CUSTOM: [],
|
|
10
|
-
};
|
|
11
4
|
class StackScrollTool extends BaseTool {
|
|
12
5
|
constructor(toolProps = {}, defaultToolProps = {
|
|
13
6
|
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
@@ -15,23 +8,13 @@ class StackScrollTool extends BaseTool {
|
|
|
15
8
|
invert: false,
|
|
16
9
|
debounceIfNotLoaded: true,
|
|
17
10
|
loop: false,
|
|
18
|
-
rotate: {
|
|
19
|
-
enabled: false,
|
|
20
|
-
direction: DIRECTIONS.Z,
|
|
21
|
-
rotateIncrementDegrees: 30,
|
|
22
|
-
},
|
|
23
11
|
},
|
|
24
12
|
}) {
|
|
25
13
|
super(toolProps, defaultToolProps);
|
|
26
14
|
this.deltaY = 1;
|
|
27
15
|
}
|
|
28
16
|
mouseWheelCallback(evt) {
|
|
29
|
-
|
|
30
|
-
this._rotate(evt);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
this._scroll(evt);
|
|
34
|
-
}
|
|
17
|
+
this._scroll(evt);
|
|
35
18
|
}
|
|
36
19
|
mouseDragCallback(evt) {
|
|
37
20
|
this._dragCallback(evt);
|
|
@@ -40,42 +23,7 @@ class StackScrollTool extends BaseTool {
|
|
|
40
23
|
this._dragCallback(evt);
|
|
41
24
|
}
|
|
42
25
|
_dragCallback(evt) {
|
|
43
|
-
|
|
44
|
-
this._rotateDrag(evt);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
this._scrollDrag(evt);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
_rotateDrag(evt) {
|
|
51
|
-
const { deltaPoints, element } = evt.detail;
|
|
52
|
-
const enabledElement = getEnabledElement(element);
|
|
53
|
-
const { viewport } = enabledElement;
|
|
54
|
-
const { direction, rotateIncrementDegrees } = this.configuration.rotate;
|
|
55
|
-
const camera = viewport.getCamera();
|
|
56
|
-
const { viewUp, position, focalPoint } = camera;
|
|
57
|
-
const deltaY = deltaPoints.canvas[1];
|
|
58
|
-
const [cx, cy, cz] = focalPoint;
|
|
59
|
-
const [ax, ay, az] = direction;
|
|
60
|
-
const angle = (deltaY * (rotateIncrementDegrees * Math.PI)) / 180;
|
|
61
|
-
const newPosition = [0, 0, 0];
|
|
62
|
-
const newFocalPoint = [0, 0, 0];
|
|
63
|
-
const newViewUp = [0, 0, 0];
|
|
64
|
-
const transform = mat4.identity(new Float32Array(16));
|
|
65
|
-
mat4.translate(transform, transform, [cx, cy, cz]);
|
|
66
|
-
mat4.rotate(transform, transform, angle, [ax, ay, az]);
|
|
67
|
-
mat4.translate(transform, transform, [-cx, -cy, -cz]);
|
|
68
|
-
vec3.transformMat4(newPosition, position, transform);
|
|
69
|
-
vec3.transformMat4(newFocalPoint, focalPoint, transform);
|
|
70
|
-
mat4.identity(transform);
|
|
71
|
-
mat4.rotate(transform, transform, angle, [ax, ay, az]);
|
|
72
|
-
vec3.transformMat4(newViewUp, viewUp, transform);
|
|
73
|
-
viewport.setCamera({
|
|
74
|
-
position: newPosition,
|
|
75
|
-
viewUp: newViewUp,
|
|
76
|
-
focalPoint: newFocalPoint,
|
|
77
|
-
});
|
|
78
|
-
viewport.render();
|
|
26
|
+
this._scrollDrag(evt);
|
|
79
27
|
}
|
|
80
28
|
_scrollDrag(evt) {
|
|
81
29
|
const { deltaPoints, viewportId, renderingEngineId } = evt.detail;
|
|
@@ -105,36 +53,6 @@ class StackScrollTool extends BaseTool {
|
|
|
105
53
|
this.deltaY = deltaY;
|
|
106
54
|
}
|
|
107
55
|
}
|
|
108
|
-
_rotate(evt) {
|
|
109
|
-
const { element, wheel } = evt.detail;
|
|
110
|
-
const enabledElement = getEnabledElement(element);
|
|
111
|
-
const { viewport } = enabledElement;
|
|
112
|
-
const { direction, rotateIncrementDegrees } = this.configuration.rotate;
|
|
113
|
-
const camera = viewport.getCamera();
|
|
114
|
-
const { viewUp, position, focalPoint } = camera;
|
|
115
|
-
const { direction: deltaY } = wheel;
|
|
116
|
-
const [cx, cy, cz] = focalPoint;
|
|
117
|
-
const [ax, ay, az] = direction;
|
|
118
|
-
const angle = (deltaY * (rotateIncrementDegrees * Math.PI)) / 180;
|
|
119
|
-
const newPosition = [0, 0, 0];
|
|
120
|
-
const newFocalPoint = [0, 0, 0];
|
|
121
|
-
const newViewUp = [0, 0, 0];
|
|
122
|
-
const transform = mat4.identity(new Float32Array(16));
|
|
123
|
-
mat4.translate(transform, transform, [cx, cy, cz]);
|
|
124
|
-
mat4.rotate(transform, transform, angle, [ax, ay, az]);
|
|
125
|
-
mat4.translate(transform, transform, [-cx, -cy, -cz]);
|
|
126
|
-
vec3.transformMat4(newPosition, position, transform);
|
|
127
|
-
vec3.transformMat4(newFocalPoint, focalPoint, transform);
|
|
128
|
-
mat4.identity(transform);
|
|
129
|
-
mat4.rotate(transform, transform, angle, [ax, ay, az]);
|
|
130
|
-
vec3.transformMat4(newViewUp, viewUp, transform);
|
|
131
|
-
viewport.setCamera({
|
|
132
|
-
position: newPosition,
|
|
133
|
-
viewUp: newViewUp,
|
|
134
|
-
focalPoint: newFocalPoint,
|
|
135
|
-
});
|
|
136
|
-
viewport.render();
|
|
137
|
-
}
|
|
138
56
|
_scroll(evt) {
|
|
139
57
|
const { wheel, element } = evt.detail;
|
|
140
58
|
const { direction } = wheel;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseTool } from './base';
|
|
2
|
+
import type { PublicToolProps, ToolProps } from '../types';
|
|
3
|
+
import type { MouseWheelEventType } from '../types/EventTypes';
|
|
4
|
+
declare class VolumeRotateMouseWheelTool extends BaseTool {
|
|
5
|
+
static toolName: any;
|
|
6
|
+
_configuration: any;
|
|
7
|
+
constructor(toolProps?: PublicToolProps, defaultToolProps?: ToolProps);
|
|
8
|
+
mouseWheelCallback(evt: MouseWheelEventType): void;
|
|
9
|
+
}
|
|
10
|
+
export default VolumeRotateMouseWheelTool;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BaseTool } from './base';
|
|
2
|
+
import { getEnabledElement } from '@cornerstonejs/core';
|
|
3
|
+
import { mat4, vec3 } from 'gl-matrix';
|
|
4
|
+
const DIRECTIONS = {
|
|
5
|
+
X: [1, 0, 0],
|
|
6
|
+
Y: [0, 1, 0],
|
|
7
|
+
Z: [0, 0, 1],
|
|
8
|
+
CUSTOM: [],
|
|
9
|
+
};
|
|
10
|
+
class VolumeRotateMouseWheelTool extends BaseTool {
|
|
11
|
+
constructor(toolProps = {}, defaultToolProps = {
|
|
12
|
+
supportedInteractionTypes: ['Mouse', 'Touch'],
|
|
13
|
+
configuration: {
|
|
14
|
+
direction: DIRECTIONS.Z,
|
|
15
|
+
rotateIncrementDegrees: 30,
|
|
16
|
+
},
|
|
17
|
+
}) {
|
|
18
|
+
super(toolProps, defaultToolProps);
|
|
19
|
+
}
|
|
20
|
+
mouseWheelCallback(evt) {
|
|
21
|
+
const { element, wheel } = evt.detail;
|
|
22
|
+
const enabledElement = getEnabledElement(element);
|
|
23
|
+
const { viewport } = enabledElement;
|
|
24
|
+
const { direction, rotateIncrementDegrees } = this.configuration;
|
|
25
|
+
const camera = viewport.getCamera();
|
|
26
|
+
const { viewUp, position, focalPoint } = camera;
|
|
27
|
+
const { direction: deltaY } = wheel;
|
|
28
|
+
const [cx, cy, cz] = focalPoint;
|
|
29
|
+
const [ax, ay, az] = direction;
|
|
30
|
+
const angle = (deltaY * (rotateIncrementDegrees * Math.PI)) / 180;
|
|
31
|
+
const newPosition = [0, 0, 0];
|
|
32
|
+
const newFocalPoint = [0, 0, 0];
|
|
33
|
+
const newViewUp = [0, 0, 0];
|
|
34
|
+
const transform = mat4.identity(new Float32Array(16));
|
|
35
|
+
mat4.translate(transform, transform, [cx, cy, cz]);
|
|
36
|
+
mat4.rotate(transform, transform, angle, [ax, ay, az]);
|
|
37
|
+
mat4.translate(transform, transform, [-cx, -cy, -cz]);
|
|
38
|
+
vec3.transformMat4(newPosition, position, transform);
|
|
39
|
+
vec3.transformMat4(newFocalPoint, focalPoint, transform);
|
|
40
|
+
mat4.identity(transform);
|
|
41
|
+
mat4.rotate(transform, transform, angle, [ax, ay, az]);
|
|
42
|
+
vec3.transformMat4(newViewUp, viewUp, transform);
|
|
43
|
+
viewport.setCamera({
|
|
44
|
+
position: newPosition,
|
|
45
|
+
viewUp: newViewUp,
|
|
46
|
+
focalPoint: newFocalPoint,
|
|
47
|
+
});
|
|
48
|
+
viewport.render();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
VolumeRotateMouseWheelTool.toolName = 'VolumeRotateMouseWheel';
|
|
52
|
+
export default VolumeRotateMouseWheelTool;
|
|
@@ -7,7 +7,7 @@ export function validateGeometry(geometry) {
|
|
|
7
7
|
throw new Error(`No contours found for geometryId ${geometry.id}`);
|
|
8
8
|
}
|
|
9
9
|
const geometryId = geometry.id;
|
|
10
|
-
if (geometry.type !== Enums.GeometryType.
|
|
10
|
+
if (geometry.type !== Enums.GeometryType.CONTOUR) {
|
|
11
11
|
throw new Error(`Geometry type ${geometry.type} not supported for rendering.`);
|
|
12
12
|
}
|
|
13
13
|
if (!geometry.data) {
|
|
@@ -16,6 +16,7 @@ import SegmentationIntersectionTool from './SegmentationIntersectionTool';
|
|
|
16
16
|
import ReferenceCursors from './ReferenceCursors';
|
|
17
17
|
import ScaleOverlayTool from './ScaleOverlayTool';
|
|
18
18
|
import SculptorTool from './SculptorTool';
|
|
19
|
+
import VolumeRotateMouseWheelTool from './VolumeRotateMouseWheelTool';
|
|
19
20
|
import BidirectionalTool from './annotation/BidirectionalTool';
|
|
20
21
|
import LengthTool from './annotation/LengthTool';
|
|
21
22
|
import HeightTool from './annotation/HeightTool';
|
|
@@ -46,4 +47,4 @@ import BrushTool from './segmentation/BrushTool';
|
|
|
46
47
|
import PaintFillTool from './segmentation/PaintFillTool';
|
|
47
48
|
import OrientationMarkerTool from './OrientationMarkerTool';
|
|
48
49
|
import SegmentSelectTool from './segmentation/SegmentSelectTool';
|
|
49
|
-
export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, };
|
|
50
|
+
export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, VolumeRotateMouseWheelTool, };
|
package/dist/esm/tools/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import SegmentationIntersectionTool from './SegmentationIntersectionTool';
|
|
|
16
16
|
import ReferenceCursors from './ReferenceCursors';
|
|
17
17
|
import ScaleOverlayTool from './ScaleOverlayTool';
|
|
18
18
|
import SculptorTool from './SculptorTool';
|
|
19
|
+
import VolumeRotateMouseWheelTool from './VolumeRotateMouseWheelTool';
|
|
19
20
|
import BidirectionalTool from './annotation/BidirectionalTool';
|
|
20
21
|
import LengthTool from './annotation/LengthTool';
|
|
21
22
|
import HeightTool from './annotation/HeightTool';
|
|
@@ -46,4 +47,4 @@ import BrushTool from './segmentation/BrushTool';
|
|
|
46
47
|
import PaintFillTool from './segmentation/PaintFillTool';
|
|
47
48
|
import OrientationMarkerTool from './OrientationMarkerTool';
|
|
48
49
|
import SegmentSelectTool from './segmentation/SegmentSelectTool';
|
|
49
|
-
export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, };
|
|
50
|
+
export { BaseTool, AnnotationTool, AnnotationDisplayTool, PanTool, TrackballRotateTool, DragProbeTool, WindowLevelTool, WindowLevelRegionTool, StackScrollTool, PlanarRotateTool, ZoomTool, MIPJumpToClickTool, ReferenceCursors, CrosshairsTool, ReferenceLinesTool, OverlayGridTool, SegmentationIntersectionTool, BidirectionalTool, LengthTool, HeightTool, ProbeTool, RectangleROITool, EllipticalROITool, CircleROITool, SplineROITool, PlanarFreehandROITool, PlanarFreehandContourSegmentationTool, LivewireContourTool, LivewireContourSegmentationTool, ArrowAnnotateTool, AngleTool, CobbAngleTool, UltrasoundDirectionalTool, KeyImageTool, AnnotationEraserTool as EraserTool, RectangleScissorsTool, CircleScissorsTool, SphereScissorsTool, RectangleROIThresholdTool, RectangleROIStartEndThresholdTool, CircleROIStartEndThresholdTool, SplineContourSegmentationTool, BrushTool, MagnifyTool, AdvancedMagnifyTool, PaintFillTool, ScaleOverlayTool, OrientationMarkerTool, SculptorTool, SegmentSelectTool, VolumeRotateMouseWheelTool, };
|
|
@@ -224,7 +224,7 @@ class BrushTool extends BaseTool {
|
|
|
224
224
|
eventTarget.dispatchEvent(event);
|
|
225
225
|
return null;
|
|
226
226
|
}
|
|
227
|
-
const volumes = actors.map((actorEntry) => cache.getVolume(actorEntry.referencedId
|
|
227
|
+
const volumes = actors.map((actorEntry) => cache.getVolume(actorEntry.referencedId));
|
|
228
228
|
const segmentationVolume = cache.getVolume(volumeId);
|
|
229
229
|
const referencedVolumeIdToThreshold = volumes.find((volume) => csUtils.isEqual(volume.dimensions, segmentationVolume.dimensions))?.volumeId || volumes[0]?.volumeId;
|
|
230
230
|
return {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type { Types } from '@cornerstonejs/core';
|
|
2
1
|
import type { PlanarFreehandROIAnnotation } from '../../types/ToolSpecificAnnotationTypes';
|
|
3
|
-
export
|
|
2
|
+
export type SmoothOptions = {
|
|
3
|
+
knotsRatioPercentage: number;
|
|
4
|
+
loop: number;
|
|
5
|
+
};
|
|
6
|
+
export default function smoothAnnotation(annotation: PlanarFreehandROIAnnotation, options?: SmoothOptions): boolean;
|
|
@@ -1,39 +1,56 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { mat4, vec3 } from 'gl-matrix';
|
|
2
2
|
import interpolateSegmentPoints from './interpolation/interpolateSegmentPoints';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!annotation?.data?.polyline ||
|
|
3
|
+
function shouldPreventInterpolation(annotation, options) {
|
|
4
|
+
const knotsRatioPercentage = options?.knotsRatioPercentage || 30;
|
|
5
|
+
if (!annotation?.data?.contour?.polyline?.length ||
|
|
6
|
+
knotsRatioPercentage <= 0) {
|
|
6
7
|
return true;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
function rotateMatrix(normal, focal) {
|
|
12
|
+
const mat = mat4.create();
|
|
13
|
+
const eye = vec3.add(vec3.create(), focal, normal);
|
|
14
|
+
const up = Math.abs(normal[0]) > 0.1
|
|
15
|
+
? vec3.fromValues(-normal[1], normal[0], 0)
|
|
16
|
+
: vec3.fromValues(0, -normal[2], normal[1]);
|
|
17
|
+
mat4.lookAt(mat, focal, eye, up);
|
|
18
|
+
return mat;
|
|
19
|
+
}
|
|
20
|
+
function rotate(list, count = Math.floor(Math.random() * (list.length - 1))) {
|
|
21
|
+
if (count === 0) {
|
|
22
|
+
return 0;
|
|
18
23
|
}
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
const srcList = [...list];
|
|
25
|
+
const { length } = list;
|
|
26
|
+
for (let i = 0; i < length; i++) {
|
|
27
|
+
list[i] = srcList[(i + count + length) % length];
|
|
22
28
|
}
|
|
23
|
-
return
|
|
24
|
-
toolInstance.isEditingOpen ||
|
|
25
|
-
toolInstance.isEditingClosed);
|
|
29
|
+
return count;
|
|
26
30
|
}
|
|
27
|
-
export default function smoothAnnotation(
|
|
28
|
-
if (shouldPreventInterpolation(
|
|
31
|
+
export default function smoothAnnotation(annotation, options) {
|
|
32
|
+
if (shouldPreventInterpolation(annotation, options)) {
|
|
29
33
|
return false;
|
|
30
34
|
}
|
|
31
|
-
const {
|
|
32
|
-
const
|
|
33
|
-
const
|
|
35
|
+
const { viewPlaneNormal } = annotation.metadata;
|
|
36
|
+
const { closed, polyline } = annotation.data.contour;
|
|
37
|
+
const rotateMat = rotateMatrix(viewPlaneNormal, annotation.data.contour.polyline[0]);
|
|
38
|
+
const canvasPoints = annotation.data.contour.polyline.map((p) => {
|
|
39
|
+
const planeP = vec3.transformMat4(vec3.create(), p, rotateMat);
|
|
40
|
+
return [planeP[0], planeP[1]];
|
|
41
|
+
});
|
|
42
|
+
let rotation = closed ? rotate(canvasPoints) : 0;
|
|
43
|
+
let interpolatedCanvasPoints = (interpolateSegmentPoints(canvasPoints, 0, canvasPoints.length, options?.knotsRatioPercentage || 30));
|
|
34
44
|
if (interpolatedCanvasPoints === canvasPoints) {
|
|
35
45
|
return false;
|
|
36
46
|
}
|
|
37
|
-
|
|
47
|
+
rotate(interpolatedCanvasPoints, -rotation);
|
|
48
|
+
for (let i = 1; i < options?.loop; i++) {
|
|
49
|
+
rotation = closed ? rotate(interpolatedCanvasPoints) : 0;
|
|
50
|
+
interpolatedCanvasPoints = (interpolateSegmentPoints(interpolatedCanvasPoints, 0, canvasPoints.length, options?.knotsRatioPercentage || 30));
|
|
51
|
+
rotate(interpolatedCanvasPoints, -rotation);
|
|
52
|
+
}
|
|
53
|
+
const unRotate = mat4.invert(mat4.create(), rotateMat);
|
|
54
|
+
annotation.data.contour.polyline = (interpolatedCanvasPoints.map((p) => vec3.transformMat4([0, 0, 0], [...p, 0], unRotate)));
|
|
38
55
|
return true;
|
|
39
56
|
}
|
|
@@ -13,6 +13,16 @@ export default function scroll(viewport, options) {
|
|
|
13
13
|
scrollVolume(viewport, volumeId, delta, scrollSlabs);
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
+
const imageIdIndex = viewport.getCurrentImageIdIndex();
|
|
17
|
+
if (imageIdIndex + delta >
|
|
18
|
+
viewport.getImageIds().length - 1 ||
|
|
19
|
+
imageIdIndex + delta < 0) {
|
|
20
|
+
const eventData = {
|
|
21
|
+
imageIdIndex,
|
|
22
|
+
direction: delta,
|
|
23
|
+
};
|
|
24
|
+
csUtils.triggerEvent(eventTarget, EVENTS.STACK_SCROLL_OUT_OF_BOUNDS, eventData);
|
|
25
|
+
}
|
|
16
26
|
viewport.scroll(delta, options.debounceLoading, options.loop);
|
|
17
27
|
}
|
|
18
28
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Enums } from '@cornerstonejs/core';
|
|
2
|
-
export declare const requestType = Enums.RequestType.
|
|
2
|
+
export declare const requestType = Enums.RequestType.PREFETCH;
|
|
3
3
|
export declare const priority = 0;
|
|
4
4
|
export declare function range(lowEnd: any, highEnd: any): any[];
|
|
5
5
|
export declare function nearestIndex(arr: any, x: any): {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getEnabledElement, StackViewport, Enums } from '@cornerstonejs/core';
|
|
2
2
|
import { getToolState } from './state';
|
|
3
|
-
export const requestType = Enums.RequestType.
|
|
3
|
+
export const requestType = Enums.RequestType.PREFETCH;
|
|
4
4
|
export const priority = 0;
|
|
5
5
|
export function range(lowEnd, highEnd) {
|
|
6
6
|
lowEnd = Math.round(lowEnd) || 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/tools",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.30",
|
|
4
4
|
"description": "Cornerstone3D Tools",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@cornerstonejs/core": "^2.0.0-beta.
|
|
100
|
+
"@cornerstonejs/core": "^2.0.0-beta.30",
|
|
101
101
|
"@types/offscreencanvas": "2019.7.3",
|
|
102
102
|
"comlink": "^4.4.1",
|
|
103
103
|
"lodash.get": "^4.4.2"
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"type": "individual",
|
|
125
125
|
"url": "https://ohif.org/donate"
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "e56a9df570b820968e23b35f0526700989ae1e3c"
|
|
128
128
|
}
|