fix(sr): correct jump to first image via viewRef (#4576)
This commit is contained in:
1 parent
6c7f535676
commit
6ec04ca65e
6 files changed
+20
-37
No files matched your search
+12
-29
@@ -9,6 +9,7 @@ import { Icon, Tooltip, useViewportGrid, ViewportActionArrows } from '@ohif/ui';
|
||||
import hydrateStructuredReport from '../utils/hydrateStructuredReport';
|
||||
import { useAppConfig } from '@state';
|
||||
import createReferencedImageDisplaySet from '../utils/createReferencedImageDisplaySet';
|
||||
import { usePositionPresentationStore } from '@ohif/extension-cornerstone';
|
||||
|
||||
const MEASUREMENT_TRACKING_EXTENSION_ID = '@ohif/extension-measurement-tracking';
|
||||
|
||||
@@ -16,7 +17,6 @@ const SR_TOOLGROUP_BASE_NAME = 'SRToolGroup';
|
||||
|
||||
function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
const {
|
||||
commandsManager,
|
||||
children,
|
||||
dataSource,
|
||||
displaySets,
|
||||
@@ -29,7 +29,6 @@ function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
|
||||
const {
|
||||
displaySetService,
|
||||
cornerstoneViewportService,
|
||||
measurementService,
|
||||
viewportActionCornersService,
|
||||
} = servicesManager.services;
|
||||
@@ -43,6 +42,9 @@ function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
|
||||
const srDisplaySet = displaySets[0];
|
||||
|
||||
const { setPositionPresentation } = usePositionPresentationStore();
|
||||
|
||||
|
||||
const [viewportGrid, viewportGridService] = useViewportGrid();
|
||||
const [measurementSelected, setMeasurementSelected] = useState(0);
|
||||
const [measurementCount, setMeasurementCount] = useState(1);
|
||||
@@ -154,33 +156,17 @@ function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
}
|
||||
|
||||
setMeasurementSelected(newMeasurementSelected);
|
||||
|
||||
setActiveImageDisplaySetData(referencedDisplaySet);
|
||||
setReferencedDisplaySetMetadata(referencedDisplaySetMetadata);
|
||||
|
||||
if (
|
||||
referencedDisplaySet.displaySetInstanceUID ===
|
||||
activeImageDisplaySetData?.displaySetInstanceUID
|
||||
) {
|
||||
const { measurements } = srDisplaySet;
|
||||
|
||||
// it means that we have a new referenced display set, and the
|
||||
// imageIdIndex will handle it by updating the viewport, but if they
|
||||
// are the same we just need to use measurementService to jump to the
|
||||
// new measurement
|
||||
const csViewport = cornerstoneViewportService.getCornerstoneViewport(viewportId);
|
||||
|
||||
if (!csViewport) {
|
||||
return;
|
||||
const { presentationIds } = viewportOptions
|
||||
const measurement = srDisplaySet.measurements[newMeasurementSelected]
|
||||
setPositionPresentation(presentationIds.positionPresentationId, {
|
||||
viewReference: {
|
||||
referencedImageId: measurement.imageId
|
||||
}
|
||||
|
||||
const imageIds = csViewport.getImageIds();
|
||||
|
||||
const imageIdIndex = imageIds.indexOf(measurements[newMeasurementSelected].imageId);
|
||||
|
||||
if (imageIdIndex !== -1) {
|
||||
csViewport.setImageIdIndex(imageIdIndex);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
[dataSource, srDisplaySet, activeImageDisplaySetData, viewportId]
|
||||
@@ -202,9 +188,7 @@ function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const initialImageIndex = activeImageDisplaySetData.images.findIndex(
|
||||
image => image.imageId === measurement.imageId
|
||||
);
|
||||
|
||||
|
||||
return (
|
||||
<Component
|
||||
@@ -230,7 +214,6 @@ function OHIFCornerstoneSRMeasurementViewport(props: withAppTypes) {
|
||||
props.onElementEnabled?.(evt);
|
||||
onElementEnabled(evt);
|
||||
}}
|
||||
initialImageIndex={initialImageIndex}
|
||||
isJumpToMeasurementDisabled={true}
|
||||
></Component>
|
||||
);
|
||||
|
||||
@@ -441,8 +441,9 @@ class SegmentationService extends PubSubService {
|
||||
|
||||
const segmentIndex = Number(SegmentNumber);
|
||||
|
||||
const imageCentroidXYZ = segDisplaySet.centroids.get(index).image || { x: 0, y: 0, z: 0 };
|
||||
const worldCentroidXYZ = segDisplaySet.centroids.get(index).world || { x: 0, y: 0, z: 0 };
|
||||
const centroid = segDisplaySet.centroids?.get(index);
|
||||
const imageCentroidXYZ = centroid?.image || { x: 0, y: 0, z: 0 };
|
||||
const worldCentroidXYZ = centroid?.world || { x: 0, y: 0, z: 0 };
|
||||
|
||||
segments[segmentIndex] = {
|
||||
segmentIndex,
|
||||
|
||||
Reference in new issue
Block a user