@cornerstonejs/core 5.11.6 → 5.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js +3 -3
- package/dist/esm/RenderingEngine/StackViewport.js +2 -2
- package/dist/esm/RenderingEngine/Viewport.d.ts +6 -2
- package/dist/esm/RenderingEngine/Viewport.js +22 -17
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/package.json +5 -5
|
@@ -209,7 +209,7 @@ class BaseVolumeViewport extends Viewport {
|
|
|
209
209
|
vtkCamera.setIsPerformingCoordinateTransformation?.(true);
|
|
210
210
|
const renderer = this.getRenderer();
|
|
211
211
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
212
|
-
const { width, height } = this.
|
|
212
|
+
const { width, height } = this.getRenderedCanvasSize();
|
|
213
213
|
const aspectRatio = width / height;
|
|
214
214
|
const [xMin, yMin, xMax, yMax] = renderer.getViewport();
|
|
215
215
|
const viewportWidth = xMax - xMin;
|
|
@@ -252,7 +252,7 @@ class BaseVolumeViewport extends Viewport {
|
|
|
252
252
|
canvasPos[1] * devicePixelRatio,
|
|
253
253
|
];
|
|
254
254
|
const renderer = this.getRenderer();
|
|
255
|
-
const { width, height } = this.
|
|
255
|
+
const { width, height } = this.getRenderedCanvasSize();
|
|
256
256
|
const [xMin, yMin, xMax, yMax] = renderer.getViewport();
|
|
257
257
|
const viewportWidth = xMax - xMin;
|
|
258
258
|
const viewportHeight = yMax - yMin;
|
|
@@ -286,7 +286,7 @@ class BaseVolumeViewport extends Viewport {
|
|
|
286
286
|
const vtkCamera = this.getVtkActiveCamera();
|
|
287
287
|
vtkCamera.setIsPerformingCoordinateTransformation?.(true);
|
|
288
288
|
const renderer = this.getRenderer();
|
|
289
|
-
const { width, height } = this.
|
|
289
|
+
const { width, height } = this.getRenderedCanvasSize();
|
|
290
290
|
const aspectRatio = width / height;
|
|
291
291
|
const [xMin, yMin, xMax, yMax] = renderer.getViewport();
|
|
292
292
|
const viewportWidth = xMax - xMin;
|
|
@@ -235,7 +235,7 @@ class StackViewport extends Viewport {
|
|
|
235
235
|
const distance = vtkCamera.getDistance();
|
|
236
236
|
vtkCamera.setClippingRange(distance, distance + 0.1);
|
|
237
237
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
238
|
-
const { width, height } = this.
|
|
238
|
+
const { width, height } = this.getRenderedCanvasSize();
|
|
239
239
|
const aspectRatio = width / height;
|
|
240
240
|
const canvasPosWithDPR = [
|
|
241
241
|
canvasPos[0] * devicePixelRatio,
|
|
@@ -286,7 +286,7 @@ class StackViewport extends Viewport {
|
|
|
286
286
|
const distance = vtkCamera.getDistance();
|
|
287
287
|
vtkCamera.setClippingRange(distance, distance + 0.1);
|
|
288
288
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
289
|
-
const { width, height } = this.
|
|
289
|
+
const { width, height } = this.getRenderedCanvasSize();
|
|
290
290
|
const aspectRatio = width / height;
|
|
291
291
|
const viewCoords = renderer.worldToView(worldPos[0], worldPos[1], worldPos[2]);
|
|
292
292
|
const projCoords = renderer.viewToProjection(viewCoords[0], viewCoords[1], viewCoords[2], aspectRatio);
|
|
@@ -102,7 +102,11 @@ declare class Viewport {
|
|
|
102
102
|
protected setInterpolationType(_interpolationType: InterpolationType, _arg?: any): void;
|
|
103
103
|
setDisplayArea(displayArea: DisplayArea, suppressEvents?: boolean): void;
|
|
104
104
|
protected setDisplayAreaScale(displayArea: DisplayArea): void;
|
|
105
|
-
protected setDisplayAreaFit(displayArea: DisplayArea): void;
|
|
105
|
+
protected setDisplayAreaFit(displayArea: DisplayArea, baseCamera?: ICamera<number>): void;
|
|
106
|
+
protected getRenderedCanvasSize(): {
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
};
|
|
106
110
|
getDisplayArea(): DisplayArea | undefined;
|
|
107
111
|
protected getWorldSizeInView(bounds?: number[]): {
|
|
108
112
|
widthWorld: number;
|
|
@@ -129,7 +133,7 @@ declare class Viewport {
|
|
|
129
133
|
setPan(pan: Point2, storeAsInitialCamera?: boolean): void;
|
|
130
134
|
protected getComparableParallelScale(compareCamera: ICamera): number;
|
|
131
135
|
getZoom(compareCamera?: ICamera<number>): number;
|
|
132
|
-
setZoom(value: number, storeAsInitialCamera?: boolean): void;
|
|
136
|
+
setZoom(value: number, storeAsInitialCamera?: boolean, compareCamera?: ICamera<number>): void;
|
|
133
137
|
getAspectRatio(): Point2;
|
|
134
138
|
setAspectRatio(value: Point2, options?: SetAspectRatioOptions): void;
|
|
135
139
|
private _getFocalPointForViewPlaneReset;
|
|
@@ -439,9 +439,7 @@ class Viewport {
|
|
|
439
439
|
}
|
|
440
440
|
setDisplayAreaScale(displayArea) {
|
|
441
441
|
const { scale = 1 } = displayArea;
|
|
442
|
-
const
|
|
443
|
-
const height = canvas.height;
|
|
444
|
-
const width = canvas.width;
|
|
442
|
+
const { width, height } = this.getRenderedCanvasSize();
|
|
445
443
|
if (height < 8 || width < 8) {
|
|
446
444
|
return;
|
|
447
445
|
}
|
|
@@ -454,10 +452,10 @@ class Viewport {
|
|
|
454
452
|
this.setDisplayAreaFit(displayArea);
|
|
455
453
|
const { focalPoint, position, viewUp, viewPlaneNormal } = this.getCamera();
|
|
456
454
|
const focalChange = vec3.create();
|
|
457
|
-
if (
|
|
455
|
+
if (height % 2) {
|
|
458
456
|
vec3.scaleAndAdd(focalChange, focalChange, viewUp, scale * 0.5 * spacing);
|
|
459
457
|
}
|
|
460
|
-
if (
|
|
458
|
+
if (width % 2) {
|
|
461
459
|
const viewRight = vec3.cross(vec3.create(), viewUp, viewPlaneNormal);
|
|
462
460
|
vec3.scaleAndAdd(focalChange, focalChange, viewRight, scale * 0.5 * spacing);
|
|
463
461
|
}
|
|
@@ -469,7 +467,7 @@ class Viewport {
|
|
|
469
467
|
position: vec3.add(vec3.create(), position, focalChange),
|
|
470
468
|
});
|
|
471
469
|
}
|
|
472
|
-
setDisplayAreaFit(displayArea) {
|
|
470
|
+
setDisplayAreaFit(displayArea, baseCamera = this.fitToCanvasCamera) {
|
|
473
471
|
const { imageArea, imageCanvasPoint } = displayArea;
|
|
474
472
|
const devicePixelRatio = window?.devicePixelRatio || 1;
|
|
475
473
|
const imageData = this.getDefaultImageData();
|
|
@@ -490,18 +488,19 @@ class Viewport {
|
|
|
490
488
|
Math.abs(canvasEdge[1] - canvasZero[1]),
|
|
491
489
|
];
|
|
492
490
|
const [imgWidth, imgHeight] = canvasImage;
|
|
493
|
-
|
|
491
|
+
const baseZoom = this.getZoom(baseCamera);
|
|
492
|
+
if (!Number.isFinite(baseZoom) || baseZoom <= 0) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
let zoom = baseZoom / this.insetImageMultiplier;
|
|
494
496
|
if (imageArea) {
|
|
495
497
|
const [areaX, areaY] = imageArea;
|
|
496
498
|
const currentScale = Math.max(Math.abs(imgWidth / canvasWidth), Math.abs(imgHeight / canvasHeight));
|
|
497
499
|
const requireX = Math.abs((areaX * imgWidth) / canvasWidth);
|
|
498
500
|
const requireY = Math.abs((areaY * imgHeight) / canvasHeight);
|
|
499
|
-
const initZoom = this.getZoom();
|
|
500
|
-
const fitZoom = this.getZoom(this.fitToCanvasCamera);
|
|
501
501
|
const absZoom = requireX > requireY ? currentScale / requireX : currentScale / requireY;
|
|
502
|
-
|
|
503
|
-
zoom
|
|
504
|
-
this.setZoom(this.insetImageMultiplier * zoom, false);
|
|
502
|
+
zoom = absZoom * baseZoom;
|
|
503
|
+
this.setZoom(this.insetImageMultiplier * zoom, false, baseCamera);
|
|
505
504
|
}
|
|
506
505
|
if (imageCanvasPoint) {
|
|
507
506
|
const { imagePoint, canvasPoint = imagePoint || [0.5, 0.5] } = imageCanvasPoint;
|
|
@@ -509,9 +508,9 @@ class Viewport {
|
|
|
509
508
|
const canvasPanX = canvasWidth * (canvasX - 0.5);
|
|
510
509
|
const canvasPanY = canvasHeight * (canvasY - 0.5);
|
|
511
510
|
const [imageX, imageY] = imagePoint || canvasPoint;
|
|
512
|
-
const useZoom = zoom;
|
|
513
|
-
const imagePanX =
|
|
514
|
-
const imagePanY =
|
|
511
|
+
const useZoom = (this.insetImageMultiplier * zoom) / baseZoom;
|
|
512
|
+
const imagePanX = useZoom * imgWidth * (0.5 - imageX);
|
|
513
|
+
const imagePanY = useZoom * imgHeight * (0.5 - imageY);
|
|
515
514
|
const newPositionX = imagePanX + canvasPanX;
|
|
516
515
|
const newPositionY = imagePanY + canvasPanY;
|
|
517
516
|
const deltaPoint2 = [newPositionX, newPositionY];
|
|
@@ -519,6 +518,12 @@ class Viewport {
|
|
|
519
518
|
this.setPan(deltaPoint2, false);
|
|
520
519
|
}
|
|
521
520
|
}
|
|
521
|
+
getRenderedCanvasSize() {
|
|
522
|
+
return {
|
|
523
|
+
width: this.sWidth || this.canvas.width,
|
|
524
|
+
height: this.sHeight || this.canvas.height,
|
|
525
|
+
};
|
|
526
|
+
}
|
|
522
527
|
getDisplayArea() {
|
|
523
528
|
return this.options?.displayArea;
|
|
524
529
|
}
|
|
@@ -723,9 +728,9 @@ class Viewport {
|
|
|
723
728
|
return (this.getComparableParallelScale(compareCamera) /
|
|
724
729
|
activeCamera.getParallelScale());
|
|
725
730
|
}
|
|
726
|
-
setZoom(value, storeAsInitialCamera = false) {
|
|
731
|
+
setZoom(value, storeAsInitialCamera = false, compareCamera = this.initialCamera) {
|
|
727
732
|
const camera = this.getCamera();
|
|
728
|
-
const initialParallelScale = this.getComparableParallelScale(
|
|
733
|
+
const initialParallelScale = this.getComparableParallelScale(compareCamera);
|
|
729
734
|
if (!initialParallelScale) {
|
|
730
735
|
return;
|
|
731
736
|
}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "5.
|
|
1
|
+
export declare const version = "5.12.0";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.
|
|
1
|
+
export const version = '5.12.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.12.0",
|
|
4
4
|
"description": "Cornerstone3D Core",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/esm/index.d.ts",
|
|
@@ -85,18 +85,18 @@
|
|
|
85
85
|
"prepublishOnly": "pnpm run build"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@cornerstonejs/utils": "5.
|
|
88
|
+
"@cornerstonejs/utils": "5.12.0",
|
|
89
89
|
"@kitware/vtk.js": "36.4.1",
|
|
90
90
|
"comlink": "4.4.2",
|
|
91
91
|
"gl-matrix": "3.4.3",
|
|
92
92
|
"loglevel": "1.9.2"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@cornerstonejs/metadata": "5.
|
|
95
|
+
"@cornerstonejs/metadata": "5.12.0"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@cornerstonejs/metadata": "5.
|
|
99
|
-
"@cornerstonejs/utils": "5.
|
|
98
|
+
"@cornerstonejs/metadata": "5.12.0",
|
|
99
|
+
"@cornerstonejs/utils": "5.12.0"
|
|
100
100
|
},
|
|
101
101
|
"contributors": [
|
|
102
102
|
{
|