@cornerstonejs/core 1.57.0 → 1.57.1
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 +6 -2
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js +34 -2
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/StackViewport.d.ts +5 -3
- package/dist/cjs/RenderingEngine/StackViewport.js +33 -3
- package/dist/cjs/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/VideoViewport.d.ts +4 -2
- package/dist/cjs/RenderingEngine/VideoViewport.js +55 -2
- package/dist/cjs/RenderingEngine/VideoViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/Viewport.d.ts +4 -2
- package/dist/cjs/RenderingEngine/Viewport.js +25 -1
- package/dist/cjs/RenderingEngine/Viewport.js.map +1 -1
- package/dist/cjs/types/IViewport.d.ts +20 -3
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js +36 -2
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/StackViewport.js +37 -3
- package/dist/esm/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/VideoViewport.js +58 -2
- package/dist/esm/RenderingEngine/VideoViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/Viewport.js +24 -1
- package/dist/esm/RenderingEngine/Viewport.js.map +1 -1
- package/dist/types/RenderingEngine/BaseVolumeViewport.d.ts +6 -2
- package/dist/types/RenderingEngine/BaseVolumeViewport.d.ts.map +1 -1
- package/dist/types/RenderingEngine/StackViewport.d.ts +5 -3
- package/dist/types/RenderingEngine/StackViewport.d.ts.map +1 -1
- package/dist/types/RenderingEngine/VideoViewport.d.ts +4 -2
- package/dist/types/RenderingEngine/VideoViewport.d.ts.map +1 -1
- package/dist/types/RenderingEngine/Viewport.d.ts +4 -2
- package/dist/types/RenderingEngine/Viewport.d.ts.map +1 -1
- package/dist/types/types/IViewport.d.ts +20 -3
- package/dist/types/types/IViewport.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/index.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 +67 -3
- package/src/RenderingEngine/StackViewport.ts +61 -4
- package/src/RenderingEngine/VideoViewport.ts +85 -3
- package/src/RenderingEngine/Viewport.ts +43 -2
- package/src/types/IViewport.ts +106 -5
- package/src/types/index.ts +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "1.57.
|
|
3
|
+
"version": "1.57.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"type": "individual",
|
|
48
48
|
"url": "https://ohif.org/donate"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f0b7bf4653169cad680753b9d79556b5998b5758"
|
|
51
51
|
}
|
|
@@ -35,11 +35,13 @@ import type {
|
|
|
35
35
|
VOIRange,
|
|
36
36
|
EventTypes,
|
|
37
37
|
VolumeViewportProperties,
|
|
38
|
-
|
|
38
|
+
ViewReferenceSpecifier,
|
|
39
|
+
ReferenceCompatibleOptions,
|
|
39
40
|
} from '../types';
|
|
40
41
|
import { VoiModifiedEventDetail } from '../types/EventTypes';
|
|
41
42
|
import type { ViewportInput } from '../types/IViewport';
|
|
42
43
|
import type IVolumeViewport from '../types/IVolumeViewport';
|
|
44
|
+
import type { ViewReference } from '../types/IViewport';
|
|
43
45
|
import {
|
|
44
46
|
actorIsA,
|
|
45
47
|
applyPreset,
|
|
@@ -49,6 +51,7 @@ import {
|
|
|
49
51
|
invertRgbTransferFunction,
|
|
50
52
|
triggerEvent,
|
|
51
53
|
colormap as colormapUtils,
|
|
54
|
+
isEqual,
|
|
52
55
|
} from '../utilities';
|
|
53
56
|
import { createVolumeActor } from './helpers';
|
|
54
57
|
import volumeNewImageEventDispatcher, {
|
|
@@ -534,6 +537,52 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
534
537
|
}
|
|
535
538
|
}
|
|
536
539
|
|
|
540
|
+
/**
|
|
541
|
+
* Gets a view target, allowing comparison between view positions as well
|
|
542
|
+
* as restoring views later.
|
|
543
|
+
*/
|
|
544
|
+
public getViewReference(
|
|
545
|
+
viewRefSpecifier: ViewReferenceSpecifier = {}
|
|
546
|
+
): ViewReference {
|
|
547
|
+
const target = super.getViewReference(viewRefSpecifier);
|
|
548
|
+
if (viewRefSpecifier?.forFrameOfReference !== false) {
|
|
549
|
+
target.volumeId = this.getVolumeId(viewRefSpecifier);
|
|
550
|
+
}
|
|
551
|
+
// TODO - add referencedImageId as a base URL for an image to allow a generic
|
|
552
|
+
// method to specify which volumes this should apply to.
|
|
553
|
+
return {
|
|
554
|
+
...target,
|
|
555
|
+
sliceIndex: this.getCurrentImageIdIndex(),
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Find out if this viewport would show this view
|
|
561
|
+
*
|
|
562
|
+
* @param options - allows specifying whether the view COULD display this with
|
|
563
|
+
* some modification - either navigation or displaying as volume.
|
|
564
|
+
* @returns true if the target is compatible with this view
|
|
565
|
+
*/
|
|
566
|
+
public isReferenceViewable(
|
|
567
|
+
viewRef: ViewReference,
|
|
568
|
+
options?: ReferenceCompatibleOptions
|
|
569
|
+
): boolean {
|
|
570
|
+
if (!super.isReferenceViewable(viewRef, options)) {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
if (options?.withNavigation) {
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
const currentSliceIndex = this.getCurrentImageIdIndex();
|
|
577
|
+
const { sliceIndex } = viewRef;
|
|
578
|
+
if (Array.isArray(sliceIndex)) {
|
|
579
|
+
return (
|
|
580
|
+
sliceIndex[0] <= currentSliceIndex && currentSliceIndex <= sliceIndex[1]
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
return sliceIndex === undefined || sliceIndex === currentSliceIndex;
|
|
584
|
+
}
|
|
585
|
+
|
|
537
586
|
/**
|
|
538
587
|
* Sets the properties for the volume viewport on the volume
|
|
539
588
|
* and if setProperties is called for the first time, the properties will also become the default one.
|
|
@@ -1395,8 +1444,23 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
1395
1444
|
|
|
1396
1445
|
abstract getCurrentImageId(): string;
|
|
1397
1446
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1447
|
+
/** Gets the volumeId to use for references */
|
|
1448
|
+
protected getVolumeId(specifier: ViewReferenceSpecifier) {
|
|
1449
|
+
if (!specifier?.volumeId) {
|
|
1450
|
+
const actorEntries = this.getActors();
|
|
1451
|
+
if (!actorEntries) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
// find the first image actor of instance type vtkVolume
|
|
1455
|
+
return actorEntries.find(
|
|
1456
|
+
(actorEntry) => actorEntry.actor.getClassName() === 'vtkVolume'
|
|
1457
|
+
)?.uid;
|
|
1458
|
+
}
|
|
1459
|
+
return specifier.volumeId;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
public getReferenceId(specifier: ViewReferenceSpecifier = {}): string {
|
|
1463
|
+
let { volumeId, sliceIndex: sliceIndex } = specifier;
|
|
1400
1464
|
if (!volumeId) {
|
|
1401
1465
|
const actorEntries = this.getActors();
|
|
1402
1466
|
if (!actorEntries) {
|
|
@@ -33,9 +33,14 @@ import type {
|
|
|
33
33
|
Scaling,
|
|
34
34
|
StackViewportProperties,
|
|
35
35
|
VOIRange,
|
|
36
|
+
ViewReference,
|
|
36
37
|
VolumeActor,
|
|
37
38
|
} from '../types';
|
|
38
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
ViewReferenceSpecifier,
|
|
41
|
+
ReferenceCompatibleOptions,
|
|
42
|
+
ViewportInput,
|
|
43
|
+
} from '../types/IViewport';
|
|
39
44
|
import {
|
|
40
45
|
actorIsA,
|
|
41
46
|
colormap as colormapUtils,
|
|
@@ -2827,9 +2832,61 @@ class StackViewport extends Viewport implements IStackViewport, IImagesLoader {
|
|
|
2827
2832
|
return this.currentImageIdIndex;
|
|
2828
2833
|
};
|
|
2829
2834
|
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2835
|
+
/**
|
|
2836
|
+
* Checks to see if this target is or could be shown in this viewport
|
|
2837
|
+
*/
|
|
2838
|
+
public isReferenceViewable(
|
|
2839
|
+
viewRef: ViewReference,
|
|
2840
|
+
options: ReferenceCompatibleOptions = {}
|
|
2841
|
+
): boolean {
|
|
2842
|
+
if (!super.isReferenceViewable(viewRef, options)) {
|
|
2843
|
+
return false;
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
let { imageURI } = options;
|
|
2847
|
+
const { referencedImageId, sliceIndex } = viewRef;
|
|
2848
|
+
|
|
2849
|
+
if (viewRef.volumeId && !referencedImageId) {
|
|
2850
|
+
return options.asVolume === true;
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
let testIndex = this.getCurrentImageIdIndex();
|
|
2854
|
+
if (options.withNavigation && typeof sliceIndex === 'number') {
|
|
2855
|
+
testIndex = sliceIndex;
|
|
2856
|
+
}
|
|
2857
|
+
const imageId = this.imageIds[testIndex];
|
|
2858
|
+
if (!imageId) {
|
|
2859
|
+
return false;
|
|
2860
|
+
}
|
|
2861
|
+
if (!imageURI) {
|
|
2862
|
+
// Remove the dataLoader scheme since that can change
|
|
2863
|
+
const colonIndex = imageId.indexOf(':');
|
|
2864
|
+
imageURI = imageId.substring(colonIndex + 1);
|
|
2865
|
+
}
|
|
2866
|
+
return referencedImageId.endsWith(imageURI);
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
/**
|
|
2870
|
+
* Gets a standard target to show this image instance.
|
|
2871
|
+
*/
|
|
2872
|
+
public getViewReference(
|
|
2873
|
+
viewRefSpecifier: ViewReferenceSpecifier = {}
|
|
2874
|
+
): ViewReference {
|
|
2875
|
+
const { sliceIndex: sliceIndex = this.currentImageIdIndex } =
|
|
2876
|
+
viewRefSpecifier;
|
|
2877
|
+
return {
|
|
2878
|
+
...super.getViewReference(viewRefSpecifier),
|
|
2879
|
+
referencedImageId: `${this.imageIds[sliceIndex as number]}`,
|
|
2880
|
+
sliceIndex: sliceIndex,
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
public getReferenceId(specifier: ViewReferenceSpecifier = {}): string {
|
|
2885
|
+
const { sliceIndex: sliceIndex = this.currentImageIdIndex } = specifier;
|
|
2886
|
+
if (Array.isArray(sliceIndex)) {
|
|
2887
|
+
throw new Error('Use of slice ranges for stacks not supported');
|
|
2888
|
+
}
|
|
2889
|
+
return `imageId:${this.imageIds[sliceIndex]}`;
|
|
2833
2890
|
}
|
|
2834
2891
|
|
|
2835
2892
|
/**
|
|
@@ -15,7 +15,9 @@ import type {
|
|
|
15
15
|
VOIRange,
|
|
16
16
|
ICanvasActor,
|
|
17
17
|
IImage,
|
|
18
|
-
|
|
18
|
+
ViewReferenceSpecifier,
|
|
19
|
+
ViewReference,
|
|
20
|
+
ReferenceCompatibleOptions,
|
|
19
21
|
} from '../types';
|
|
20
22
|
import * as metaData from '../metaData';
|
|
21
23
|
import { Transform } from './helpers/cpuFallback/rendering/transform';
|
|
@@ -673,11 +675,20 @@ class VideoViewport extends Viewport implements IVideoViewport {
|
|
|
673
675
|
return current;
|
|
674
676
|
}
|
|
675
677
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
+
/**
|
|
679
|
+
* Gets a target id that can be used to specify how to show this
|
|
680
|
+
*/
|
|
681
|
+
public getReferenceId(specifier: ViewReferenceSpecifier = {}): string {
|
|
682
|
+
const { sliceIndex: sliceIndex } = specifier;
|
|
678
683
|
if (sliceIndex === undefined) {
|
|
679
684
|
return `videoId:${this.getCurrentImageId()}`;
|
|
680
685
|
}
|
|
686
|
+
if (Array.isArray(sliceIndex)) {
|
|
687
|
+
// Just remove the 1 from the end of the base URL - TODO, handle other types
|
|
688
|
+
return `videoId:${this.imageId.substring(0, this.imageId.length - 1)}${
|
|
689
|
+
sliceIndex[0] + 1
|
|
690
|
+
}-${sliceIndex[1] + 1}`;
|
|
691
|
+
}
|
|
681
692
|
const baseTarget = this.imageId.replace(
|
|
682
693
|
'/frames/1',
|
|
683
694
|
`/frames/${1 + sliceIndex}`
|
|
@@ -685,6 +696,69 @@ class VideoViewport extends Viewport implements IVideoViewport {
|
|
|
685
696
|
return `videoId:${baseTarget}`;
|
|
686
697
|
}
|
|
687
698
|
|
|
699
|
+
/**
|
|
700
|
+
* Figure out if a given view can be shown in the current viewport.
|
|
701
|
+
*/
|
|
702
|
+
public isReferenceViewable(
|
|
703
|
+
viewRef: ViewReference,
|
|
704
|
+
options: ReferenceCompatibleOptions = {}
|
|
705
|
+
): boolean {
|
|
706
|
+
let { imageURI } = options;
|
|
707
|
+
const { referencedImageId, sliceIndex: sliceIndex } = viewRef;
|
|
708
|
+
if (!super.isReferenceViewable(viewRef)) {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
const imageId = this.getCurrentImageId();
|
|
713
|
+
if (!imageURI) {
|
|
714
|
+
// Remove the dataLoader scheme and frame number
|
|
715
|
+
// TODO - handle more imageURI types.
|
|
716
|
+
const colonIndex = imageId.indexOf(':');
|
|
717
|
+
imageURI = imageId.substring(colonIndex + 1, imageId.length - 1);
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (options.withNavigation) {
|
|
721
|
+
return true;
|
|
722
|
+
}
|
|
723
|
+
const currentIndex = this.getCurrentImageIdIndex();
|
|
724
|
+
if (Array.isArray(sliceIndex)) {
|
|
725
|
+
return currentIndex >= sliceIndex[0] && currentIndex <= sliceIndex[1];
|
|
726
|
+
}
|
|
727
|
+
if (sliceIndex !== undefined) {
|
|
728
|
+
return currentIndex === sliceIndex;
|
|
729
|
+
}
|
|
730
|
+
if (!referencedImageId) {
|
|
731
|
+
return false;
|
|
732
|
+
}
|
|
733
|
+
const match = referencedImageId.match(VideoViewport.frameRangeExtractor);
|
|
734
|
+
if (!match || !match[2]) {
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
const range = match[2].split('-').map((it) => Number(it));
|
|
738
|
+
const frame = currentIndex + 1;
|
|
739
|
+
return range[0] <= frame && frame <= (range[1] ?? range[0]);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Gets a view target that species what type of view is required to show
|
|
744
|
+
* the current view, or the one specified in the forTarget modifiers.
|
|
745
|
+
*/
|
|
746
|
+
public getViewReference(
|
|
747
|
+
viewRefSpecifier?: ViewReferenceSpecifier
|
|
748
|
+
): ViewReference {
|
|
749
|
+
let sliceIndex = viewRefSpecifier?.sliceIndex;
|
|
750
|
+
if (!sliceIndex) {
|
|
751
|
+
sliceIndex = this.isPlaying
|
|
752
|
+
? [this.frameRange[0] - 1, this.frameRange[1] - 1]
|
|
753
|
+
: this.getCurrentImageIdIndex();
|
|
754
|
+
}
|
|
755
|
+
return {
|
|
756
|
+
...super.getViewReference(viewRefSpecifier),
|
|
757
|
+
referencedImageId: this.getReferenceId(viewRefSpecifier),
|
|
758
|
+
sliceIndex: sliceIndex,
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
|
|
688
762
|
/**
|
|
689
763
|
* Gets the 1 based frame number (ala DICOM value), eg `1+ currentImageIdIndex`
|
|
690
764
|
*/
|
|
@@ -962,6 +1036,14 @@ class VideoViewport extends Viewport implements IVideoViewport {
|
|
|
962
1036
|
time: this.videoElement.currentTime,
|
|
963
1037
|
duration: this.videoElement.duration,
|
|
964
1038
|
});
|
|
1039
|
+
triggerEvent(this.element, EVENTS.IMAGE_RENDERED, {
|
|
1040
|
+
element: this.element,
|
|
1041
|
+
viewportId: this.id,
|
|
1042
|
+
viewport: this,
|
|
1043
|
+
renderingEngineId: this.renderingEngineId,
|
|
1044
|
+
time: this.videoElement.currentTime,
|
|
1045
|
+
duration: this.videoElement.duration,
|
|
1046
|
+
});
|
|
965
1047
|
|
|
966
1048
|
const frame = this.getFrameNumber();
|
|
967
1049
|
if (this.isPlaying) {
|
|
@@ -33,7 +33,9 @@ import type {
|
|
|
33
33
|
import type {
|
|
34
34
|
ViewportInput,
|
|
35
35
|
IViewport,
|
|
36
|
-
|
|
36
|
+
ViewReferenceSpecifier,
|
|
37
|
+
ViewReference,
|
|
38
|
+
ReferenceCompatibleOptions,
|
|
37
39
|
} from '../types/IViewport';
|
|
38
40
|
import type { vtkSlabCamera } from './vtkClasses/vtkSlabCamera';
|
|
39
41
|
import { getConfiguration } from '../init';
|
|
@@ -898,7 +900,7 @@ class Viewport implements IViewport {
|
|
|
898
900
|
throw new Error('Not implemented');
|
|
899
901
|
}
|
|
900
902
|
|
|
901
|
-
public
|
|
903
|
+
public getReferenceId(specifier?: ViewReferenceSpecifier): string {
|
|
902
904
|
return null;
|
|
903
905
|
}
|
|
904
906
|
|
|
@@ -1381,6 +1383,45 @@ class Viewport implements IViewport {
|
|
|
1381
1383
|
return { widthWorld: maxX - minX, heightWorld: maxY - minY };
|
|
1382
1384
|
}
|
|
1383
1385
|
|
|
1386
|
+
public getViewReference(
|
|
1387
|
+
viewRefSpecifier: ViewReferenceSpecifier = {}
|
|
1388
|
+
): ViewReference {
|
|
1389
|
+
const { focalPoint: cameraFocalPoint, viewPlaneNormal } = this.getCamera();
|
|
1390
|
+
const target: ViewReference = {
|
|
1391
|
+
FrameOfReferenceUID: this.getFrameOfReferenceUID(),
|
|
1392
|
+
cameraFocalPoint,
|
|
1393
|
+
viewPlaneNormal,
|
|
1394
|
+
sliceIndex: viewRefSpecifier.sliceIndex ?? this.getCurrentImageIdIndex(),
|
|
1395
|
+
};
|
|
1396
|
+
return target;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
public isReferenceViewable(
|
|
1400
|
+
viewRef: ViewReference,
|
|
1401
|
+
options?: ReferenceCompatibleOptions
|
|
1402
|
+
): boolean {
|
|
1403
|
+
if (
|
|
1404
|
+
viewRef.FrameOfReferenceUID &&
|
|
1405
|
+
viewRef.FrameOfReferenceUID !== this.getFrameOfReferenceUID()
|
|
1406
|
+
) {
|
|
1407
|
+
return false;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
const { viewPlaneNormal } = viewRef;
|
|
1411
|
+
const camera = this.getCamera();
|
|
1412
|
+
if (
|
|
1413
|
+
!isEqual(viewPlaneNormal, camera.viewPlaneNormal) &&
|
|
1414
|
+
!isEqual(
|
|
1415
|
+
vec3.negate(camera.viewPlaneNormal, camera.viewPlaneNormal),
|
|
1416
|
+
viewPlaneNormal
|
|
1417
|
+
)
|
|
1418
|
+
) {
|
|
1419
|
+
// Could navigate as a volume to the reference
|
|
1420
|
+
return options?.asVolume === true;
|
|
1421
|
+
}
|
|
1422
|
+
return true;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1384
1425
|
protected _shouldUseNativeDataType() {
|
|
1385
1426
|
const { useNorm16Texture, preferSizeOverAccuracy } =
|
|
1386
1427
|
getConfiguration().rendering;
|
package/src/types/IViewport.ts
CHANGED
|
@@ -6,14 +6,23 @@ import { ActorEntry } from './IActor';
|
|
|
6
6
|
import ViewportType from '../enums/ViewportType';
|
|
7
7
|
import ViewportStatus from '../enums/ViewportStatus';
|
|
8
8
|
import DisplayArea from './displayArea';
|
|
9
|
+
import BoundsLPS from './BoundsLPS';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
|
-
* Specifies what
|
|
12
|
+
* Specifies what view to get a reference for.
|
|
13
|
+
* This set of options allows a Viewport to return a reference for an image
|
|
14
|
+
* not currently in view, such as for a different slice, or for a given set of
|
|
15
|
+
* points.
|
|
12
16
|
*/
|
|
13
|
-
export type
|
|
17
|
+
export type ViewReferenceSpecifier = {
|
|
14
18
|
/** The slice index within the current viewport camera to get a reference for */
|
|
15
|
-
sliceIndex?: number;
|
|
16
|
-
/**
|
|
19
|
+
sliceIndex?: number | [number, number];
|
|
20
|
+
/**
|
|
21
|
+
* Specifies to get a view reference that refers to the generic frame of
|
|
22
|
+
* reference rather than to a specific volume or stack. Thus, the view
|
|
23
|
+
* reference would be compatible with any view showing the same frame of
|
|
24
|
+
* reference UID.
|
|
25
|
+
*/
|
|
17
26
|
forFrameOfReference?: boolean;
|
|
18
27
|
/** Set of points to get a reference for, in world space */
|
|
19
28
|
points?: Point3[];
|
|
@@ -21,6 +30,81 @@ export type TargetSpecifier = {
|
|
|
21
30
|
volumeId?: string;
|
|
22
31
|
};
|
|
23
32
|
|
|
33
|
+
/**
|
|
34
|
+
* These are the options arguments to determine whether a view reference
|
|
35
|
+
* is compatible with a viewport, that is, could be or is shown in a viewport.
|
|
36
|
+
* That specifies whether a view could be shown in a given viewport or not.
|
|
37
|
+
*/
|
|
38
|
+
export type ReferenceCompatibleOptions = {
|
|
39
|
+
/**
|
|
40
|
+
* Test whether the view could be shown if the viewport were navigated.
|
|
41
|
+
* That is, test is just changing the slice position and zoom/pan would
|
|
42
|
+
* allow showing the view.
|
|
43
|
+
*/
|
|
44
|
+
withNavigation?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* For a stack viewport, return true if this viewport could show the given
|
|
47
|
+
* view if it were converted into a volume viewport, while for a volume,
|
|
48
|
+
* could it be shown if the camera/orientation were changed.
|
|
49
|
+
* That is, is the specified view showing an image in the stack but with a
|
|
50
|
+
* different orientation than acquisition.
|
|
51
|
+
*/
|
|
52
|
+
asVolume?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Use this imageURI for testing - may or may not be the current one.
|
|
55
|
+
* Should be a straight contains URI for the set of imageIds in any of
|
|
56
|
+
* the volumes or set of image ids.
|
|
57
|
+
* This is an optimization setting only that makes the test faster, and does
|
|
58
|
+
* not need to be provided.
|
|
59
|
+
*/
|
|
60
|
+
imageURI?: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A view reference references the image/location of an image. It
|
|
65
|
+
* basically says would this viewport show this view, or can direct a viewport
|
|
66
|
+
* to show a specific view.
|
|
67
|
+
*/
|
|
68
|
+
export type ViewReference = {
|
|
69
|
+
/**
|
|
70
|
+
* The FrameOfReferenceUID
|
|
71
|
+
*/
|
|
72
|
+
FrameOfReferenceUID: string;
|
|
73
|
+
/**
|
|
74
|
+
* An optional property used to specify the particular image that this view includes.
|
|
75
|
+
* For volumes, that will specify which image is closest to the requested
|
|
76
|
+
* point(s) in some fashion, or will be undefined when the reference applies
|
|
77
|
+
* to any volume with the same frame of reference.
|
|
78
|
+
*
|
|
79
|
+
* The naming of this particular attribute matches the DICOM SR naming for the
|
|
80
|
+
* referenced image, as well as historical naming in CS3D.
|
|
81
|
+
*/
|
|
82
|
+
referencedImageId?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The focal point of the camera in world space
|
|
86
|
+
*/
|
|
87
|
+
cameraFocalPoint?: Point3;
|
|
88
|
+
/**
|
|
89
|
+
* The normal for the current view
|
|
90
|
+
*/
|
|
91
|
+
viewPlaneNormal?: Point3;
|
|
92
|
+
/**
|
|
93
|
+
* The slice index or range for this view
|
|
94
|
+
*/
|
|
95
|
+
sliceIndex?: number | [number, number];
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* VolumeId that the referencedImageId was chosen from
|
|
99
|
+
*/
|
|
100
|
+
volumeId?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The bounds that are shown. Allows specifying whether a view includes
|
|
103
|
+
* particular bounds or not. This will be in world coordinates.
|
|
104
|
+
*/
|
|
105
|
+
bounds?: BoundsLPS;
|
|
106
|
+
};
|
|
107
|
+
|
|
24
108
|
/**
|
|
25
109
|
* Viewport interface for cornerstone viewports
|
|
26
110
|
*/
|
|
@@ -124,7 +208,24 @@ interface IViewport {
|
|
|
124
208
|
/** Gets the current slice in the current camera orientation */
|
|
125
209
|
getCurrentImageIdIndex(): number;
|
|
126
210
|
/** Gets a referenced image url of some sort - could be a real image id, or could be a URL with parameters */
|
|
127
|
-
|
|
211
|
+
getReferenceId(viewRefSpecifier?: ViewReferenceSpecifier): string;
|
|
212
|
+
/**
|
|
213
|
+
* Gets a view target, allowing comparison between view positions as well
|
|
214
|
+
* as restoring views later.
|
|
215
|
+
*/
|
|
216
|
+
getViewReference(viewRefSpecifier?: ViewReferenceSpecifier): ViewReference;
|
|
217
|
+
/**
|
|
218
|
+
* Find out if this viewport does or could show this view reference.
|
|
219
|
+
*
|
|
220
|
+
* @param options - allows specifying whether the view COULD display this with
|
|
221
|
+
* some modification - either navigation or displaying as volume.
|
|
222
|
+
* @returns true if the viewport could show this view reference
|
|
223
|
+
*/
|
|
224
|
+
isReferenceViewable(
|
|
225
|
+
viewRef: ViewReference,
|
|
226
|
+
options?: ReferenceCompatibleOptions
|
|
227
|
+
): boolean;
|
|
228
|
+
|
|
128
229
|
/** whether the viewport has custom rendering */
|
|
129
230
|
customRenderViewportToCanvas: () => unknown;
|
|
130
231
|
_getCorners(bounds: Array<number>): Array<number>[];
|
package/src/types/index.ts
CHANGED
|
@@ -16,7 +16,9 @@ import type CustomEventType from './CustomEventType';
|
|
|
16
16
|
import type {
|
|
17
17
|
IViewport,
|
|
18
18
|
PublicViewportInput,
|
|
19
|
-
|
|
19
|
+
ViewReferenceSpecifier,
|
|
20
|
+
ReferenceCompatibleOptions,
|
|
21
|
+
ViewReference,
|
|
20
22
|
} from './IViewport';
|
|
21
23
|
import type {
|
|
22
24
|
VolumeActor,
|
|
@@ -157,7 +159,9 @@ export type {
|
|
|
157
159
|
IRegisterImageLoader,
|
|
158
160
|
IStreamingVolumeProperties,
|
|
159
161
|
IViewport,
|
|
160
|
-
|
|
162
|
+
ViewReference,
|
|
163
|
+
ReferenceCompatibleOptions,
|
|
164
|
+
ViewReferenceSpecifier as ViewReferenceSpecifier,
|
|
161
165
|
StackViewportProperties,
|
|
162
166
|
VolumeViewportProperties,
|
|
163
167
|
ViewportProperties,
|