@cornerstonejs/tools 3.33.4 → 3.33.5

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.
@@ -140,7 +140,8 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
140
140
  this._deactivateModify(element);
141
141
  this._deactivateDraw(element);
142
142
  resetElementCursor(element);
143
- const enabledElement = getEnabledElement(element);
143
+ const { metadata } = annotation;
144
+ const { enabledElement } = metadata;
144
145
  this.editData = null;
145
146
  this.isDrawing = false;
146
147
  if (this.isHandleOutsideImage &&
@@ -176,6 +177,7 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
176
177
  const { annotationUID, data, metadata } = annotation;
177
178
  const { startCoordinate, endCoordinate } = data;
178
179
  const { points, activeHandleIndex } = data.handles;
180
+ const { enabledElement: annotationEnabledElement } = metadata;
179
181
  styleSpecifier.annotationUID = annotationUID;
180
182
  const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
181
183
  const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
@@ -219,8 +221,12 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
219
221
  isMiddleSlice = true;
220
222
  }
221
223
  data.handles.points[0][this._getIndexOfCoordinatesForViewplaneNormal(viewplaneNormal)] = middleCoordinate;
222
- if (annotation.invalidated) {
223
- this._throttledCalculateCachedStats(annotation, enabledElement);
224
+ const iteratorVolumeIDs = annotationEnabledElement.viewport?.volumeIds.values();
225
+ for (const volumeId of iteratorVolumeIDs) {
226
+ if (annotation.invalidated &&
227
+ annotation.metadata.volumeId === volumeId) {
228
+ this._throttledCalculateCachedStats(annotation, annotationEnabledElement);
229
+ }
224
230
  }
225
231
  if (!viewport.getRenderingEngine()) {
226
232
  console.warn('Rendering Engine has been destroyed');
@@ -323,24 +329,32 @@ class CircleROIStartEndThresholdTool extends CircleROITool {
323
329
  const { viewPlaneNormal, spacingInNormal } = metadata;
324
330
  const { startCoordinate, endCoordinate } = data;
325
331
  const { points } = data.handles;
326
- const handlesToStart = csUtils.deepClone(points);
332
+ const projectionAxisIndex = this._getIndexOfCoordinatesForViewplaneNormal(viewPlaneNormal);
327
333
  const startWorld = vec3.clone(points[0]);
334
+ startWorld[projectionAxisIndex] = startCoordinate;
328
335
  const endWorld = vec3.clone(points[0]);
329
- const indexOfNormal = this._getIndexOfCoordinatesForViewplaneNormal(viewPlaneNormal);
330
- startWorld[indexOfNormal] = startCoordinate;
331
- endWorld[indexOfNormal] = endCoordinate;
332
- handlesToStart.forEach((handlePoint) => {
333
- handlePoint[indexOfNormal] = startCoordinate;
334
- });
335
- const distance = vec3.distance(startWorld, endWorld);
336
- const newProjectionPoints = [];
337
- if (distance >= 0) {
338
- newProjectionPoints.push(handlesToStart.map((p) => Array.from(p)));
336
+ endWorld[projectionAxisIndex] = endCoordinate;
337
+ const direction = vec3.create();
338
+ vec3.subtract(direction, endWorld, startWorld);
339
+ const distance = vec3.length(direction);
340
+ if (distance === 0) {
341
+ const handlesOnStartPlane = points.map(p => {
342
+ const newPoint = vec3.clone(p);
343
+ newPoint[projectionAxisIndex] = startCoordinate;
344
+ return Array.from(newPoint);
345
+ });
346
+ data.cachedStats.projectionPoints = [handlesOnStartPlane];
347
+ return;
339
348
  }
340
- for (let dist = spacingInNormal; dist <= distance; dist += spacingInNormal) {
349
+ vec3.normalize(direction, direction);
350
+ const handlesToStart = csUtils.deepClone(points);
351
+ handlesToStart[0][projectionAxisIndex] = startCoordinate;
352
+ handlesToStart[1][projectionAxisIndex] = startCoordinate;
353
+ const newProjectionPoints = [];
354
+ for (let dist = 0; dist <= distance + 1e-6; dist += spacingInNormal) {
341
355
  newProjectionPoints.push(handlesToStart.map((point) => {
342
356
  const newPoint = vec3.create();
343
- vec3.scaleAndAdd(newPoint, point, viewPlaneNormal, dist);
357
+ vec3.scaleAndAdd(newPoint, point, direction, dist);
344
358
  return Array.from(newPoint);
345
359
  }));
346
360
  }
@@ -128,7 +128,8 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
128
128
  this._deactivateModify(element);
129
129
  this._deactivateDraw(element);
130
130
  resetElementCursor(element);
131
- const enabledElement = getEnabledElement(element);
131
+ const { metadata } = annotation;
132
+ const { enabledElement } = metadata;
132
133
  this.editData = null;
133
134
  this.isDrawing = false;
134
135
  if (this.isHandleOutsideImage &&
@@ -164,6 +165,7 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
164
165
  const { annotationUID, data, metadata } = annotation;
165
166
  const { startCoordinate, endCoordinate } = data;
166
167
  const { points, activeHandleIndex } = data.handles;
168
+ const { enabledElement: annotationEnabledElement } = metadata;
167
169
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
168
170
  styleSpecifier.annotationUID = annotationUID;
169
171
  const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
@@ -194,8 +196,12 @@ class RectangleROIStartEndThresholdTool extends RectangleROITool {
194
196
  roundedCoord > Math.max(roundedStartCoord, roundedEndCoord)) {
195
197
  continue;
196
198
  }
197
- if (annotation.invalidated) {
198
- this._throttledCalculateCachedStats(annotation, enabledElement);
199
+ const iteratorVolumeIDs = annotationEnabledElement.viewport?.volumeIds.values();
200
+ for (const volumeId of iteratorVolumeIDs) {
201
+ if (annotation.invalidated &&
202
+ annotation.metadata.volumeId === volumeId) {
203
+ this._throttledCalculateCachedStats(annotation, annotationEnabledElement);
204
+ }
199
205
  }
200
206
  let firstOrLastSlice = false;
201
207
  if (roundedCoord === roundedStartCoord ||
@@ -4,6 +4,7 @@ export type AnnotationMetadata = Types.ViewReference & {
4
4
  cameraPosition?: Types.Point3;
5
5
  viewUp?: Types.Point3;
6
6
  segmentColor?: any;
7
+ enabledElement?: Types.IEnabledElement;
7
8
  };
8
9
  export type AnnotationData = {
9
10
  handles?: Handles;
@@ -1 +1 @@
1
- export declare const version = "3.33.4";
1
+ export declare const version = "3.33.5";
@@ -1 +1 @@
1
- export const version = '3.33.4';
1
+ export const version = '3.33.5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "3.33.4",
3
+ "version": "3.33.5",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "^3.1.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "^3.33.4",
111
+ "@cornerstonejs/core": "^3.33.5",
112
112
  "@kitware/vtk.js": "32.12.1",
113
113
  "@types/d3-array": "^3.0.4",
114
114
  "@types/d3-interpolate": "^3.0.1",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "b88b09753745ab843cb89e4232b19c9018ed075f"
130
+ "gitHead": "2b17e979df54cdc1fd91df95141feaa273a29de7"
131
131
  }