Switch toolState usage since ES6 modules are read-only
This commit is contained in:
parent
ddef3c4710
commit
27296a8bca
@ -16,8 +16,6 @@ import * as cornerstoneMath from 'cornerstone-math';
|
||||
import * as cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
||||
import * as dicomParser from 'dicom-parser';
|
||||
|
||||
debugger;
|
||||
|
||||
export {
|
||||
cornerstone,
|
||||
cornerstoneTools,
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
|
||||
(function(cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Delete a lesion if Ctrl+D or DELETE is pressed while a lesion is selected
|
||||
var keys = {
|
||||
D: 68,
|
||||
@ -95,5 +91,3 @@ import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
|
||||
// module/private exports
|
||||
cornerstoneTools.deleteLesionKeyboardTool = cornerstoneTools.keyboardTool(keyDownCallback);
|
||||
|
||||
})(cornerstoneTools);
|
||||
|
||||
@ -1,8 +1,3 @@
|
||||
|
||||
(function($, cornerstone, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
function drawLine(context, startPoint, endPoint, config) {
|
||||
context.moveTo(startPoint.x, startPoint.y);
|
||||
context.lineTo(endPoint.x, endPoint.y);
|
||||
@ -174,8 +169,8 @@
|
||||
}
|
||||
|
||||
const config = {
|
||||
hscaleBounds: hscaleBounds,
|
||||
vscaleBounds: vscaleBounds,
|
||||
hscaleBounds,
|
||||
vscaleBounds,
|
||||
verticalMinorTick: verticalIntervalScale,
|
||||
horizontalMinorTick: horizontalIntervalScale,
|
||||
minorTickLength: 12.5,
|
||||
@ -225,5 +220,3 @@
|
||||
// module exports
|
||||
cornerstoneTools.scaleOverlayTool = cornerstoneTools.displayTool(onImageRendered);
|
||||
cornerstoneTools.scaleOverlayTool.disable = disable;
|
||||
|
||||
})($, cornerstone, cornerstoneTools);
|
||||
|
||||
@ -2,7 +2,7 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
const removeToolDataWithMeasurementId = (imageId, toolType, measurementId) => {
|
||||
OHIF.log.info('removeToolDataWithMeasurementId');
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||
|
||||
// Find any related toolData
|
||||
if (!toolState[imageId] || !toolState[imageId][toolType]) {
|
||||
@ -32,6 +32,8 @@ const removeToolDataWithMeasurementId = (imageId, toolType, measurementId) => {
|
||||
toRemove.forEach(function(index) {
|
||||
toolData.splice(index, 1);
|
||||
});
|
||||
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState);
|
||||
};
|
||||
|
||||
OHIF.lesiontracker.clearMeasurementTimepointData = (measurementId, timepointId) => {
|
||||
|
||||
@ -315,7 +315,8 @@ class MeasurementApi {
|
||||
const measurementNumber = filter.measurementNumber || entries[0].measurementNumber;
|
||||
|
||||
// Synchronize the new data with cornerstone tools
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||
|
||||
_.each(entries, entry => {
|
||||
if (toolState[entry.imageId]) {
|
||||
const toolData = toolState[entry.imageId][entry.toolType];
|
||||
@ -331,6 +332,8 @@ class MeasurementApi {
|
||||
}
|
||||
});
|
||||
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState);
|
||||
|
||||
// Synchronize the updated measurements with Cornerstone Tools
|
||||
// toolData to make sure the displayed measurements show 'Target X' correctly
|
||||
const syncFilter = _.clone(filter);
|
||||
|
||||
@ -107,7 +107,6 @@ class MeasurementHandlers {
|
||||
Collection._c2._simpleSchema.clean(measurement);
|
||||
|
||||
// Insert the new measurement into the collection
|
||||
console.log(measurement);
|
||||
Collection.update(measurementId, {
|
||||
$set: measurement
|
||||
});
|
||||
|
||||
@ -10,7 +10,8 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
function activateTool(measurementData) {
|
||||
const toolType = measurementData.toolType;
|
||||
const imageId = measurementData.imageId;
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||
|
||||
const toolData = toolState[imageId][toolType];
|
||||
if (!toolData || !toolData.data || !toolData.data.length) {
|
||||
return;
|
||||
@ -19,7 +20,11 @@ function activateTool(measurementData) {
|
||||
// When a measurement is selected, it will be activated in Cornerstone's
|
||||
// tool data
|
||||
const tool = toolData.data.find(data => data._id === measurementData._id);
|
||||
if (tool) {
|
||||
tool.active = true;
|
||||
}
|
||||
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,24 +1,26 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { OHIF } from 'meteor/ohif:core'
|
||||
|
||||
/**
|
||||
* Sets all tool data entries value for 'active' to false
|
||||
* This is used to remove the active color on entire sets of tools
|
||||
*/
|
||||
OHIF.measurements.deactivateAllToolData = () => {
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState()
|
||||
|
||||
Object.keys(toolState).forEach(imageId => {
|
||||
const toolData = toolState[imageId];
|
||||
|
||||
Object.keys(toolData).forEach(toolType => {
|
||||
const specificToolData = toolData[toolType];
|
||||
const specificToolData = toolData[toolType]
|
||||
if (!specificToolData || !specificToolData.data || !specificToolData.data.length) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
specificToolData.data.forEach(data => {
|
||||
data.active = false;
|
||||
data.active = false
|
||||
});
|
||||
});
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState)
|
||||
}
|
||||
|
||||
@ -82,8 +82,6 @@ OHIF.measurements.jumpToRowItem = (rowItem, timepoints) => {
|
||||
// Deactivate stack synchronizer because it will be re-activated later
|
||||
OHIF.viewer.stackImagePositionOffsetSynchronizer.deactivate();
|
||||
|
||||
console.log('jumpToRowItem');
|
||||
|
||||
// Retrieve the timepoints that are currently being displayed in the
|
||||
// Measurement Table
|
||||
const numTimepoints = Math.max(timepoints.length, 1);
|
||||
@ -124,7 +122,7 @@ OHIF.measurements.jumpToRowItem = (rowItem, timepoints) => {
|
||||
try {
|
||||
enabledElement = cornerstone.getEnabledElement(element)
|
||||
} catch(error) {
|
||||
OHIF.log.warn(error);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (enabledElement && enabledElement.image) {
|
||||
|
||||
@ -4,7 +4,7 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
OHIF.measurements.syncMeasurementAndToolData = measurement => {
|
||||
OHIF.log.info('syncMeasurementAndToolData');
|
||||
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
|
||||
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.saveToolState();
|
||||
const imageId = measurement.imageId;
|
||||
const toolType = measurement.toolType;
|
||||
|
||||
@ -55,4 +55,6 @@ OHIF.measurements.syncMeasurementAndToolData = measurement => {
|
||||
|
||||
// Add the MeasurementData into the toolData for this imageId
|
||||
toolState[imageId][toolType].data.push(measurement);
|
||||
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState(toolState);
|
||||
};
|
||||
|
||||
@ -71,4 +71,7 @@ Template.viewerMain.onDestroyed(() => {
|
||||
|
||||
// Stop prefetching when we close the viewer
|
||||
instance.studyPrefetcher.destroy();
|
||||
|
||||
// Clear references to all stacks in the StackManager
|
||||
OHIF.viewerbase.stackManager.clearStacks();
|
||||
});
|
||||
|
||||
@ -10,7 +10,7 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
*/
|
||||
export const prepareViewerData = ({ studyInstanceUids, timepointId, timepointsFilter={} }) => {
|
||||
// Clear the cornerstone tool data to sync the measurements with the measurements API
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager = cornerstoneTools.newImageIdSpecificToolStateManager();
|
||||
cornerstoneTools.globalImageIdSpecificToolStateManager.restoreToolState({});
|
||||
|
||||
// Retrieve the studies metadata
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
@ -109,7 +109,7 @@ const getDataFromTimepoint = timepoint => {
|
||||
|
||||
return {
|
||||
studyInstanceUids: relatedStudies,
|
||||
timepointIds: timepointIds
|
||||
timepointIds
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user