Integrate Cornerstone Tools v3 (#235) - WIP
- fix(stack-scroll): Activate mouse wheel and scrollbar stack scroll - fix(touch): Activate pinch zoom, two-finger pan and three (or more) finger stack scroll
This commit is contained in:
parent
3f2968b05f
commit
0a5feb9a0d
@ -2,6 +2,8 @@ import { $ } from 'meteor/jquery';
|
|||||||
import { cornerstone, cornerstoneTools } from 'meteor/ohif:cornerstone';
|
import { cornerstone, cornerstoneTools } from 'meteor/ohif:cornerstone';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
|
|
||||||
|
const scrollToIndex = cornerstoneTools.import('util/scrollToIndex');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activates a specific tool data instance and deactivates all other
|
* Activates a specific tool data instance and deactivates all other
|
||||||
* target and non-target measurement data
|
* target and non-target measurement data
|
||||||
@ -76,7 +78,7 @@ OHIF.measurements.activateMeasurements = (element, measurementData) => {
|
|||||||
// If we aren't currently displaying the image that this tool is on,
|
// If we aren't currently displaying the image that this tool is on,
|
||||||
// scroll to it now.
|
// scroll to it now.
|
||||||
if (currentImageId !== imageId) {
|
if (currentImageId !== imageId) {
|
||||||
cornerstoneTools.scrollToIndex(element, imageIdIndex);
|
scrollToIndex(element, imageIdIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
const $element = $(element);
|
const $element = $(element);
|
||||||
|
|||||||
@ -267,8 +267,8 @@ const loadDisplaySetIntoViewport = (data, templateData) => {
|
|||||||
cornerstoneTools.playClip(element);
|
cornerstoneTools.playClip(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstantiateTools on the new element.
|
// Instantiate the tools
|
||||||
toolManager.instantiateTools(element);
|
toolManager.instantiateTools();
|
||||||
|
|
||||||
// Use the tool manager to enable the currently active tool for this
|
// Use the tool manager to enable the currently active tool for this
|
||||||
// newly rendered element
|
// newly rendered element
|
||||||
@ -646,17 +646,13 @@ Template.imageViewerViewport.onDestroyed(function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable mouse functions
|
// Remove all tools for the destroyed element
|
||||||
cornerstoneTools.mouseInput.disable(element);
|
toolManager.removeToolsForElement(element);
|
||||||
cornerstoneTools.touchInput.disable(element);
|
|
||||||
cornerstoneTools.mouseWheelInput.disable(element);
|
|
||||||
|
|
||||||
OHIF.viewer.updateImageSynchronizer.remove(element);
|
OHIF.viewer.updateImageSynchronizer.remove(element);
|
||||||
|
|
||||||
// Clear the stack prefetch data
|
// Clear the stack prefetch data
|
||||||
let stackPrefetchData = cornerstoneTools.getToolState(element, 'stackPrefetch');
|
cornerstoneTools.clearToolState(element, 'stackPrefetch');
|
||||||
stackPrefetchData = [];
|
|
||||||
cornerstoneTools.stackPrefetch.disable(element);
|
|
||||||
|
|
||||||
// Try to stop any currently playing clips
|
// Try to stop any currently playing clips
|
||||||
// Otherwise the interval will continuously throw errors
|
// Otherwise the interval will continuously throw errors
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import { viewportUtils } from './viewportUtils';
|
import { viewportUtils } from './viewportUtils';
|
||||||
|
import { cornerstoneTools } from 'meteor/ohif:cornerstone';
|
||||||
|
|
||||||
|
const scrollToIndex = cornerstoneTools.import('util/scrollToIndex');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function switches to an image given an element and the index of the image in the current stack
|
* This function switches to an image given an element and the index of the image in the current stack
|
||||||
@ -11,5 +14,5 @@ import { viewportUtils } from './viewportUtils';
|
|||||||
*/
|
*/
|
||||||
export function switchToImageByIndex(newImageIdIndex) {
|
export function switchToImageByIndex(newImageIdIndex) {
|
||||||
var element = viewportUtils.getActiveViewportElement();
|
var element = viewportUtils.getActiveViewportElement();
|
||||||
cornerstoneTools.scrollToIndex(element, newImageIdIndex);
|
scrollToIndex(element, newImageIdIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,11 +42,12 @@ export const toolManager = {
|
|||||||
magnify: 'MagnifyTool',
|
magnify: 'MagnifyTool',
|
||||||
crosshairs: 'CrosshairsTool',
|
crosshairs: 'CrosshairsTool',
|
||||||
stackScroll: 'StackScrollTool',
|
stackScroll: 'StackScrollTool',
|
||||||
zoomTouchPinch: 'ZoomTouchPinchTool',
|
|
||||||
zoomMouseWheel: 'ZoomMouseWheelTool',
|
|
||||||
ellipticalRoi: 'EllipticalRoiTool',
|
ellipticalRoi: 'EllipticalRoiTool',
|
||||||
rectangleRoi: 'RectangleRoiTool',
|
rectangleRoi: 'RectangleRoiTool',
|
||||||
wwwcRegion: 'WwwcRegionTool'
|
wwwcRegion: 'WwwcRegionTool',
|
||||||
|
zoomTouchPinch: 'ZoomTouchPinchTool',
|
||||||
|
panMultiTouch: 'PanMultiTouchTool',
|
||||||
|
stackScrollMouseWheel: 'StackScrollMouseWheelTool'
|
||||||
};
|
};
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
@ -109,8 +110,6 @@ export const toolManager = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toolManager.setAllToolsPassive();
|
|
||||||
|
|
||||||
// Set active tools for the other buttons than this one
|
// Set active tools for the other buttons than this one
|
||||||
switch(button) {
|
switch(button) {
|
||||||
case 'left':
|
case 'left':
|
||||||
@ -146,20 +145,38 @@ export const toolManager = {
|
|||||||
Session.set('ToolManagerActiveToolUpdated', Random.id());
|
Session.set('ToolManagerActiveToolUpdated', Random.id());
|
||||||
},
|
},
|
||||||
|
|
||||||
setAllToolsPassive() {
|
|
||||||
cornerstoneTools.store.state.tools.forEach((tool) => {
|
|
||||||
cornerstoneTools.setToolPassive(tool.name)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
instantiateTools() {
|
instantiateTools() {
|
||||||
|
// Instantiate all cornerstone tools for all enabled elements
|
||||||
Object.keys(tools).forEach(toolName => {
|
Object.keys(tools).forEach(toolName => {
|
||||||
const apiTool = cornerstoneTools[tools[toolName]];
|
const apiTool = cornerstoneTools[tools[toolName]];
|
||||||
if (apiTool) {
|
if (apiTool) {
|
||||||
cornerstoneTools.addTool(apiTool, { name: toolName });
|
cornerstoneTools.addTool(apiTool, { name: toolName });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toolManager.setAllToolsPassive();
|
|
||||||
|
// Activate pinch zoom
|
||||||
|
cornerstoneTools.setToolActive('zoomTouchPinch', {
|
||||||
|
mouseButtonMask: 0,
|
||||||
|
isTouchActive: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activate two-finger pan
|
||||||
|
cornerstoneTools.setToolActive('panMultiTouch', {
|
||||||
|
mouseButtonMask: 0,
|
||||||
|
isTouchActive: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Activate mouse wheel and three (or more) finger stack scroll
|
||||||
|
cornerstoneTools.setToolActive('stackScrollMouseWheel', {
|
||||||
|
mouseButtonMask: 0,
|
||||||
|
isTouchActive: true
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
removeToolsForElement(element) {
|
||||||
|
Object.keys(tools).forEach(toolName => {
|
||||||
|
cornerstoneTools.removeToolForElement(element, toolName);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getNearbyToolData() {
|
getNearbyToolData() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user