2016-07-12 20:37:53 +02:00
|
|
|
import { OHIF } from 'meteor/ohif:core';
|
|
|
|
|
|
2015-12-09 14:24:40 +01:00
|
|
|
/**
|
|
|
|
|
* This function disables reference lines for a specific viewport element.
|
2016-07-12 20:37:53 +02:00
|
|
|
* It also enables reference lines for all other viewports with the
|
2015-12-09 14:24:40 +01:00
|
|
|
* class .imageViewerViewport.
|
|
|
|
|
*
|
|
|
|
|
* @param element {node} DOM Node representing the viewport element
|
|
|
|
|
*/
|
2017-01-16 18:30:54 +01:00
|
|
|
export function displayReferenceLines(element) {
|
2015-12-09 14:24:40 +01:00
|
|
|
|
2015-12-19 04:24:00 +01:00
|
|
|
// Check if image plane (orientation / loction) data is present for the current image
|
2016-11-04 13:31:15 +01:00
|
|
|
const enabledElement = cornerstone.getEnabledElement(element);
|
2017-01-16 18:30:54 +01:00
|
|
|
|
|
|
|
|
// Check if element is already enabled and it's image was rendered
|
|
|
|
|
if(!enabledElement || !enabledElement.image) {
|
|
|
|
|
OHIF.log.info('displayReferenceLines enabled element is undefined or it\'s image is not rendered');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 13:31:15 +01:00
|
|
|
const imageId = enabledElement.image.imageId;
|
2017-10-25 09:56:24 +02:00
|
|
|
const imagePlane = cornerstone.metaData.get('imagePlane', imageId);
|
2015-12-19 04:24:00 +01:00
|
|
|
|
2017-01-16 18:30:54 +01:00
|
|
|
// Disable reference lines for the current element
|
|
|
|
|
cornerstoneTools.referenceLines.tool.disable(element);
|
|
|
|
|
|
2015-12-19 04:24:00 +01:00
|
|
|
if (!OHIF.viewer.refLinesEnabled || !imagePlane || !imagePlane.frameOfReferenceUID) {
|
2017-01-16 18:30:54 +01:00
|
|
|
OHIF.log.info('displayReferenceLines refLinesEnabled is not enabled, no imagePlane or no frameOfReferenceUID');
|
2015-12-19 04:24:00 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-16 18:30:54 +01:00
|
|
|
OHIF.log.info(`displayReferenceLines for image with id: ${imageId}`);
|
2015-12-09 14:24:40 +01:00
|
|
|
|
|
|
|
|
// Loop through all other viewport elements and enable reference lines
|
2016-11-04 13:31:15 +01:00
|
|
|
$('.imageViewerViewport').not(element).each((index, viewportElement) => {
|
|
|
|
|
let imageId;
|
|
|
|
|
if($(viewportElement).find('canvas').length) {
|
|
|
|
|
try {
|
|
|
|
|
const enabledElement = cornerstone.getEnabledElement(viewportElement);
|
|
|
|
|
imageId = enabledElement.image.imageId;
|
|
|
|
|
} catch(error) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-12-09 14:24:40 +01:00
|
|
|
|
2016-11-04 13:31:15 +01:00
|
|
|
if (!imageId) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-12-09 14:24:40 +01:00
|
|
|
|
2016-11-04 13:31:15 +01:00
|
|
|
cornerstoneTools.referenceLines.tool.enable(viewportElement, OHIF.viewer.updateImageSynchronizer);
|
|
|
|
|
}
|
2015-12-09 14:24:40 +01:00
|
|
|
});
|
2017-01-16 18:30:54 +01:00
|
|
|
}
|