@cornerstonejs/tools 2.17.0 → 2.17.2

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.
@@ -2,6 +2,7 @@ import type { Types } from '@cornerstonejs/core';
2
2
  import { BaseTool } from '../base';
3
3
  import type vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
4
4
  import * as LabelmapMemo from '../../utilities/segmentation/createLabelmapMemo';
5
+ import type { LabelmapToolOperationData } from '../../types/LabelmapToolOperationData';
5
6
  export type PreviewData = {
6
7
  preview: unknown;
7
8
  timer?: number;
@@ -10,6 +11,25 @@ export type PreviewData = {
10
11
  element: HTMLDivElement;
11
12
  isDrag: boolean;
12
13
  };
14
+ type EditDataReturnType = {
15
+ volumeId: string;
16
+ referencedVolumeId: string;
17
+ segmentsLocked: number[];
18
+ } | {
19
+ imageId: string;
20
+ segmentsLocked: number[];
21
+ override?: {
22
+ voxelManager: Types.IVoxelManager<number> | Types.IVoxelManager<Types.RGB>;
23
+ imageData: vtkImageData;
24
+ };
25
+ } | null;
26
+ type ModifiedLabelmapToolOperationData = Omit<LabelmapToolOperationData, 'voxelManager' | 'override'> & {
27
+ voxelManager?: Types.IVoxelManager<number> | Types.IVoxelManager<Types.RGB>;
28
+ override?: {
29
+ voxelManager: Types.IVoxelManager<number> | Types.IVoxelManager<Types.RGB>;
30
+ imageData: vtkImageData;
31
+ };
32
+ };
13
33
  export default class LabelmapBaseTool extends BaseTool {
14
34
  protected _editData: {
15
35
  override: {
@@ -35,28 +55,14 @@ export default class LabelmapBaseTool extends BaseTool {
35
55
  constructor(toolProps: any, defaultToolProps: any);
36
56
  protected get _previewData(): PreviewData;
37
57
  createMemo(segmentId: string, segmentationVoxelManager: any, preview: any): LabelmapMemo.LabelmapMemo;
38
- createEditData(element: any): {
39
- volumeId: string;
40
- referencedVolumeId: any;
41
- segmentsLocked: number[] | [];
42
- imageId?: undefined;
43
- override?: undefined;
44
- } | {
45
- imageId: string;
46
- segmentsLocked: number[] | [];
47
- override: {
48
- voxelManager: Types.IVoxelManager<number> | Types.IVoxelManager<Types.RGB>;
49
- imageData: vtkImageData;
50
- };
51
- volumeId?: undefined;
52
- referencedVolumeId?: undefined;
53
- } | {
54
- imageId: string;
55
- segmentsLocked: number[] | [];
56
- volumeId?: undefined;
57
- referencedVolumeId?: undefined;
58
- override?: undefined;
59
- };
58
+ protected createEditData(element: any): EditDataReturnType;
59
+ protected getEditData({ viewport, representationData, segmentsLocked, segmentationId, volumeOperation, }: {
60
+ viewport: any;
61
+ representationData: any;
62
+ segmentsLocked: any;
63
+ segmentationId: any;
64
+ volumeOperation?: boolean;
65
+ }): EditDataReturnType;
60
66
  protected createHoverData(element: any, centerCanvas?: any): {
61
67
  brushCursor: {
62
68
  metadata: {
@@ -81,78 +87,7 @@ export default class LabelmapBaseTool extends BaseTool {
81
87
  segmentationId: string;
82
88
  segmentColor: Types.Color;
83
89
  };
84
- protected getOperationData(element?: any): {
85
- points: any;
86
- segmentIndex: number;
87
- previewColors: any;
88
- viewPlaneNormal: any;
89
- toolGroupId: string;
90
- segmentationId: string;
91
- viewUp: any;
92
- strategySpecificConfiguration: any;
93
- preview: unknown;
94
- createMemo: (segmentId: string, segmentationVoxelManager: any, preview: any) => LabelmapMemo.LabelmapMemo;
95
- override: {
96
- voxelManager: Types.IVoxelManager<number>;
97
- imageData: vtkImageData;
98
- };
99
- segmentsLocked: number[];
100
- imageId?: string;
101
- imageIds?: string[];
102
- volumeId?: string;
103
- referencedVolumeId?: string;
104
- } | {
105
- points: any;
106
- segmentIndex: number;
107
- previewColors: any;
108
- viewPlaneNormal: any;
109
- toolGroupId: string;
110
- segmentationId: string;
111
- viewUp: any;
112
- strategySpecificConfiguration: any;
113
- preview: unknown;
114
- createMemo: (segmentId: string, segmentationVoxelManager: any, preview: any) => LabelmapMemo.LabelmapMemo;
115
- volumeId: string;
116
- referencedVolumeId: any;
117
- segmentsLocked: number[] | [];
118
- imageId?: undefined;
119
- override?: undefined;
120
- } | {
121
- points: any;
122
- segmentIndex: number;
123
- previewColors: any;
124
- viewPlaneNormal: any;
125
- toolGroupId: string;
126
- segmentationId: string;
127
- viewUp: any;
128
- strategySpecificConfiguration: any;
129
- preview: unknown;
130
- createMemo: (segmentId: string, segmentationVoxelManager: any, preview: any) => LabelmapMemo.LabelmapMemo;
131
- imageId: string;
132
- segmentsLocked: number[] | [];
133
- override: {
134
- voxelManager: Types.IVoxelManager<number> | Types.IVoxelManager<Types.RGB>;
135
- imageData: vtkImageData;
136
- };
137
- volumeId?: undefined;
138
- referencedVolumeId?: undefined;
139
- } | {
140
- points: any;
141
- segmentIndex: number;
142
- previewColors: any;
143
- viewPlaneNormal: any;
144
- toolGroupId: string;
145
- segmentationId: string;
146
- viewUp: any;
147
- strategySpecificConfiguration: any;
148
- preview: unknown;
149
- createMemo: (segmentId: string, segmentationVoxelManager: any, preview: any) => LabelmapMemo.LabelmapMemo;
150
- imageId: string;
151
- segmentsLocked: number[] | [];
152
- volumeId?: undefined;
153
- referencedVolumeId?: undefined;
154
- override?: undefined;
155
- };
90
+ protected getOperationData(element?: any): ModifiedLabelmapToolOperationData;
156
91
  addPreview(element?: HTMLDivElement, options?: {
157
92
  acceptReject: boolean;
158
93
  }): unknown;
@@ -162,3 +97,4 @@ export default class LabelmapBaseTool extends BaseTool {
162
97
  removeContours: boolean;
163
98
  }): void;
164
99
  }
100
+ export {};
@@ -53,6 +53,15 @@ export default class LabelmapBaseTool extends BaseTool {
53
53
  const { segmentationId } = activeSegmentation;
54
54
  const segmentsLocked = getLockedSegmentIndices(segmentationId);
55
55
  const { representationData } = getSegmentation(segmentationId);
56
+ const editData = this.getEditData({
57
+ viewport,
58
+ representationData,
59
+ segmentsLocked,
60
+ segmentationId,
61
+ });
62
+ return editData;
63
+ }
64
+ getEditData({ viewport, representationData, segmentsLocked, segmentationId, volumeOperation = false, }) {
56
65
  if (viewport instanceof BaseVolumeViewport) {
57
66
  const { volumeId } = representationData[SegmentationRepresentations.Labelmap];
58
67
  const actors = viewport.getActors();
@@ -82,7 +91,8 @@ export default class LabelmapBaseTool extends BaseTool {
82
91
  if (!segmentationImageId) {
83
92
  return;
84
93
  }
85
- if (this.configuration.activeStrategy.includes('SPHERE')) {
94
+ if (this.configuration.activeStrategy.includes('SPHERE') ||
95
+ volumeOperation) {
86
96
  const referencedImageIds = viewport.getImageIds();
87
97
  const isValidVolumeForSphere = csUtils.isValidVolume(referencedImageIds);
88
98
  if (!isValidVolumeForSphere) {
@@ -101,7 +111,7 @@ export default class LabelmapBaseTool extends BaseTool {
101
111
  };
102
112
  }
103
113
  else {
104
- const labelmapImageIds = getStackSegmentationImageIdsForViewport(viewport.id, segmentationId);
114
+ const { imageIds: labelmapImageIds } = representationData.Labelmap;
105
115
  if (!labelmapImageIds || labelmapImageIds.length === 1) {
106
116
  return {
107
117
  imageId: segmentationImageId,
@@ -1,5 +1,4 @@
1
- import { BaseVolumeViewport, cache, getEnabledElement, } from '@cornerstonejs/core';
2
- import { BaseTool } from '../base';
1
+ import { getEnabledElement } from '@cornerstonejs/core';
3
2
  import { fillInsideSphere } from './strategies/fillSphere';
4
3
  import { eraseInsideSphere } from './strategies/eraseSphere';
5
4
  import { Events, SegmentationRepresentations } from '../../enums';
@@ -88,21 +87,17 @@ class SphereScissorsTool extends LabelmapBaseTool {
88
87
  imageId: null,
89
88
  };
90
89
  const { representationData } = getSegmentation(segmentationId);
91
- const labelmapData = representationData[SegmentationRepresentations.Labelmap];
92
- if (viewport instanceof BaseVolumeViewport) {
93
- const { volumeId } = labelmapData;
94
- const segmentation = cache.getVolume(volumeId);
95
- this.editData = {
96
- ...this.editData,
97
- volumeId,
98
- referencedVolumeId: segmentation.referencedVolumeId,
99
- };
100
- }
101
- else {
102
- this.editData = {
103
- ...this.editData,
104
- };
105
- }
90
+ const editData = this.getEditData({
91
+ viewport,
92
+ representationData,
93
+ segmentsLocked,
94
+ segmentationId,
95
+ volumeOperation: true,
96
+ });
97
+ this.editData = {
98
+ ...this.editData,
99
+ ...editData,
100
+ };
106
101
  this._activateDraw(element);
107
102
  hideElementCursor(element);
108
103
  evt.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "2.17.0",
3
+ "version": "2.17.2",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -104,7 +104,7 @@
104
104
  "canvas": "^2.11.2"
105
105
  },
106
106
  "peerDependencies": {
107
- "@cornerstonejs/core": "^2.17.0",
107
+ "@cornerstonejs/core": "^2.17.2",
108
108
  "@kitware/vtk.js": "32.9.0",
109
109
  "@types/d3-array": "^3.0.4",
110
110
  "@types/d3-interpolate": "^3.0.1",
@@ -123,5 +123,5 @@
123
123
  "type": "individual",
124
124
  "url": "https://ohif.org/donate"
125
125
  },
126
- "gitHead": "912559cd9b86ddac21f2e0d6087980fc02343f52"
126
+ "gitHead": "26657751a6e715570cc44115ee8cc673aa453037"
127
127
  }