Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const collection = measurementApi.tools[tool.parentTool];
// Stop here if the tool data shall not be persisted (e.g. temp tools)
if (!collection) return;
log.info('CornerstoneToolsMeasurementModified');
const measurement = collection.find(t => t._id === measurementData._id);
let childMeasurement = measurement && measurement[tool.attribute];
// Stop here if the measurement is already deleted
if (!childMeasurement) return;
childMeasurement = Object.assign(childMeasurement, measurementData);
childMeasurement.viewport = cornerstone.getViewport(eventData.element);
// Update the parent measurement
measurement[tool.attribute] = childMeasurement;
measurementApi.updateMeasurement(tool.parentTool, measurement);
// TODO: Notify about the last activated measurement
if (MeasurementApi.isToolIncluded(tool)) {
// TODO: Notify that viewer suffered changes
}
}
const { measurementData, toolType } = eventData;
const collection = measurementApi.tools[toolType];
// Stop here if the tool data shall not be persisted (e.g. temp tools)
if (!collection) return;
log.info('CornerstoneToolsMeasurementModified');
let measurement = collection.find(t => t._id === measurementData._id);
// Stop here if the measurement is already deleted
if (!measurement) return;
measurement = Object.assign(measurement, measurementData);
measurement.viewport = cornerstone.getViewport(eventData.element);
measurementApi.updateMeasurement(toolType, measurement);
// TODO: Notify about the last activated measurement
if (MeasurementApi.isToolIncluded(tool)) {
// TODO: Notify that viewer suffered changes
}
}
zoomout = /* istanbul ignore next */ () => {
const cornerstoneElement = this.getImgBlock();
const viewport = cornerstone.getViewport(cornerstoneElement);
if (viewport.scale > 0.1) {
viewport.scale -= 0.1;
cornerstone.setViewport(cornerstoneElement, viewport);
}
};
invertViewport: ({ viewports }) => {
const enabledElement = getEnabledElement(viewports.activeViewportIndex);
if (enabledElement) {
let viewport = cornerstone.getViewport(enabledElement);
viewport.invert = !viewport.invert;
cornerstone.setViewport(enabledElement, viewport);
}
},
// TODO: this is receiving `evt` from `ToolbarRow`. We could use it to have
flipViewportVertical: ({ viewports }) => {
const enabledElement = getEnabledElement(viewports.activeViewportIndex);
if (enabledElement) {
let viewport = cornerstone.getViewport(enabledElement);
viewport.vflip = !viewport.vflip;
cornerstone.setViewport(enabledElement, viewport);
}
},
scaleViewport: ({ direction, viewports }) => {
scaleViewport: ({ direction, viewports }) => {
const enabledElement = getEnabledElement(viewports.activeViewportIndex);
const step = direction * 0.15;
if (enabledElement) {
if (step) {
let viewport = cornerstone.getViewport(enabledElement);
viewport.scale += step;
cornerstone.setViewport(enabledElement, viewport);
} else {
cornerstone.fitToWindow(enabledElement);
}
}
},
resetViewport: ({ viewports }) => {
rotateViewport: ({ viewports, rotation }) => {
const enabledElement = getEnabledElement(viewports.activeViewportIndex);
if (enabledElement) {
let viewport = cornerstone.getViewport(enabledElement);
viewport.rotation += rotation;
cornerstone.setViewport(enabledElement, viewport);
}
},
flipViewportHorizontal: ({ viewports }) => {
.then((image) => {
const viewport = Object.assign(
{},
cornerstone.getViewport(model.container)
);
if (resetViewport) {
Object.assign(
viewport,
cornerstone.getDefaultViewportForImage(model.container, image)
);
}
Object.assign(viewport, {
voi: {
windowWidth: model.representation.getColorWindow(),
windowCenter: model.representation.getColorLevel(),
},
hflip: model.representation.getHFlip(),
vflip: model.representation.getVFlip(),
flipViewportHorizontal: ({ viewports }) => {
const enabledElement = getEnabledElement(viewports.activeViewportIndex);
if (enabledElement) {
let viewport = cornerstone.getViewport(enabledElement);
viewport.hflip = !viewport.hflip;
cornerstone.setViewport(enabledElement, viewport);
}
},
flipViewportVertical: ({ viewports }) => {