Adapting Viewers to the new cornerstone structure
This commit is contained in:
1 parent
99b88f08b3
commit
dc767e5c83
19 files changed
+82
-70
No files matched your search
+3
-3
@@ -44,7 +44,7 @@ export default function(mouseEventData) {
|
||||
disableDefaultHandlers();
|
||||
|
||||
// Update the perpendicular line handles position
|
||||
const updateHandler = (event, eventData) => updatePerpendicularLineHandles(eventData, measurementData);
|
||||
const updateHandler = event => updatePerpendicularLineHandles(event.detail, measurementData);
|
||||
$element.on('CornerstoneToolsMouseDrag', updateHandler);
|
||||
$element.on('CornerstoneToolsMouseUp', updateHandler);
|
||||
|
||||
@@ -95,7 +95,7 @@ export default function(mouseEventData) {
|
||||
};
|
||||
|
||||
// Bind the event listener for image rendering
|
||||
$element.on('CornerstoneImageRendered', imageRenderedHandler);
|
||||
$element.on('cornerstoneimagerendered', imageRenderedHandler);
|
||||
|
||||
// Bind the tool deactivation and enlargement handlers
|
||||
$element.on('CornerstoneToolsToolDeactivated', cancelAction);
|
||||
@@ -128,7 +128,7 @@ export default function(mouseEventData) {
|
||||
$element.off('mousedown', mousedownHandler);
|
||||
|
||||
// Unbind the event listener for image rendering
|
||||
$element.off('CornerstoneImageRendered', imageRenderedHandler);
|
||||
$element.off('cornerstoneimagerendered', imageRenderedHandler);
|
||||
|
||||
// Unbind the tool deactivation and enlargement handlers
|
||||
$element.off('CornerstoneToolsToolDeactivated', cancelAction);
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ export default function(touchEventData) {
|
||||
$element.off('CornerstoneToolsDragStartActive', touchDownActivateCallback);
|
||||
|
||||
// Update the perpendicular line handles position
|
||||
const updateHandler = (event, eventData) => updatePerpendicularLineHandles(eventData, measurementData);
|
||||
const updateHandler = event => updatePerpendicularLineHandles(event.detail, measurementData);
|
||||
$element.on('CornerstoneToolsTouchDrag', updateHandler);
|
||||
$element.on('CornerstoneToolsTouchEnd', updateHandler);
|
||||
|
||||
|
||||
+2
-1
@@ -2,7 +2,8 @@ import { cornerstone, cornerstoneTools } from 'meteor/ohif:cornerstone';
|
||||
import { toolType } from './definitions';
|
||||
import pointNearTool from './pointNearTool';
|
||||
|
||||
export default function (event, eventData) {
|
||||
export default function (event) {
|
||||
const eventData = event.detail;
|
||||
const { element } = eventData.element;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
|
||||
+4
-2
@@ -38,10 +38,12 @@ const setHandlesMovingState = (handles, state) => {
|
||||
};
|
||||
|
||||
// mouseDowCallback is used to restrict behaviour of perpendicular-line
|
||||
export default function(event, eventData) {
|
||||
export default function(event) {
|
||||
const eventData = event.detail;
|
||||
let data;
|
||||
const element = eventData.element;
|
||||
const $element = $(element);
|
||||
const options = cornerstoneTools.getToolOptions(toolType, element);
|
||||
|
||||
// Add an event listener to clear the selected state when a measurement is activated
|
||||
const activateEventKey = 'ViewerMeasurementsActivated';
|
||||
@@ -75,7 +77,7 @@ export default function(event, eventData) {
|
||||
$element.on('CornerstoneToolsMouseMove', eventData, mouseMoveCallback);
|
||||
}
|
||||
|
||||
if (cornerstoneTools.isMouseButtonEnabled(eventData.which, event.data.mouseButtonMask)) {
|
||||
if (cornerstoneTools.isMouseButtonEnabled(eventData.which, options.mouseButtonMask)) {
|
||||
const coords = eventData.startPoints.canvas;
|
||||
const toolData = cornerstoneTools.getToolState(event.currentTarget, toolType);
|
||||
|
||||
|
||||
+2
-1
@@ -24,7 +24,8 @@ const handleActivator = (element, handles, canvasPoint, distanceThreshold=6) =>
|
||||
};
|
||||
|
||||
// mouseMoveCallback is used to hide handles when mouse is away
|
||||
export default function (event, eventData) {
|
||||
export default function (event) {
|
||||
const eventData = event.detail;
|
||||
cornerstoneTools.toolCoordinates.setCoords(eventData);
|
||||
// if a mouse button is down, do nothing
|
||||
if (eventData.which !== 0) {
|
||||
|
||||
+4
-3
@@ -9,7 +9,8 @@ export default function (mouseEventData, toolType, data, handle, doneMovingCallb
|
||||
y: handle.y - mouseEventData.currentPoints.image.y
|
||||
};
|
||||
|
||||
const mouseDragCallback = (event, eventData) => {
|
||||
const mouseDragCallback = event => {
|
||||
const eventData = event.detail;
|
||||
handle.active = true;
|
||||
|
||||
if (handle.index === undefined || handle.index === null) {
|
||||
@@ -51,13 +52,13 @@ export default function (mouseEventData, toolType, data, handle, doneMovingCallb
|
||||
};
|
||||
|
||||
// Bind the event listener for image rendering
|
||||
$element.on('CornerstoneImageRendered', imageRenderedHandler);
|
||||
$element.on('cornerstoneimagerendered', imageRenderedHandler);
|
||||
|
||||
const mouseUpCallback = () => {
|
||||
$element.off('CornerstoneToolsMouseDrag', mouseDragCallback);
|
||||
$element.off('CornerstoneToolsMouseUp', mouseUpCallback);
|
||||
$element.off('CornerstoneToolsMouseClick', mouseUpCallback);
|
||||
$element.off('CornerstoneImageRendered', imageRenderedHandler);
|
||||
$element.off('cornerstoneimagerendered', imageRenderedHandler);
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (typeof doneMovingCallback === 'function') {
|
||||
|
||||
+2
-1
@@ -6,7 +6,8 @@ import updatePerpendicularLineHandles from '../updatePerpendicularLineHandles';
|
||||
import drawPerpendicularLine from './drawPerpendicularLine';
|
||||
import drawSelectedMarker from './drawSelectedMarker';
|
||||
|
||||
export default function(event, eventData) {
|
||||
export default function(event) {
|
||||
const eventData = event.detail;
|
||||
const { element, canvasContext } = eventData;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
|
||||
@@ -78,7 +78,8 @@ function getNearbyToolData(element, coords) {
|
||||
return pointNearTool ? nearbyTool : undefined;
|
||||
}
|
||||
|
||||
function keyDownCallback(event, eventData) {
|
||||
function keyDownCallback(event) {
|
||||
const eventData = event.detail;
|
||||
const keyCode = eventData.which;
|
||||
|
||||
// Stop here if the locked flag is set to true
|
||||
|
||||
@@ -142,7 +142,7 @@ function addNewMeasurement(mouseEventData) {
|
||||
};
|
||||
|
||||
// Bind the event listener for image rendering
|
||||
$element.on('CornerstoneImageRendered', imageRenderedHandler);
|
||||
$element.on('cornerstoneimagerendered', imageRenderedHandler);
|
||||
|
||||
// Bind the tool deactivation and enlargement handlers
|
||||
$element.on('CornerstoneToolsToolDeactivated', cancelAction);
|
||||
@@ -165,7 +165,7 @@ function addNewMeasurement(mouseEventData) {
|
||||
$element.off('mousedown', mousedownHandler);
|
||||
|
||||
// Unbind the event listener for image rendering
|
||||
$element.off('CornerstoneImageRendered', imageRenderedHandler);
|
||||
$element.off('cornerstoneimagerendered', imageRenderedHandler);
|
||||
|
||||
// Unbind the tool deactivation and enlargement handlers
|
||||
$element.off('CornerstoneToolsToolDeactivated', cancelAction);
|
||||
@@ -252,7 +252,8 @@ function pointNearTool(element, data, coords) {
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
function onImageRendered(e) {
|
||||
const eventData = e.detail;
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
@@ -399,7 +400,8 @@ function addNewMeasurementTouch(touchEventData) {
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
function doubleClickCallback(e) {
|
||||
const eventData = e.detail;
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ function createQualitativeTargetTool(toolType, responseText='') {
|
||||
};
|
||||
|
||||
// Bind the event listener for image rendering
|
||||
$element.on('CornerstoneImageRendered', imageRenderedHandler);
|
||||
$element.on('cornerstoneimagerendered', imageRenderedHandler);
|
||||
|
||||
// Bind the tool deactivation and enlargement handlers
|
||||
$element.on('CornerstoneToolsToolDeactivated', cancelAction);
|
||||
@@ -139,7 +139,7 @@ function createQualitativeTargetTool(toolType, responseText='') {
|
||||
$element.off('mousedown', mousedownHandler);
|
||||
|
||||
// Unbind the event listener for image rendering
|
||||
$element.off('CornerstoneImageRendered', imageRenderedHandler);
|
||||
$element.off('cornerstoneimagerendered', imageRenderedHandler);
|
||||
|
||||
// Unbind the tool deactivation and enlargement handlers
|
||||
$element.off('CornerstoneToolsToolDeactivated', cancelAction);
|
||||
@@ -261,7 +261,8 @@ function createQualitativeTargetTool(toolType, responseText='') {
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
function onImageRendered(e) {
|
||||
const eventData = e.detail;
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
@@ -416,7 +417,8 @@ function createQualitativeTargetTool(toolType, responseText='') {
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
function doubleClickCallback(e) {
|
||||
const eventData = e.detail;
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
|
||||
@@ -144,7 +144,8 @@ function computeScaleBounds(eventData, canvasSize, imageSize, horizontalReductio
|
||||
};
|
||||
}
|
||||
|
||||
function onImageRendered(e, eventData) {
|
||||
function onImageRendered(e) {
|
||||
const eventData = e.detail;
|
||||
|
||||
// Check whether pixel spacing is defined
|
||||
if (!eventData.image.rowPixelSpacing || !eventData.image.columnPixelSpacing) {
|
||||
@@ -219,7 +220,7 @@ function onImageRendered(e, eventData) {
|
||||
|
||||
function disable(element) {
|
||||
// TODO: displayTool does not have cornerstone.updateImage(element) method to hide tool
|
||||
$(element).off('CornerstoneImageRendered', onImageRendered);
|
||||
$(element).off('cornerstoneimagerendered', onImageRendered);
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user