Pull in main

This commit is contained in:
James A. Petts committed 2020-07-01 11:12:41 +02:00
commit d956c3008c
53 files changed
+771 -310

No files matched your search

@@ -1,9 +1,7 @@
import id from './id';
import { utils, classes } from '@ohif/core';
import addMeasurement from './utils/addMeasurement.js';
import { adapters } from 'dcmjs';
const cornerstoneAdapters = adapters.Cornerstone;
import addMeasurement from './utils/addMeasurement';
import isRehydratable from './utils/isRehydratable';
const { ImageSet } = classes;
@@ -95,7 +93,12 @@ function _getDisplaySetsFromSeries(
sopClassUids,
};
if (_isRehydratable(displaySet, MeasurementService)) {
const mappings = MeasurementService.getSourceMappings(
'CornerstoneTools',
'4'
);
if (isRehydratable(displaySet, mappings)) {
displaySet.isLocked = false;
displaySet.isHydrated = false;
} else {
+1
View File
@@ -25,6 +25,7 @@ export default {
id,
dependencies: [
// TODO -> This isn't used anywhere yet, but we do have a hard dependency, and need to check for these in the future.
// OHIF-229
{
id: 'org.ohif.cornerstone',
version: '3.0.0',
@@ -14,6 +14,7 @@ export default function getToolStateToCornerstoneMeasurementSchema(
// TODO -> I get why this was attemped, but its not nearly flexible enough.
// A single measurement may have an ellipse + a bidirectional measurement, for instances.
// You can't define a bidirectional tool as a single type..
// OHIF-230
const TOOL_TYPE_TO_VALUE_TYPE = {
Length: POLYLINE,
EllipticalRoi: ELLIPSE,
@@ -0,0 +1,48 @@
import { adapters } from 'dcmjs';
const cornerstoneAdapters = adapters.Cornerstone;
/**
* Checks if the given `displySet`can be rehydrated into the `MeasurementService`.
*
* @param {object} displaySet The SR `displaySet` to check.
* @param {object[]} mappings The CornerstoneTools 4 mappings to the `MeasurementService`.
* @returns {boolean} True if the SR can be rehydrated into the `MeasurementService`.
*/
export default function isRehydratable(displaySet, mappings) {
if (!mappings || !mappings.length) {
return false;
}
const mappingDefinitions = mappings.map(m => m.definition);
const { measurements } = displaySet;
const adapterKeys = Object.keys(cornerstoneAdapters).filter(
adapterKey =>
typeof cornerstoneAdapters[adapterKey]
.isValidCornerstoneTrackingIdentifier === 'function'
);
const adapters = [];
adapterKeys.forEach(key => {
if (mappingDefinitions.includes(key)) {
// Must have both a dcmjs adapter and a MeasurementService
// Definition in order to be a candidate for import.
adapters.push(cornerstoneAdapters[key]);
}
});
for (let i = 0; i < measurements.length; i++) {
const TrackingIdentifier = measurements[i].TrackingIdentifier;
const hydratable = adapters.some(adapter =>
adapter.isValidCornerstoneTrackingIdentifier(TrackingIdentifier)
);
if (hydratable) {
return true;
}
}
return false;
}