Skip to content

Commit

Permalink
feat(streamingVolumeLoader): added IMAGE_VOLUME_LOADING_COMPLETED eve…
Browse files Browse the repository at this point in the history
…nt (#699)

* added IMAGE_VOLUME_LOADING_COMPLETED event

* api doc
  • Loading branch information
lscoder committed Jul 26, 2023
1 parent cfde297 commit c8c8f59
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
13 changes: 13 additions & 0 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,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 @@ -679,6 +681,8 @@ declare namespace EventTypes {
ImageRenderedEvent,
ImageVolumeModifiedEvent,
ImageVolumeModifiedEventDetail,
ImageVolumeLoadingCompletedEvent,
ImageVolumeLoadingCompletedEventDetail,
ImageLoadedEvent,
ImageLoadedEventDetail,
ImageLoadedFailedEventDetail,
Expand Down Expand Up @@ -1503,6 +1507,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 @@ -473,9 +473,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 @@ -516,6 +517,8 @@ declare namespace EventTypes {
ImageRenderedEvent,
ImageVolumeModifiedEvent,
ImageVolumeModifiedEventDetail,
ImageVolumeLoadingCompletedEvent,
ImageVolumeLoadingCompletedEventDetail,
ImageLoadedEvent,
ImageLoadedEventDetail,
ImageLoadedFailedEventDetail,
Expand Down Expand Up @@ -1031,6 +1034,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 @@ -1818,6 +1818,8 @@ declare namespace EventTypes {
ImageRenderedEvent,
ImageVolumeModifiedEvent,
ImageVolumeModifiedEventDetail,
ImageVolumeLoadingCompletedEvent,
ImageVolumeLoadingCompletedEventDetail,
ImageLoadedEvent,
ImageLoadedEventDetail,
ImageLoadedFailedEventDetail,
Expand Down Expand Up @@ -2730,6 +2732,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 @@ -111,6 +111,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 @@ -308,6 +318,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 @@ -401,6 +419,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 @@ -307,6 +307,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

0 comments on commit c8c8f59

Please sign in to comment.