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

feat(streamingVolumeLoader): added IMAGE_VOLUME_LOADING_COMPLETED event #699

Merged
merged 2 commits into from
Jul 26, 2023
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
13 changes: 13 additions & 0 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ export enum EVENTS {
// (undocumented)
IMAGE_SPACING_CALIBRATED = "CORNERSTONE_IMAGE_SPACING_CALIBRATED",
// (undocumented)
IMAGE_VOLUME_LOADING_COMPLETED = "CORNERSTONE_IMAGE_VOLUME_LOADING_COMPLETED",
// (undocumented)
IMAGE_VOLUME_MODIFIED = "CORNERSTONE_IMAGE_VOLUME_MODIFIED",
// (undocumented)
PRE_STACK_NEW_IMAGE = "CORNERSTONE_PRE_STACK_NEW_IMAGE",
Expand Down Expand Up @@ -660,6 +662,8 @@ declare namespace EventTypes {
ImageRenderedEvent,
ImageVolumeModifiedEvent,
ImageVolumeModifiedEventDetail,
ImageVolumeLoadingCompletedEvent,
ImageVolumeLoadingCompletedEventDetail,
ImageLoadedEvent,
ImageLoadedEventDetail,
ImageLoadedFailedEventDetail,
Expand Down Expand Up @@ -1464,6 +1468,15 @@ export class ImageVolume implements IImageVolume {
vtkOpenGLTexture: any;
}

// @public (undocumented)
type ImageVolumeLoadingCompletedEvent = CustomEvent_2<ImageVolumeLoadingCompletedEventDetail>;

// @public (undocumented)
type ImageVolumeLoadingCompletedEventDetail = {
volumeId: string;
FrameOfReferenceUID: string;
};

// @public (undocumented)
type ImageVolumeModifiedEvent = CustomEvent_2<ImageVolumeModifiedEventDetail>;

Expand Down
15 changes: 14 additions & 1 deletion common/reviews/api/streaming-image-volume-loader.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,10 @@ enum Events {
IMAGE_LOAD_FAILED = 'CORNERSTONE_IMAGE_LOAD_FAILED',
IMAGE_LOAD_PROGRESS = 'CORNERSTONE_IMAGE_LOAD_PROGRESS',
IMAGE_LOADED = 'CORNERSTONE_IMAGE_LOADED',

IMAGE_RENDERED = 'CORNERSTONE_IMAGE_RENDERED',

IMAGE_SPACING_CALIBRATED = 'CORNERSTONE_IMAGE_SPACING_CALIBRATED',
IMAGE_VOLUME_LOADING_COMPLETED = 'CORNERSTONE_IMAGE_VOLUME_LOADING_COMPLETED',
IMAGE_VOLUME_MODIFIED = 'CORNERSTONE_IMAGE_VOLUME_MODIFIED',
PRE_STACK_NEW_IMAGE = 'CORNERSTONE_PRE_STACK_NEW_IMAGE',
STACK_NEW_IMAGE = 'CORNERSTONE_STACK_NEW_IMAGE',
Expand Down Expand Up @@ -503,6 +504,8 @@ declare namespace EventTypes {
ImageRenderedEvent,
ImageVolumeModifiedEvent,
ImageVolumeModifiedEventDetail,
ImageVolumeLoadingCompletedEvent,
ImageVolumeLoadingCompletedEventDetail,
ImageLoadedEvent,
ImageLoadedEventDetail,
ImageLoadedFailedEventDetail,
Expand Down Expand Up @@ -1004,6 +1007,16 @@ type ImageSpacingCalibratedEventDetail = {
worldToIndex: mat4;
};

// @public
type ImageVolumeLoadingCompletedEvent =
CustomEvent_2<ImageVolumeLoadingCompletedEventDetail>;

// @public
type ImageVolumeLoadingCompletedEventDetail = {
volumeId: string;
FrameOfReferenceUID: string;
};

// @public
type ImageVolumeModifiedEvent = CustomEvent_2<ImageVolumeModifiedEventDetail>;

Expand Down
12 changes: 12 additions & 0 deletions common/reviews/api/tools.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,8 @@ declare namespace EventTypes {
ImageRenderedEvent,
ImageVolumeModifiedEvent,
ImageVolumeModifiedEventDetail,
ImageVolumeLoadingCompletedEvent,
ImageVolumeLoadingCompletedEventDetail,
ImageLoadedEvent,
ImageLoadedEventDetail,
ImageLoadedFailedEventDetail,
Expand Down Expand Up @@ -2714,6 +2716,16 @@ type ImageSpacingCalibratedEventDetail = {
worldToIndex: mat4;
};

// @public
type ImageVolumeLoadingCompletedEvent =
CustomEvent_2<ImageVolumeLoadingCompletedEventDetail>;

// @public
type ImageVolumeLoadingCompletedEventDetail = {
volumeId: string;
FrameOfReferenceUID: string;
};

// @public
type ImageVolumeModifiedEvent = CustomEvent_2<ImageVolumeModifiedEventDetail>;

Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/enums/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ enum Events {
* and see what event detail is included in {@link EventTypes.ImageVolumeModifiedEventDetail | ImageVolumeModified Event Detail }
*/
IMAGE_VOLUME_MODIFIED = 'CORNERSTONE_IMAGE_VOLUME_MODIFIED',
/**
* Triggers on the eventTarget when the image volume loading is completed and all
* frames are loaded and inserted into a volume.
*
* Make use of {@link EventTypes.ImageVolumeLoadingCompletedEvent | ImageVolumeLoadingCompleted Event Type } for typing your
* event listeners for IMAGE_VOLUME_LOADING_COMPLETED event, and see what event detail is included
* in {@link EventTypes.ImageVolumeLoadingCompletedEventDetail | ImageVolumeLoadingCompleted Event Detail }
*/
IMAGE_VOLUME_LOADING_COMPLETED = 'CORNERSTONE_IMAGE_VOLUME_LOADING_COMPLETED',
/**
* Triggers on the eventTarget when the image has successfully loaded by imageLoaders
*
Expand Down
20 changes: 20 additions & 0 deletions packages/core/src/types/EventTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ type ImageVolumeModifiedEventDetail = {
FrameOfReferenceUID: string;
};

/**
* IMAGE_VOLUME_LOADING_COMPLETED Event's data
*/
type ImageVolumeLoadingCompletedEventDetail = {
/** the loaded volume */
volumeId: string;
/** FrameOfReferenceUID where the volume belongs to */
FrameOfReferenceUID: string;
};

/**
* IMAGE_LOADED Event's data
*/
Expand Down Expand Up @@ -304,6 +314,14 @@ type ImageRenderedEvent = CustomEventType<ElementEnabledEventDetail>;
*/
type ImageVolumeModifiedEvent = CustomEventType<ImageVolumeModifiedEventDetail>;

/**
* IMAGE_VOLUME_LOADING_COMPLETED Event type
* This event is fired when a volume is fully loaded, means all the frames
* are loaded and cached.
*/
type ImageVolumeLoadingCompletedEvent =
CustomEventType<ImageVolumeLoadingCompletedEventDetail>;

/**
* IMAGE_LOADED Event type
*/
Expand Down Expand Up @@ -397,6 +415,8 @@ export type {
ImageRenderedEvent,
ImageVolumeModifiedEvent,
ImageVolumeModifiedEventDetail,
ImageVolumeLoadingCompletedEvent,
ImageVolumeLoadingCompletedEventDetail,
ImageLoadedEvent,
ImageLoadedEventDetail,
ImageLoadedFailedEventDetail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,17 @@ export default class BaseStreamingImageVolume extends ImageVolume {

if (evt.framesProcessed === evt.totalNumFrames) {
loadStatus.callbacks.forEach((callback) => callback(evt));

const eventDetail = {
FrameOfReferenceUID,
volumeId: volumeId,
};

triggerEvent(
eventTarget,
Enums.Events.IMAGE_VOLUME_LOADING_COMPLETED,
eventDetail
);
}
}

Expand Down