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

fix(colormap invert): and dynamic volume new timePoint index event #841

Merged
merged 3 commits into from
Oct 20, 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/streaming-image-volume-loader.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ type ElementEnabledEventDetail = {
renderingEngineId: string;
};

declare namespace Enums {
export {
Events_2 as Events
}
}
export { Enums }

// @public
enum Events {
CACHE_SIZE_EXCEEDED = 'CACHE_SIZE_EXCEEDED',
Expand Down Expand Up @@ -513,6 +520,12 @@ enum Events {
// ELEMENT_RESIZED = 'CORNERSTONE_ELEMENT_RESIZED',
}

// @public (undocumented)
enum Events_2 {
// (undocumented)
DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED = "DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED"
}

declare namespace EventTypes {
export {
CameraModifiedEventDetail,
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/RenderingEngine/BaseVolumeViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import {
invertRgbTransferFunction,
triggerEvent,
colormap as colormapUtils,
isImageActor,
} from '../utilities';
import { createVolumeActor } from './helpers';
import volumeNewImageEventDispatcher, {
Expand Down Expand Up @@ -565,7 +564,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
this.setVOILUTFunction(VOILUTFunction, volumeId, suppressEvents);
}

if (invert !== undefined) {
if (invert !== undefined && this.viewportProperties.invert !== invert) {
this.setInvert(invert, volumeId, suppressEvents);
}

Expand Down Expand Up @@ -1033,8 +1032,6 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
// New volume actors implies resetting the inverted flag (i.e. like starting from scratch).

for (let i = 0; i < volumeActorEntries.length; i++) {
const volumeId = volumeActorEntries[i].uid;

this.viewportProperties.invert = false;
}
this.setActors(volumeActorEntries);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Types } from '@cornerstonejs/core';
import { eventTarget, triggerEvent, type Types } from '@cornerstonejs/core';
import BaseStreamingImageVolume from './BaseStreamingImageVolume';
import { Events as StreamingEvents } from './enums';

type TimePoint = {
/** imageIds of each timepoint */
Expand Down Expand Up @@ -146,6 +147,15 @@ export default class StreamingDynamicImageVolume
this._timePointIndex = newTimePointIndex;
imageData.getPointData().setActiveScalars(`timePoint-${newTimePointIndex}`);
this.invalidateVolume(true);

triggerEvent(
eventTarget,
StreamingEvents.DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED,
{
volumeId: this.volumeId,
timePointIndex: newTimePointIndex,
}
);
}

/**
Expand Down
16 changes: 16 additions & 0 deletions packages/streaming-image-volume-loader/src/enums/Events.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* The events for cornerstone streaming image volume
*
*/
enum Events {
///////////////////////////////////////
// Loading Events
///////////////////////////////////////

/**
* Dynamic image volume time point index changed
*/
DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED = 'DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED',
}

export default Events;
3 changes: 3 additions & 0 deletions packages/streaming-image-volume-loader/src/enums/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Events from './Events';

export { Events };
2 changes: 2 additions & 0 deletions packages/streaming-image-volume-loader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import StreamingImageVolume from './StreamingImageVolume';
import StreamingDynamicImageVolume from './StreamingDynamicImageVolume';
import getDynamicVolumeInfo from './helpers/getDynamicVolumeInfo';
import { sortImageIdsAndGetSpacing } from './helpers';
import * as Enums from './enums';

const helpers = {
getDynamicVolumeInfo,
Expand All @@ -16,4 +17,5 @@ export {
StreamingImageVolume,
StreamingDynamicImageVolume,
helpers,
Enums,
};