fix: cine scrolling was broken when navigating back to studylist (#2974)
* fix: cine clean up when exited * fix: make cine work while dragging and dropping another displayset
This commit is contained in:
parent
1d47f31738
commit
7f770e4fb6
@ -10,6 +10,7 @@ import {
|
|||||||
useViewportDialog,
|
useViewportDialog,
|
||||||
} from '@ohif/ui';
|
} from '@ohif/ui';
|
||||||
|
|
||||||
|
import { eventTarget, Enums } from '@cornerstonejs/core';
|
||||||
import { annotation } from '@cornerstonejs/tools';
|
import { annotation } from '@cornerstonejs/tools';
|
||||||
import { useTrackedMeasurements } from './../getContextModule';
|
import { useTrackedMeasurements } from './../getContextModule';
|
||||||
|
|
||||||
@ -64,6 +65,26 @@ function TrackedCornerstoneViewport(props) {
|
|||||||
ManufacturerModelName,
|
ManufacturerModelName,
|
||||||
} = displaySet.images[0];
|
} = displaySet.images[0];
|
||||||
|
|
||||||
|
const cineHandler = () => {
|
||||||
|
if (!cines || !cines[viewportIndex] || !element) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cine = cines[viewportIndex];
|
||||||
|
const isPlaying = cine.isPlaying || false;
|
||||||
|
const frameRate = cine.frameRate || 24;
|
||||||
|
|
||||||
|
const validFrameRate = Math.max(frameRate, 1);
|
||||||
|
|
||||||
|
if (isPlaying) {
|
||||||
|
cineService.playClip(element, {
|
||||||
|
framesPerSecond: validFrameRate,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
cineService.stopClip(element);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isTracked) {
|
if (isTracked) {
|
||||||
annotation.config.style.setViewportToolStyles(viewportId, {
|
annotation.config.style.setViewportToolStyles(viewportId, {
|
||||||
@ -92,25 +113,33 @@ function TrackedCornerstoneViewport(props) {
|
|||||||
};
|
};
|
||||||
}, [isTracked]);
|
}, [isTracked]);
|
||||||
|
|
||||||
|
// unmount cleanup
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!cines || !cines[viewportIndex]) {
|
eventTarget.addEventListener(
|
||||||
|
Enums.Events.STACK_VIEWPORT_NEW_STACK,
|
||||||
|
cineHandler
|
||||||
|
);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cineService.setCine({ id: viewportIndex, isPlaying: false });
|
||||||
|
eventTarget.removeEventListener(
|
||||||
|
Enums.Events.STACK_VIEWPORT_NEW_STACK,
|
||||||
|
cineHandler
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}, [element]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!cines || !cines[viewportIndex] || !element) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cine = cines[viewportIndex];
|
cineHandler();
|
||||||
const isPlaying = (cine && cine.isPlaying) || false;
|
|
||||||
const frameRate = (cine && cine.frameRate) || 24;
|
|
||||||
|
|
||||||
const validFrameRate = Math.max(frameRate, 1);
|
return () => {
|
||||||
|
|
||||||
if (isPlaying) {
|
|
||||||
cineService.playClip(element, {
|
|
||||||
framesPerSecond: validFrameRate,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
cineService.stopClip(element);
|
cineService.stopClip(element);
|
||||||
}
|
};
|
||||||
}, [cines, viewportIndex, cineService, element, displaySet]);
|
}, [cines, viewportIndex, cineService, element]);
|
||||||
|
|
||||||
if (trackedSeries.includes(SeriesInstanceUID) !== isTracked) {
|
if (trackedSeries.includes(SeriesInstanceUID) !== isTracked) {
|
||||||
setIsTracked(!isTracked);
|
setIsTracked(!isTracked);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user