prettier applied to all files in src/

This commit is contained in:
dannyrb committed 2019-05-29 08:39:54 -04:00
1 parent 433bb219b0
commit fb7c229b43
69 files changed
+1128 -1116

No files matched your search

+7 -7
View File
@@ -1,21 +1,21 @@
import cornerstoneTools from 'cornerstone-tools'
import updateTableWithNewMeasurementData from './updateTableWithNewMeasurementData'
import cornerstoneTools from 'cornerstone-tools';
import updateTableWithNewMeasurementData from './updateTableWithNewMeasurementData';
export default function getMeasurementLocationCallback(
eventData,
tool,
options
) {
const { toolType } = tool
const { element } = eventData
const doneCallback = updateTableWithNewMeasurementData
const { toolType } = tool;
const { element } = eventData;
const doneCallback = updateTableWithNewMeasurementData;
const ToolInstance = cornerstoneTools.getToolForElement(element, toolType)
const ToolInstance = cornerstoneTools.getToolForElement(element, toolType);
ToolInstance.configuration.getMeasurementLocationCallback(
tool,
eventData,
doneCallback,
options
)
);
}
+33 -33
View File
@@ -1,4 +1,4 @@
import { OHIF } from 'ohif-core'
import { OHIF } from 'ohif-core';
// TODO: Move this function to OHIF itself so we can use it on the OHIF measurment table (when it is finished)
@@ -16,48 +16,48 @@ export default function jumpToRowItem(
timepointManagerState,
options = { invertViewportTimepointsOrder: false, childToolKey: null }
) {
const numViewports = viewportsState.layout.viewports.length
const numTimepoints = timepointManagerState.timepoints.length
const { measurements, timepoints } = timepointManagerState
const numViewportsToUpdate = Math.min(numTimepoints, numViewports)
const { toolType, measurementNumber } = measurementData
const numViewports = viewportsState.layout.viewports.length;
const numTimepoints = timepointManagerState.timepoints.length;
const { measurements, timepoints } = timepointManagerState;
const numViewportsToUpdate = Math.min(numTimepoints, numViewports);
const { toolType, measurementNumber } = measurementData;
if (options.invertViewportTimepointsOrder) {
timepoints.reverse()
timepoints.reverse();
}
const measurementsForToolGroup = measurements[toolType]
const measurementsForToolGroup = measurements[toolType];
// Retrieve the measurements data
const measurementsToJumpTo = []
const measurementsToJumpTo = [];
for (let i = 0; i < numViewportsToUpdate; i++) {
const { timepointId } = timepoints[i]
const { timepointId } = timepoints[i];
const dataAtThisTimepoint = measurementsForToolGroup.find(entry => {
return (
entry.timepointId === timepointId &&
entry.measurementNumber === measurementNumber
)
})
);
});
if (!dataAtThisTimepoint) {
measurementsToJumpTo.push(null)
continue
measurementsToJumpTo.push(null);
continue;
}
let measurement = dataAtThisTimepoint
let measurement = dataAtThisTimepoint;
const { tool } = OHIF.measurements.MeasurementApi.getToolConfiguration(
toolType
)
);
if (options.childToolKey) {
measurement = dataAtThisTimepoint[options.childToolKey]
measurement = dataAtThisTimepoint[options.childToolKey];
} else if (Array.isArray(tool.childTools)) {
const key = tool.childTools.find(key => !!dataAtThisTimepoint[key])
measurement = dataAtThisTimepoint[key]
const key = tool.childTools.find(key => !!dataAtThisTimepoint[key]);
measurement = dataAtThisTimepoint[key];
}
measurementsToJumpTo.push(measurement)
measurementsToJumpTo.push(measurement);
}
// TODO: Add a single viewports state action which allows
@@ -70,41 +70,41 @@ export default function jumpToRowItem(
const displaySetContainsSopInstance = (displaySet, sopInstanceUid) =>
displaySet.images.find(
image => image.getSOPInstanceUID() === sopInstanceUid
)
);
const viewportSpecificData = []
const viewportSpecificData = [];
measurementsToJumpTo.forEach((data, viewportIndex) => {
// Skip if there is no measurement to jump
if (!data) {
return
return;
}
const study = OHIF.utils.studyMetadataManager.get(data.studyInstanceUid)
const study = OHIF.utils.studyMetadataManager.get(data.studyInstanceUid);
if (!study) {
throw new Error('Study not found.')
throw new Error('Study not found.');
}
const displaySet = study.findDisplaySet(displaySet => {
return displaySetContainsSopInstance(displaySet, data.sopInstanceUid)
})
return displaySetContainsSopInstance(displaySet, data.sopInstanceUid);
});
if (!displaySet) {
throw new Error('Display set not found.')
throw new Error('Display set not found.');
}
displaySet.sopInstanceUid = data.sopInstanceUid
displaySet.sopInstanceUid = data.sopInstanceUid;
if (data.frameIndex) {
displaySet.frameIndex = data.frameIndex
displaySet.frameIndex = data.frameIndex;
}
viewportSpecificData.push({
viewportIndex,
displaySet,
})
})
});
});
return {
viewportSpecificData,
layout: [], // TODO: if we need to change layout, we should return this here
}
};
}
+11 -11
View File
@@ -1,5 +1,5 @@
import OHIF from 'ohif-core'
import cornerstone from 'cornerstone-core'
import OHIF from 'ohif-core';
import cornerstone from 'cornerstone-core';
export default function updateTableWithNewMeasurementData({
toolType,
@@ -8,22 +8,22 @@ export default function updateTableWithNewMeasurementData({
description,
}) {
// Update all measurements by measurement number
const measurementApi = OHIF.measurements.MeasurementApi.Instance
const measurementApi = OHIF.measurements.MeasurementApi.Instance;
const measurements = measurementApi.tools[toolType].filter(
m => m.measurementNumber === measurementNumber
)
);
measurements.forEach(measurement => {
measurement.location = location
measurement.description = description
measurement.location = location;
measurement.description = description;
measurementApi.updateMeasurement(measurement.toolType, measurement)
})
measurementApi.updateMeasurement(measurement.toolType, measurement);
});
measurementApi.syncMeasurementsAndToolData()
measurementApi.syncMeasurementsAndToolData();
// Update images in all active viewports
cornerstone.getEnabledElements().forEach(enabledElement => {
cornerstone.updateImage(enabledElement.element)
})
cornerstone.updateImage(enabledElement.element);
});
}
+14 -14
View File
@@ -1,46 +1,46 @@
export default function bounding(elementRef, currentPosition = {}) {
if (!elementRef.current) {
return
return;
}
const currentElement = elementRef.current
const currentElement = elementRef.current;
const {
offsetParent,
offsetTop,
offsetHeight,
offsetLeft,
offsetWidth,
} = currentElement
let top = currentPosition.top || offsetTop
let left = currentPosition.left || offsetLeft
} = currentElement;
let top = currentPosition.top || offsetTop;
let left = currentPosition.left || offsetLeft;
if (!offsetParent) {
return
return;
}
let maxHeight = `${offsetParent.offsetHeight}px`
let maxHeight = `${offsetParent.offsetHeight}px`;
if (offsetHeight + top > offsetParent.offsetHeight) {
top = top - (offsetHeight + top - offsetParent.offsetHeight)
top = top - (offsetHeight + top - offsetParent.offsetHeight);
if (top < 0) {
top = 0
top = 0;
}
}
if (left + offsetWidth > offsetParent.offsetWidth) {
left = offsetParent.offsetWidth - offsetWidth
left = offsetParent.offsetWidth - offsetWidth;
if (left < 0) {
left = 0
left = 0;
}
}
if (maxHeight && currentElement.style.maxHeight !== maxHeight) {
currentElement.style.maxHeight = maxHeight
currentElement.style.maxHeight = maxHeight;
}
if (currentElement.style.top !== `${top}px`) {
currentElement.style.top = `${top}px`
currentElement.style.top = `${top}px`;
}
if (currentElement.style.left !== `${left}px`) {
currentElement.style.left = `${left}px`
currentElement.style.left = `${left}px`;
}
}