@cornerstonejs/tools 3.11.5 → 3.11.7

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.
@@ -32,13 +32,16 @@ function normalizeSegments(segmentsConfig, type, data) {
32
32
  const normalizedSegments = {};
33
33
  if (segmentsConfig) {
34
34
  Object.entries(segmentsConfig).forEach(([segmentIndex, segment]) => {
35
- normalizedSegments[segmentIndex] = {
35
+ const { label, locked, cachedStats, active, ...rest } = segment;
36
+ const normalizedSegment = {
36
37
  segmentIndex: Number(segmentIndex),
37
- label: segment.label ?? `Segment ${segmentIndex}`,
38
- locked: segment.locked ?? false,
39
- cachedStats: segment.cachedStats ?? {},
40
- active: segment.active ?? false,
38
+ label: label ?? `Segment ${segmentIndex}`,
39
+ locked: locked ?? false,
40
+ cachedStats: cachedStats ?? {},
41
+ active: active ?? false,
42
+ ...rest,
41
43
  };
44
+ normalizedSegments[segmentIndex] = normalizedSegment;
42
45
  });
43
46
  }
44
47
  else if (type === SegmentationRepresentations.Surface) {
@@ -16,10 +16,10 @@ function removeRepresentation(viewportId, segmentationId, renderImmediate = fals
16
16
  return;
17
17
  }
18
18
  const { viewport } = enabledElement;
19
+ removeContourFromElement(viewportId, segmentationId);
19
20
  if (!renderImmediate) {
20
21
  return;
21
22
  }
22
- removeContourFromElement(viewportId, segmentationId);
23
23
  viewport.render();
24
24
  }
25
25
  async function render(viewport, contourRepresentation) {
@@ -91,11 +91,23 @@ async function render(viewport, contourRepresentation) {
91
91
  handleContourSegmentation(viewport, contourData.geometryIds, contourData.annotationUIDsMap, contourRepresentation);
92
92
  }
93
93
  function _checkContourGeometryMatchViewport(geometryIds, viewportNormal) {
94
- const geometry = cache.getGeometry(geometryIds[0]);
95
- if (!geometry) {
94
+ let validGeometry = null;
95
+ let geometryData = null;
96
+ for (const geometryId of geometryIds) {
97
+ const geometry = cache.getGeometry(geometryId);
98
+ if (!geometry) {
99
+ continue;
100
+ }
101
+ const data = geometry.data;
102
+ if (data.contours?.[0]?.points?.length >= 3) {
103
+ validGeometry = geometry;
104
+ geometryData = data;
105
+ break;
106
+ }
107
+ }
108
+ if (!validGeometry || !geometryData) {
96
109
  return false;
97
110
  }
98
- const geometryData = geometry.data;
99
111
  const contours = geometryData.contours;
100
112
  const points = contours[0].points;
101
113
  const point1 = points[0];
@@ -63,6 +63,7 @@ async function calculateVolumeStatistics({ operationData, indices, unit, mode, }
63
63
  segmentationInfo,
64
64
  imageInfo,
65
65
  indices,
66
+ unit,
66
67
  mode,
67
68
  });
68
69
  triggerWorkerProgress(WorkerTypes.COMPUTE_STATISTICS, 100);
@@ -213,10 +213,22 @@ class ColorbarTicks {
213
213
  return { labelPoint, tickPoints };
214
214
  }
215
215
  _getTopTickInfo({ position, labelMeasure }) {
216
- throw new Error('Not implemented');
216
+ const { height } = this._canvas;
217
+ const labelY = height - this.tickSize - this._labelMargin;
218
+ const labelPoint = [position, labelY];
219
+ const tickPoints = {
220
+ start: [position, height - this._tickSize],
221
+ end: [position, height],
222
+ };
223
+ return { labelPoint, tickPoints };
217
224
  }
218
225
  _getBottomTickInfo({ position, labelMeasure }) {
219
- throw new Error('Not implemented');
226
+ const labelPoint = [position, this._tickSize + this._labelMargin];
227
+ const tickPoints = {
228
+ start: [position, 0],
229
+ end: [position, this._tickSize],
230
+ };
231
+ return { labelPoint, tickPoints };
220
232
  }
221
233
  render() {
222
234
  const { _canvas: canvas } = this;
@@ -235,7 +247,8 @@ class ColorbarTicks {
235
247
  const { ticks } = this._getTicks(range);
236
248
  canvasContext.clearRect(0, 0, width, height);
237
249
  canvasContext.font = this._font;
238
- canvasContext.textBaseline = 'middle';
250
+ canvasContext.textBaseline = isHorizontal ? 'top' : 'middle';
251
+ canvasContext.textAlign = isHorizontal ? 'center' : 'left';
239
252
  canvasContext.fillStyle = this._color;
240
253
  canvasContext.strokeStyle = this._color;
241
254
  canvasContext.lineWidth = this.tickWidth;
@@ -105,7 +105,7 @@ const computeWorker = {
105
105
  };
106
106
  },
107
107
  calculateSegmentsStatisticsVolume: (args) => {
108
- const { mode, indices } = args;
108
+ const { mode, indices, unit } = args;
109
109
  const { segmentation, image } = computeWorker.getArgsFromInfo(args);
110
110
  const { voxelManager: segVoxelManager, spacing: segmentationSpacing } = segmentation;
111
111
  const { voxelManager: imageVoxelManager } = image;
@@ -119,8 +119,8 @@ const computeWorker = {
119
119
  });
120
120
  const stats = SegmentStatsCalculator.getStatistics({
121
121
  spacing: segmentationSpacing,
122
- unit: 'mm',
123
122
  mode,
123
+ unit,
124
124
  });
125
125
  return stats;
126
126
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "3.11.5",
3
+ "version": "3.11.7",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -103,7 +103,7 @@
103
103
  "canvas": "^3.1.0"
104
104
  },
105
105
  "peerDependencies": {
106
- "@cornerstonejs/core": "^3.11.5",
106
+ "@cornerstonejs/core": "^3.11.7",
107
107
  "@kitware/vtk.js": "32.12.1",
108
108
  "@types/d3-array": "^3.0.4",
109
109
  "@types/d3-interpolate": "^3.0.1",
@@ -122,5 +122,5 @@
122
122
  "type": "individual",
123
123
  "url": "https://ohif.org/donate"
124
124
  },
125
- "gitHead": "10c1b64a5564152261575a6372136be3c97d940b"
125
+ "gitHead": "06bda800542fef976683b2dd679962100ab1da7c"
126
126
  }