OHIF-176: v2 - Render non-tracked measurements as a dashed lines. (#1805)
* Render non-tracked measurements as a dashed line. * bump CST version. * Update extensions/measurement-tracking/src/viewports/TrackedCornerstoneViewport.js remove tracked series console log * Remove empty console log * Remove debugger * Remove debugger Co-authored-by: Danny Brown <danny.ri.brown@gmail.com>
This commit is contained in:
parent
f0739b65e8
commit
6aac69e1ba
@ -33,7 +33,7 @@
|
|||||||
"@ohif/ui": "^0.50.0",
|
"@ohif/ui": "^0.50.0",
|
||||||
"cornerstone-core": "^2.3.0",
|
"cornerstone-core": "^2.3.0",
|
||||||
"cornerstone-math": "^0.1.8",
|
"cornerstone-math": "^0.1.8",
|
||||||
"cornerstone-tools": "4.15.1",
|
"cornerstone-tools": "4.16.0",
|
||||||
"dcmjs": "^0.12.3",
|
"dcmjs": "^0.12.3",
|
||||||
"cornerstone-wado-image-loader": "^3.1.2",
|
"cornerstone-wado-image-loader": "^3.1.2",
|
||||||
"dicom-parser": "^1.8.3",
|
"dicom-parser": "^1.8.3",
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@ohif/core": "^0.50.0",
|
"@ohif/core": "^0.50.0",
|
||||||
"cornerstone-core": "^2.2.8",
|
"cornerstone-core": "^2.2.8",
|
||||||
"cornerstone-tools": "4.15.1",
|
"cornerstone-tools": "4.16.0",
|
||||||
"dcmjs": "^0.12.3",
|
"dcmjs": "^0.12.3",
|
||||||
"prop-types": "^15.6.2",
|
"prop-types": "^15.6.2",
|
||||||
"react": "^16.8.6",
|
"react": "^16.8.6",
|
||||||
|
|||||||
@ -33,7 +33,7 @@
|
|||||||
"@ohif/ui": "^0.50.0",
|
"@ohif/ui": "^0.50.0",
|
||||||
"cornerstone-core": "^2.3.0",
|
"cornerstone-core": "^2.3.0",
|
||||||
"cornerstone-math": "^0.1.8",
|
"cornerstone-math": "^0.1.8",
|
||||||
"cornerstone-tools": "4.15.1",
|
"cornerstone-tools": "4.16.0",
|
||||||
"dcmjs": "^0.12.3",
|
"dcmjs": "^0.12.3",
|
||||||
"cornerstone-wado-image-loader": "^3.1.2",
|
"cornerstone-wado-image-loader": "^3.1.2",
|
||||||
"dicom-parser": "^1.8.3",
|
"dicom-parser": "^1.8.3",
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import cornerstone from 'cornerstone-core';
|
import cornerstone from 'cornerstone-core';
|
||||||
|
import cornerstoneTools from 'cornerstone-tools';
|
||||||
import CornerstoneViewport from 'react-cornerstone-viewport';
|
import CornerstoneViewport from 'react-cornerstone-viewport';
|
||||||
import OHIF, { DicomMetadataStore } from '@ohif/core';
|
import OHIF, { DicomMetadataStore } from '@ohif/core';
|
||||||
import {
|
import {
|
||||||
@ -13,6 +14,18 @@ import debounce from 'lodash.debounce';
|
|||||||
import throttle from 'lodash.throttle';
|
import throttle from 'lodash.throttle';
|
||||||
import { useTrackedMeasurements } from './../getContextModule';
|
import { useTrackedMeasurements } from './../getContextModule';
|
||||||
|
|
||||||
|
// TODO -> Get this list from the list of tracked measurements.
|
||||||
|
const {
|
||||||
|
ArrowAnnotateTool,
|
||||||
|
BidirectionalTool,
|
||||||
|
EllipticalRoiTool,
|
||||||
|
LengthTool,
|
||||||
|
} = cornerstoneTools;
|
||||||
|
|
||||||
|
const BaseAnnotationTool = cornerstoneTools.importInternal(
|
||||||
|
'base/BaseAnnotationTool'
|
||||||
|
);
|
||||||
|
|
||||||
// const cine = viewportSpecificData.cine;
|
// const cine = viewportSpecificData.cine;
|
||||||
|
|
||||||
// isPlaying = cine.isPlaying === true;
|
// isPlaying = cine.isPlaying === true;
|
||||||
@ -27,6 +40,7 @@ function TrackedCornerstoneViewport({
|
|||||||
viewportIndex,
|
viewportIndex,
|
||||||
}) {
|
}) {
|
||||||
const [trackedMeasurements] = useTrackedMeasurements();
|
const [trackedMeasurements] = useTrackedMeasurements();
|
||||||
|
|
||||||
const [
|
const [
|
||||||
{ activeViewportIndex, viewports },
|
{ activeViewportIndex, viewports },
|
||||||
dispatchViewportGrid,
|
dispatchViewportGrid,
|
||||||
@ -34,6 +48,8 @@ function TrackedCornerstoneViewport({
|
|||||||
// viewportIndex, onSubmit
|
// viewportIndex, onSubmit
|
||||||
const [viewportDialogState, viewportDialogApi] = useViewportDialog();
|
const [viewportDialogState, viewportDialogApi] = useViewportDialog();
|
||||||
const [viewportData, setViewportData] = useState(null);
|
const [viewportData, setViewportData] = useState(null);
|
||||||
|
const [element, setElement] = useState(null);
|
||||||
|
const [isTracked, setIsTracked] = useState(false);
|
||||||
// TODO: Still needed? Better way than import `OHIF` and destructure?
|
// TODO: Still needed? Better way than import `OHIF` and destructure?
|
||||||
// Why is this managed by `core`?
|
// Why is this managed by `core`?
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -42,6 +58,75 @@ function TrackedCornerstoneViewport({
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!element) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const allTools = cornerstoneTools.store.state.tools;
|
||||||
|
const toolsForElement = allTools.filter(tool => tool.element === element);
|
||||||
|
|
||||||
|
toolsForElement.forEach(tool => {
|
||||||
|
if (
|
||||||
|
tool instanceof ArrowAnnotateTool ||
|
||||||
|
tool instanceof BidirectionalTool ||
|
||||||
|
tool instanceof EllipticalRoiTool ||
|
||||||
|
tool instanceof LengthTool
|
||||||
|
) {
|
||||||
|
const configuration = tool.configuration;
|
||||||
|
|
||||||
|
configuration.renderDashed = !isTracked;
|
||||||
|
|
||||||
|
tool.configuration = configuration;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const enabledElement = cornerstone.getEnabledElement(element);
|
||||||
|
|
||||||
|
if (enabledElement.image) {
|
||||||
|
cornerstone.updateImage(element);
|
||||||
|
}
|
||||||
|
}, [isTracked]);
|
||||||
|
|
||||||
|
const onElementEnabled = evt => {
|
||||||
|
const eventData = evt.detail;
|
||||||
|
const targetElement = eventData.element;
|
||||||
|
|
||||||
|
const allTools = cornerstoneTools.store.state.tools;
|
||||||
|
|
||||||
|
const toolsForElement = allTools.filter(
|
||||||
|
tool => tool.element === targetElement
|
||||||
|
);
|
||||||
|
|
||||||
|
toolsForElement.forEach(tool => {
|
||||||
|
if (
|
||||||
|
tool instanceof ArrowAnnotateTool ||
|
||||||
|
tool instanceof BidirectionalTool ||
|
||||||
|
tool instanceof EllipticalRoiTool ||
|
||||||
|
tool instanceof LengthTool
|
||||||
|
) {
|
||||||
|
const configuration = tool.configuration;
|
||||||
|
|
||||||
|
configuration.renderDashed = !isTracked;
|
||||||
|
|
||||||
|
tool.configuration = configuration;
|
||||||
|
} else if (tool instanceof BaseAnnotationTool) {
|
||||||
|
const configuration = tool.configuration;
|
||||||
|
|
||||||
|
configuration.renderDashed = true;
|
||||||
|
|
||||||
|
tool.configuration = configuration;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const enabledElement = cornerstone.getEnabledElement(targetElement);
|
||||||
|
|
||||||
|
if (enabledElement.image) {
|
||||||
|
cornerstone.updateImage(targetElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
setElement(targetElement);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const {
|
const {
|
||||||
StudyInstanceUID,
|
StudyInstanceUID,
|
||||||
@ -116,6 +201,7 @@ function TrackedCornerstoneViewport({
|
|||||||
vp => vp.displaySetInstanceUID === displaySet.displaySetInstanceUID
|
vp => vp.displaySetInstanceUID === displaySet.displaySetInstanceUID
|
||||||
);
|
);
|
||||||
const { trackedSeries } = trackedMeasurements.context;
|
const { trackedSeries } = trackedMeasurements.context;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Modality,
|
Modality,
|
||||||
SeriesDate,
|
SeriesDate,
|
||||||
@ -131,6 +217,11 @@ function TrackedCornerstoneViewport({
|
|||||||
SliceThickness,
|
SliceThickness,
|
||||||
} = displaySet.images[0];
|
} = displaySet.images[0];
|
||||||
|
|
||||||
|
|
||||||
|
if (trackedSeries.includes(SeriesInstanceUID) !== isTracked) {
|
||||||
|
setIsTracked(!isTracked);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewportActionBar
|
<ViewportActionBar
|
||||||
@ -159,6 +250,7 @@ function TrackedCornerstoneViewport({
|
|||||||
{/* TODO: Viewport interface to accept stack or layers of content like this? */}
|
{/* TODO: Viewport interface to accept stack or layers of content like this? */}
|
||||||
<div className="relative flex flex-row w-full h-full">
|
<div className="relative flex flex-row w-full h-full">
|
||||||
<CornerstoneViewport
|
<CornerstoneViewport
|
||||||
|
onElementEnabled={onElementEnabled}
|
||||||
viewportIndex={viewportIndex}
|
viewportIndex={viewportIndex}
|
||||||
imageIds={imageIds}
|
imageIds={imageIds}
|
||||||
imageIdIndex={currentImageIdIndex}
|
imageIdIndex={currentImageIdIndex}
|
||||||
|
|||||||
@ -55,7 +55,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ohif/core": "^2.9.6",
|
"@ohif/core": "^2.9.6",
|
||||||
"cornerstone-tools": "4.15.1",
|
"cornerstone-tools": "4.16.0",
|
||||||
"@ohif/ui": "^2.0.0",
|
"@ohif/ui": "^2.0.0",
|
||||||
"cornerstone-core": "^2.3.0",
|
"cornerstone-core": "^2.3.0",
|
||||||
"cornerstone-wado-image-loader": "^3.1.2",
|
"cornerstone-wado-image-loader": "^3.1.2",
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"cornerstone-core": "^2.3.0",
|
"cornerstone-core": "^2.3.0",
|
||||||
"cornerstone-tools": "^4.12.0",
|
"cornerstone-tools": "4.16.0",
|
||||||
"cornerstone-wado-image-loader": "^3.1.2",
|
"cornerstone-wado-image-loader": "^3.1.2",
|
||||||
"dicom-parser": "^1.8.3"
|
"dicom-parser": "^1.8.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -67,7 +67,7 @@
|
|||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"core-js": "^3.2.1",
|
"core-js": "^3.2.1",
|
||||||
"cornerstone-math": "^0.1.8",
|
"cornerstone-math": "^0.1.8",
|
||||||
"cornerstone-tools": "4.15.1",
|
"cornerstone-tools": "4.16.0",
|
||||||
"cornerstone-wado-image-loader": "^3.1.2",
|
"cornerstone-wado-image-loader": "^3.1.2",
|
||||||
"dcmjs": "^0.12.2",
|
"dcmjs": "^0.12.2",
|
||||||
"dicom-parser": "^1.8.3",
|
"dicom-parser": "^1.8.3",
|
||||||
|
|||||||
@ -6755,10 +6755,10 @@ cornerstone-math@^0.1.8:
|
|||||||
resolved "https://registry.yarnpkg.com/cornerstone-math/-/cornerstone-math-0.1.8.tgz#68ab1f9e4fdcd7c5cb23a0d2eb4263f9f894f1c5"
|
resolved "https://registry.yarnpkg.com/cornerstone-math/-/cornerstone-math-0.1.8.tgz#68ab1f9e4fdcd7c5cb23a0d2eb4263f9f894f1c5"
|
||||||
integrity sha512-x7NEQHBtVG7j1yeyj/aRoKTpXv1Vh2/H9zNLMyqYJDtJkNng8C4Q8M3CgZ1qer0Yr7eVq2x+Ynmj6kfOm5jXKw==
|
integrity sha512-x7NEQHBtVG7j1yeyj/aRoKTpXv1Vh2/H9zNLMyqYJDtJkNng8C4Q8M3CgZ1qer0Yr7eVq2x+Ynmj6kfOm5jXKw==
|
||||||
|
|
||||||
cornerstone-tools@4.15.1:
|
cornerstone-tools@4.16.0:
|
||||||
version "4.15.1"
|
version "4.16.0"
|
||||||
resolved "https://registry.yarnpkg.com/cornerstone-tools/-/cornerstone-tools-4.15.1.tgz#f0b1026da9c7758defc088bb2f1e78426a23d91e"
|
resolved "https://registry.yarnpkg.com/cornerstone-tools/-/cornerstone-tools-4.16.0.tgz#af3d32d13722b97bec258492642e622312280196"
|
||||||
integrity sha512-fJuTUJW/NDSD520jPB++tX//Kq80jPDngChHZrhx2xjj/9dCnexD9kmTX30Z0WUq0a2JEHZ6FlcOX38kSmw1hQ==
|
integrity sha512-kUhuSb2Ixpd2hgbdem+740rnN4hmoxzcOBNaUcsizFRWjMAsgc0yUxBFwLl0mIs811mefq79JOL+juwRA8T3Tg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "7.1.2"
|
"@babel/runtime" "7.1.2"
|
||||||
cornerstone-math "0.1.7"
|
cornerstone-math "0.1.7"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user