fix(Measurement): Use dashed lines for measurments of viewports where getCurrentImageId returns undefined (#3392)

* fix(Measurement): Use dashed lines for measurments of viewports where getCurrentImageId returns undefined

* Updated cornerstone3d packages

* Fixed code comment.

* Removed unused imports.
This commit is contained in:
Joe Boccanfuso authored and GitHub committed 2023-05-16 10:02:10 -04:00
1 parent 52eb0edd6f
commit 045e54aa02
8 files changed
+42 -43

No files matched your search

@@ -2,13 +2,7 @@ import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import OHIF, { utils } from '@ohif/core';
import {
Notification,
ViewportActionBar,
useViewportDialog,
Tooltip,
Icon,
} from '@ohif/ui';
import { ViewportActionBar, Tooltip, Icon } from '@ohif/ui';
import { useTranslation } from 'react-i18next';
@@ -19,13 +13,11 @@ const { formatDate } = utils;
function TrackedCornerstoneViewport(props) {
const {
children,
displaySets,
viewportIndex,
viewportLabel,
servicesManager,
extensionManager,
commandsManager,
viewportOptions,
} = props;
@@ -40,7 +32,6 @@ function TrackedCornerstoneViewport(props) {
const displaySet = displaySets[0];
const [trackedMeasurements] = useTrackedMeasurements();
const [viewportDialogState] = useViewportDialog();
const [isTracked, setIsTracked] = useState(false);
const [trackedMeasurementUID, setTrackedMeasurementUID] = useState(null);
@@ -48,7 +39,6 @@ function TrackedCornerstoneViewport(props) {
const viewportId = viewportOptions.viewportId;
const {
Modality,
SeriesDate,
SeriesDescription,
SeriesInstanceUID,
@@ -93,8 +83,17 @@ function TrackedCornerstoneViewport(props) {
};
}, [isTracked]);
if (trackedSeries.includes(SeriesInstanceUID) !== isTracked) {
setIsTracked(!isTracked);
// A current image id will only exist for viewports that can have measurements tracked.
// Typically these are stack viewports and those volume viewports for the series of acquisition.
const currentImageId = cornerstoneViewportService
.getCornerstoneViewport(viewportId)
?.getCurrentImageId();
if (currentImageId) {
if (trackedSeries.includes(SeriesInstanceUID) !== isTracked) {
setIsTracked(!isTracked);
}
} else if (isTracked) {
setIsTracked(false);
}
function switchMeasurement(direction) {