fix(hydration): Maintain the same slice that the user was on pre hydration in post hydration for SR and SEG. (#4200)

This commit is contained in:
Ibrahim authored and GitHub committed 2024-06-05 10:07:53 -04:00
1 parent ddc7559e16
commit 430330f7e3
8 files changed
+60 -10

No files matched your search

@@ -11,6 +11,7 @@ import { Enums, cache } from '@cornerstonejs/core';
* @param params.loadFn - Function to load the segmentation data.
* @param params.servicesManager - The services manager.
* @param params.displaySet - the display set.
* @param params.initialSliceIndex - The initial slice index.
*
* @returns Returns true upon successful update of viewports for segmentation rendering.
*/
@@ -19,11 +20,13 @@ async function updateViewportsForSegmentationRendering({
loadFn,
servicesManager,
displaySet,
initialSliceIndex = null,
}: {
viewportId: string;
loadFn: () => Promise<string>;
servicesManager: AppTypes.ServicesManager;
displaySet?: any;
initialSliceIndex?: number;
}) {
const { cornerstoneViewportService, segmentationService, viewportGridService } =
servicesManager.services;
@@ -61,6 +64,14 @@ async function updateViewportsForSegmentationRendering({
};
const viewportId = viewport.viewportId;
// maintain the prehydration slice on the target viewport only
if (viewportId === targetViewportId) {
viewport.viewportOptions.initialImageOptions = {
index: initialSliceIndex,
useOnce: true,
};
}
const csViewport = cornerstoneViewportService.getCornerstoneViewport(viewportId);
const prevCamera = csViewport.getCamera();