From 84f9ab91b37fa1b898e211b5ec68ea090aba2691 Mon Sep 17 00:00:00 2001 From: Alireza Date: Mon, 9 Oct 2023 17:16:41 -0400 Subject: [PATCH] fix(voi): should publish voi change event on reset (#821) --- .../src/RenderingEngine/VolumeViewport.ts | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/core/src/RenderingEngine/VolumeViewport.ts b/packages/core/src/RenderingEngine/VolumeViewport.ts index a21e6ecd4a..5008c90b34 100644 --- a/packages/core/src/RenderingEngine/VolumeViewport.ts +++ b/packages/core/src/RenderingEngine/VolumeViewport.ts @@ -1,9 +1,11 @@ import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane'; +import vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume'; + import { vec3 } from 'gl-matrix'; import cache from '../cache'; import { MPR_CAMERA_VALUES, RENDERING_DEFAULTS } from '../constants'; -import { BlendModes, OrientationAxis } from '../enums'; +import { BlendModes, OrientationAxis, Events } from '../enums'; import type { ActorEntry, IImageVolume, @@ -12,10 +14,9 @@ import type { Point3, } from '../types'; import type { ViewportInput } from '../types/IViewport'; -import { actorIsA, getClosestImageId } from '../utilities'; +import { actorIsA, getClosestImageId, triggerEvent } from '../utilities'; import BaseVolumeViewport from './BaseVolumeViewport'; import setDefaultVolumeVOI from './helpers/setDefaultVolumeVOI'; -import vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume'; /** * An object representing a VolumeViewport. VolumeViewports are used to render @@ -383,6 +384,22 @@ class VolumeViewport extends BaseVolumeViewport { ); } setDefaultVolumeVOI(volumeActor.actor as vtkVolume, imageVolume, false); + + const range = (volumeActor.actor as vtkVolume) + .getProperty() + .getRGBTransferFunction(0) + .getMappingRange(); + + const eventDetails = { + viewportId: volumeActor.uid, + range: { + lower: range[0], + upper: range[1], + }, + volumeId: volumeActor.uid, + }; + + triggerEvent(this.element, Events.VOI_MODIFIED, eventDetails); } }