Skip to content

Commit

Permalink
feat(vide): Add new Video Viewport with zoom and pan (#828)
Browse files Browse the repository at this point in the history
* making video viewport work

* more

* conflict

* fix build for video viewport

* Fix the tools so they work with video viewport

* Added playback rate control

* Adding support for stack scroll tool

* Add range bar to set positioning.

* Start removing video specific rendering in rendering engine

* Remove redundant code in rendering engine

* Remove unneeded changes

* Add docs and continuous updates for video display

* Added setFrame to specify a frame number

* Api check

* Change to the public video example

* try to use video new camera

* try to fix video camera

* add docs

* remaining

* apply review comments

* api

* fix camera

* fix build

* Address comment about two pulldowns

* update

---------

Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>
  • Loading branch information
sedghi and wayfarer3130 committed Oct 27, 2023
1 parent d3a8801 commit 5046db9
Show file tree
Hide file tree
Showing 40 changed files with 4,107 additions and 1,706 deletions.
145 changes: 139 additions & 6 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ declare namespace Enums {
ContourType,
VOILUTFunctionType,
DynamicOperatorType,
ViewportStatus
ViewportStatus,
VideoViewport_2 as VideoViewport
}
}
export { Enums }
Expand Down Expand Up @@ -1607,6 +1608,12 @@ function indexWithinDimensions(index: Point3, dimensions: Point3): boolean;
// @public (undocumented)
export function init(configuration?: Cornerstone3DConfig): Promise<boolean>;

// @public (undocumented)
type InternalVideoCamera = {
panWorld?: Point2;
parallelScale?: number;
};

// @public (undocumented)
enum InterpolationType {
// (undocumented)
Expand Down Expand Up @@ -1641,9 +1648,11 @@ interface IRenderingEngine {
// (undocumented)
getStackViewports(): Array<IStackViewport>;
// (undocumented)
getViewport(id: string): IStackViewport | IVolumeViewport;
getVideoViewports(): Array<IVideoViewport>;
// (undocumented)
getViewport(id: string): IViewport;
// (undocumented)
getViewports(): Array<IStackViewport | IVolumeViewport>;
getViewports(): Array<IViewport>;
// (undocumented)
getVolumeViewports(): Array<IVolumeViewport>;
// (undocumented)
Expand Down Expand Up @@ -1774,6 +1783,26 @@ interface IStreamingVolumeProperties {
};
}

// @public (undocumented)
interface IVideoViewport extends IViewport {
// (undocumented)
getProperties: () => VideoViewportProperties;
// (undocumented)
pause: () => void;
// (undocumented)
play: () => void;
// (undocumented)
resetCamera(resetPan?: boolean, resetZoom?: boolean): boolean;
// (undocumented)
resetProperties(): void;
// (undocumented)
resize: () => void;
// (undocumented)
setProperties(props: VideoViewportProperties, suppressEvents?: boolean): void;
// (undocumented)
setVideoURL: (url: string) => void;
}

// @public (undocumented)
interface IViewport {
// (undocumented)
Expand Down Expand Up @@ -2203,9 +2232,11 @@ export class RenderingEngine implements IRenderingEngine {
// (undocumented)
getStackViewports(): Array<IStackViewport>;
// (undocumented)
getViewport(viewportId: string): IStackViewport | IVolumeViewport;
getVideoViewports(): Array<IVideoViewport>;
// (undocumented)
getViewport(viewportId: string): IViewport;
// (undocumented)
getViewports(): Array<IStackViewport | IVolumeViewport>;
getViewports(): Array<IViewport>;
// (undocumented)
getVolumeViewports(): Array<IVolumeViewport>;
// (undocumented)
Expand Down Expand Up @@ -2342,6 +2373,14 @@ const spatialRegistrationMetadataProvider: {
get: (type: string, query: string[]) => mat4;
};

// @public (undocumented)
enum SpeedUnit {
// (undocumented)
FRAME = "f",
// (undocumented)
SECOND = "s"
}

// @public (undocumented)
type StackNewImageEvent = CustomEvent_2<StackNewImageEventDetail>;

Expand Down Expand Up @@ -2535,6 +2574,7 @@ declare namespace Types {
Cornerstone3DConfig,
ICamera,
IStackViewport,
IVideoViewport,
IVolumeViewport,
IEnabledElement,
ICache,
Expand Down Expand Up @@ -2580,6 +2620,7 @@ declare namespace Types {
Mat3,
Plane,
ViewportInputOptions,
VideoViewportProperties,
VOIRange,
VOI,
DisplayArea,
Expand Down Expand Up @@ -2616,7 +2657,9 @@ declare namespace Types {
PixelDataTypedArray,
ImagePixelModule,
ImagePlaneModule,
AffineMatrix
AffineMatrix,
InternalVideoCamera,
VideoViewportInput
}
}
export { Types }
Expand Down Expand Up @@ -2689,6 +2732,94 @@ export { utilities }
// @public (undocumented)
function uuidv4(): string;

// @public (undocumented)
export class VideoViewport extends Viewport implements IVideoViewport {
constructor(props: VideoViewportInput);
// (undocumented)
readonly canvasContext: CanvasRenderingContext2D;
// (undocumented)
canvasToWorld: (canvasPos: Point2) => Point3;
// (undocumented)
customRenderViewportToCanvas: () => void;
// (undocumented)
end(): Promise<void>;
// (undocumented)
getCamera(): ICamera;
// (undocumented)
getFrameOfReferenceUID: () => string;
// (undocumented)
getImageData(): any;
// (undocumented)
getProperties: () => VideoViewportProperties;
// (undocumented)
pause(): Promise<void>;
// (undocumented)
play(): void;
// (undocumented)
readonly renderingEngineId: string;
// (undocumented)
resetCamera: () => boolean;
// (undocumented)
resetProperties(): void;
// (undocumented)
resize: () => void;
// (undocumented)
scroll(delta?: number): Promise<void>;
// (undocumented)
setCamera(camera: ICamera): void;
// (undocumented)
setFrame(frame: number): Promise<void>;
// (undocumented)
setPlaybackRate(rate?: number): void;
// (undocumented)
setProperties(videoInterface: VideoViewportProperties): void;
// (undocumented)
setScrollSpeed(scrollSpeed?: number, unit?: VideoViewport_2.SpeedUnit): void;
// (undocumented)
setTime(timeInSeconds: number): Promise<void>;
// (undocumented)
setVideoURL(videoURL: string): Promise<unknown>;
// (undocumented)
start(): Promise<void>;
// (undocumented)
togglePlayPause(): boolean;
// (undocumented)
readonly uid: any;
// (undocumented)
static readonly useCustomRenderingPipeline = true;
// (undocumented)
worldToCanvas: (worldPos: Point3) => Point2;
}

declare namespace VideoViewport_2 {
export {
SpeedUnit
}
}

// @public (undocumented)
type VideoViewportInput = {
id: string;
renderingEngineId: string;
type: ViewportType;
element: HTMLDivElement;
sx: number;
sy: number;
sWidth: number;
sHeight: number;
defaultOptions: any;
canvas: HTMLCanvasElement;
};

// @public (undocumented)
type VideoViewportProperties = ViewportProperties & {
loop?: boolean;
muted?: boolean;
pan?: Point2;
playbackRate?: number;
parallelScale?: number;
};

// @public (undocumented)
export class Viewport implements IViewport {
constructor(props: ViewportInput);
Expand Down Expand Up @@ -2906,6 +3037,8 @@ enum ViewportType {
// (undocumented)
STACK = "stack",
// (undocumented)
VIDEO = "video",
// (undocumented)
VOLUME_3D = "volume3d"
}

Expand Down
Loading

0 comments on commit 5046db9

Please sign in to comment.