Skip to content

Commit

Permalink
fix(types): type fixes (#1638)
Browse files Browse the repository at this point in the history
* fix(tools): Update types for getActoryEntry

Prevent invalid internal type import in the generated .d.ts types file

* fix(tools): Imporove extractWindowLevelRegionToolData types

Prevent internal import in generated .d.ts types

* docs(tools): Update api documentation

* refactor: Update extractWindowLevelRegionToolData argument types

Use exported IVolumeViewport and IStackViewport
  • Loading branch information
jmannau authored Dec 12, 2024
1 parent e0522fd commit 87626a5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
14 changes: 2 additions & 12 deletions common/reviews/api/tools.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -2464,23 +2463,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: Types_2.IVolumeViewport | Types_2.IStackViewport): {
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Types } from '@cornerstonejs/core';
import { getEnabledElementByViewportId } from '@cornerstonejs/core';
import { SegmentationRepresentations } from '../../../enums';

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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: Types.IVolumeViewport | Types.IStackViewport
) {
if (viewport instanceof VolumeViewport) {
return extractImageDataVolume(viewport);
}
Expand All @@ -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 } =
Expand All @@ -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 } =
Expand Down

0 comments on commit 87626a5

Please sign in to comment.