Skip to content

Commit

Permalink
feat(rendering): Correct the positioning for the viewport (#755)
Browse files Browse the repository at this point in the history
* chore(beta): release beta for v2

* chore(beta): release beta for v2 (#715)

* chore(beta): release beta for v2 again (#716)

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* fix(camera initial zoom): make the image fit the canvas for initial reset

* fix: Render to pixel exact positioning, and add a zoom setting

* api-check

* PR updates - mostly docs and some cleanup

* fix: Offset positions sometimes render moire patterns

* fix: Fractional positioning for center point

* Fix the center offset

* PR review comments

* API check

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* feat(structuredClone): drop lodash.clonedeep in favor of structuredClone (#517)

* drop lodash.clonedeep in favor of structuredClone

* copy svgNodeCache outside structured clone when resetting state

* remove  clonedeep leftovers

* api

---------

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* api

* new stack images

* Revert changes

* Add synchronizer and test configuration for scale

* Fix positioning

* fix zoom

* Fix pan for scale to fit

* Fixes for resize

* Changes to make tests pass again

* Fix scale display

* Fixes for resize viewport

* Fix centering/positioning without needing initial camera setting

* Fix resize issues with rotation

* Cleanup for build

* Add todo for fuzzy fit to viewport scaling issue

* Cleanup of types/values

* fix: render annotations without plane normal on viewports and update default svg colors (#1159)

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* fix(cine): playclip to allow loop config (#1163)

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* fix(DicomImageLoader): Returns options.loader (#1154)

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* docs: Update getAnnotation Api (#1169)

annotations' S word should be removed and getAnnotations method parameters are written in reverse order

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* examples: Add better helper method for adding tools dropdown (#1150)

* test: Add better helper method for adding tools dropdown.

* Add stack annotation example

* Add labelmap tools as well

* Add contour tools import as well.

* PR review comment fixes

* api-check

* chore(version): version.json [skip ci]

* chore(version): Update package versions [skip ci]

* Make the size work for positioning

* Fix ES6 change

* update

* Add color utility module to core package

* Add color utility module to core package

* revert structured clone

* Fix cloning of lastSliceAnnotation in ContourInterpolation_test.js

* Fix lodash import in addSegmentations.ts

* PR comments
  • Loading branch information
wayfarer3130 committed Apr 9, 2024
1 parent ac8dc92 commit cfb19c4
Show file tree
Hide file tree
Showing 40 changed files with 1,651 additions and 329 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.css
*.md
*.json
packages/adapters/config/webpack/*.js
packages/docs/*.js
97 changes: 88 additions & 9 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,14 @@ export abstract class BaseVolumeViewport extends Viewport implements IVolumeView
// (undocumented)
setDefaultProperties(ViewportProperties: VolumeViewportProperties, volumeId?: string): void;
// (undocumented)
protected setInterpolationType(interpolationType: InterpolationType, volumeId?: string): void;
// (undocumented)
setOrientation(orientation: OrientationAxis, immediate?: boolean): void;
// (undocumented)
setProperties({ voiRange, VOILUTFunction, invert, colormap, preset, interpolationType, slabThickness, rotation, }?: VolumeViewportProperties, volumeId?: string, suppressEvents?: boolean): void;
// (undocumented)
protected setRotation: (rotation: number) => void;
// (undocumented)
abstract setSlabThickness(slabThickness: number, filterActorUIDs?: Array<string>): void;
// (undocumented)
setVolumes(volumeInputArray: Array<IVolumeInput>, immediate?: boolean, suppressEvents?: boolean): Promise<void>;
Expand Down Expand Up @@ -266,6 +270,13 @@ function clamp(value: number, min: number, max: number): number;
// @public (undocumented)
type Color = [number, number, number, number];

declare namespace color {
export {
hexToRgb,
rgbToHex
}
}

// @public (undocumented)
type ColorLUT = Array<Color>;

Expand Down Expand Up @@ -701,10 +712,13 @@ const deepMerge: (target?: {}, source?: {}, optionsArgument?: any) => any;

// @public (undocumented)
type DisplayArea = {
type?: 'SCALE' | 'FIT';
scale?: number;
interpolationType?: InterpolationType;
imageArea?: [number, number];
imageCanvasPoint?: {
imagePoint: [number, number];
canvasPoint: [number, number];
canvasPoint?: [number, number];
};
storeAsInitialCamera?: boolean;
};
Expand Down Expand Up @@ -1096,6 +1110,13 @@ export function getWebWorkerManager(): any;
// @public (undocumented)
function hasNaNValues(input: number[] | number): boolean;

// @public (undocumented)
function hexToRgb(hex: any): {
r: number;
g: number;
b: number;
};

// @public (undocumented)
interface ICache {
// (undocumented)
Expand Down Expand Up @@ -2227,6 +2248,8 @@ interface IViewport {
// (undocumented)
getRotation: () => number;
// (undocumented)
getViewPresentation(viewPresSel?: ViewPresentationSelector): ViewPresentation;
// (undocumented)
getViewReference(viewRefSpecifier?: ViewReferenceSpecifier): ViewReference;
// (undocumented)
getZoom(): number;
Expand Down Expand Up @@ -2261,6 +2284,8 @@ interface IViewport {
// (undocumented)
setRendered(): void;
// (undocumented)
setView(viewRef?: ViewReference, viewPres?: ViewPresentation): any;
// (undocumented)
setZoom(zoom: number, storeAsInitialCamera?: boolean): any;
// (undocumented)
sHeight: number;
Expand Down Expand Up @@ -2810,10 +2835,10 @@ export class RenderingEngine implements IRenderingEngine {
}

// @public (undocumented)
function renderToCanvasCPU(canvas: HTMLCanvasElement, image: IImage, modality?: string, renderingEngineId?: string): Promise<string>;
function renderToCanvasCPU(canvas: HTMLCanvasElement, image: IImage, modality?: string, _renderingEngineId?: string, _viewportOptions?: ViewportInputOptions): Promise<string>;

// @public (undocumented)
function renderToCanvasGPU(canvas: HTMLCanvasElement, image: IImage, modality?: any, renderingEngineId?: string): Promise<string>;
function renderToCanvasGPU(canvas: HTMLCanvasElement, image: IImage, modality?: any, renderingEngineId?: string, viewportOptions?: ViewportInputOptions): Promise<string>;

// @public (undocumented)
enum RequestType {
Expand Down Expand Up @@ -2859,6 +2884,9 @@ export interface RetrieveStage {
// @public (undocumented)
type RGB = [number, number, number];

// @public (undocumented)
function rgbToHex(r: any, g: any, b: any): string;

// @public (undocumented)
function roundNumber(value: string | number | (string | number)[], precision?: number): string;

Expand Down Expand Up @@ -3112,12 +3140,18 @@ export class StackViewport extends Viewport implements IStackViewport, IImagesLo
// (undocumented)
setImageIdIndex(imageIdIndex: number): Promise<string>;
// (undocumented)
protected setInterpolationType: (interpolationType: InterpolationType) => void;
// (undocumented)
setProperties({ colormap, voiRange, VOILUTFunction, invert, interpolationType, rotation, }?: StackViewportProperties, suppressEvents?: boolean): void;
// (undocumented)
protected setRotation: (rotation: number) => void;
// (undocumented)
setStack(imageIds: Array<string>, currentImageIdIndex?: number): Promise<string>;
// (undocumented)
setUseCPURendering(value: boolean): void;
// (undocumented)
setView(viewRef?: ViewReference, viewPres?: ViewPresentation): void;
// (undocumented)
successCallback(imageId: any, image: any): void;
// (undocumented)
unsetColormap: () => void;
Expand Down Expand Up @@ -3282,6 +3316,8 @@ declare namespace Types {
IStreamingVolumeProperties,
IViewport,
ViewReference,
ViewPresentation,
ViewPresentationSelector,
ReferenceCompatibleOptions,
ViewReferenceSpecifier,
StackViewportProperties,
Expand Down Expand Up @@ -3450,7 +3486,8 @@ declare namespace utilities {
roundToPrecision,
getViewportImageIds,
getRandomSampleFromArray,
getVolumeId
getVolumeId,
color
}
}
export { utilities }
Expand All @@ -3474,7 +3511,7 @@ export class VideoViewport extends Viewport implements IVideoViewport {
// (undocumented)
protected canvasToIndex: (canvasPos: Point2) => Point2;
// (undocumented)
canvasToWorld: (canvasPos: Point2) => Point3;
canvasToWorld: (canvasPos: Point2, destPos?: Point3) => Point3;
// (undocumented)
protected createActorMapper(image: any): CanvasActor;
// (undocumented)
Expand Down Expand Up @@ -3512,7 +3549,7 @@ export class VideoViewport extends Viewport implements IVideoViewport {
getScalarData: () => CanvasScalarData;
getSpacing: () => any;
worldToIndex: (point: Point3) => number[];
indexToWorld: (point: Point3) => Point3;
indexToWorld: (point: Point2, destPoint?: Point3) => Point3;
};
hasPixelSpacing: boolean;
calibration: IImageCalibration;
Expand Down Expand Up @@ -3651,8 +3688,12 @@ export class Viewport implements IViewport {
// (undocumented)
addActors(actors: Array<ActorEntry>, resetCameraPanAndZoom?: boolean): void;
// (undocumented)
static boundsRadius(bounds: number[]): number;
// (undocumented)
protected calibration: IImageCalibration;
// (undocumented)
static readonly CameraViewPresentation: ViewPresentationSelector;
// (undocumented)
readonly canvas: HTMLCanvasElement;
// (undocumented)
canvasToWorld: (canvasPos: Point2) => Point3;
Expand All @@ -3663,6 +3704,8 @@ export class Viewport implements IViewport {
// (undocumented)
readonly element: HTMLDivElement;
// (undocumented)
protected fitToCanvasCamera: ICamera;
// (undocumented)
protected flip({ flipHorizontal, flipVertical }: FlipDirection): void;
// (undocumented)
protected flipHorizontal: boolean;
Expand Down Expand Up @@ -3704,9 +3747,9 @@ export class Viewport implements IViewport {
// (undocumented)
getNumberOfSlices: () => number;
// (undocumented)
getPan(): Point2;
getPan(initialCamera?: ICamera): Point2;
// (undocumented)
getProperties: () => void;
getProperties: () => ViewportProperties;
// (undocumented)
getReferenceId(_specifier?: ViewReferenceSpecifier): string;
// (undocumented)
Expand All @@ -3716,11 +3759,13 @@ export class Viewport implements IViewport {
// (undocumented)
getRotation: () => number;
// (undocumented)
getViewPresentation(viewPresSel?: ViewPresentationSelector): ViewPresentation;
// (undocumented)
getViewReference(viewRefSpecifier?: ViewReferenceSpecifier): ViewReference;
// (undocumented)
protected getVtkActiveCamera(): vtkCamera | vtkSlabCamera;
// (undocumented)
getZoom(): number;
getZoom(compareCamera?: ICamera): number;
// (undocumented)
protected hasPixelSpacing: boolean;
// (undocumented)
Expand Down Expand Up @@ -3764,10 +3809,16 @@ export class Viewport implements IViewport {
// (undocumented)
setDisplayArea(displayArea: DisplayArea, suppressEvents?: boolean): void;
// (undocumented)
protected setDisplayAreaFit(displayArea: DisplayArea): void;
// (undocumented)
protected setDisplayAreaScale(displayArea: DisplayArea): void;
// (undocumented)
protected setFitToCanvasCamera(camera: ICamera): void;
// (undocumented)
protected setInitialCamera(camera: ICamera): void;
// (undocumented)
protected setInterpolationType(_interpolationType: InterpolationType, _arg?: any): void;
// (undocumented)
setOptions(options: ViewportInputOptions, immediate?: boolean): void;
// (undocumented)
setOrientationOfClippingPlanes(vtkPlanes: Array<vtkPlane>, slabThickness: number, viewPlaneNormal: Point3, focalPoint: Point3): void;
Expand All @@ -3776,12 +3827,18 @@ export class Viewport implements IViewport {
// (undocumented)
setRendered(): void;
// (undocumented)
protected setRotation: (_rotation: number) => void;
// (undocumented)
setView(viewRef?: ViewReference, viewPres?: ViewPresentation): void;
// (undocumented)
setZoom(value: number, storeAsInitialCamera?: boolean): void;
// (undocumented)
sHeight: number;
// (undocumented)
protected _shouldUseNativeDataType(): boolean;
// (undocumented)
_suppressCameraModifiedEvents: boolean;
// (undocumented)
readonly suppressEvents: boolean;
// (undocumented)
sWidth: number;
Expand All @@ -3790,6 +3847,8 @@ export class Viewport implements IViewport {
// (undocumented)
sy: number;
// (undocumented)
static readonly TransferViewPresentation: ViewPresentationSelector;
// (undocumented)
triggerCameraModifiedEventIfNecessary(previousCamera: ICamera, updatedCamera: ICamera): void;
// (undocumented)
readonly type: ViewportType;
Expand Down Expand Up @@ -3878,6 +3937,26 @@ enum ViewportType {
VOLUME_3D = "volume3d"
}

// @public (undocumented)
type ViewPresentation = {
slabThickness?: number;
rotation?: number;
displayArea?: DisplayArea;
zoom?: number;
pan?: Point2;
};

// @public (undocumented)
type ViewPresentationSelector = {
slabThickness?: boolean;
rotation?: boolean;
displayArea?: boolean;
zoom?: boolean;
pan?: boolean;
windowLevel?: boolean;
paletteLut?: boolean;
};

// @public (undocumented)
type ViewReference = {
FrameOfReferenceUID: string;
Expand Down
Loading

0 comments on commit cfb19c4

Please sign in to comment.