Skip to content

Commit

Permalink
feat(invertSync): add invert sync to voi sync (#677)
Browse files Browse the repository at this point in the history
* feat(invertSync): add invert sync to voi sync

* update api
  • Loading branch information
sedghi committed Jul 4, 2023
1 parent 5119d8f commit a1dcfbc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions common/reviews/api/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,7 @@ type VoiModifiedEventDetail = {
volumeId?: string;
VOILUTFunction?: VOILUTFunctionType;
invert?: boolean;
invertStateChanged?: boolean;
};

// @public (undocumented)
Expand Down
1 change: 1 addition & 0 deletions common/reviews/api/streaming-image-volume-loader.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,7 @@ type VoiModifiedEventDetail = {
volumeId?: string;
VOILUTFunction?: VOILUTFunctionType;
invert?: boolean;
invertStateChanged?: boolean;
};

// @public (undocumented)
Expand Down
1 change: 1 addition & 0 deletions common/reviews/api/tools.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5466,6 +5466,7 @@ type VoiModifiedEventDetail = {
volumeId?: string;
VOILUTFunction?: VOILUTFunctionType;
invert?: boolean;
invertStateChanged?: boolean;
};

// @public (undocumented)
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/RenderingEngine/BaseVolumeViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
volumeId: volumeIdToUse,
VOILUTFunction: this.VOILUTFunction,
invert: this.inverted,
invertStateChanged: true,
};

triggerEvent(this.element, Events.VOI_MODIFIED, eventDetail);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/types/EventTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type VoiModifiedEventDetail = {
VOILUTFunction?: VOILUTFunctionType;
/** inverted */
invert?: boolean;
/** Indicates if the 'invert' state has changed from the previous state */
invertStateChanged?: boolean;
};

/**
Expand Down
22 changes: 12 additions & 10 deletions packages/tools/src/synchronizers/callbacks/voiSyncCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function voiSyncCallback(
voiModifiedEvent: Types.EventTypes.VoiModifiedEvent
): void {
const eventDetail = voiModifiedEvent.detail;
const { volumeId, range } = eventDetail;
const { volumeId, range, invertStateChanged, invert } = eventDetail;

const renderingEngine = getRenderingEngine(targetViewport.renderingEngineId);
if (!renderingEngine) {
Expand All @@ -31,18 +31,20 @@ export default function voiSyncCallback(
}

const tViewport = renderingEngine.getViewport(targetViewport.viewportId);
const tProperties:
| Types.VolumeViewportProperties
| Types.StackViewportProperties = {
voiRange: range,
};

if (invertStateChanged) {
tProperties.invert = invert;
}

if (tViewport instanceof VolumeViewport) {
tViewport.setProperties(
{
voiRange: range,
},
volumeId
);
tViewport.setProperties(tProperties, volumeId);
} else if (tViewport instanceof StackViewport) {
tViewport.setProperties({
voiRange: range,
});
tViewport.setProperties(tProperties);
} else {
throw new Error('Viewport type not supported.');
}
Expand Down

0 comments on commit a1dcfbc

Please sign in to comment.