fix(rt): jump to segment discards the configured width (#4799)
This commit is contained in:
parent
76da2d86a9
commit
afd528b8d7
@ -16,7 +16,7 @@ import {
|
|||||||
} from '@cornerstonejs/tools';
|
} from '@cornerstonejs/tools';
|
||||||
import { PubSubService, Types as OHIFTypes } from '@ohif/core';
|
import { PubSubService, Types as OHIFTypes } from '@ohif/core';
|
||||||
import i18n from '@ohif/i18n';
|
import i18n from '@ohif/i18n';
|
||||||
import { easeInOutBell, reverseEaseInOutBell } from '../../utils/transitions';
|
import { easeInOutBell, easeInOutBellRelative } from '../../utils/transitions';
|
||||||
import { mapROIContoursToRTStructData } from './RTSTRUCT/mapROIContoursToRTStructData';
|
import { mapROIContoursToRTStructData } from './RTSTRUCT/mapROIContoursToRTStructData';
|
||||||
import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
import { SegmentationRepresentations } from '@cornerstonejs/tools/enums';
|
||||||
import { addColorLUT } from '@cornerstonejs/tools/segmentation/addColorLUT';
|
import { addColorLUT } from '@cornerstonejs/tools/segmentation/addColorLUT';
|
||||||
@ -1637,10 +1637,7 @@ class SegmentationService extends PubSubService {
|
|||||||
const startTime = performance.now();
|
const startTime = performance.now();
|
||||||
|
|
||||||
const prevStyle = cstSegmentation.config.style.getStyle({
|
const prevStyle = cstSegmentation.config.style.getStyle({
|
||||||
viewportId,
|
|
||||||
segmentationId,
|
|
||||||
type: CONTOUR,
|
type: CONTOUR,
|
||||||
segmentIndex,
|
|
||||||
}) as ContourStyle;
|
}) as ContourStyle;
|
||||||
|
|
||||||
const prevOutlineWidth = prevStyle.outlineWidth;
|
const prevOutlineWidth = prevStyle.outlineWidth;
|
||||||
@ -1650,18 +1647,11 @@ class SegmentationService extends PubSubService {
|
|||||||
const animate = (currentTime: number) => {
|
const animate = (currentTime: number) => {
|
||||||
const progress = (currentTime - startTime) / animationLength;
|
const progress = (currentTime - startTime) / animationLength;
|
||||||
if (progress >= 1) {
|
if (progress >= 1) {
|
||||||
cstSegmentation.config.style.setStyle(
|
cstSegmentation.config.style.resetToGlobalStyle();
|
||||||
{
|
|
||||||
segmentationId,
|
|
||||||
segmentIndex,
|
|
||||||
type: CONTOUR,
|
|
||||||
},
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const reversedProgress = reverseEaseInOutBell(progress, baseline);
|
const reversedProgress = easeInOutBellRelative(progress, baseline, prevOutlineWidth);
|
||||||
|
|
||||||
cstSegmentation.config.style.setStyle(
|
cstSegmentation.config.style.setStyle(
|
||||||
{
|
{
|
||||||
|
|||||||
@ -34,3 +34,30 @@ export function reverseEaseInOutBell(x: number, baseline: number): number {
|
|||||||
const y = easeInOutBell(x, baseline);
|
const y = easeInOutBell(x, baseline);
|
||||||
return -y + 1 + baseline;
|
return -y + 1 + baseline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function easeInOutBellRelative(
|
||||||
|
x: number,
|
||||||
|
baseline: number,
|
||||||
|
prevOutlineWidth: number
|
||||||
|
): number {
|
||||||
|
const range = baseline - prevOutlineWidth;
|
||||||
|
|
||||||
|
if (x < 1 / 4) {
|
||||||
|
return prevOutlineWidth + 4 * Math.pow(2 * x, 3) * range;
|
||||||
|
} else if (x < 1 / 2) {
|
||||||
|
return prevOutlineWidth + (1 - Math.pow(-4 * x + 2, 3) / 2) * range;
|
||||||
|
} else if (x < 3 / 4) {
|
||||||
|
return prevOutlineWidth + (1 - Math.pow(4 * x - 2, 3) / 2) * range;
|
||||||
|
} else {
|
||||||
|
return prevOutlineWidth + -4 * Math.pow(2 * x - 2, 3) * range;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function reverseEaseInOutBellRelative(
|
||||||
|
x: number,
|
||||||
|
baseline: number,
|
||||||
|
prevOutlineWidth: number
|
||||||
|
): number {
|
||||||
|
const y = easeInOutBellRelative(x, baseline, prevOutlineWidth);
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user