@cornerstonejs/core 1.71.4 → 1.71.6
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/cjs/RenderingEngine/BaseVolumeViewport.d.ts +5 -5
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js +83 -10
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/StackViewport.d.ts +5 -5
- package/dist/cjs/RenderingEngine/StackViewport.js +71 -50
- package/dist/cjs/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/Viewport.d.ts +2 -1
- package/dist/cjs/RenderingEngine/Viewport.js +21 -16
- package/dist/cjs/RenderingEngine/Viewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/VolumeViewport.d.ts +3 -2
- package/dist/cjs/RenderingEngine/VolumeViewport.js +13 -14
- package/dist/cjs/RenderingEngine/VolumeViewport.js.map +1 -1
- package/dist/cjs/types/IViewport.d.ts +5 -1
- package/dist/cjs/utilities/index.d.ts +3 -2
- package/dist/cjs/utilities/index.js +8 -4
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/cjs/utilities/isEqual.d.ts +3 -0
- package/dist/cjs/utilities/isEqual.js +8 -0
- package/dist/cjs/utilities/isEqual.js.map +1 -1
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js +83 -13
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/StackViewport.js +53 -34
- package/dist/esm/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/Viewport.js +20 -16
- package/dist/esm/RenderingEngine/Viewport.js.map +1 -1
- package/dist/esm/RenderingEngine/VolumeViewport.js +13 -14
- package/dist/esm/RenderingEngine/VolumeViewport.js.map +1 -1
- package/dist/esm/utilities/index.js +3 -2
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/isEqual.js +5 -0
- package/dist/esm/utilities/isEqual.js.map +1 -1
- package/dist/types/RenderingEngine/BaseVolumeViewport.d.ts +5 -5
- package/dist/types/RenderingEngine/BaseVolumeViewport.d.ts.map +1 -1
- package/dist/types/RenderingEngine/StackViewport.d.ts +5 -5
- package/dist/types/RenderingEngine/StackViewport.d.ts.map +1 -1
- package/dist/types/RenderingEngine/Viewport.d.ts +2 -1
- package/dist/types/RenderingEngine/Viewport.d.ts.map +1 -1
- package/dist/types/RenderingEngine/VolumeViewport.d.ts +3 -2
- package/dist/types/RenderingEngine/VolumeViewport.d.ts.map +1 -1
- package/dist/types/types/IViewport.d.ts +5 -1
- package/dist/types/types/IViewport.d.ts.map +1 -1
- package/dist/types/types/displayArea.d.ts.map +1 -1
- package/dist/types/utilities/index.d.ts +3 -2
- package/dist/types/utilities/index.d.ts.map +1 -1
- package/dist/types/utilities/isEqual.d.ts +3 -0
- package/dist/types/utilities/isEqual.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
- package/src/RenderingEngine/BaseVolumeViewport.ts +182 -19
- package/src/RenderingEngine/StackViewport.ts +81 -50
- package/src/RenderingEngine/Viewport.ts +37 -24
- package/src/RenderingEngine/VolumeViewport.ts +40 -25
- package/src/types/IViewport.ts +64 -18
- package/src/types/displayArea.ts +27 -0
- package/src/utilities/index.ts +6 -2
- package/src/utilities/isEqual.ts +27 -0
package/src/types/IViewport.ts
CHANGED
|
@@ -15,7 +15,12 @@ import BoundsLPS from './BoundsLPS';
|
|
|
15
15
|
* set of points.
|
|
16
16
|
*/
|
|
17
17
|
export type ViewReferenceSpecifier = {
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* The slice index within the current viewport camera to get a reference for.
|
|
20
|
+
* Note that slice indexes are dependent on the particular view being shown
|
|
21
|
+
* and cannot be shared across different view types such as stacks and
|
|
22
|
+
* volumes, or two viewports showing different orientations or slab thicknesses.
|
|
23
|
+
*/
|
|
19
24
|
sliceIndex?: number | [number, number];
|
|
20
25
|
/**
|
|
21
26
|
* Specifies to get a view reference that refers to the generic frame of
|
|
@@ -47,12 +52,15 @@ export type ReferenceCompatibleOptions = {
|
|
|
47
52
|
withNavigation?: boolean;
|
|
48
53
|
/**
|
|
49
54
|
* For a stack viewport, return true if this viewport could show the given
|
|
50
|
-
* view if it were converted into a volume viewport
|
|
51
|
-
*
|
|
52
|
-
* That is, is the specified view showing an image in the stack but with a
|
|
53
|
-
* different orientation than acquisition.
|
|
55
|
+
* view if it were converted into a volume viewport. Has no affect on volume
|
|
56
|
+
* viewports.
|
|
54
57
|
*/
|
|
55
58
|
asVolume?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* For volume viewports, return true if this viewport could show the given view
|
|
61
|
+
* if the orientation was changed.
|
|
62
|
+
*/
|
|
63
|
+
withOrientation?: boolean;
|
|
56
64
|
/**
|
|
57
65
|
* Use this imageURI for testing - may or may not be the current one.
|
|
58
66
|
* Should be a straight contains URI for the set of imageIds in any of
|
|
@@ -86,15 +94,39 @@ export type ViewReference = {
|
|
|
86
94
|
referencedImageId?: string;
|
|
87
95
|
|
|
88
96
|
/**
|
|
89
|
-
* The focal point of the camera in world space
|
|
97
|
+
* The focal point of the camera in world space.
|
|
98
|
+
* The focal point is used for to define the stack positioning, but not the
|
|
99
|
+
* zoom/pan (which is defined by the view presentation
|
|
100
|
+
* object.)
|
|
101
|
+
*
|
|
102
|
+
* Single point objects (probe etc) should use the probe point as the camera
|
|
103
|
+
* focal point as that allows omitting the view plane normal and showing the probe
|
|
104
|
+
* in any orientation.
|
|
90
105
|
*/
|
|
91
106
|
cameraFocalPoint?: Point3;
|
|
92
107
|
/**
|
|
93
|
-
* The normal for the current view
|
|
108
|
+
* The normal for the current view. This defines the plane used to show the
|
|
109
|
+
* 2d annotation. This should be omitted if the annotation is a point to
|
|
110
|
+
* allows for single-point annotations.
|
|
94
111
|
*/
|
|
95
112
|
viewPlaneNormal?: Point3;
|
|
96
113
|
/**
|
|
97
|
-
* The
|
|
114
|
+
* The view up - this is only used for resetting orientation
|
|
115
|
+
*/
|
|
116
|
+
viewUp?: Point3;
|
|
117
|
+
/**
|
|
118
|
+
* The slice index or range for this view.
|
|
119
|
+
* <b>NOTE</b> The slice index is relative to the volume or stack of images.
|
|
120
|
+
* You cannot apply a slice index from one volume to another as they do NOT
|
|
121
|
+
* apply. The referencedImageId should belong to the volume you are trying
|
|
122
|
+
* to apply to, the viewPlane normal should be identical, and then you can
|
|
123
|
+
* apply the sliceIndex.
|
|
124
|
+
*
|
|
125
|
+
* For stack viewports, the referencedImageId should occur at the given slice index.
|
|
126
|
+
*
|
|
127
|
+
* <b>Note 2</b>slice indices don't necessarily indicate anything positionally
|
|
128
|
+
* within the stack of images - subsequent slice indexes can be at opposite
|
|
129
|
+
* ends or can be co-incident but separate types of images.
|
|
98
130
|
*/
|
|
99
131
|
sliceIndex?: number | [number, number];
|
|
100
132
|
|
|
@@ -292,11 +324,22 @@ interface IViewport {
|
|
|
292
324
|
setPan(pan: Point2, storeAsInitialCamera?: boolean);
|
|
293
325
|
/** sets the camera */
|
|
294
326
|
setCamera(cameraInterface: ICamera, storeAsInitialCamera?: boolean): void;
|
|
327
|
+
/** Resets the camera */
|
|
328
|
+
resetCamera(
|
|
329
|
+
resetPan?: boolean,
|
|
330
|
+
resetZoom?: boolean,
|
|
331
|
+
resetToCenter?: boolean,
|
|
332
|
+
storeAsInitialCamera?: boolean
|
|
333
|
+
): boolean;
|
|
295
334
|
/** Gets the number of slices in the current camera orientation */
|
|
296
335
|
getNumberOfSlices(): number;
|
|
297
336
|
/** Gets the current slice in the current camera orientation */
|
|
298
337
|
getCurrentImageIdIndex(): number;
|
|
299
|
-
/**
|
|
338
|
+
/**
|
|
339
|
+
* Gets a referenced image url of some sort - could be a real image id, or
|
|
340
|
+
* could be a URL with parameters. Regardless it refers to the currently displaying
|
|
341
|
+
* image as a string value.
|
|
342
|
+
*/
|
|
300
343
|
getReferenceId(viewRefSpecifier?: ViewReferenceSpecifier): string;
|
|
301
344
|
/**
|
|
302
345
|
* Gets a view target specifying WHAT a view is displaying,
|
|
@@ -343,20 +386,23 @@ interface IViewport {
|
|
|
343
386
|
* @param viewPresSel - select which attributes to display.
|
|
344
387
|
*/
|
|
345
388
|
getViewPresentation(viewPresSel?: ViewPresentationSelector): ViewPresentation;
|
|
389
|
+
|
|
346
390
|
/**
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* remember specific sets of attributes.
|
|
351
|
-
*
|
|
352
|
-
* @param viewRef - the basic positioning in terms of what image id/slice index/orientation to display
|
|
353
|
-
* * The viewRef must be applicable to the current stack or volume, otherwise an exception will be thrown
|
|
354
|
-
* @param viewPres - the presentation information to apply to the current image (as chosen above)
|
|
391
|
+
* Navigates this viewport to the specified viewRef.
|
|
392
|
+
* Throws an exception if that isn't possible on this viewport.
|
|
393
|
+
* Returns immediately if viewRef isn't defined.
|
|
355
394
|
*/
|
|
356
|
-
|
|
395
|
+
setViewReference(viewRef: ViewReference);
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Sets the presentation parameters from the specified viewPres object.
|
|
399
|
+
* Sets display area, zoom, pan, rotation, voi LUT
|
|
400
|
+
*/
|
|
401
|
+
setViewPresentation(viewPres: ViewPresentation);
|
|
357
402
|
|
|
358
403
|
/** whether the viewport has custom rendering */
|
|
359
404
|
customRenderViewportToCanvas: () => unknown;
|
|
405
|
+
|
|
360
406
|
_getCorners(bounds: Array<number>): Array<number>[];
|
|
361
407
|
updateRenderingPipeline: () => void;
|
|
362
408
|
}
|
package/src/types/displayArea.ts
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import InterpolationType from '../enums/InterpolationType';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* The display area type allows specifying or updating the image position and
|
|
5
|
+
* size based on the display area that it is shown in and based on the image
|
|
6
|
+
* size.
|
|
7
|
+
*
|
|
8
|
+
* Two types are currently defined, the default 'FIT', specifies scaling
|
|
9
|
+
* to fit the given image area. For this type, the area that is scaled to
|
|
10
|
+
* fit is the imageArea times the image size. For example, an imageArea of
|
|
11
|
+
* `[0.5,2]` with a 512 square image will try to fit 0.5*512 = 256 pixels width wise,
|
|
12
|
+
* and 2*512 = 1024 height wise.
|
|
13
|
+
*
|
|
14
|
+
* The type 'SCALE' means to use a scale factor, such as 1.0, which means to make
|
|
15
|
+
* every image pixel fit one physical display pixel.
|
|
16
|
+
*
|
|
17
|
+
* Then, the image is positioned such that the image fractional position imagePoint
|
|
18
|
+
* is located at the canvas fractional point canvasPoint. Using fractional
|
|
19
|
+
* points allows being independent of image size.
|
|
20
|
+
*
|
|
21
|
+
* Finally, the store as initial camera allows the zoom and pan values to be
|
|
22
|
+
* set to 1 and [0,0] respectively for the initially displayed position, as well
|
|
23
|
+
* as having the reset camera reset to the specified display area.
|
|
24
|
+
*/
|
|
3
25
|
type DisplayArea = {
|
|
4
26
|
type?: 'SCALE' | 'FIT';
|
|
5
27
|
scale?: number;
|
|
6
28
|
interpolationType?: InterpolationType;
|
|
7
29
|
imageArea?: [number, number]; // areaX, areaY
|
|
8
30
|
imageCanvasPoint?: {
|
|
31
|
+
/** Use the fractional imagePoint as the target image point to position */
|
|
9
32
|
imagePoint: [number, number]; // imageX, imageY
|
|
33
|
+
/** Pan the image such that the target imagePoint is located at the
|
|
34
|
+
* canvas point fraction of the canvas.
|
|
35
|
+
*/
|
|
10
36
|
canvasPoint?: [number, number]; // canvasX, canvasY
|
|
11
37
|
};
|
|
38
|
+
/** Make this display area the default and reset/navigate will reapply this */
|
|
12
39
|
storeAsInitialCamera?: boolean;
|
|
13
40
|
};
|
|
14
41
|
|
package/src/utilities/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ import getRuntimeId from './getRuntimeId';
|
|
|
11
11
|
import imageIdToURI from './imageIdToURI';
|
|
12
12
|
import calibratedPixelSpacingMetadataProvider from './calibratedPixelSpacingMetadataProvider';
|
|
13
13
|
import clamp from './clamp';
|
|
14
|
-
import isEqual from './isEqual';
|
|
14
|
+
import { isEqual, isEqualAbs, isEqualNegative } from './isEqual';
|
|
15
15
|
import isOpposite from './isOpposite';
|
|
16
16
|
import createUint8SharedArray from './createUint8SharedArray';
|
|
17
17
|
import createFloat32SharedArray from './createFloat32SharedArray';
|
|
@@ -66,6 +66,7 @@ import { generateVolumePropsFromImageIds } from './generateVolumePropsFromImageI
|
|
|
66
66
|
import { convertStackToVolumeViewport } from './convertStackToVolumeViewport';
|
|
67
67
|
import { convertVolumeToStackViewport } from './convertVolumeToStackViewport';
|
|
68
68
|
import VoxelManager from './VoxelManager';
|
|
69
|
+
import RLEVoxelMap from './RLEVoxelMap';
|
|
69
70
|
import roundNumber, { roundToPrecision } from './roundNumber';
|
|
70
71
|
import convertToGrayscale from './convertToGrayscale';
|
|
71
72
|
import getViewportImageIds from './getViewportImageIds';
|
|
@@ -97,6 +98,8 @@ export {
|
|
|
97
98
|
getMinMax,
|
|
98
99
|
getRuntimeId,
|
|
99
100
|
isEqual,
|
|
101
|
+
isEqualAbs,
|
|
102
|
+
isEqualNegative,
|
|
100
103
|
isOpposite,
|
|
101
104
|
createFloat32SharedArray,
|
|
102
105
|
createUint8SharedArray,
|
|
@@ -151,9 +154,10 @@ export {
|
|
|
151
154
|
isValidVolume,
|
|
152
155
|
genericMetadataProvider,
|
|
153
156
|
isVideoTransferSyntax,
|
|
157
|
+
generateVolumePropsFromImageIds,
|
|
154
158
|
getBufferConfiguration,
|
|
155
159
|
VoxelManager,
|
|
156
|
-
|
|
160
|
+
RLEVoxelMap,
|
|
157
161
|
convertStackToVolumeViewport,
|
|
158
162
|
convertVolumeToStackViewport,
|
|
159
163
|
cacheUtils,
|
package/src/utilities/isEqual.ts
CHANGED
|
@@ -63,3 +63,30 @@ export default function isEqual<ValueType>(
|
|
|
63
63
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
const negative = (v) =>
|
|
68
|
+
typeof v === 'number' ? -v : v?.map ? v.map(negative) : !v;
|
|
69
|
+
|
|
70
|
+
const abs = (v) =>
|
|
71
|
+
typeof v === 'number' ? Math.abs(v) : v?.map ? v.map(abs) : v;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Compare negative values of both single numbers and vectors
|
|
75
|
+
*/
|
|
76
|
+
const isEqualNegative = <ValueType>(
|
|
77
|
+
v1: ValueType,
|
|
78
|
+
v2: ValueType,
|
|
79
|
+
tolerance = undefined
|
|
80
|
+
) => isEqual(v1, negative(v2) as unknown as ValueType, tolerance);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Compare absolute values for single numbers and vectors.
|
|
84
|
+
* Not recommended for large vectors as this creates a copy
|
|
85
|
+
*/
|
|
86
|
+
const isEqualAbs = <ValueType>(
|
|
87
|
+
v1: ValueType,
|
|
88
|
+
v2: ValueType,
|
|
89
|
+
tolerance = undefined
|
|
90
|
+
) => isEqual(abs(v1), abs(v2) as unknown as ValueType, tolerance);
|
|
91
|
+
|
|
92
|
+
export { isEqualNegative, isEqual, isEqualAbs };
|