From 5cedeb8dc82a528e5a789ee8bf1ebfce43179da1 Mon Sep 17 00:00:00 2001 From: James Manners Date: Fri, 29 Nov 2024 09:28:46 +1100 Subject: [PATCH 1/4] fix(tools): Update types for getActoryEntry Prevent invalid internal type import in the generated .d.ts types file --- .../segmentation/helpers/getSegmentationActor.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/tools/src/stateManagement/segmentation/helpers/getSegmentationActor.ts b/packages/tools/src/stateManagement/segmentation/helpers/getSegmentationActor.ts index 58e463c037..0c088d69fe 100644 --- a/packages/tools/src/stateManagement/segmentation/helpers/getSegmentationActor.ts +++ b/packages/tools/src/stateManagement/segmentation/helpers/getSegmentationActor.ts @@ -1,3 +1,4 @@ +import type { Types } from '@cornerstonejs/core'; import { getEnabledElementByViewportId } from '@cornerstonejs/core'; import { SegmentationRepresentations } from '../../../enums'; @@ -11,8 +12,8 @@ import { SegmentationRepresentations } from '../../../enums'; function getActorEntry( viewportId: string, segmentationId: string, - filterFn: (actor: unknown) => boolean -) { + filterFn: (actor: Types.ActorEntry) => boolean +): Types.ActorEntry | undefined { const enabledElement = getEnabledElementByViewportId(viewportId); if (!enabledElement) { From f03f1d7d58518f6666403805984e9c3fa47e9855 Mon Sep 17 00:00:00 2001 From: James Manners Date: Fri, 29 Nov 2024 09:30:00 +1100 Subject: [PATCH 2/4] fix(tools): Imporove extractWindowLevelRegionToolData types Prevent internal import in generated .d.ts types --- .../windowlevel/extractWindowLevelRegionToolData.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/tools/src/utilities/voi/windowlevel/extractWindowLevelRegionToolData.ts b/packages/tools/src/utilities/voi/windowlevel/extractWindowLevelRegionToolData.ts index 663ca7fe6d..5af4d390f5 100644 --- a/packages/tools/src/utilities/voi/windowlevel/extractWindowLevelRegionToolData.ts +++ b/packages/tools/src/utilities/voi/windowlevel/extractWindowLevelRegionToolData.ts @@ -1,11 +1,13 @@ +import type { Types } from '@cornerstonejs/core'; import { - VolumeViewport, utilities as csUtils, - cache, StackViewport, + VolumeViewport, } from '@cornerstonejs/core'; -function extractWindowLevelRegionToolData(viewport) { +function extractWindowLevelRegionToolData( + viewport: VolumeViewport | StackViewport +) { if (viewport instanceof VolumeViewport) { return extractImageDataVolume(viewport); } @@ -16,7 +18,7 @@ function extractWindowLevelRegionToolData(viewport) { throw new Error('Viewport not supported'); } -function extractImageDataVolume(viewport) { +function extractImageDataVolume(viewport: Types.IVolumeViewport) { const { scalarData, width, height } = csUtils.getCurrentVolumeViewportSlice(viewport); const { min: minPixelValue, max: maxPixelValue } = @@ -33,7 +35,7 @@ function extractImageDataVolume(viewport) { }; } -function extractImageDataStack(viewport) { +function extractImageDataStack(viewport: Types.IStackViewport) { const imageData = viewport.getImageData(); const { scalarData } = imageData; const { min: minPixelValue, max: maxPixelValue } = From f6a5962a60d75793104c1103266ccdab0d36a4b0 Mon Sep 17 00:00:00 2001 From: James Manners Date: Sat, 30 Nov 2024 15:17:43 +1100 Subject: [PATCH 3/4] docs(tools): Update api documentation --- common/reviews/api/tools.api.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/common/reviews/api/tools.api.md b/common/reviews/api/tools.api.md index 2cb0a1958b..3b1bb9b4c2 100644 --- a/common/reviews/api/tools.api.md +++ b/common/reviews/api/tools.api.md @@ -9,7 +9,6 @@ import { Corners } from '@kitware/vtk.js/Interaction/Widgets/OrientationMarkerWi import type { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps'; import type { mat3 } from 'gl-matrix'; import { mat4 } from 'gl-matrix'; -import { PixelDataTypedArray as PixelDataTypedArray_2 } from 'packages/core/dist/esm/types'; import type { Range as Range_2 } from '@kitware/vtk.js/types'; import { vec3 } from 'gl-matrix'; import type vtkActor from '@kitware/vtk.js/Rendering/Core/Actor'; @@ -2463,23 +2462,14 @@ declare namespace EventTypes_2 { function extend2DBoundingBoxInViewAxis(boundsIJK: [Types_2.Point2, Types_2.Point2, Types_2.Point2], numSlicesToProject: number): [Types_2.Point2, Types_2.Point2, Types_2.Point2]; // @public (undocumented) -function extractWindowLevelRegionToolData(viewport: any): { - scalarData: PixelDataTypedArray_2; +function extractWindowLevelRegionToolData(viewport: VolumeViewport | StackViewport): { + scalarData: Types_2.PixelDataTypedArray; minPixelValue: number; maxPixelValue: number; width: number; height: number; rows: number; columns: number; -} | { - scalarData: any; - width: any; - height: any; - minPixelValue: number; - maxPixelValue: number; - rows: any; - columns: any; - color: any; }; // @public (undocumented) From 2c7d8406239f9361849381b4eb21f0a76990f7b0 Mon Sep 17 00:00:00 2001 From: James Manners Date: Thu, 12 Dec 2024 11:29:45 +1100 Subject: [PATCH 4/4] refactor: Update extractWindowLevelRegionToolData argument types Use exported IVolumeViewport and IStackViewport --- common/reviews/api/tools.api.md | 2 +- .../voi/windowlevel/extractWindowLevelRegionToolData.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/reviews/api/tools.api.md b/common/reviews/api/tools.api.md index 3b1bb9b4c2..ac3f5f441d 100644 --- a/common/reviews/api/tools.api.md +++ b/common/reviews/api/tools.api.md @@ -2462,7 +2462,7 @@ declare namespace EventTypes_2 { function extend2DBoundingBoxInViewAxis(boundsIJK: [Types_2.Point2, Types_2.Point2, Types_2.Point2], numSlicesToProject: number): [Types_2.Point2, Types_2.Point2, Types_2.Point2]; // @public (undocumented) -function extractWindowLevelRegionToolData(viewport: VolumeViewport | StackViewport): { +function extractWindowLevelRegionToolData(viewport: Types_2.IVolumeViewport | Types_2.IStackViewport): { scalarData: Types_2.PixelDataTypedArray; minPixelValue: number; maxPixelValue: number; diff --git a/packages/tools/src/utilities/voi/windowlevel/extractWindowLevelRegionToolData.ts b/packages/tools/src/utilities/voi/windowlevel/extractWindowLevelRegionToolData.ts index 5af4d390f5..9c1ce723b8 100644 --- a/packages/tools/src/utilities/voi/windowlevel/extractWindowLevelRegionToolData.ts +++ b/packages/tools/src/utilities/voi/windowlevel/extractWindowLevelRegionToolData.ts @@ -6,7 +6,7 @@ import { } from '@cornerstonejs/core'; function extractWindowLevelRegionToolData( - viewport: VolumeViewport | StackViewport + viewport: Types.IVolumeViewport | Types.IStackViewport ) { if (viewport instanceof VolumeViewport) { return extractImageDataVolume(viewport);