@cornerstonejs/core 4.17.2 → 4.17.3
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.
|
@@ -131,15 +131,39 @@ class ContextPoolRenderingEngine extends BaseRenderingEngine {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
_resizeVTKViewports(vtkDrivenViewports, keepCamera = true, immediate = true) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
135
|
+
const viewportsNeedingResize = [];
|
|
136
|
+
for (const vp of vtkDrivenViewports) {
|
|
137
|
+
const canvas = getOrCreateCanvas(vp.element);
|
|
138
|
+
const displayedWidth = Math.round(canvas.clientWidth * devicePixelRatio);
|
|
139
|
+
const displayedHeight = Math.round(canvas.clientHeight * devicePixelRatio);
|
|
140
|
+
if (displayedWidth === 0 || displayedHeight === 0) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const renderedWidth = canvas.width;
|
|
144
|
+
const renderedHeight = canvas.height;
|
|
145
|
+
if (displayedWidth === renderedWidth &&
|
|
146
|
+
displayedHeight === renderedHeight) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
viewportsNeedingResize.push(vp);
|
|
150
|
+
}
|
|
151
|
+
if (viewportsNeedingResize.length === 0) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (this._animationFrameSet) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
for (const vp of viewportsNeedingResize) {
|
|
158
|
+
const canvas = getOrCreateCanvas(vp.element);
|
|
159
|
+
const displayedWidth = Math.round(canvas.clientWidth * devicePixelRatio);
|
|
160
|
+
const displayedHeight = Math.round(canvas.clientHeight * devicePixelRatio);
|
|
161
|
+
const targetWidth = Math.max(VIEWPORT_MIN_SIZE, displayedWidth);
|
|
162
|
+
const targetHeight = Math.max(VIEWPORT_MIN_SIZE, displayedHeight);
|
|
163
|
+
vp.sWidth = targetWidth;
|
|
164
|
+
vp.sHeight = targetHeight;
|
|
165
|
+
}
|
|
166
|
+
if (vtkDrivenViewports.length) {
|
|
143
167
|
this._resize(vtkDrivenViewports);
|
|
144
168
|
}
|
|
145
169
|
vtkDrivenViewports.forEach((vp) => {
|
|
@@ -181,6 +205,10 @@ class ContextPoolRenderingEngine extends BaseRenderingEngine {
|
|
|
181
205
|
return eventDetail;
|
|
182
206
|
}
|
|
183
207
|
_renderViewportWithContext(viewport, offscreenMultiRenderWindow, offScreenCanvasContainer) {
|
|
208
|
+
if (viewport.canvas.clientWidth === 0 ||
|
|
209
|
+
viewport.canvas.clientHeight === 0) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
184
212
|
if (viewport.sWidth < VIEWPORT_MIN_SIZE ||
|
|
185
213
|
viewport.sHeight < VIEWPORT_MIN_SIZE) {
|
|
186
214
|
console.warn('Viewport is too small', viewport.sWidth, viewport.sHeight);
|
|
@@ -210,8 +238,8 @@ class ContextPoolRenderingEngine extends BaseRenderingEngine {
|
|
|
210
238
|
const renderer = offscreenMultiRenderWindow.getRenderer(viewport.id);
|
|
211
239
|
const contextIndex = this.contextPool.getContextIndexForViewport(viewport.id);
|
|
212
240
|
const maxSize = this.contextPool.getMaxSizeForContext(contextIndex);
|
|
213
|
-
const viewportWidth = viewport.
|
|
214
|
-
const viewportHeight = viewport.
|
|
241
|
+
const viewportWidth = viewport.sWidth;
|
|
242
|
+
const viewportHeight = viewport.sHeight;
|
|
215
243
|
const xEnd = Math.min(1, viewportWidth / maxSize.width);
|
|
216
244
|
const yEnd = Math.min(1, viewportHeight / maxSize.height);
|
|
217
245
|
renderer.setViewport(0, 0, xEnd, yEnd);
|
|
@@ -245,7 +273,7 @@ class ContextPoolRenderingEngine extends BaseRenderingEngine {
|
|
|
245
273
|
if (contextIndex === undefined) {
|
|
246
274
|
return;
|
|
247
275
|
}
|
|
248
|
-
const maxSizeChanged = this.contextPool.updateViewportSize(viewport.id, viewport.
|
|
276
|
+
const maxSizeChanged = this.contextPool.updateViewportSize(viewport.id, viewport.sWidth, viewport.sHeight);
|
|
249
277
|
if (!maxSizeChanged) {
|
|
250
278
|
return;
|
|
251
279
|
}
|
|
@@ -260,7 +288,14 @@ class ContextPoolRenderingEngine extends BaseRenderingEngine {
|
|
|
260
288
|
}
|
|
261
289
|
_copyToOnscreenCanvas(viewport, offScreenCanvas) {
|
|
262
290
|
const { element, canvas, id: viewportId, renderingEngineId, suppressEvents, } = viewport;
|
|
263
|
-
const
|
|
291
|
+
const dWidth = viewport.sWidth;
|
|
292
|
+
const dHeight = viewport.sHeight;
|
|
293
|
+
if (canvas.width !== dWidth ||
|
|
294
|
+
(canvas.height !== dHeight && dWidth >= 1 && dHeight >= 1)) {
|
|
295
|
+
canvas.width = dWidth;
|
|
296
|
+
canvas.height = dHeight;
|
|
297
|
+
canvas.style.aspectRatio = `${dWidth} / ${dHeight}`;
|
|
298
|
+
}
|
|
264
299
|
const onScreenContext = canvas.getContext('2d');
|
|
265
300
|
const contextIndex = this.contextPool.getContextIndexForViewport(viewportId);
|
|
266
301
|
const maxSize = this.contextPool.getMaxSizeForContext(contextIndex);
|
|
@@ -279,10 +314,8 @@ class ContextPoolRenderingEngine extends BaseRenderingEngine {
|
|
|
279
314
|
for (const viewport of viewportsDrivenByVtkJs) {
|
|
280
315
|
viewport.sx = 0;
|
|
281
316
|
viewport.sy = 0;
|
|
282
|
-
viewport.sWidth = viewport.canvas.width;
|
|
283
|
-
viewport.sHeight = viewport.canvas.height;
|
|
284
317
|
const contextIndex = this.contextPool.getContextIndexForViewport(viewport.id);
|
|
285
|
-
const maxSizeChanged = this.contextPool.updateViewportSize(viewport.id, viewport.
|
|
318
|
+
const maxSizeChanged = this.contextPool.updateViewportSize(viewport.id, viewport.sWidth, viewport.sHeight);
|
|
286
319
|
if (maxSizeChanged) {
|
|
287
320
|
contextsToResize.add(contextIndex);
|
|
288
321
|
}
|
|
@@ -290,8 +323,8 @@ class ContextPoolRenderingEngine extends BaseRenderingEngine {
|
|
|
290
323
|
const { context: offscreenMultiRenderWindow } = contextData;
|
|
291
324
|
const renderer = offscreenMultiRenderWindow.getRenderer(viewport.id);
|
|
292
325
|
const maxSize = this.contextPool.getMaxSizeForContext(contextIndex);
|
|
293
|
-
const xEnd = Math.min(1, viewport.
|
|
294
|
-
const yEnd = Math.min(1, viewport.
|
|
326
|
+
const xEnd = Math.min(1, viewport.sWidth / maxSize.width);
|
|
327
|
+
const yEnd = Math.min(1, viewport.sHeight / maxSize.height);
|
|
295
328
|
renderer.setViewport(0, 0, xEnd, yEnd);
|
|
296
329
|
}
|
|
297
330
|
contextsToResize.forEach((contextIndex) => {
|
|
@@ -43,8 +43,11 @@ export function getOrCreateCanvas(element) {
|
|
|
43
43
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
44
44
|
const width = Math.ceil(rect.width * devicePixelRatio);
|
|
45
45
|
const height = Math.ceil(rect.height * devicePixelRatio);
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (width > 0 && height > 0) {
|
|
47
|
+
canvas.width = width;
|
|
48
|
+
canvas.height = height;
|
|
49
|
+
canvas.style.aspectRatio = `${width} / ${height}`;
|
|
50
|
+
}
|
|
48
51
|
return canvas;
|
|
49
52
|
}
|
|
50
53
|
export default getOrCreateCanvas;
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "4.17.
|
|
1
|
+
export declare const version = "4.17.3";
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '4.17.
|
|
1
|
+
export const version = '4.17.3';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "4.17.
|
|
3
|
+
"version": "4.17.3",
|
|
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": "35a09b7057c1778bf4970c4a342fde94761fdaf0"
|
|
101
101
|
}
|