@cornerstonejs/core 4.22.11 → 4.22.12
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/RenderingEngine/StackViewport.d.ts +4 -0
- package/dist/esm/RenderingEngine/StackViewport.js +66 -8
- package/dist/esm/RenderingEngine/Viewport.d.ts +4 -0
- package/dist/esm/RenderingEngine/Viewport.js +84 -6
- package/dist/esm/RenderingEngine/VolumeViewport.js +4 -2
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/calculateTransform.js +6 -1
- package/dist/esm/RenderingEngine/helpers/getProjectionScaleMatrix.d.ts +2 -0
- package/dist/esm/RenderingEngine/helpers/getProjectionScaleMatrix.js +10 -0
- package/dist/esm/RenderingEngine/helpers/index.d.ts +2 -1
- package/dist/esm/RenderingEngine/helpers/index.js +2 -1
- package/dist/esm/RenderingEngine/vtkClasses/extendedVtkCamera.d.ts +38 -0
- package/dist/esm/RenderingEngine/vtkClasses/extendedVtkCamera.js +35 -0
- package/dist/esm/RenderingEngine/vtkClasses/vtkSlabCamera.d.ts +2 -0
- package/dist/esm/RenderingEngine/vtkClasses/vtkSlabCamera.js +9 -2
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/types/CPUFallbackViewport.d.ts +2 -0
- package/dist/esm/types/ICamera.d.ts +9 -1
- package/dist/esm/types/IImage.d.ts +1 -0
- package/dist/esm/types/IViewport.d.ts +2 -0
- package/dist/esm/types/ViewportInputOptions.d.ts +2 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/utilities/getNormalizedAspectRatio.d.ts +2 -0
- package/dist/esm/utilities/getNormalizedAspectRatio.js +12 -0
- package/dist/esm/utilities/index.d.ts +2 -1
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -64,6 +64,7 @@ declare class StackViewport extends Viewport {
|
|
|
64
64
|
resetZoom?: boolean;
|
|
65
65
|
resetToCenter?: boolean;
|
|
66
66
|
suppressEvents?: boolean;
|
|
67
|
+
resetAspectRatio?: boolean;
|
|
67
68
|
}) => boolean;
|
|
68
69
|
canvasToWorld: (canvasPos: Point2) => Point3;
|
|
69
70
|
worldToCanvas: (worldPos: Point3) => Point2;
|
|
@@ -104,11 +105,14 @@ declare class StackViewport extends Viewport {
|
|
|
104
105
|
private _getVOIFromCache;
|
|
105
106
|
private _setPropertiesFromCache;
|
|
106
107
|
private getCameraCPU;
|
|
108
|
+
private setAspectRatioForViewport;
|
|
107
109
|
private setCameraCPU;
|
|
108
110
|
private getPanCPU;
|
|
109
111
|
private setPanCPU;
|
|
110
112
|
private getZoomCPU;
|
|
111
113
|
private setZoomCPU;
|
|
114
|
+
getAspectRatioCPU(): Point2;
|
|
115
|
+
setAspectRatioCPU(value: Point2, isFitViewportAfterStretch?: boolean, storeAsInitialCamera?: boolean): void;
|
|
112
116
|
private setFlipCPU;
|
|
113
117
|
private getRotationCPU;
|
|
114
118
|
private getRotationGPU;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
|
|
2
2
|
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
|
|
3
|
-
import
|
|
3
|
+
import extendedVtkCamera from './vtkClasses/extendedVtkCamera';
|
|
4
4
|
import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction';
|
|
5
5
|
import vtkColorMaps from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps';
|
|
6
6
|
import vtkImageMapper from '@kitware/vtk.js/Rendering/Core/ImageMapper';
|
|
@@ -149,6 +149,7 @@ class StackViewport extends Viewport {
|
|
|
149
149
|
resetPan: true,
|
|
150
150
|
resetZoom: true,
|
|
151
151
|
resetToCenter: true,
|
|
152
|
+
resetAspectRatio: true,
|
|
152
153
|
suppressEvents: true,
|
|
153
154
|
});
|
|
154
155
|
};
|
|
@@ -395,6 +396,14 @@ class StackViewport extends Viewport {
|
|
|
395
396
|
cpu: this.setZoomCPU,
|
|
396
397
|
gpu: super.setZoom,
|
|
397
398
|
},
|
|
399
|
+
getAspectRatio: {
|
|
400
|
+
cpu: this.getAspectRatioCPU,
|
|
401
|
+
gpu: super.getAspectRatio,
|
|
402
|
+
},
|
|
403
|
+
setAspectRatio: {
|
|
404
|
+
cpu: this.setAspectRatioCPU,
|
|
405
|
+
gpu: super.setAspectRatio,
|
|
406
|
+
},
|
|
398
407
|
setVOI: {
|
|
399
408
|
cpu: this.setVOICPU,
|
|
400
409
|
gpu: this.setVOIGPU,
|
|
@@ -418,8 +427,8 @@ class StackViewport extends Viewport {
|
|
|
418
427
|
return true;
|
|
419
428
|
},
|
|
420
429
|
gpu: (options = {}) => {
|
|
421
|
-
const { resetPan = true, resetZoom = true } = options;
|
|
422
|
-
this.resetCameraGPU({ resetPan, resetZoom });
|
|
430
|
+
const { resetPan = true, resetZoom = true, resetAspectRatio = true, } = options;
|
|
431
|
+
this.resetCameraGPU({ resetPan, resetZoom, resetAspectRatio });
|
|
423
432
|
return true;
|
|
424
433
|
},
|
|
425
434
|
},
|
|
@@ -528,12 +537,12 @@ class StackViewport extends Viewport {
|
|
|
528
537
|
canvas: this.canvas,
|
|
529
538
|
renderingTools: {},
|
|
530
539
|
transform: new Transform(),
|
|
531
|
-
viewport: { rotation: 0 },
|
|
540
|
+
viewport: { rotation: 0, aspectRatio: [1, 1] },
|
|
532
541
|
};
|
|
533
542
|
}
|
|
534
543
|
_resetGPUViewport() {
|
|
535
544
|
const renderer = this.getRenderer();
|
|
536
|
-
const camera =
|
|
545
|
+
const camera = extendedVtkCamera.newInstance();
|
|
537
546
|
renderer.setActiveCamera(camera);
|
|
538
547
|
const viewPlaneNormal = [0, 0, -1];
|
|
539
548
|
this.initialViewUp = [0, -1, 0];
|
|
@@ -817,15 +826,46 @@ class StackViewport extends Viewport {
|
|
|
817
826
|
viewPlaneNormal[1],
|
|
818
827
|
viewPlaneNormal[2],
|
|
819
828
|
],
|
|
829
|
+
aspectRatio: viewport.aspectRatio ?? [1, 1],
|
|
820
830
|
viewUp: [viewUp[0], viewUp[1], viewUp[2]],
|
|
821
831
|
flipHorizontal: this.flipHorizontal,
|
|
822
832
|
flipVertical: this.flipVertical,
|
|
823
833
|
};
|
|
824
834
|
}
|
|
835
|
+
setAspectRatioForViewport(aspectRatio, isFitViewportAfterStretch = true) {
|
|
836
|
+
const { viewport, image } = this._cpuFallbackEnabledElement;
|
|
837
|
+
if (!isFitViewportAfterStretch) {
|
|
838
|
+
viewport.aspectRatio = aspectRatio;
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
const { clientWidth, clientHeight } = this.element;
|
|
842
|
+
const { rowPixelSpacing, columnPixelSpacing, width, height } = image;
|
|
843
|
+
const getRatioValue = ([x, y]) => x / y;
|
|
844
|
+
const oldRatioValue = getRatioValue(viewport.aspectRatio || [1, 1]);
|
|
845
|
+
const newRatioValue = getRatioValue(aspectRatio);
|
|
846
|
+
const canvasRatio = clientWidth / clientHeight;
|
|
847
|
+
const baseHeight = clientHeight * rowPixelSpacing * 0.5;
|
|
848
|
+
const calculateFitParallelScale = (rVal) => {
|
|
849
|
+
const effectiveWidth = width * columnPixelSpacing * rVal;
|
|
850
|
+
const effectiveHeight = height * rowPixelSpacing;
|
|
851
|
+
if (effectiveWidth / effectiveHeight > canvasRatio) {
|
|
852
|
+
return baseHeight / (clientWidth / effectiveWidth);
|
|
853
|
+
}
|
|
854
|
+
const fitPScale = effectiveHeight * 0.5;
|
|
855
|
+
return rVal < 1 ? fitPScale / rVal : fitPScale;
|
|
856
|
+
};
|
|
857
|
+
const ratioFactor = calculateFitParallelScale(newRatioValue) /
|
|
858
|
+
calculateFitParallelScale(oldRatioValue);
|
|
859
|
+
viewport.aspectRatio = aspectRatio;
|
|
860
|
+
if (viewport.parallelScale) {
|
|
861
|
+
viewport.parallelScale *= ratioFactor;
|
|
862
|
+
viewport.scale = baseHeight / viewport.parallelScale;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
825
865
|
setCameraCPU(cameraInterface) {
|
|
826
866
|
const { viewport, image } = this._cpuFallbackEnabledElement;
|
|
827
867
|
const previousCamera = this.getCameraCPU();
|
|
828
|
-
const { focalPoint, parallelScale, scale, flipHorizontal, flipVertical } = cameraInterface;
|
|
868
|
+
const { focalPoint, parallelScale, scale, flipHorizontal, flipVertical, aspectRatio, isFitViewportAfterStretch, } = cameraInterface;
|
|
829
869
|
const { clientHeight } = this.element;
|
|
830
870
|
if (focalPoint) {
|
|
831
871
|
const focalPointCanvas = this.worldToCanvasCPU(focalPoint);
|
|
@@ -849,6 +889,9 @@ class StackViewport extends Viewport {
|
|
|
849
889
|
viewport.scale = scale;
|
|
850
890
|
viewport.parallelScale = (clientHeight * rowPixelSpacing * 0.5) / scale;
|
|
851
891
|
}
|
|
892
|
+
if (aspectRatio) {
|
|
893
|
+
this.setAspectRatioForViewport(aspectRatio, isFitViewportAfterStretch);
|
|
894
|
+
}
|
|
852
895
|
if (flipHorizontal !== undefined || flipVertical !== undefined) {
|
|
853
896
|
this.setFlipCPU({ flipHorizontal, flipVertical });
|
|
854
897
|
}
|
|
@@ -881,6 +924,21 @@ class StackViewport extends Viewport {
|
|
|
881
924
|
const camera = this.getCameraCPU();
|
|
882
925
|
this.setCameraCPU({ ...camera, scale: zoom });
|
|
883
926
|
}
|
|
927
|
+
getAspectRatioCPU() {
|
|
928
|
+
const { aspectRatio } = this.getCameraCPU();
|
|
929
|
+
return aspectRatio ?? this.options?.aspectRatio ?? [1, 1];
|
|
930
|
+
}
|
|
931
|
+
setAspectRatioCPU(value, isFitViewportAfterStretch = true, storeAsInitialCamera = false) {
|
|
932
|
+
const camera = this.getCameraCPU();
|
|
933
|
+
if (storeAsInitialCamera) {
|
|
934
|
+
this.options.aspectRatio = value;
|
|
935
|
+
}
|
|
936
|
+
this.setCameraCPU({
|
|
937
|
+
...camera,
|
|
938
|
+
aspectRatio: value,
|
|
939
|
+
isFitViewportAfterStretch,
|
|
940
|
+
});
|
|
941
|
+
}
|
|
884
942
|
setFlipCPU({ flipHorizontal, flipVertical }) {
|
|
885
943
|
const { viewport } = this._cpuFallbackEnabledElement;
|
|
886
944
|
if (flipHorizontal !== undefined) {
|
|
@@ -1682,14 +1740,14 @@ class StackViewport extends Viewport {
|
|
|
1682
1740
|
scale,
|
|
1683
1741
|
});
|
|
1684
1742
|
}
|
|
1685
|
-
resetCameraGPU(
|
|
1743
|
+
resetCameraGPU(resetOptions) {
|
|
1686
1744
|
this.setCamera({
|
|
1687
1745
|
flipHorizontal: false,
|
|
1688
1746
|
flipVertical: false,
|
|
1689
1747
|
viewUp: this.initialViewUp,
|
|
1690
1748
|
});
|
|
1691
1749
|
const resetToCenter = true;
|
|
1692
|
-
return super.resetCamera({
|
|
1750
|
+
return super.resetCamera({ resetToCenter, ...resetOptions });
|
|
1693
1751
|
}
|
|
1694
1752
|
scroll(delta, debounce = true, loop = false) {
|
|
1695
1753
|
const imageIds = this.imageIds;
|
|
@@ -100,6 +100,7 @@ declare class Viewport {
|
|
|
100
100
|
resetZoom?: boolean;
|
|
101
101
|
resetToCenter?: boolean;
|
|
102
102
|
storeAsInitialCamera?: boolean;
|
|
103
|
+
resetAspectRatio?: boolean;
|
|
103
104
|
}): boolean;
|
|
104
105
|
protected setInitialCamera(camera: ICamera): void;
|
|
105
106
|
protected setFitToCanvasCamera(camera: ICamera): void;
|
|
@@ -111,11 +112,14 @@ declare class Viewport {
|
|
|
111
112
|
setPan(pan: Point2, storeAsInitialCamera?: boolean): void;
|
|
112
113
|
getZoom(compareCamera?: ICamera): number;
|
|
113
114
|
setZoom(value: number, storeAsInitialCamera?: boolean): void;
|
|
115
|
+
getAspectRatio(): Point2;
|
|
116
|
+
setAspectRatio(value: Point2, isFitViewportAfterStretch?: boolean, storeAsInitialCamera?: boolean): void;
|
|
114
117
|
private _getFocalPointForViewPlaneReset;
|
|
115
118
|
getCanvas(): HTMLCanvasElement;
|
|
116
119
|
protected getVtkActiveCamera(): vtkCamera | vtkSlabCamera;
|
|
117
120
|
protected getCameraNoRotation(): ICamera;
|
|
118
121
|
getCamera(): ICamera;
|
|
122
|
+
private setAspectRatioForVTKCamera;
|
|
119
123
|
setCamera(cameraInterface: ICamera, storeAsInitialCamera?: boolean): void;
|
|
120
124
|
triggerCameraModifiedEventIfNecessary(previousCamera: ICamera, updatedCamera: ICamera): void;
|
|
121
125
|
updateCameraClippingPlanesAndRange(): void;
|
|
@@ -22,6 +22,7 @@ class Viewport {
|
|
|
22
22
|
rotation: true,
|
|
23
23
|
pan: true,
|
|
24
24
|
zoom: true,
|
|
25
|
+
aspectRatio: true,
|
|
25
26
|
displayArea: true,
|
|
26
27
|
}; }
|
|
27
28
|
static { this.TransferViewPresentation = {
|
|
@@ -503,7 +504,7 @@ class Viewport {
|
|
|
503
504
|
return this.options?.displayArea;
|
|
504
505
|
}
|
|
505
506
|
resetCamera(options) {
|
|
506
|
-
const { resetPan = true, resetZoom = true, resetToCenter = true, storeAsInitialCamera = true, } = options || {};
|
|
507
|
+
const { resetPan = true, resetZoom = true, resetToCenter = true, storeAsInitialCamera = true, resetAspectRatio = true, } = options || {};
|
|
507
508
|
const renderer = this.getRenderer();
|
|
508
509
|
this.setCameraNoEvent({
|
|
509
510
|
flipHorizontal: false,
|
|
@@ -567,6 +568,9 @@ class Viewport {
|
|
|
567
568
|
];
|
|
568
569
|
activeCamera.setPhysicalScale(radius);
|
|
569
570
|
activeCamera.setPhysicalTranslation(-focalPointToSet[0], -focalPointToSet[1], -focalPointToSet[2]);
|
|
571
|
+
const targetAspectRatio = resetAspectRatio
|
|
572
|
+
? this.options?.aspectRatio || [1, 1]
|
|
573
|
+
: this.getAspectRatio();
|
|
570
574
|
this.setCamera({
|
|
571
575
|
parallelScale: resetZoom ? parallelScale : previousCamera.parallelScale,
|
|
572
576
|
focalPoint: focalPointToSet,
|
|
@@ -574,6 +578,8 @@ class Viewport {
|
|
|
574
578
|
viewAngle: 90,
|
|
575
579
|
viewUp: viewUpToSet,
|
|
576
580
|
clippingRange: clippingRangeToUse,
|
|
581
|
+
aspectRatio: targetAspectRatio,
|
|
582
|
+
isFitViewportAfterStretch: false,
|
|
577
583
|
});
|
|
578
584
|
const modifiedCamera = this.getCamera();
|
|
579
585
|
this.setFitToCanvasCamera(this.getCamera());
|
|
@@ -667,6 +673,21 @@ class Viewport {
|
|
|
667
673
|
parallelScale,
|
|
668
674
|
}, storeAsInitialCamera);
|
|
669
675
|
}
|
|
676
|
+
getAspectRatio() {
|
|
677
|
+
const { aspectRatio } = this.getCamera();
|
|
678
|
+
return aspectRatio ?? this.options?.aspectRatio ?? [1, 1];
|
|
679
|
+
}
|
|
680
|
+
setAspectRatio(value, isFitViewportAfterStretch = true, storeAsInitialCamera = false) {
|
|
681
|
+
const camera = this.getCamera();
|
|
682
|
+
if (storeAsInitialCamera) {
|
|
683
|
+
this.options.aspectRatio = value;
|
|
684
|
+
}
|
|
685
|
+
this.setCamera({
|
|
686
|
+
...camera,
|
|
687
|
+
aspectRatio: value,
|
|
688
|
+
isFitViewportAfterStretch,
|
|
689
|
+
}, storeAsInitialCamera);
|
|
690
|
+
}
|
|
670
691
|
_getFocalPointForViewPlaneReset(imageData) {
|
|
671
692
|
const { focalPoint, viewPlaneNormal: normal } = this.getCamera();
|
|
672
693
|
const intersections = this._getViewImageDataIntersections(imageData, focalPoint, normal);
|
|
@@ -715,6 +736,7 @@ class Viewport {
|
|
|
715
736
|
viewAngle: vtkCamera.getViewAngle(),
|
|
716
737
|
flipHorizontal: this.flipHorizontal,
|
|
717
738
|
flipVertical: this.flipVertical,
|
|
739
|
+
aspectRatio: vtkCamera.getAspectRatio(),
|
|
718
740
|
};
|
|
719
741
|
}
|
|
720
742
|
getCamera() {
|
|
@@ -724,11 +746,56 @@ class Viewport {
|
|
|
724
746
|
rotation: this.getRotation(),
|
|
725
747
|
};
|
|
726
748
|
}
|
|
749
|
+
setAspectRatioForVTKCamera(aspectRatio, isFitViewportAfterStretch = true) {
|
|
750
|
+
const vtkCamera = this.getVtkActiveCamera();
|
|
751
|
+
if (!isFitViewportAfterStretch) {
|
|
752
|
+
vtkCamera.setAspectRatio(aspectRatio);
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
const currentAspect = vtkCamera.getAspectRatio() || [1, 1];
|
|
756
|
+
if (currentAspect[0] === aspectRatio[0] &&
|
|
757
|
+
currentAspect[1] === aspectRatio[1]) {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
const getRatioValue = ([x, y]) => x / y;
|
|
761
|
+
const oldRatioValue = getRatioValue(currentAspect);
|
|
762
|
+
const newRatioValue = getRatioValue(aspectRatio);
|
|
763
|
+
vtkCamera.setAspectRatio(aspectRatio);
|
|
764
|
+
const imageData = this.getDefaultImageData();
|
|
765
|
+
if (!imageData)
|
|
766
|
+
return;
|
|
767
|
+
const getFitScale = (rVal) => {
|
|
768
|
+
const { widthWorld, heightWorld } = getCubeSizeInView(imageData, vtkCamera.getViewPlaneNormal(), vtkCamera.getViewUp());
|
|
769
|
+
const canvasAspectRatio = this.sWidth / this.sHeight;
|
|
770
|
+
const effectiveWidth = widthWorld * rVal;
|
|
771
|
+
const effectiveImageRatio = effectiveWidth / heightWorld;
|
|
772
|
+
let fitScale = effectiveImageRatio > canvasAspectRatio
|
|
773
|
+
? effectiveWidth / (2 * canvasAspectRatio)
|
|
774
|
+
: heightWorld / 2;
|
|
775
|
+
if (rVal < 1)
|
|
776
|
+
fitScale /= rVal;
|
|
777
|
+
return fitScale;
|
|
778
|
+
};
|
|
779
|
+
const ratioFactor = getFitScale(newRatioValue) / getFitScale(oldRatioValue);
|
|
780
|
+
vtkCamera.setParallelScale(vtkCamera.getParallelScale() * ratioFactor);
|
|
781
|
+
if (this.initialCamera?.parallelScale) {
|
|
782
|
+
this.initialCamera = {
|
|
783
|
+
...this.initialCamera,
|
|
784
|
+
parallelScale: this.initialCamera.parallelScale * ratioFactor,
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
if (this.fitToCanvasCamera?.parallelScale) {
|
|
788
|
+
this.fitToCanvasCamera = {
|
|
789
|
+
...this.fitToCanvasCamera,
|
|
790
|
+
parallelScale: this.fitToCanvasCamera.parallelScale * ratioFactor,
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
}
|
|
727
794
|
setCamera(cameraInterface, storeAsInitialCamera = false) {
|
|
728
795
|
const vtkCamera = this.getVtkActiveCamera();
|
|
729
796
|
const previousCamera = this.getCamera();
|
|
730
797
|
const updatedCamera = Object.assign({}, previousCamera, cameraInterface);
|
|
731
|
-
const { viewUp, viewPlaneNormal, position, focalPoint, parallelScale, viewAngle, flipHorizontal, flipVertical, clippingRange, } = cameraInterface;
|
|
798
|
+
const { viewUp, viewPlaneNormal, position, focalPoint, parallelScale, viewAngle, flipHorizontal, flipVertical, clippingRange, aspectRatio, isFitViewportAfterStretch, } = cameraInterface;
|
|
732
799
|
if (flipHorizontal !== undefined) {
|
|
733
800
|
const flipH = (flipHorizontal && !this.flipHorizontal) ||
|
|
734
801
|
(!flipHorizontal && this.flipHorizontal);
|
|
@@ -764,6 +831,9 @@ class Viewport {
|
|
|
764
831
|
if (clippingRange !== undefined) {
|
|
765
832
|
vtkCamera.setClippingRange(clippingRange);
|
|
766
833
|
}
|
|
834
|
+
if (aspectRatio) {
|
|
835
|
+
this.setAspectRatioForVTKCamera(aspectRatio, isFitViewportAfterStretch);
|
|
836
|
+
}
|
|
767
837
|
const prevFocalPoint = previousCamera.focalPoint;
|
|
768
838
|
const prevViewUp = previousCamera.viewUp;
|
|
769
839
|
if ((prevFocalPoint && focalPoint) || (prevViewUp && viewUp)) {
|
|
@@ -986,6 +1056,7 @@ class Viewport {
|
|
|
986
1056
|
displayArea: true,
|
|
987
1057
|
zoom: true,
|
|
988
1058
|
pan: true,
|
|
1059
|
+
aspectRatio: true,
|
|
989
1060
|
flipHorizontal: true,
|
|
990
1061
|
flipVertical: true,
|
|
991
1062
|
}) {
|
|
@@ -1001,9 +1072,14 @@ class Viewport {
|
|
|
1001
1072
|
if (zoom) {
|
|
1002
1073
|
target.zoom = initZoom;
|
|
1003
1074
|
}
|
|
1075
|
+
const currentAspectRatio = this.getAspectRatio();
|
|
1076
|
+
target.aspectRatio = currentAspectRatio;
|
|
1004
1077
|
if (pan) {
|
|
1005
|
-
|
|
1006
|
-
|
|
1078
|
+
const currentPan = this.getPan();
|
|
1079
|
+
const [aspectX, aspectY] = currentAspectRatio;
|
|
1080
|
+
const normalizedPanX = currentPan[0] / (initZoom * aspectX);
|
|
1081
|
+
const normalizedPanY = currentPan[1] / (initZoom * aspectY);
|
|
1082
|
+
target.pan = [normalizedPanX, normalizedPanY];
|
|
1007
1083
|
}
|
|
1008
1084
|
if (flipHorizontal) {
|
|
1009
1085
|
target.flipHorizontal = this.flipHorizontal;
|
|
@@ -1019,13 +1095,15 @@ class Viewport {
|
|
|
1019
1095
|
if (!viewPres) {
|
|
1020
1096
|
return;
|
|
1021
1097
|
}
|
|
1022
|
-
const { displayArea, zoom = this.getZoom(), pan, rotation, flipHorizontal = this.flipHorizontal, flipVertical = this.flipVertical, } = viewPres;
|
|
1098
|
+
const { displayArea, zoom = this.getZoom(), pan, aspectRatio = this.getAspectRatio(), rotation, flipHorizontal = this.flipHorizontal, flipVertical = this.flipVertical, } = viewPres;
|
|
1023
1099
|
if (displayArea !== this.getDisplayArea()) {
|
|
1024
1100
|
this.setDisplayArea(displayArea);
|
|
1025
1101
|
}
|
|
1026
1102
|
this.setZoom(zoom);
|
|
1103
|
+
this.setAspectRatio(aspectRatio);
|
|
1027
1104
|
if (pan) {
|
|
1028
|
-
|
|
1105
|
+
const [aspectX, aspectY] = aspectRatio;
|
|
1106
|
+
this.setPan([pan[0] * zoom * aspectX, pan[1] * zoom * aspectY]);
|
|
1029
1107
|
}
|
|
1030
1108
|
if (flipHorizontal !== undefined &&
|
|
1031
1109
|
flipHorizontal !== this.flipHorizontal) {
|
|
@@ -276,12 +276,12 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
resetCamera(options) {
|
|
279
|
-
const { resetPan = true, resetZoom = true, resetRotation = true, resetToCenter = true, suppressEvents = false, resetOrientation = true, } = options || {};
|
|
279
|
+
const { resetPan = true, resetZoom = true, resetRotation = true, resetToCenter = true, suppressEvents = false, resetOrientation = true, resetAspectRatio = true, } = options || {};
|
|
280
280
|
const { orientation } = this.viewportProperties;
|
|
281
281
|
if (orientation && resetOrientation) {
|
|
282
282
|
this.applyViewOrientation(orientation, false);
|
|
283
283
|
}
|
|
284
|
-
super.resetCamera({ resetPan, resetZoom, resetToCenter });
|
|
284
|
+
super.resetCamera({ resetPan, resetZoom, resetToCenter, resetAspectRatio });
|
|
285
285
|
const activeCamera = this.getVtkActiveCamera();
|
|
286
286
|
const viewPlaneNormal = activeCamera.getViewPlaneNormal();
|
|
287
287
|
const focalPoint = activeCamera.getFocalPoint();
|
|
@@ -473,11 +473,13 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
473
473
|
const resetZoom = true;
|
|
474
474
|
const resetToCenter = true;
|
|
475
475
|
const resetCameraRotation = true;
|
|
476
|
+
const resetAspectRatio = true;
|
|
476
477
|
this.resetCamera({
|
|
477
478
|
resetPan,
|
|
478
479
|
resetZoom,
|
|
479
480
|
resetToCenter,
|
|
480
481
|
resetCameraRotation,
|
|
482
|
+
resetAspectRatio,
|
|
481
483
|
});
|
|
482
484
|
triggerEvent(this.element, Events.VOI_MODIFIED, eventDetails);
|
|
483
485
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Transform } from './transform';
|
|
2
2
|
export default function (enabledElement, scale) {
|
|
3
3
|
const transform = new Transform();
|
|
4
|
+
const aspectRatio = enabledElement.viewport.aspectRatio;
|
|
4
5
|
if (!enabledElement.viewport.displayedArea) {
|
|
5
6
|
return transform;
|
|
6
7
|
}
|
|
@@ -59,9 +60,13 @@ export default function (enabledElement, scale) {
|
|
|
59
60
|
if (angle !== 0) {
|
|
60
61
|
transform.rotate((angle * Math.PI) / 180);
|
|
61
62
|
}
|
|
62
|
-
if (scale !== undefined) {
|
|
63
|
+
if (scale !== undefined && aspectRatio === undefined) {
|
|
63
64
|
transform.scale(scale, scale);
|
|
64
65
|
}
|
|
66
|
+
if (aspectRatio !== undefined && scale === undefined) {
|
|
67
|
+
const [scaleX, scaleY] = aspectRatio;
|
|
68
|
+
transform.scale(scaleX, scaleY);
|
|
69
|
+
}
|
|
65
70
|
if (enabledElement.viewport.hflip) {
|
|
66
71
|
transform.scale(-1, 1);
|
|
67
72
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { mat4 } from 'gl-matrix';
|
|
2
|
+
export function getProjectionScaleMatrix(aspectRatio) {
|
|
3
|
+
const [scaleX, scaleY] = aspectRatio;
|
|
4
|
+
const projectionScaleMatrix = mat4.fromScaling(mat4.create(), [
|
|
5
|
+
scaleX,
|
|
6
|
+
scaleY,
|
|
7
|
+
1.0,
|
|
8
|
+
]);
|
|
9
|
+
return projectionScaleMatrix;
|
|
10
|
+
}
|
|
@@ -5,4 +5,5 @@ import setVolumesForViewports from './setVolumesForViewports';
|
|
|
5
5
|
import addVolumesToViewports from './addVolumesToViewports';
|
|
6
6
|
import volumeNewImageEventDispatcher from './volumeNewImageEventDispatcher';
|
|
7
7
|
import addImageSlicesToViewports from './addImageSlicesToViewports';
|
|
8
|
-
|
|
8
|
+
import { getProjectionScaleMatrix } from './getProjectionScaleMatrix';
|
|
9
|
+
export { createVolumeActor, createVolumeMapper, setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, volumeNewImageEventDispatcher, getProjectionScaleMatrix, };
|
|
@@ -5,4 +5,5 @@ import setVolumesForViewports from './setVolumesForViewports';
|
|
|
5
5
|
import addVolumesToViewports from './addVolumesToViewports';
|
|
6
6
|
import volumeNewImageEventDispatcher from './volumeNewImageEventDispatcher';
|
|
7
7
|
import addImageSlicesToViewports from './addImageSlicesToViewports';
|
|
8
|
-
|
|
8
|
+
import { getProjectionScaleMatrix } from './getProjectionScaleMatrix';
|
|
9
|
+
export { createVolumeActor, createVolumeMapper, setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, volumeNewImageEventDispatcher, getProjectionScaleMatrix, };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
|
|
2
|
+
interface ICameraInitialValues {
|
|
3
|
+
position?: number[];
|
|
4
|
+
focalPoint?: number[];
|
|
5
|
+
viewUp?: number[];
|
|
6
|
+
directionOfProjection?: number[];
|
|
7
|
+
parallelProjection?: boolean;
|
|
8
|
+
useHorizontalViewAngle?: boolean;
|
|
9
|
+
viewAngle?: number;
|
|
10
|
+
parallelScale?: number;
|
|
11
|
+
clippingRange?: number[];
|
|
12
|
+
windowCenter?: number[];
|
|
13
|
+
viewPlaneNormal?: number[];
|
|
14
|
+
useOffAxisProjection?: boolean;
|
|
15
|
+
screenBottomLeft?: number[];
|
|
16
|
+
screenBottomRight?: number[];
|
|
17
|
+
screenTopRight?: number[];
|
|
18
|
+
freezeFocalPoint?: boolean;
|
|
19
|
+
physicalTranslation?: number[];
|
|
20
|
+
physicalScale?: number;
|
|
21
|
+
physicalViewUp?: number[];
|
|
22
|
+
physicalViewNorth?: number[];
|
|
23
|
+
aspectRatio?: number[];
|
|
24
|
+
}
|
|
25
|
+
declare module '@kitware/vtk.js/Rendering/Core/Camera' {
|
|
26
|
+
interface vtkCamera {
|
|
27
|
+
getAspectRatio(): [x: number, y: number];
|
|
28
|
+
setAspectRatio(aspectRatio: [x: number, y: number]): boolean;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export type extendedVtkCamera = vtkCamera;
|
|
32
|
+
export declare function extend(publicAPI: any, model: any, initialValues?: {}): void;
|
|
33
|
+
export declare const newInstance: (initialValues?: ICameraInitialValues) => extendedVtkCamera;
|
|
34
|
+
declare const _default: {
|
|
35
|
+
newInstance: (initialValues?: ICameraInitialValues) => extendedVtkCamera;
|
|
36
|
+
extend: typeof extend;
|
|
37
|
+
};
|
|
38
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import macro from '@kitware/vtk.js/macros';
|
|
2
|
+
import vtkCamera from '@kitware/vtk.js/Rendering/Core/Camera';
|
|
3
|
+
import { getProjectionScaleMatrix } from '../helpers/getProjectionScaleMatrix';
|
|
4
|
+
import { getNormalizedAspectRatio } from '../../utilities/getNormalizedAspectRatio';
|
|
5
|
+
import { mat4 } from 'gl-matrix';
|
|
6
|
+
function extendedVtkCamera(publicAPI, model) {
|
|
7
|
+
model.classHierarchy.push('extendedVtkCamera');
|
|
8
|
+
const superGetProjectionMatrix = publicAPI.getProjectionMatrix;
|
|
9
|
+
publicAPI.getProjectionMatrix = (aspect, nearZ, farZ) => {
|
|
10
|
+
const matrix = superGetProjectionMatrix(aspect, nearZ, farZ);
|
|
11
|
+
const [sx, sy] = getNormalizedAspectRatio(model.aspectRatio);
|
|
12
|
+
if (sx !== 1.0 || sy !== 1.0) {
|
|
13
|
+
const scaleMatrix = getProjectionScaleMatrix([sx, sy]);
|
|
14
|
+
mat4.multiply(matrix, scaleMatrix, matrix);
|
|
15
|
+
}
|
|
16
|
+
return matrix;
|
|
17
|
+
};
|
|
18
|
+
publicAPI.getAspectRatio = () => {
|
|
19
|
+
return model.aspectRatio;
|
|
20
|
+
};
|
|
21
|
+
publicAPI.setAspectRatio = (aspectRatio) => {
|
|
22
|
+
model.aspectRatio = aspectRatio;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const DEFAULT_VALUES = {
|
|
26
|
+
aspectRatio: [1, 1],
|
|
27
|
+
};
|
|
28
|
+
export function extend(publicAPI, model, initialValues = {}) {
|
|
29
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
30
|
+
vtkCamera.extend(publicAPI, model, initialValues);
|
|
31
|
+
macro.setGet(publicAPI, model, ['aspectRatio']);
|
|
32
|
+
extendedVtkCamera(publicAPI, model);
|
|
33
|
+
}
|
|
34
|
+
export const newInstance = macro.newInstance(extend, 'extendedVtkCamera');
|
|
35
|
+
export default { newInstance, extend };
|
|
@@ -131,6 +131,8 @@ export interface vtkSlabCamera extends vtkObject {
|
|
|
131
131
|
zoom(factor: number): void;
|
|
132
132
|
setIsPerformingCoordinateTransformation(status: boolean): void;
|
|
133
133
|
computeCameraLightTransform(): void;
|
|
134
|
+
getAspectRatio(): [x: number, y: number];
|
|
135
|
+
setAspectRatio(aspectRatio: [x: number, y: number]): boolean;
|
|
134
136
|
}
|
|
135
137
|
declare function extend(publicAPI: any, model: any, initialValues?: ICameraInitialValues): void;
|
|
136
138
|
declare const newInstance: (initialValues?: ICameraInitialValues) => vtkSlabCamera;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import macro from '@kitware/vtk.js/macros';
|
|
2
|
-
import
|
|
2
|
+
import extendedVtkCamera from './extendedVtkCamera';
|
|
3
3
|
import vtkMath from '@kitware/vtk.js/Common/Core/Math';
|
|
4
4
|
import { vec3, mat4 } from 'gl-matrix';
|
|
5
|
+
import { getProjectionScaleMatrix } from '../helpers/getProjectionScaleMatrix';
|
|
6
|
+
import { getNormalizedAspectRatio } from '../../utilities/getNormalizedAspectRatio';
|
|
5
7
|
const DEFAULT_VALUES = {
|
|
6
8
|
isPerformingCoordinateTransformation: false,
|
|
7
9
|
};
|
|
8
10
|
function extend(publicAPI, model, initialValues = {}) {
|
|
9
11
|
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
10
|
-
|
|
12
|
+
extendedVtkCamera.extend(publicAPI, model, initialValues);
|
|
11
13
|
macro.setGet(publicAPI, model, ['isPerformingCoordinateTransformation']);
|
|
12
14
|
vtkSlabCamera(publicAPI, model);
|
|
13
15
|
}
|
|
@@ -78,6 +80,11 @@ function vtkSlabCamera(publicAPI, model) {
|
|
|
78
80
|
tmpMatrix[11] = (-2.0 * znear * zfar) / (zfar - znear);
|
|
79
81
|
tmpMatrix[15] = 0.0;
|
|
80
82
|
}
|
|
83
|
+
const [sx, sy] = getNormalizedAspectRatio(model.aspectRatio);
|
|
84
|
+
if (sx !== 1.0 || sy !== 1.0) {
|
|
85
|
+
const scaleMatrix = getProjectionScaleMatrix([sx, sy]);
|
|
86
|
+
mat4.multiply(tmpMatrix, scaleMatrix, tmpMatrix);
|
|
87
|
+
}
|
|
81
88
|
mat4.copy(result, tmpMatrix);
|
|
82
89
|
return result;
|
|
83
90
|
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ import { convertColorArrayToRgbString } from './utilities/convertColorArrayToRgb
|
|
|
38
38
|
import { cornerstoneStreamingImageVolumeLoader } from './loaders/cornerstoneStreamingImageVolumeLoader';
|
|
39
39
|
import { cornerstoneStreamingDynamicImageVolumeLoader } from './loaders/cornerstoneStreamingDynamicImageVolumeLoader';
|
|
40
40
|
import { cornerstoneMeshLoader } from './loaders/cornerstoneMeshLoader';
|
|
41
|
-
import { setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports } from './RenderingEngine/helpers';
|
|
41
|
+
import { setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, getProjectionScaleMatrix } from './RenderingEngine/helpers';
|
|
42
42
|
export * from './loaders/decimatedVolumeLoader';
|
|
43
43
|
export type { Types, IRetrieveConfiguration, RetrieveOptions, RetrieveStage, ImageLoadListener, IImagesLoader, };
|
|
44
|
-
export { init, isCornerstoneInitialized, peerImport, resetInitialization, getConfiguration, setConfiguration, getWebWorkerManager, canRenderFloatTextures, Enums, CONSTANTS, Events as EVENTS, Settings, BaseVolumeViewport, VolumeViewport, VolumeViewport3D, Viewport, StackViewport, VideoViewport, WSIViewport, ECGViewport, RenderingEngine, BaseRenderingEngine, TiledRenderingEngine, ContextPoolRenderingEngine, ImageVolume, Surface, getRenderingEngine, getRenderingEngines, getEnabledElement, getEnabledElementByIds, getEnabledElements, getEnabledElementByViewportId, createVolumeActor, createVolumeMapper, cache, eventTarget, triggerEvent, convertColorArrayToRgbString, imageLoader, registerImageLoader, volumeLoader, metaData, utilities, setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, imageLoadPoolManager as requestPoolManager, imageRetrievalPoolManager, imageLoadPoolManager, getShouldUseCPURendering, setUseCPURendering, setPreferSizeOverAccuracy, resetUseCPURendering, geometryLoader, cornerstoneMeshLoader, ProgressiveRetrieveImages, decimatedVolumeLoader, cornerstoneStreamingImageVolumeLoader, cornerstoneStreamingDynamicImageVolumeLoader, StreamingDynamicImageVolume, StreamingImageVolume, convertMapperToNotSharedMapper, version, };
|
|
44
|
+
export { init, isCornerstoneInitialized, peerImport, resetInitialization, getConfiguration, setConfiguration, getWebWorkerManager, canRenderFloatTextures, Enums, CONSTANTS, Events as EVENTS, Settings, BaseVolumeViewport, VolumeViewport, VolumeViewport3D, Viewport, StackViewport, VideoViewport, WSIViewport, ECGViewport, RenderingEngine, BaseRenderingEngine, TiledRenderingEngine, ContextPoolRenderingEngine, ImageVolume, Surface, getRenderingEngine, getRenderingEngines, getEnabledElement, getEnabledElementByIds, getEnabledElements, getEnabledElementByViewportId, createVolumeActor, createVolumeMapper, cache, eventTarget, triggerEvent, convertColorArrayToRgbString, imageLoader, registerImageLoader, volumeLoader, metaData, utilities, setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, getProjectionScaleMatrix, imageLoadPoolManager as requestPoolManager, imageRetrievalPoolManager, imageLoadPoolManager, getShouldUseCPURendering, setUseCPURendering, setPreferSizeOverAccuracy, resetUseCPURendering, geometryLoader, cornerstoneMeshLoader, ProgressiveRetrieveImages, decimatedVolumeLoader, cornerstoneStreamingImageVolumeLoader, cornerstoneStreamingDynamicImageVolumeLoader, StreamingDynamicImageVolume, StreamingImageVolume, convertMapperToNotSharedMapper, version, };
|
package/dist/esm/index.js
CHANGED
|
@@ -36,6 +36,6 @@ import { convertColorArrayToRgbString } from './utilities/convertColorArrayToRgb
|
|
|
36
36
|
import { cornerstoneStreamingImageVolumeLoader } from './loaders/cornerstoneStreamingImageVolumeLoader';
|
|
37
37
|
import { cornerstoneStreamingDynamicImageVolumeLoader } from './loaders/cornerstoneStreamingDynamicImageVolumeLoader';
|
|
38
38
|
import { cornerstoneMeshLoader } from './loaders/cornerstoneMeshLoader';
|
|
39
|
-
import { setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, } from './RenderingEngine/helpers';
|
|
39
|
+
import { setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, getProjectionScaleMatrix, } from './RenderingEngine/helpers';
|
|
40
40
|
export * from './loaders/decimatedVolumeLoader';
|
|
41
|
-
export { init, isCornerstoneInitialized, peerImport, resetInitialization, getConfiguration, setConfiguration, getWebWorkerManager, canRenderFloatTextures, Enums, CONSTANTS, Events as EVENTS, Settings, BaseVolumeViewport, VolumeViewport, VolumeViewport3D, Viewport, StackViewport, VideoViewport, WSIViewport, ECGViewport, RenderingEngine, BaseRenderingEngine, TiledRenderingEngine, ContextPoolRenderingEngine, ImageVolume, Surface, getRenderingEngine, getRenderingEngines, getEnabledElement, getEnabledElementByIds, getEnabledElements, getEnabledElementByViewportId, createVolumeActor, createVolumeMapper, cache, eventTarget, triggerEvent, convertColorArrayToRgbString, imageLoader, registerImageLoader, volumeLoader, metaData, utilities, setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, imageLoadPoolManager as requestPoolManager, imageRetrievalPoolManager, imageLoadPoolManager, getShouldUseCPURendering, setUseCPURendering, setPreferSizeOverAccuracy, resetUseCPURendering, geometryLoader, cornerstoneMeshLoader, ProgressiveRetrieveImages, decimatedVolumeLoader, cornerstoneStreamingImageVolumeLoader, cornerstoneStreamingDynamicImageVolumeLoader, StreamingDynamicImageVolume, StreamingImageVolume, convertMapperToNotSharedMapper, version, };
|
|
41
|
+
export { init, isCornerstoneInitialized, peerImport, resetInitialization, getConfiguration, setConfiguration, getWebWorkerManager, canRenderFloatTextures, Enums, CONSTANTS, Events as EVENTS, Settings, BaseVolumeViewport, VolumeViewport, VolumeViewport3D, Viewport, StackViewport, VideoViewport, WSIViewport, ECGViewport, RenderingEngine, BaseRenderingEngine, TiledRenderingEngine, ContextPoolRenderingEngine, ImageVolume, Surface, getRenderingEngine, getRenderingEngines, getEnabledElement, getEnabledElementByIds, getEnabledElements, getEnabledElementByViewportId, createVolumeActor, createVolumeMapper, cache, eventTarget, triggerEvent, convertColorArrayToRgbString, imageLoader, registerImageLoader, volumeLoader, metaData, utilities, setVolumesForViewports, addVolumesToViewports, addImageSlicesToViewports, getProjectionScaleMatrix, imageLoadPoolManager as requestPoolManager, imageRetrievalPoolManager, imageLoadPoolManager, getShouldUseCPURendering, setUseCPURendering, setPreferSizeOverAccuracy, resetUseCPURendering, geometryLoader, cornerstoneMeshLoader, ProgressiveRetrieveImages, decimatedVolumeLoader, cornerstoneStreamingImageVolumeLoader, cornerstoneStreamingDynamicImageVolumeLoader, StreamingDynamicImageVolume, StreamingImageVolume, convertMapperToNotSharedMapper, version, };
|
|
@@ -2,6 +2,7 @@ import type CPUFallbackViewportDisplayedArea from './CPUFallbackViewportDisplaye
|
|
|
2
2
|
import type CPUFallbackColormap from './CPUFallbackColormap';
|
|
3
3
|
import type CPUFallbackLUT from './CPUFallbackLUT';
|
|
4
4
|
import type VOILUTFunctionType from '../enums/VOILUTFunctionType';
|
|
5
|
+
import type Point2 from './Point2';
|
|
5
6
|
interface CPUFallbackViewport {
|
|
6
7
|
scale?: number;
|
|
7
8
|
parallelScale?: number;
|
|
@@ -25,5 +26,6 @@ interface CPUFallbackViewport {
|
|
|
25
26
|
colormap?: CPUFallbackColormap;
|
|
26
27
|
displayedArea?: CPUFallbackViewportDisplayedArea;
|
|
27
28
|
modality?: string;
|
|
29
|
+
aspectRatio?: Point2;
|
|
28
30
|
}
|
|
29
31
|
export type { CPUFallbackViewport as default };
|
|
@@ -13,5 +13,13 @@ interface ICamera {
|
|
|
13
13
|
flipHorizontal?: boolean;
|
|
14
14
|
flipVertical?: boolean;
|
|
15
15
|
clippingRange?: Point2;
|
|
16
|
+
aspectRatio?: Point2;
|
|
17
|
+
isFitViewportAfterStretch?: boolean;
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
interface ResetCameraOptions {
|
|
20
|
+
resetPan?: boolean;
|
|
21
|
+
resetZoom?: boolean;
|
|
22
|
+
resetToCenter?: boolean;
|
|
23
|
+
resetAspectRatio?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export type { ICamera as default, ResetCameraOptions };
|
|
@@ -118,6 +118,7 @@ interface CPUFallbackEnabledElement {
|
|
|
118
118
|
imagePixelModule?: ImagePixelModule;
|
|
119
119
|
};
|
|
120
120
|
voxelManager?: IVoxelManager<number> | IVoxelManager<RGB>;
|
|
121
|
+
aspectRatio?: Point2;
|
|
121
122
|
}
|
|
122
123
|
export type { IImage as default };
|
|
123
124
|
export type { CPUFallbackEnabledElement };
|
|
@@ -51,6 +51,7 @@ export interface ViewPresentation {
|
|
|
51
51
|
pan?: Point2;
|
|
52
52
|
flipHorizontal?: boolean;
|
|
53
53
|
flipVertical?: boolean;
|
|
54
|
+
aspectRatio?: Point2;
|
|
54
55
|
}
|
|
55
56
|
export interface ViewPresentationSelector {
|
|
56
57
|
slabThickness?: number;
|
|
@@ -58,6 +59,7 @@ export interface ViewPresentationSelector {
|
|
|
58
59
|
displayArea?: boolean;
|
|
59
60
|
zoom?: boolean;
|
|
60
61
|
pan?: boolean;
|
|
62
|
+
aspectRatio?: boolean;
|
|
61
63
|
flipHorizontal?: boolean;
|
|
62
64
|
flipVertical?: boolean;
|
|
63
65
|
windowLevel?: boolean;
|
|
@@ -2,11 +2,13 @@ import type { OrientationAxis } from '../enums';
|
|
|
2
2
|
import type OrientationVectors from './OrientationVectors';
|
|
3
3
|
import type DisplayArea from './displayArea';
|
|
4
4
|
import type RGB from './RGB';
|
|
5
|
+
import type Point2 from './Point2';
|
|
5
6
|
interface ViewportInputOptions {
|
|
6
7
|
background?: RGB;
|
|
7
8
|
orientation?: OrientationAxis | OrientationVectors;
|
|
8
9
|
displayArea?: DisplayArea;
|
|
9
10
|
suppressEvents?: boolean;
|
|
10
11
|
parallelProjection?: boolean;
|
|
12
|
+
aspectRatio?: Point2;
|
|
11
13
|
}
|
|
12
14
|
export type { ViewportInputOptions as default };
|
|
@@ -106,6 +106,7 @@ import type JumpToSliceOptions from './JumpToSliceOptions';
|
|
|
106
106
|
import type GeometryLoaderFn from './GeometryLoaderFn';
|
|
107
107
|
import type { RenderingEngineModeType } from './RenderingEngineMode';
|
|
108
108
|
import type { VtkOffscreenMultiRenderWindow } from './VtkOffscreenMultiRenderWindow';
|
|
109
|
+
import type { ResetCameraOptions } from './ICamera';
|
|
109
110
|
export type * from './MetadataModuleTypes';
|
|
110
111
|
export type * from './InstanceTypes';
|
|
111
|
-
export type { Cornerstone3DConfig, IBaseStreamingImageVolume, ICamera, IStackViewport, IVideoViewport, IECGViewport, IWSIViewport, IVolumeViewport, IEnabledElement, ICache, IVolume, IViewportId, IImageVolume, ImageVolumeProps, IDynamicImageVolume, IRenderingEngine, ScalingParameters, PTScaling, IPointsManager, PolyDataPointConfiguration, Scaling, IStreamingImageVolume, IImage, IImageData, IImageCalibration, CPUIImageData, CPUImageData, EventTypes, ImageLoaderFn, VolumeLoaderFn, IRegisterImageLoader, IStreamingVolumeProperties, IViewport, ViewReference, DataSetOptions as ImageSetOptions, ViewPresentation, ViewPresentationSelector, ReferenceCompatibleOptions, ViewReferenceSpecifier, StackViewportProperties, VolumeViewportProperties, ViewportProperties, PublicViewportInput, VolumeActor, Actor, ActorEntry, ImageActor, ICanvasActor, IImageLoadObject, IVolumeLoadObject, IVolumeInput, VolumeInputCallback, IStackInput, StackInputCallback, ViewportPreset, Metadata, OrientationVectors, AABB2, AABB3, Point2, Point3, PointsXYZ, Point4, Mat3, Plane, ViewportInputOptions, VideoViewportProperties, WSIViewportProperties, VOIRange, VOI, DisplayArea, FlipDirection, ICachedImage, ICachedVolume, CPUFallbackEnabledElement, CPUFallbackViewport, CPUFallbackTransform, CPUFallbackColormapData, CPUFallbackViewportDisplayedArea, CPUFallbackColormapsData, CPUFallbackColormap, TransformMatrix2D, CPUFallbackLookupTable, CPUFallbackLUT, CPUFallbackRenderingTools, CustomEventType, ActorSliceRange, ImageSliceData, IGeometry, IGeometryLoadObject, ICachedGeometry, PublicContourSetData, ContourSetData, ContourData, IContourSet, IContour, PublicSurfaceData, SurfaceData, ISurface, PublicMeshData, MeshData, IMesh, RGB, ColormapPublic, ColormapRegistration, PixelDataTypedArray, PixelDataTypedArrayString, ImagePixelModule, ImagePlaneModule, AffineMatrix, ImageLoadListener, InternalVideoCamera, VideoViewportInput, InternalECGCamera, ECGViewportInput, ECGChannel, ECGWaveformData, ECGViewportProperties, BoundsIJK, BoundsLPS, Color, ColorLUT, VolumeProps, IImageFrame, LocalVolumeOptions, IVoxelManager, IRLEVoxelMap, RLERun, ViewportInput, ImageLoadRequests, IBaseVolumeViewport, GeometryLoaderFn, ScrollOptions, JumpToSliceOptions, Memo, HistoryMemo, VoxelManager, RLEVoxelMap, RenderingEngineModeType, VtkOffscreenMultiRenderWindow, };
|
|
112
|
+
export type { Cornerstone3DConfig, IBaseStreamingImageVolume, ICamera, ResetCameraOptions, IStackViewport, IVideoViewport, IECGViewport, IWSIViewport, IVolumeViewport, IEnabledElement, ICache, IVolume, IViewportId, IImageVolume, ImageVolumeProps, IDynamicImageVolume, IRenderingEngine, ScalingParameters, PTScaling, IPointsManager, PolyDataPointConfiguration, Scaling, IStreamingImageVolume, IImage, IImageData, IImageCalibration, CPUIImageData, CPUImageData, EventTypes, ImageLoaderFn, VolumeLoaderFn, IRegisterImageLoader, IStreamingVolumeProperties, IViewport, ViewReference, DataSetOptions as ImageSetOptions, ViewPresentation, ViewPresentationSelector, ReferenceCompatibleOptions, ViewReferenceSpecifier, StackViewportProperties, VolumeViewportProperties, ViewportProperties, PublicViewportInput, VolumeActor, Actor, ActorEntry, ImageActor, ICanvasActor, IImageLoadObject, IVolumeLoadObject, IVolumeInput, VolumeInputCallback, IStackInput, StackInputCallback, ViewportPreset, Metadata, OrientationVectors, AABB2, AABB3, Point2, Point3, PointsXYZ, Point4, Mat3, Plane, ViewportInputOptions, VideoViewportProperties, WSIViewportProperties, VOIRange, VOI, DisplayArea, FlipDirection, ICachedImage, ICachedVolume, CPUFallbackEnabledElement, CPUFallbackViewport, CPUFallbackTransform, CPUFallbackColormapData, CPUFallbackViewportDisplayedArea, CPUFallbackColormapsData, CPUFallbackColormap, TransformMatrix2D, CPUFallbackLookupTable, CPUFallbackLUT, CPUFallbackRenderingTools, CustomEventType, ActorSliceRange, ImageSliceData, IGeometry, IGeometryLoadObject, ICachedGeometry, PublicContourSetData, ContourSetData, ContourData, IContourSet, IContour, PublicSurfaceData, SurfaceData, ISurface, PublicMeshData, MeshData, IMesh, RGB, ColormapPublic, ColormapRegistration, PixelDataTypedArray, PixelDataTypedArrayString, ImagePixelModule, ImagePlaneModule, AffineMatrix, ImageLoadListener, InternalVideoCamera, VideoViewportInput, InternalECGCamera, ECGViewportInput, ECGChannel, ECGWaveformData, ECGViewportProperties, BoundsIJK, BoundsLPS, Color, ColorLUT, VolumeProps, IImageFrame, LocalVolumeOptions, IVoxelManager, IRLEVoxelMap, RLERun, ViewportInput, ImageLoadRequests, IBaseVolumeViewport, GeometryLoaderFn, ScrollOptions, JumpToSliceOptions, Memo, HistoryMemo, VoxelManager, RLEVoxelMap, RenderingEngineModeType, VtkOffscreenMultiRenderWindow, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import isEqual from './isEqual';
|
|
2
|
+
const EPSILON = 1e10;
|
|
3
|
+
export const getNormalizedAspectRatio = (aspectRatio) => {
|
|
4
|
+
const [width, height] = aspectRatio;
|
|
5
|
+
if (isEqual(width, height)) {
|
|
6
|
+
return [1, 1];
|
|
7
|
+
}
|
|
8
|
+
const min = Math.min(width, height);
|
|
9
|
+
const normalizedW = Math.round((width / min) * EPSILON) / EPSILON;
|
|
10
|
+
const normalizedH = Math.round((height / min) * EPSILON) / EPSILON;
|
|
11
|
+
return [normalizedW, normalizedH];
|
|
12
|
+
};
|
|
@@ -97,7 +97,8 @@ export * from './getPixelSpacingInformation';
|
|
|
97
97
|
export * from './getPlaneCubeIntersectionDimensions';
|
|
98
98
|
export * from './rotateToViewCoordinates';
|
|
99
99
|
import { asArray } from './asArray';
|
|
100
|
+
import { getNormalizedAspectRatio } from './getNormalizedAspectRatio';
|
|
100
101
|
export { updatePlaneRestriction } from './updatePlaneRestriction';
|
|
101
102
|
declare const getViewportModality: (viewport: IViewport, volumeId?: string) => string;
|
|
102
103
|
export * from './isEqual';
|
|
103
|
-
export { FrameRange, eventListener, csUtils as invertRgbTransferFunction, createSigmoidRGBTransferFunction, getVoiFromSigmoidRGBTransferFunction, createLinearRGBTransferFunction, scaleRgbTransferFunction, triggerEvent, imageIdToURI, fnv1aHash, calibratedPixelSpacingMetadataProvider, clamp, uuidv4, getMinMax, getRuntimeId, isOpposite, getViewportModality, windowLevel, convertToGrayscale, convertColorArrayToRgbString, getClosestImageId, getSpacingInNormalDirection, getTargetVolumeAndSpacingInNormalDir, getVolumeActorCorners, indexWithinDimensions, getVolumeViewportsContainingSameVolumes, getViewportsWithVolumeId, transformWorldToIndex, transformIndexToWorld, loadImageToCanvas, renderToCanvasCPU, renderToCanvasGPU, worldToImageCoords, imageToWorldCoords, getVolumeSliceRangeInfo, getVolumeViewportScrollInfo, getSliceRange, snapFocalPointToSlice, getImageSliceDataForVolumeViewport, isImageActor, isPTPrescaledWithSUV, actorIsA, getViewportsWithImageURI, getClosestStackImageIndexForPoint, getCurrentVolumeViewportSlice, calculateViewportsSpatialRegistration, spatialRegistrationMetadataProvider, getViewportImageCornersInWorld, hasNaNValues, applyPreset, deepMerge, PointsManager, getScalingParameters, colormap, getImageLegacy, ProgressiveIterator, decimate, imageRetrieveMetadataProvider, transferFunctionUtils, updateVTKImageDataWithCornerstoneImage, sortImageIdsAndGetSpacing, makeVolumeMetadata, isValidVolume, genericMetadataProvider, isVideoTransferSyntax, HistoryMemo, generateVolumePropsFromImageIds, getBufferConfiguration, VoxelManager, RLEVoxelMap, convertStackToVolumeViewport, convertVolumeToStackViewport, roundNumber, roundToPrecision, getViewportImageIds, getRandomSampleFromArray, getVolumeId, color, hasFloatScalingParameters, getDynamicVolumeInfo, autoLoad, scaleArray, deepClone, splitImageIdsBy4DTags, handleMultiframe4D, generateFrameImageId, pointInShapeCallback, deepEqual, jumpToSlice, scroll, clip, transformWorldToIndexContinuous, createSubVolume, getVolumeDirectionVectors, calculateSpacingBetweenImageIds, getImageDataMetadata, buildMetadata, calculateNeighborhoodStats, asArray, };
|
|
104
|
+
export { FrameRange, eventListener, csUtils as invertRgbTransferFunction, createSigmoidRGBTransferFunction, getVoiFromSigmoidRGBTransferFunction, createLinearRGBTransferFunction, scaleRgbTransferFunction, triggerEvent, imageIdToURI, fnv1aHash, calibratedPixelSpacingMetadataProvider, clamp, uuidv4, getMinMax, getRuntimeId, isOpposite, getViewportModality, windowLevel, convertToGrayscale, convertColorArrayToRgbString, getClosestImageId, getSpacingInNormalDirection, getTargetVolumeAndSpacingInNormalDir, getVolumeActorCorners, indexWithinDimensions, getVolumeViewportsContainingSameVolumes, getViewportsWithVolumeId, transformWorldToIndex, transformIndexToWorld, loadImageToCanvas, renderToCanvasCPU, renderToCanvasGPU, worldToImageCoords, imageToWorldCoords, getVolumeSliceRangeInfo, getVolumeViewportScrollInfo, getSliceRange, snapFocalPointToSlice, getImageSliceDataForVolumeViewport, isImageActor, isPTPrescaledWithSUV, actorIsA, getViewportsWithImageURI, getClosestStackImageIndexForPoint, getCurrentVolumeViewportSlice, calculateViewportsSpatialRegistration, spatialRegistrationMetadataProvider, getViewportImageCornersInWorld, hasNaNValues, applyPreset, deepMerge, PointsManager, getScalingParameters, colormap, getImageLegacy, ProgressiveIterator, decimate, imageRetrieveMetadataProvider, transferFunctionUtils, updateVTKImageDataWithCornerstoneImage, sortImageIdsAndGetSpacing, makeVolumeMetadata, isValidVolume, genericMetadataProvider, isVideoTransferSyntax, HistoryMemo, generateVolumePropsFromImageIds, getBufferConfiguration, VoxelManager, RLEVoxelMap, convertStackToVolumeViewport, convertVolumeToStackViewport, roundNumber, roundToPrecision, getViewportImageIds, getRandomSampleFromArray, getVolumeId, color, hasFloatScalingParameters, getDynamicVolumeInfo, autoLoad, scaleArray, deepClone, splitImageIdsBy4DTags, handleMultiframe4D, generateFrameImageId, pointInShapeCallback, deepEqual, jumpToSlice, scroll, clip, transformWorldToIndexContinuous, createSubVolume, getVolumeDirectionVectors, calculateSpacingBetweenImageIds, getImageDataMetadata, buildMetadata, calculateNeighborhoodStats, asArray, getNormalizedAspectRatio, };
|
|
@@ -98,7 +98,8 @@ export * from './getPixelSpacingInformation';
|
|
|
98
98
|
export * from './getPlaneCubeIntersectionDimensions';
|
|
99
99
|
export * from './rotateToViewCoordinates';
|
|
100
100
|
import { asArray } from './asArray';
|
|
101
|
+
import { getNormalizedAspectRatio } from './getNormalizedAspectRatio';
|
|
101
102
|
export { updatePlaneRestriction } from './updatePlaneRestriction';
|
|
102
103
|
const getViewportModality = (viewport, volumeId) => _getViewportModality(viewport, volumeId, cache.getVolume);
|
|
103
104
|
export * from './isEqual';
|
|
104
|
-
export { FrameRange, eventListener, csUtils as invertRgbTransferFunction, createSigmoidRGBTransferFunction, getVoiFromSigmoidRGBTransferFunction, createLinearRGBTransferFunction, scaleRgbTransferFunction, triggerEvent, imageIdToURI, fnv1aHash, calibratedPixelSpacingMetadataProvider, clamp, uuidv4, getMinMax, getRuntimeId, isOpposite, getViewportModality, windowLevel, convertToGrayscale, convertColorArrayToRgbString, getClosestImageId, getSpacingInNormalDirection, getTargetVolumeAndSpacingInNormalDir, getVolumeActorCorners, indexWithinDimensions, getVolumeViewportsContainingSameVolumes, getViewportsWithVolumeId, transformWorldToIndex, transformIndexToWorld, loadImageToCanvas, renderToCanvasCPU, renderToCanvasGPU, worldToImageCoords, imageToWorldCoords, getVolumeSliceRangeInfo, getVolumeViewportScrollInfo, getSliceRange, snapFocalPointToSlice, getImageSliceDataForVolumeViewport, isImageActor, isPTPrescaledWithSUV, actorIsA, getViewportsWithImageURI, getClosestStackImageIndexForPoint, getCurrentVolumeViewportSlice, calculateViewportsSpatialRegistration, spatialRegistrationMetadataProvider, getViewportImageCornersInWorld, hasNaNValues, applyPreset, deepMerge, PointsManager, getScalingParameters, colormap, getImageLegacy, ProgressiveIterator, decimate, imageRetrieveMetadataProvider, transferFunctionUtils, updateVTKImageDataWithCornerstoneImage, sortImageIdsAndGetSpacing, makeVolumeMetadata, isValidVolume, genericMetadataProvider, isVideoTransferSyntax, HistoryMemo, generateVolumePropsFromImageIds, getBufferConfiguration, VoxelManager, RLEVoxelMap, convertStackToVolumeViewport, convertVolumeToStackViewport, roundNumber, roundToPrecision, getViewportImageIds, getRandomSampleFromArray, getVolumeId, color, hasFloatScalingParameters, getDynamicVolumeInfo, autoLoad, scaleArray, deepClone, splitImageIdsBy4DTags, handleMultiframe4D, generateFrameImageId, pointInShapeCallback, deepEqual, jumpToSlice, scroll, clip, transformWorldToIndexContinuous, createSubVolume, getVolumeDirectionVectors, calculateSpacingBetweenImageIds, getImageDataMetadata, buildMetadata, calculateNeighborhoodStats, asArray, };
|
|
105
|
+
export { FrameRange, eventListener, csUtils as invertRgbTransferFunction, createSigmoidRGBTransferFunction, getVoiFromSigmoidRGBTransferFunction, createLinearRGBTransferFunction, scaleRgbTransferFunction, triggerEvent, imageIdToURI, fnv1aHash, calibratedPixelSpacingMetadataProvider, clamp, uuidv4, getMinMax, getRuntimeId, isOpposite, getViewportModality, windowLevel, convertToGrayscale, convertColorArrayToRgbString, getClosestImageId, getSpacingInNormalDirection, getTargetVolumeAndSpacingInNormalDir, getVolumeActorCorners, indexWithinDimensions, getVolumeViewportsContainingSameVolumes, getViewportsWithVolumeId, transformWorldToIndex, transformIndexToWorld, loadImageToCanvas, renderToCanvasCPU, renderToCanvasGPU, worldToImageCoords, imageToWorldCoords, getVolumeSliceRangeInfo, getVolumeViewportScrollInfo, getSliceRange, snapFocalPointToSlice, getImageSliceDataForVolumeViewport, isImageActor, isPTPrescaledWithSUV, actorIsA, getViewportsWithImageURI, getClosestStackImageIndexForPoint, getCurrentVolumeViewportSlice, calculateViewportsSpatialRegistration, spatialRegistrationMetadataProvider, getViewportImageCornersInWorld, hasNaNValues, applyPreset, deepMerge, PointsManager, getScalingParameters, colormap, getImageLegacy, ProgressiveIterator, decimate, imageRetrieveMetadataProvider, transferFunctionUtils, updateVTKImageDataWithCornerstoneImage, sortImageIdsAndGetSpacing, makeVolumeMetadata, isValidVolume, genericMetadataProvider, isVideoTransferSyntax, HistoryMemo, generateVolumePropsFromImageIds, getBufferConfiguration, VoxelManager, RLEVoxelMap, convertStackToVolumeViewport, convertVolumeToStackViewport, roundNumber, roundToPrecision, getViewportImageIds, getRandomSampleFromArray, getVolumeId, color, hasFloatScalingParameters, getDynamicVolumeInfo, autoLoad, scaleArray, deepClone, splitImageIdsBy4DTags, handleMultiframe4D, generateFrameImageId, pointInShapeCallback, deepEqual, jumpToSlice, scroll, clip, transformWorldToIndexContinuous, createSubVolume, getVolumeDirectionVectors, calculateSpacingBetweenImageIds, getImageDataMetadata, buildMetadata, calculateNeighborhoodStats, asArray, getNormalizedAspectRatio, };
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.22.
|
|
1
|
+
export declare const version = "4.22.12";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.22.
|
|
1
|
+
export const version = '4.22.12';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "4.22.
|
|
3
|
+
"version": "4.22.12",
|
|
4
4
|
"description": "Cornerstone3D Core",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/esm/index.d.ts",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"type": "individual",
|
|
98
98
|
"url": "https://ohif.org/donate"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "5cb108650fe38eac81881750b859b08de4c45cce"
|
|
101
101
|
}
|