Merging toolManager, enablePrefetchOnElement and imageViewerViewport...
This commit is contained in:
1 parent
068192e035
commit
00656ef943
4 files changed
+407
-187
No files matched your search
@@ -1,25 +1,42 @@
|
||||
import { Session } from 'meteor/session';
|
||||
import { $ } from 'meteor/jquery';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
import { StackManager } from './StackManager.js';
|
||||
import { OHIFError } from './classes/OHIFError';
|
||||
/**
|
||||
* This function enables stack prefetching for a specified element (viewport)
|
||||
* It first disables any prefetching currently occurring on any other viewports.
|
||||
*
|
||||
* @param element {node} DOM Node representing the viewport element
|
||||
* @param element
|
||||
*/
|
||||
enablePrefetchOnElement = function(element) {
|
||||
OHIF.log.info("imageViewerViewport enablePrefetchOnElement");
|
||||
export function enablePrefetchOnElement(element) {
|
||||
OHIF.log.info('enablePrefetchOnElement');
|
||||
|
||||
// Loop through all viewports and disable stackPrefetch
|
||||
$('.imageViewerViewport').each(function() {
|
||||
if (!$(this).find('canvas').length) {
|
||||
return;
|
||||
// Loop through all of the viewports and disable stackPrefetch
|
||||
$('.viewportContainer .imageViewerViewport').each((index, viewportElement) => {
|
||||
if ($(viewportElement).find('canvas').length) {
|
||||
cornerstoneTools.stackPrefetch.disable(viewportElement);
|
||||
}
|
||||
cornerstoneTools.stackPrefetch.disable(this);
|
||||
});
|
||||
|
||||
// Make sure there is a stack to fetch
|
||||
const stack = cornerstoneTools.getToolState(element, 'stack');
|
||||
if (stack && stack.data.length && stack.data[0].imageIds.length > 1) {
|
||||
cornerstoneTools.stackPrefetch.enable(element);
|
||||
if ($(element).find('canvas').length) {
|
||||
// If the stack in the active viewport has more than one image,
|
||||
// enable prefetching for the element
|
||||
const cornerstoneStack = cornerstoneTools.getToolState(element, 'stack');
|
||||
if (cornerstoneStack && cornerstoneStack.data.length && cornerstoneStack.data[0].imageIds.length > 1) {
|
||||
|
||||
// Check if this is a clip or not
|
||||
const activeViewportIndex = Session.get('activeViewport');
|
||||
const contentId = Session.get('activeContentId');
|
||||
const displaySetInstanceUid = ViewerData[contentId].loadedSeriesData[activeViewportIndex].displaySetInstanceUid;
|
||||
|
||||
const stack = StackManager.findStack(displaySetInstanceUid);
|
||||
|
||||
if (!stack) {
|
||||
throw new OHIFError(`Requested stack ${displaySetInstanceUid} was not created`);
|
||||
}
|
||||
|
||||
cornerstoneTools.stackPrefetch.enable(element);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user