[OHIF-261 & OHIF-262] (#1862)
* WIP * Reset viewport grid on mode switch. * Make lifecyclehooks distinct from modules. Add needed SR hydration state on creation. * Update extensions/cornerstone/src/init.js * Remove unused REMOVE_MEASUREMENT listener. Co-authored-by: Danny Brown <danny.ri.brown@gmail.com>
This commit is contained in:
1 parent
4dfe144bf8
commit
14797a8973
13 files changed
+156
-25
No files matched your search
@@ -5,6 +5,7 @@ import cornerstone from 'cornerstone-core';
|
||||
import csTools from 'cornerstone-tools';
|
||||
import merge from 'lodash.merge';
|
||||
import initCornerstoneTools from './initCornerstoneTools.js';
|
||||
import cornerstoneTools from 'cornerstone-tools';
|
||||
import initWADOImageLoader from './initWADOImageLoader.js';
|
||||
import measurementServiceMappingsFactory from './utils/measurementServiceMappings/measurementServiceMappingsFactory';
|
||||
//
|
||||
@@ -329,6 +330,14 @@ const _connectToolsToMeasurementService = measurementService => {
|
||||
}
|
||||
}
|
||||
|
||||
const { MEASUREMENTS_CLEARED } = measurementService.EVENTS;
|
||||
|
||||
measurementService.subscribe(MEASUREMENTS_CLEARED, () => {
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(
|
||||
{}
|
||||
);
|
||||
});
|
||||
|
||||
const enabledElement = evt.detail.element;
|
||||
const completedEvt = csTools.EVENTS.MEASUREMENT_COMPLETED;
|
||||
const updatedEvt = csTools.EVENTS.MEASUREMENT_MODIFIED;
|
||||
|
||||
@@ -109,8 +109,8 @@ function OHIFCornerstoneSRViewport({
|
||||
useEffect(() => {
|
||||
if (!displaySet.isLoaded) {
|
||||
displaySet.load();
|
||||
setIsHydrated(displaySet.isHydrated);
|
||||
}
|
||||
setIsHydrated(displaySet.isHydrated);
|
||||
}, [displaySet]);
|
||||
|
||||
const setTrackingUniqueIdentifiersForElement = useCallback(targetElement => {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import id from './id';
|
||||
import { SOPClassHandlerName, SOPClassHandlerId } from './id';
|
||||
import { utils, classes } from '@ohif/core';
|
||||
import addMeasurement from './utils/addMeasurement';
|
||||
import isRehydratable from './utils/isRehydratable';
|
||||
|
||||
const { ImageSet } = classes;
|
||||
|
||||
const sopClassHandlerName = 'dicom-sr';
|
||||
|
||||
// TODO ->
|
||||
// Add SR thumbnail
|
||||
// Make viewport
|
||||
@@ -70,7 +68,7 @@ function _getDisplaySetsFromSeries(
|
||||
if (
|
||||
!ConceptNameCodeSequence ||
|
||||
ConceptNameCodeSequence.CodeValue !==
|
||||
CodeNameCodeSequenceValues.ImagingMeasurementReport
|
||||
CodeNameCodeSequenceValues.ImagingMeasurementReport
|
||||
) {
|
||||
console.warn(
|
||||
'Only support Imaging Measurement Report SRs (TID1500) for now'
|
||||
@@ -79,7 +77,7 @@ function _getDisplaySetsFromSeries(
|
||||
}
|
||||
|
||||
const displaySet = {
|
||||
plugin: id,
|
||||
//plugin: id,
|
||||
Modality: 'SR',
|
||||
displaySetInstanceUID: utils.guid(),
|
||||
SeriesDescription,
|
||||
@@ -88,7 +86,7 @@ function _getDisplaySetsFromSeries(
|
||||
SOPInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
StudyInstanceUID,
|
||||
SOPClassHandlerId: `${id}.sopClassHandlerModule.${sopClassHandlerName}`,
|
||||
SOPClassHandlerId,
|
||||
referencedImages: null,
|
||||
measurements: null,
|
||||
isDerivedDisplaySet: true,
|
||||
@@ -119,6 +117,7 @@ function _load(displaySet, servicesManager, extensionManager) {
|
||||
|
||||
displaySet.isHydrated = false;
|
||||
displaySet.isLocked = isRehydratable(displaySet, mappings) ? false : true;
|
||||
displaySet.isLoaded = true;
|
||||
|
||||
// Check currently added displaySets and add measurements if the sources exist.
|
||||
DisplaySetService.activeDisplaySets.forEach(activeDisplaySet => {
|
||||
@@ -250,7 +249,7 @@ function getSopClassHandlerModule({ servicesManager, extensionManager }) {
|
||||
|
||||
return [
|
||||
{
|
||||
name: sopClassHandlerName,
|
||||
name: SOPClassHandlerName,
|
||||
sopClassUids,
|
||||
getDisplaySetsFromSeries,
|
||||
},
|
||||
@@ -282,7 +281,7 @@ function _getMeasurements(ImagingMeasurementReportContentSequence) {
|
||||
trackingUniqueIdentifier => {
|
||||
const mergedContentSequence =
|
||||
mergedContentSequencesByTrackingUniqueIdentifiers[
|
||||
trackingUniqueIdentifier
|
||||
trackingUniqueIdentifier
|
||||
];
|
||||
|
||||
const measurement = _processMeasurement(mergedContentSequence);
|
||||
@@ -322,7 +321,7 @@ function _getMergedContentSequencesByTrackingUniqueIdentifiers(
|
||||
|
||||
if (
|
||||
mergedContentSequencesByTrackingUniqueIdentifiers[
|
||||
trackingUniqueIdentifier
|
||||
trackingUniqueIdentifier
|
||||
] === undefined
|
||||
) {
|
||||
// Add the full ContentSequence
|
||||
@@ -448,9 +447,9 @@ function _processNonGeometricallyDefinedMeasurement(mergedContentSequence) {
|
||||
const cornerstoneFreeTextFinding = Findings.find(
|
||||
Finding =>
|
||||
Finding.ConceptCodeSequence.CodingSchemeDesignator ===
|
||||
CORNERSTONE_CODING_SCHEME_DESIGNATOR &&
|
||||
CORNERSTONE_CODING_SCHEME_DESIGNATOR &&
|
||||
Finding.ConceptCodeSequence.CodeValue ===
|
||||
CORNERSTONE_FREETEXT_CODE_VALUE
|
||||
CORNERSTONE_FREETEXT_CODE_VALUE
|
||||
);
|
||||
if (cornerstoneFreeTextFinding) {
|
||||
measurement.labels.push({
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
export default 'org.ohif.dicom-sr';
|
||||
const id = 'org.ohif.dicom-sr';
|
||||
|
||||
export default id;
|
||||
|
||||
const SOPClassHandlerName = 'dicom-sr';
|
||||
const SOPClassHandlerId = `${id}.sopClassHandlerModule.${SOPClassHandlerName}`;
|
||||
export { SOPClassHandlerName, SOPClassHandlerId };
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import getSopClassHandlerModule from './getSopClassHandlerModule';
|
||||
import onModeEnter from './onModeEnter';
|
||||
import id from './id.js';
|
||||
import init from './init';
|
||||
|
||||
@@ -60,4 +61,5 @@ export default {
|
||||
return [{ name: 'dicom-sr', component: ExtendedOHIFCornerstoneSRViewport }];
|
||||
},
|
||||
getSopClassHandlerModule,
|
||||
onModeEnter,
|
||||
};
|
||||
@@ -14,7 +14,7 @@ const defaultConfig = {
|
||||
/**
|
||||
* @param {object} configuration
|
||||
*/
|
||||
export default function init({ configuration = {} }) {
|
||||
export default function init({ configuration = {}, servicesManager }) {
|
||||
const conifg = Object.assign({}, defaultConfig, configuration);
|
||||
|
||||
TOOL_NAMES.DICOM_SR_DISPLAY_TOOL = conifg.TOOL_NAMES.DICOM_SR_DISPLAY_TOOL;
|
||||
@@ -22,4 +22,22 @@ export default function init({ configuration = {} }) {
|
||||
cornerstoneTools.register('module', id, dicomSRModule);
|
||||
cornerstoneTools.addTool(DICOMSRDisplayTool);
|
||||
cornerstoneTools.setToolEnabled(TOOL_NAMES.DICOM_SR_DISPLAY_TOOL);
|
||||
|
||||
const { DisplaySetService } = servicesManager.services;
|
||||
|
||||
DisplaySetService.subscribe(
|
||||
DisplaySetService.EVENTS.DISPLAY_SETS_ADDED,
|
||||
data => {
|
||||
const { displaySetsAdded, options } = data;
|
||||
displaySetsAdded.forEach(dSet => {
|
||||
if (options.madeInClient) {
|
||||
// Set just made displaySets as hydrated.
|
||||
if (!dSet.isLoaded) {
|
||||
dSet.load();
|
||||
}
|
||||
dSet.isHydrated = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { SOPClassHandlerId } from './id';
|
||||
|
||||
export default function onModeEnter({ servicesManager }) {
|
||||
const { DisplaySetService } = servicesManager.services;
|
||||
const displaySetCache = DisplaySetService.getDisplaySetCache();
|
||||
|
||||
const srDisplaySets = displaySetCache.filter(
|
||||
ds => ds.SOPClassHandlerId === SOPClassHandlerId
|
||||
);
|
||||
|
||||
srDisplaySets.forEach(ds => {
|
||||
// New mode route, allow SRs to be hydrated again
|
||||
ds.isHydrated = false;
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user