Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jump to click and voisync for volume3d #678

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export abstract class BaseVolumeViewport extends Viewport implements IVolumeView
// (undocumented)
getBounds(): number[];
// (undocumented)
getCurrentImageId: () => string;
abstract getCurrentImageId(): string;
// (undocumented)
getCurrentImageIdIndex: () => number;
abstract getCurrentImageIdIndex(): number;
// (undocumented)
getFrameOfReferenceUID: () => string;
// (undocumented)
Expand All @@ -86,17 +86,15 @@ export abstract class BaseVolumeViewport extends Viewport implements IVolumeView
// (undocumented)
removeVolumeActors(actorUIDs: Array<string>, immediate?: boolean): void;
// (undocumented)
resetCamera(resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean): boolean;
// (undocumented)
protected resetVolumeViewportClippingRange(): void;
// (undocumented)
setBlendMode(blendMode: BlendModes, filterActorUIDs?: string[], immediate?: boolean): void;
abstract setBlendMode(blendMode: BlendModes, filterActorUIDs?: Array<string>, immediate?: boolean): void;
// (undocumented)
setOrientation(orientation: OrientationAxis, immediate?: boolean): void;
// (undocumented)
setProperties({ voiRange, VOILUTFunction, invert, colormap, preset, }?: VolumeViewportProperties, volumeId?: string, suppressEvents?: boolean): void;
// (undocumented)
setSlabThickness(slabThickness: number, filterActorUIDs?: string[]): void;
abstract setSlabThickness(slabThickness: number, filterActorUIDs?: Array<string>): void;
// (undocumented)
setVolumes(volumeInputArray: Array<IVolumeInput>, immediate?: boolean, suppressEvents?: boolean): Promise<void>;
// (undocumented)
Expand Down Expand Up @@ -2579,7 +2577,7 @@ export class Viewport implements IViewport {
// (undocumented)
reset(immediate?: boolean): void;
// (undocumented)
protected resetCamera(resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean, storeAsInitialCamera?: boolean): boolean;
resetCamera(resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean, storeAsInitialCamera?: boolean): boolean;
// (undocumented)
protected resetCameraNoEvent(): void;
// (undocumented)
Expand Down Expand Up @@ -2801,12 +2799,8 @@ export class VolumeViewport extends BaseVolumeViewport {
// (undocumented)
getCurrentImageIdIndex: () => number | undefined;
// (undocumented)
getIntensityFromWorld(point: Point3): number;
// (undocumented)
getRotation: () => number;
// (undocumented)
getSlabThickness(): number;
// (undocumented)
resetCamera(resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean): boolean;
// (undocumented)
setBlendMode(blendMode: BlendModes, filterActorUIDs?: any[], immediate?: boolean): void;
Expand All @@ -2829,6 +2823,10 @@ export class VolumeViewport3D extends BaseVolumeViewport {
getRotation: () => number;
// (undocumented)
resetCamera(resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean): boolean;
// (undocumented)
setBlendMode(blendMode: BlendModes, filterActorUIDs?: string[], immediate?: boolean): void;
// (undocumented)
setSlabThickness(slabThickness: number, filterActorUIDs?: Array<string>): void;
}

// @public (undocumented)
Expand Down
76 changes: 48 additions & 28 deletions packages/core/src/RenderingEngine/BaseVolumeViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import volumeNewImageEventDispatcher, {
import Viewport from './Viewport';
import type { vtkSlabCamera as vtkSlabCameraType } from './vtkClasses/vtkSlabCamera';
import vtkSlabCamera from './vtkClasses/vtkSlabCamera';
import transformWorldToIndex from '../utilities/transformWorldToIndex';

/**
* Abstract base class for volume viewports. VolumeViewports are used to render
Expand Down Expand Up @@ -1031,45 +1032,64 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
);
}
}

/**
* Reset the camera for the volume viewport
* Gets the largest slab thickness from all actors in the viewport.
*
* @returns slabThickness - The slab thickness.
*/
resetCamera(
resetPan?: boolean,
resetZoom?: boolean,
resetToCenter?: boolean
): boolean {
return super.resetCamera(resetPan, resetZoom, resetToCenter);
public getSlabThickness(): number {
const actors = this.getActors();
let slabThickness = RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS;
actors.forEach((actor) => {
if (actor.slabThickness > slabThickness) {
slabThickness = actor.slabThickness;
}
});

return slabThickness;
}
/**
* Given a point in world coordinates, return the intensity at that point
* @param point - The point in world coordinates to get the intensity
* from.
* @returns The intensity value of the voxel at the given point.
*/
public getIntensityFromWorld(point: Point3): number {
const actorEntry = this.getDefaultActor();
if (!actorIsA(actorEntry, 'vtkVolume')) {
return;
}

getCurrentImageIdIndex = (): number => {
throw new Error('Method not implemented.');
};
const { actor, uid } = actorEntry;
const imageData = actor.getMapper().getInputData();

getCurrentImageId = (): string => {
throw new Error('Method not implemented.');
};
const volume = cache.getVolume(uid);
const { dimensions } = volume;

const index = transformWorldToIndex(imageData, point);

const voxelIndex =
index[2] * dimensions[0] * dimensions[1] +
index[1] * dimensions[0] +
index[0];

getIntensityFromWorld(point: Point3): number {
throw new Error('Method not implemented.');
return volume.getScalarData()[voxelIndex];
}

setBlendMode(
abstract getCurrentImageIdIndex(): number;

abstract getCurrentImageId(): string;

abstract setBlendMode(
blendMode: BlendModes,
filterActorUIDs?: string[],
filterActorUIDs?: Array<string>,
immediate?: boolean
): void {
throw new Error('Method not implemented.');
}
): void;

setSlabThickness(slabThickness: number, filterActorUIDs?: string[]): void {
throw new Error('Method not implemented.');
}

getSlabThickness(): number {
throw new Error('Method not implemented.');
}
abstract setSlabThickness(
slabThickness: number,
filterActorUIDs?: Array<string>
): void;
}

export default BaseVolumeViewport;
2 changes: 1 addition & 1 deletion packages/core/src/RenderingEngine/Viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class Viewport implements IViewport {
* be detected for pan/zoom values)
* @returns boolean
*/
protected resetCamera(
public resetCamera(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you making this public, protected is good enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sedghi, resetCamera should be public in Viewport.ts because in the others viewports classes it convert it to public
VolumeViewport.ts:
resetCamera( resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean ): boolean { return super.resetCamera(resetPan, resetZoom, resetToCenter); }
VolumeViewport3D.ts:
public resetCamera( resetPan = true, resetZoom = true, resetToCenter = true ): boolean { super.resetCamera(resetPan, resetZoom, resetToCenter); this.resetVolumeViewportClippingRange(); return; }

resetPan = true,
resetZoom = true,
resetToCenter = true,
Expand Down
47 changes: 0 additions & 47 deletions packages/core/src/RenderingEngine/VolumeViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type {
} from '../types';
import type { ViewportInput } from '../types/IViewport';
import { actorIsA, getClosestImageId } from '../utilities';
import transformWorldToIndex from '../utilities/transformWorldToIndex';
import BaseVolumeViewport from './BaseVolumeViewport';

/**
Expand Down Expand Up @@ -182,34 +181,6 @@ class VolumeViewport extends BaseVolumeViewport {
this.resetCamera();
}

/**
* Given a point in world coordinates, return the intensity at that point
* @param point - The point in world coordinates to get the intensity
* from.
* @returns The intensity value of the voxel at the given point.
*/
public getIntensityFromWorld(point: Point3): number {
const actorEntry = this.getDefaultActor();
if (!actorIsA(actorEntry, 'vtkVolume')) {
return;
}

const { actor, uid } = actorEntry;
const imageData = actor.getMapper().getInputData();

const volume = cache.getVolume(uid);
const { dimensions } = volume;

const index = transformWorldToIndex(imageData, point);

const voxelIndex =
index[2] * dimensions[0] * dimensions[1] +
index[1] * dimensions[0] +
index[0];

return volume.getScalarData()[voxelIndex];
}

public setBlendMode(
blendMode: BlendModes,
filterActorUIDs = [],
Expand Down Expand Up @@ -294,7 +265,6 @@ class VolumeViewport extends BaseVolumeViewport {
* filterActorUIDs are provided, all actors will be affected.
*
* @param slabThickness - The slab thickness to set.
* @param blendMode - The blend mode to use when rendering the actors.
* @param filterActorUIDs - Optional argument to filter the actors to apply
* the slab thickness to (if not provided, all actors will be affected).
*/
Expand All @@ -318,23 +288,6 @@ class VolumeViewport extends BaseVolumeViewport {
this.triggerCameraModifiedEventIfNecessary(currentCamera, currentCamera);
}

/**
* Gets the largest slab thickness from all actors in the viewport.
*
* @returns slabThickness - The slab thickness.
*/
public getSlabThickness(): number {
const actors = this.getActors();
let slabThickness = RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS;
actors.forEach((actor) => {
if (actor.slabThickness > slabThickness) {
slabThickness = actor.slabThickness;
}
});

return slabThickness;
}

/**
* Uses the origin and focalPoint to calculate the slice index.
* Todo: This only works if the imageIds are properly sorted
Expand Down
21 changes: 18 additions & 3 deletions packages/core/src/RenderingEngine/VolumeViewport3D.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OrientationAxis } from '../enums';
import { BlendModes, OrientationAxis } from '../enums';
import type { ViewportInput } from '../types/IViewport';
import BaseVolumeViewport from './BaseVolumeViewport';

Expand Down Expand Up @@ -38,13 +38,28 @@ class VolumeViewport3D extends BaseVolumeViewport {

getRotation = (): number => 0;

public getCurrentImageIdIndex = (): number | undefined => {
getCurrentImageIdIndex = (): number | undefined => {
return undefined;
};

public getCurrentImageId = (): string => {
getCurrentImageId = (): string => {
return null;
};

setSlabThickness(
slabThickness: number,
filterActorUIDs?: Array<string>
): void {
return null;
}

setBlendMode(
blendMode: BlendModes,
filterActorUIDs?: string[],
immediate?: boolean
): void {
return null;
}
}

export default VolumeViewport3D;
Loading