@cornerstonejs/core 4.2.2 → 4.2.4

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.
@@ -172,13 +172,16 @@ class BaseVolumeViewport extends Viewport {
172
172
  const devicePixelRatio = window.devicePixelRatio || 1;
173
173
  const { width, height } = this.canvas;
174
174
  const aspectRatio = width / height;
175
+ const [xMin, yMin, xMax, yMax] = renderer.getViewport();
176
+ const viewportWidth = xMax - xMin;
177
+ const viewportHeight = yMax - yMin;
175
178
  const canvasPosWithDPR = [
176
179
  canvasPos[0] * devicePixelRatio,
177
180
  canvasPos[1] * devicePixelRatio,
178
181
  ];
179
182
  const normalizedDisplay = [
180
- canvasPosWithDPR[0] / width,
181
- 1 - canvasPosWithDPR[1] / height,
183
+ xMin + (canvasPosWithDPR[0] / width) * viewportWidth,
184
+ yMin + (1 - canvasPosWithDPR[1] / height) * viewportHeight,
182
185
  0,
183
186
  ];
184
187
  const projCoords = renderer.normalizedDisplayToProjection(normalizedDisplay[0], normalizedDisplay[1], normalizedDisplay[2]);
@@ -209,8 +212,14 @@ class BaseVolumeViewport extends Viewport {
209
212
  canvasPos[0] * devicePixelRatio,
210
213
  canvasPos[1] * devicePixelRatio,
211
214
  ];
212
- const { height } = this.canvas;
213
- const displayCoord = [canvasPosWithDPR[0], height - canvasPosWithDPR[1]];
215
+ const renderer = this.getRenderer();
216
+ const { width, height } = this.canvas;
217
+ const [xMin, yMin, xMax, yMax] = renderer.getViewport();
218
+ const viewportWidth = xMax - xMin;
219
+ const viewportHeight = yMax - yMin;
220
+ const scaledX = (canvasPosWithDPR[0] / width) * viewportWidth * width;
221
+ const scaledY = (canvasPosWithDPR[1] / height) * viewportHeight * height;
222
+ const displayCoord = [scaledX, viewportHeight * height - scaledY];
214
223
  return [displayCoord[0], displayCoord[1], 0];
215
224
  };
216
225
  this.worldToCanvasTiled = (worldPos) => {
@@ -240,11 +249,16 @@ class BaseVolumeViewport extends Viewport {
240
249
  const renderer = this.getRenderer();
241
250
  const { width, height } = this.canvas;
242
251
  const aspectRatio = width / height;
252
+ const [xMin, yMin, xMax, yMax] = renderer.getViewport();
253
+ const viewportWidth = xMax - xMin;
254
+ const viewportHeight = yMax - yMin;
243
255
  const viewCoords = renderer.worldToView(worldPos[0], worldPos[1], worldPos[2]);
244
256
  const projCoords = renderer.viewToProjection(viewCoords[0], viewCoords[1], viewCoords[2], aspectRatio);
245
257
  const normalizedDisplay = renderer.projectionToNormalizedDisplay(projCoords[0], projCoords[1], projCoords[2]);
246
- const canvasX = normalizedDisplay[0] * width;
247
- const canvasY = (1 - normalizedDisplay[1]) * height;
258
+ const canvasNormalizedX = (normalizedDisplay[0] - xMin) / viewportWidth;
259
+ const canvasNormalizedY = (normalizedDisplay[1] - yMin) / viewportHeight;
260
+ const canvasX = canvasNormalizedX * width;
261
+ const canvasY = (1 - canvasNormalizedY) * height;
248
262
  const devicePixelRatio = window.devicePixelRatio || 1;
249
263
  const canvasCoordWithDPR = [
250
264
  canvasX / devicePixelRatio,
@@ -209,9 +209,13 @@ class StackViewport extends Viewport {
209
209
  canvasPos[0] * devicePixelRatio,
210
210
  canvasPos[1] * devicePixelRatio,
211
211
  ];
212
+ const viewport = renderer.getViewport();
213
+ const [xStart, yStart, xEnd, yEnd] = viewport;
214
+ const viewportWidth = xEnd - xStart;
215
+ const viewportHeight = yEnd - yStart;
212
216
  const normalizedDisplay = [
213
- canvasPosWithDPR[0] / width,
214
- 1 - canvasPosWithDPR[1] / height,
217
+ xStart + (canvasPosWithDPR[0] / width) * viewportWidth,
218
+ yStart + (1 - canvasPosWithDPR[1] / height) * viewportHeight,
215
219
  0,
216
220
  ];
217
221
  const projCoords = renderer.normalizedDisplayToProjection(normalizedDisplay[0], normalizedDisplay[1], normalizedDisplay[2]);
@@ -255,8 +259,12 @@ class StackViewport extends Viewport {
255
259
  const viewCoords = renderer.worldToView(worldPos[0], worldPos[1], worldPos[2]);
256
260
  const projCoords = renderer.viewToProjection(viewCoords[0], viewCoords[1], viewCoords[2], aspectRatio);
257
261
  const normalizedDisplay = renderer.projectionToNormalizedDisplay(projCoords[0], projCoords[1], projCoords[2]);
258
- const canvasX = normalizedDisplay[0] * width;
259
- const canvasY = (1 - normalizedDisplay[1]) * height;
262
+ const viewport = renderer.getViewport();
263
+ const [xStart, yStart, xEnd, yEnd] = viewport;
264
+ const viewportWidth = xEnd - xStart;
265
+ const viewportHeight = yEnd - yStart;
266
+ const canvasX = ((normalizedDisplay[0] - xStart) / viewportWidth) * width;
267
+ const canvasY = (1 - (normalizedDisplay[1] - yStart) / viewportHeight) * height;
260
268
  vtkCamera.setClippingRange(crange[0], crange[1]);
261
269
  const canvasCoordWithDPR = [
262
270
  canvasX / devicePixelRatio,
@@ -1 +1 @@
1
- export declare const version = "4.2.2";
1
+ export declare const version = "4.2.4";
@@ -1 +1 @@
1
- export const version = '4.2.2';
1
+ export const version = '4.2.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "4.2.2",
3
+ "version": "4.2.4",
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": "4f72463ab07c045e223800f5db9b1373f9e53b07"
100
+ "gitHead": "6c47c1ba0dc3307bde44ea13b6adaedaec001825"
101
101
  }