Move towards NPM for Cornerstone dependencies
This commit is contained in:
1 parent
6c98c6a589
commit
ddef3c4710
59 files changed
+2435
-29162
No files matched your search
@@ -9,6 +9,6 @@ Template.dialogLoading.onRendered(() => {
|
||||
$modal.modal({
|
||||
backdrop: 'static',
|
||||
keyboard: false,
|
||||
modal: true
|
||||
show: true
|
||||
});
|
||||
});
|
||||
@@ -8,7 +8,7 @@ Template.dialogSimple.onCreated(() => {
|
||||
|
||||
instance.close = () => {
|
||||
const $modal = instance.$('.modal');
|
||||
$modal.on('hidden.bs.modal', () => instance.data.promiseResolve()).modal('hide');
|
||||
$modal.one('hidden.bs.modal', () => instance.data.promiseResolve()).modal('hide');
|
||||
};
|
||||
|
||||
// Automatically close the modal if a timeout value was given
|
||||
|
||||
@@ -12,7 +12,7 @@ Template.unsavedChangesDialog.onRendered(function() {
|
||||
const instance = Template.instance();
|
||||
const $modal = instance.$('.modal.unsavedChangesDialog');
|
||||
|
||||
// Routine which effectivelly displays the BS modal...
|
||||
// Routine which effectively displays the BS modal...
|
||||
instance.displayModal = () => {
|
||||
|
||||
// Make modal options extensible...
|
||||
@@ -22,7 +22,7 @@ Template.unsavedChangesDialog.onRendered(function() {
|
||||
}, instance.data.modalOptions);
|
||||
|
||||
// Set handler for "hidden" event... Simply remove the view!
|
||||
$modal.on('hidden.bs.modal', () => {
|
||||
$modal.one('hidden.bs.modal', () => {
|
||||
Blaze.remove(instance.view);
|
||||
});
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,4 +1,4 @@
|
||||
import { Cornerstone } from '../namespace';
|
||||
import { OHIF } from '../namespace';
|
||||
|
||||
import { MetadataProvider } from './lib/classes/MetadataProvider';
|
||||
Cornerstone.metadataProvider = new MetadataProvider();
|
||||
OHIF.cornerstone.metadataProvider = new MetadataProvider();
|
||||
@@ -1,33 +0,0 @@
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery', 'hammerjs'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
factory(require('jquery'), require('hammerjs'));
|
||||
} else {
|
||||
factory(jQuery, Hammer);
|
||||
}
|
||||
}(function($, Hammer) {
|
||||
function hammerify(el, options) {
|
||||
var $el = $(el);
|
||||
if(!$el.data("hammer")) {
|
||||
$el.data("hammer", new Hammer($el[0], options));
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.hammer = function(options) {
|
||||
return this.each(function() {
|
||||
hammerify(this, options);
|
||||
});
|
||||
};
|
||||
|
||||
// extend the emit method to also trigger jQuery events
|
||||
Hammer.Manager.prototype.emit = (function(originalEmit) {
|
||||
return function(type, data) {
|
||||
originalEmit.call(this, type, data);
|
||||
$(this.element).trigger({
|
||||
type: type,
|
||||
gesture: data
|
||||
});
|
||||
};
|
||||
})(Hammer.Manager.prototype.emit);
|
||||
}));
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as cornerstoneMath from 'cornerstone-math';
|
||||
import { parsingUtils } from '../parsingUtils';
|
||||
|
||||
const FUNCTION = 'function';
|
||||
@@ -245,22 +246,17 @@ export class MetadataProvider {
|
||||
}
|
||||
|
||||
return {
|
||||
frameOfReferenceUID:
|
||||
instance.frameOfReferenceUID,
|
||||
rows:
|
||||
instance.rows,
|
||||
columns:
|
||||
instance.columns,
|
||||
frameOfReferenceUID: instance.frameOfReferenceUID,
|
||||
rows: instance.rows,
|
||||
columns: instance.columns,
|
||||
rowCosines:
|
||||
new cornerstoneMath.Vector3(parseFloat(imageOrientation[0]), parseFloat(imageOrientation[1]), parseFloat(imageOrientation[2])),
|
||||
columnCosines:
|
||||
new cornerstoneMath.Vector3(parseFloat(imageOrientation[3]), parseFloat(imageOrientation[4]), parseFloat(imageOrientation[5])),
|
||||
imagePositionPatient:
|
||||
new cornerstoneMath.Vector3(parseFloat(imagePosition[0]), parseFloat(imagePosition[1]), parseFloat(imagePosition[2])),
|
||||
rowPixelSpacing:
|
||||
rowPixelSpacing,
|
||||
columnPixelSpacing:
|
||||
columnPixelSpacing,
|
||||
rowPixelSpacing,
|
||||
columnPixelSpacing,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -318,7 +314,7 @@ export class MetadataProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a bound reference to the privider function.
|
||||
* Get a bound reference to the provider function.
|
||||
*/
|
||||
getProvider() {
|
||||
let provider = this._provider;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Globals: dicomParser
|
||||
*/
|
||||
import * as dicomParser from 'dicom-parser';
|
||||
|
||||
/**
|
||||
* A small set of utilities to help parsing DICOM element values.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Import namespace...
|
||||
*/
|
||||
|
||||
import { OHIF, Cornerstone } from './namespace.js';
|
||||
import { OHIF } from './namespace.js';
|
||||
|
||||
/**
|
||||
* Import scripts that will populate the Cornerstone namespace as a side effect only import. This is effectively the public API...
|
||||
@@ -10,4 +10,20 @@ import { OHIF, Cornerstone } from './namespace.js';
|
||||
|
||||
import './client/'; // which is actually: import './client/index.js';
|
||||
|
||||
export { OHIF, Cornerstone };
|
||||
import * as cornerstone from 'cornerstone-core';
|
||||
import * as cornerstoneTools from 'cornerstone-tools';
|
||||
import * as cornerstoneMath from 'cornerstone-math';
|
||||
import * as cornerstoneWADOImageLoader from 'cornerstone-wado-image-loader';
|
||||
import * as dicomParser from 'dicom-parser';
|
||||
|
||||
debugger;
|
||||
|
||||
export {
|
||||
cornerstone,
|
||||
cornerstoneTools,
|
||||
cornerstoneMath,
|
||||
cornerstoneWADOImageLoader,
|
||||
dicomParser
|
||||
};
|
||||
|
||||
export { OHIF };
|
||||
@@ -22,4 +22,4 @@ OHIF.cornerstone = Cornerstone;
|
||||
* Export relevant objects
|
||||
*/
|
||||
|
||||
export { OHIF, Cornerstone };
|
||||
export { OHIF };
|
||||
@@ -4,45 +4,31 @@ Package.describe({
|
||||
version: '0.0.1'
|
||||
});
|
||||
|
||||
Npm.depends({
|
||||
'hammerjs': '2.0.8',
|
||||
'jquery-hammerjs': '2.0.0',
|
||||
'cornerstone-core': '0.11.0',
|
||||
'cornerstone-tools': '0.8.9',
|
||||
'cornerstone-math': '0.1.6',
|
||||
'dicom-parser': '1.7.5',
|
||||
'cornerstone-wado-image-loader': '0.14.6'
|
||||
});
|
||||
|
||||
Package.onUse(function(api) {
|
||||
api.versionsFrom('1.4');
|
||||
api.versionsFrom('1.5');
|
||||
|
||||
api.use('ecmascript');
|
||||
|
||||
api.use('jquery');
|
||||
|
||||
api.use('ohif:core');
|
||||
|
||||
api.addFiles('client/cornerstone.js', 'client', {
|
||||
bare: true
|
||||
});
|
||||
api.addFiles('client/cornerstoneMath.js', 'client', {
|
||||
bare: true
|
||||
});
|
||||
api.addFiles('client/cornerstoneTools.js', 'client', {
|
||||
bare: true
|
||||
});
|
||||
api.addFiles('client/cornerstoneWADOImageLoader.js', 'client', {
|
||||
bare: true
|
||||
});
|
||||
api.addFiles('client/dicomParser.js', 'client', {
|
||||
bare: true
|
||||
});
|
||||
api.addFiles('client/hammer.js', 'client', {
|
||||
bare: true
|
||||
});
|
||||
api.addFiles('client/jquery.hammer.js', 'client', {
|
||||
bare: true
|
||||
});
|
||||
|
||||
api.addAssets('public/js/cornerstoneWADOImageLoaderCodecs.es5.js', 'client');
|
||||
api.addAssets('public/js/cornerstoneWADOImageLoaderWebWorker.es5.js', 'client');
|
||||
|
||||
api.mainModule('main.js', 'client');
|
||||
|
||||
api.export('cornerstone', 'client');
|
||||
api.export('cornerstoneMath', 'client');
|
||||
api.export('cornerstoneTools', 'client');
|
||||
api.export('cornerstoneWADOImageLoader', 'client');
|
||||
api.export('dicomParser', 'client');
|
||||
|
||||
api.mainModule('main.js', 'client');
|
||||
});
|
||||
@@ -5,8 +5,6 @@ import { retrieveMeasurements, storeMeasurements, retrieveTimepoints, storeTimep
|
||||
import { validateMeasurements } from './dataValidation';
|
||||
import { FieldLesionLocation, FieldLesionLocationResponse } from 'meteor/ohif:lesiontracker/both/schema/fields';
|
||||
|
||||
console.log('OHIF-LesionTracker: Defining Configuration for Measurements');
|
||||
|
||||
const newMeasurementTool = {
|
||||
id: 'newLesions',
|
||||
name: 'New Lesions'
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,417 +1,412 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
import { cornerstone, cornerstoneMath, cornerstoneTools } from 'meteor/ohif:cornerstone';
|
||||
|
||||
'use strict';
|
||||
const toolType = 'nonTarget';
|
||||
|
||||
const toolType = 'nonTarget';
|
||||
const toolDefaultStates = Viewerbase.toolManager.getToolDefaultStates();
|
||||
const shadowConfig = toolDefaultStates.shadowConfig;
|
||||
const textBoxConfig = toolDefaultStates.textBoxConfig;
|
||||
|
||||
const toolDefaultStates = Viewerbase.toolManager.getToolDefaultStates();
|
||||
const shadowConfig = toolDefaultStates.shadowConfig;
|
||||
const textBoxConfig = toolDefaultStates.textBoxConfig;
|
||||
const configuration = {
|
||||
getMeasurementLocationCallback,
|
||||
changeMeasurementLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: true,
|
||||
arrowFirst: true,
|
||||
textBox: textBoxConfig,
|
||||
...shadowConfig,
|
||||
};
|
||||
|
||||
const configuration = {
|
||||
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
||||
changeMeasurementLocationCallback: changeMeasurementLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: true,
|
||||
arrowFirst: true,
|
||||
textBox: textBoxConfig,
|
||||
...shadowConfig,
|
||||
// Used to cancel tool placement
|
||||
const keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
const getPosition = eventData => {
|
||||
const event = eventData.event;
|
||||
return {
|
||||
x: event.clientX,
|
||||
y: event.clientY
|
||||
};
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
const keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
const getPosition = eventData => {
|
||||
const event = eventData.event;
|
||||
return {
|
||||
x: event.clientX,
|
||||
y: event.clientY
|
||||
};
|
||||
};
|
||||
|
||||
// Define a callback to get your text annotation
|
||||
// This could be used, e.g. to open a modal
|
||||
function getMeasurementLocationCallback(measurementData, eventData) {
|
||||
if (OHIF.lesiontracker.removeMeasurementIfInvalid(measurementData, eventData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete measurementData.isCreating;
|
||||
|
||||
OHIF.ui.showDialog('dialogNonTargetMeasurement', {
|
||||
position: getPosition(eventData),
|
||||
title: 'Select Lesion Location',
|
||||
element: eventData.element,
|
||||
measurementData
|
||||
});
|
||||
// Define a callback to get your text annotation
|
||||
// This could be used, e.g. to open a modal
|
||||
function getMeasurementLocationCallback(measurementData, eventData) {
|
||||
if (OHIF.lesiontracker.removeMeasurementIfInvalid(measurementData, eventData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
function changeMeasurementLocationCallback(measurementData, eventData) {
|
||||
if (OHIF.lesiontracker.removeMeasurementIfInvalid(measurementData, eventData)) {
|
||||
return;
|
||||
}
|
||||
delete measurementData.isCreating;
|
||||
|
||||
OHIF.ui.showDialog('dialogNonTargetMeasurement', {
|
||||
position: getPosition(eventData),
|
||||
title: 'Change Lesion Location',
|
||||
element: eventData.element,
|
||||
measurementData,
|
||||
edit: true
|
||||
});
|
||||
OHIF.ui.showDialog('dialogNonTargetMeasurement', {
|
||||
position: getPosition(eventData),
|
||||
title: 'Select Lesion Location',
|
||||
element: eventData.element,
|
||||
measurementData
|
||||
});
|
||||
}
|
||||
|
||||
function changeMeasurementLocationCallback(measurementData, eventData) {
|
||||
if (OHIF.lesiontracker.removeMeasurementIfInvalid(measurementData, eventData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
const element = mouseEventData.element;
|
||||
OHIF.ui.showDialog('dialogNonTargetMeasurement', {
|
||||
position: getPosition(eventData),
|
||||
title: 'Change Lesion Location',
|
||||
element: eventData.element,
|
||||
measurementData,
|
||||
edit: true
|
||||
});
|
||||
}
|
||||
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
const measurementData = createNewMeasurement(mouseEventData);
|
||||
measurementData.viewport = cornerstone.getViewport(element);
|
||||
|
||||
const eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
const config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
let cancelled = false;
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
const element = mouseEventData.element;
|
||||
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getMeasurementLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
const measurementData = createNewMeasurement(mouseEventData);
|
||||
measurementData.viewport = cornerstone.getViewport(element);
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
const eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
const config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
isCreating: true,
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
allowedOutsideImage: true,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
allowedOutsideImage: true,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
let cancelled = false;
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getMeasurementLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools.nonTarget.mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools.nonTarget.mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools.nonTarget.mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
isCreating: true,
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
allowedOutsideImage: true,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: '',
|
||||
isTarget: false,
|
||||
toolType: 'nonTarget'
|
||||
};
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
allowedOutsideImage: true,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: '',
|
||||
isTarget: false,
|
||||
toolType: 'nonTarget'
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = config.shadowColor || '#000000';
|
||||
context.shadowOffsetX = config.shadowOffsetX || 1;
|
||||
context.shadowOffsetY = config.shadowOffsetY || 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
cornerstoneTools.drawArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ data.handles.start ], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ data.handles.end ], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.measurementNumber) {
|
||||
|
||||
var textLine = `Non-Target ${data.measurementNumber}`;
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, textLine, canvasTextLocation.x, canvasTextLocation.y, color, config.textBox);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
|
||||
OHIF.cornerstone.repositionTextBox(eventData, data, config.textBox);
|
||||
|
||||
// Draw linked line as dashed
|
||||
var link = {
|
||||
start: {},
|
||||
end: {}
|
||||
};
|
||||
|
||||
var midpointCanvas = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2,
|
||||
};
|
||||
|
||||
var points = [ handleStartCanvas, handleEndCanvas, midpointCanvas ];
|
||||
|
||||
link.end.x = canvasTextLocation.x;
|
||||
link.end.y = canvasTextLocation.y;
|
||||
|
||||
link.start = cornerstoneMath.point.findClosestPoint(points, link.end);
|
||||
|
||||
var boundingBoxPoints = [ {
|
||||
// Top middle point of bounding box
|
||||
x: boundingBox.left + boundingBox.width / 2,
|
||||
y: boundingBox.top
|
||||
}, {
|
||||
// Left middle point of bounding box
|
||||
x: boundingBox.left,
|
||||
y: boundingBox.top + boundingBox.height / 2
|
||||
}, {
|
||||
// Bottom middle point of bounding box
|
||||
x: boundingBox.left + boundingBox.width / 2,
|
||||
y: boundingBox.top + boundingBox.height
|
||||
}, {
|
||||
// Right middle point of bounding box
|
||||
x: boundingBox.left + boundingBox.width,
|
||||
y: boundingBox.top + boundingBox.height / 2
|
||||
},
|
||||
];
|
||||
|
||||
link.end = cornerstoneMath.point.findClosestPoint(boundingBoxPoints, link.start);
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([ 2, 3 ]);
|
||||
|
||||
context.moveTo(link.start.x, link.start.y);
|
||||
context.lineTo(link.end.x, link.end.y);
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = config.shadowColor || '#000000';
|
||||
context.shadowOffsetX = config.shadowOffsetX || 1;
|
||||
context.shadowOffsetY = config.shadowOffsetY || 1;
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
cornerstoneTools.drawArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ data.handles.start ], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [ data.handles.end ], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.measurementNumber) {
|
||||
|
||||
var textLine = `Non-Target ${data.measurementNumber}`;
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, textLine, canvasTextLocation.x, canvasTextLocation.y, color, config.textBox);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
|
||||
OHIF.cornerstone.repositionTextBox(eventData, data, config.textBox);
|
||||
|
||||
// Draw linked line as dashed
|
||||
var link = {
|
||||
start: {},
|
||||
end: {}
|
||||
};
|
||||
|
||||
var midpointCanvas = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2,
|
||||
};
|
||||
|
||||
var points = [ handleStartCanvas, handleEndCanvas, midpointCanvas ];
|
||||
|
||||
link.end.x = canvasTextLocation.x;
|
||||
link.end.y = canvasTextLocation.y;
|
||||
|
||||
link.start = cornerstoneMath.point.findClosestPoint(points, link.end);
|
||||
|
||||
var boundingBoxPoints = [ {
|
||||
// Top middle point of bounding box
|
||||
x: boundingBox.left + boundingBox.width / 2,
|
||||
y: boundingBox.top
|
||||
}, {
|
||||
// Left middle point of bounding box
|
||||
x: boundingBox.left,
|
||||
y: boundingBox.top + boundingBox.height / 2
|
||||
}, {
|
||||
// Bottom middle point of bounding box
|
||||
x: boundingBox.left + boundingBox.width / 2,
|
||||
y: boundingBox.top + boundingBox.height
|
||||
}, {
|
||||
// Right middle point of bounding box
|
||||
x: boundingBox.left + boundingBox.width,
|
||||
y: boundingBox.top + boundingBox.height / 2
|
||||
},
|
||||
];
|
||||
|
||||
link.end = cornerstoneMath.point.findClosestPoint(boundingBoxPoints, link.start);
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([ 2, 3 ]);
|
||||
|
||||
context.moveTo(link.start.x, link.start.y);
|
||||
context.lineTo(link.end.x, link.end.y);
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getMeasurementLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
config.getMeasurementLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools.nonTargetTouch.touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools.nonTargetTouch.touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools.nonTargetTouch.tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeMeasurementLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
cornerstoneTools.nonTarget = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
cornerstoneTools.nonTarget.setConfiguration(configuration);
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
|
||||
cornerstoneTools.nonTargetTouch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeMeasurementLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cornerstoneTools.nonTarget = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement,
|
||||
createNewMeasurement,
|
||||
onImageRendered,
|
||||
pointNearTool,
|
||||
toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
cornerstoneTools.nonTarget.setConfiguration(configuration);
|
||||
|
||||
cornerstoneTools.nonTargetTouch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement,
|
||||
onImageRendered,
|
||||
pointNearTool,
|
||||
toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
@@ -1,424 +1,420 @@
|
||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||
import { cornerstone, cornerstoneMath, cornerstoneTools } from 'meteor/ohif:cornerstone';
|
||||
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
var responseByToolType = [{
|
||||
"toolType": "targetCR",
|
||||
"toolResponse": "CR"
|
||||
}, {
|
||||
"toolType": "targetUN",
|
||||
"toolResponse": "UN"
|
||||
}, {
|
||||
"toolType": "targetEX",
|
||||
"toolResponse": "EX"
|
||||
}];
|
||||
|
||||
'use strict';
|
||||
var responseByToolType = [{
|
||||
"toolType": "targetCR",
|
||||
"toolResponse": "CR"
|
||||
}, {
|
||||
"toolType": "targetUN",
|
||||
"toolResponse": "UN"
|
||||
}, {
|
||||
"toolType": "targetEX",
|
||||
"toolResponse": "EX"
|
||||
}];
|
||||
const toolDefaultStates = Viewerbase.toolManager.getToolDefaultStates();
|
||||
const textBoxConfig = toolDefaultStates.textBoxConfig;
|
||||
|
||||
const toolDefaultStates = Viewerbase.toolManager.getToolDefaultStates();
|
||||
const textBoxConfig = toolDefaultStates.textBoxConfig;
|
||||
var configuration = {
|
||||
getMeasurementLocationCallback,
|
||||
changeMeasurementLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: false,
|
||||
arrowFirst: true,
|
||||
textBox: textBoxConfig
|
||||
};
|
||||
|
||||
var configuration = {
|
||||
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
||||
changeMeasurementLocationCallback: changeMeasurementLocationCallback,
|
||||
drawHandles: false,
|
||||
drawHandlesOnHover: false,
|
||||
arrowFirst: true,
|
||||
textBox: textBoxConfig
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
// Define a callback to get your text annotation
|
||||
// This could be used, e.g. to open a modal
|
||||
function getMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Enter your lesion location:'));
|
||||
}
|
||||
|
||||
function changeMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
|
||||
|
||||
function createQualitativeTargetTool(toolType) {
|
||||
var toolInterface = {
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
ESC: 27
|
||||
};
|
||||
var response;
|
||||
|
||||
// Define a callback to get your text annotation
|
||||
// This could be used, e.g. to open a modal
|
||||
function getMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Enter your lesion location:'));
|
||||
responseByToolType.forEach(function(tool) {
|
||||
if (tool.toolType === toolInterface.toolType) {
|
||||
response = tool.toolResponse;
|
||||
}
|
||||
});
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getMeasurementLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
}
|
||||
|
||||
function changeMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your lesion location:'));
|
||||
}
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
function createQualitativeTargetTool(toolType) {
|
||||
var toolInterface = {
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
allowedOutsideImage: true,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
allowedOutsideImage: true,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: response,
|
||||
isTarget: true,
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
var response;
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
responseByToolType.forEach(function(tool) {
|
||||
if (tool.toolType === toolInterface.toolType) {
|
||||
response = tool.toolResponse;
|
||||
}
|
||||
});
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
// associate this data with this imageId so we can render it and manipulate it
|
||||
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
|
||||
|
||||
// since we are dragging to another place to drop the end point, we can just activate
|
||||
// the end point and let the moveHandle move it for us.
|
||||
$(element).off('CornerstoneToolsMouseMove', cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).off('CornerstoneToolsMouseDown', cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).off('CornerstoneToolsMouseDownActivate', cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
cancelled = true;
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
}
|
||||
|
||||
// Don't propagate this keydown event so it can't interfere
|
||||
// with anything outside of this tool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind a one-time event listener for the Esc key
|
||||
$(element).one('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandle(mouseEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
if (cancelled || cornerstoneTools.anyHandlesOutsideImage(mouseEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(mouseEventData.element, toolType, measurementData);
|
||||
} else {
|
||||
config.getMeasurementLocationCallback(measurementData, mouseEventData, doneCallback);
|
||||
}
|
||||
|
||||
// Unbind the Esc keydown hook
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsMouseMove', eventData, cornerstoneTools[toolType].mouseMoveCallback);
|
||||
$(element).on('CornerstoneToolsMouseDown', eventData, cornerstoneTools[toolType].mouseDownCallback);
|
||||
$(element).on('CornerstoneToolsMouseDownActivate', eventData, cornerstoneTools[toolType].mouseDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsMouseDoubleClick', eventData, doubleClickCallback);
|
||||
|
||||
$(element).off('keydown', cancelCallback);
|
||||
|
||||
cornerstone.updateImage(mouseEventData.element);
|
||||
});
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function createNewMeasurement(mouseEventData) {
|
||||
var imageId = mouseEventData.image.imageId;
|
||||
|
||||
// Get studyInstanceUid
|
||||
var study = cornerstoneTools.metaData.get('study', imageId);
|
||||
var studyInstanceUid = study.studyInstanceUid;
|
||||
var patientId = study.patientId;
|
||||
|
||||
// Get seriesInstanceUid
|
||||
var series = cornerstoneTools.metaData.get('series', imageId);
|
||||
var seriesInstanceUid = series.seriesInstanceUid;
|
||||
|
||||
// create the measurement data for this tool with the end handle activated
|
||||
var measurementData = {
|
||||
visible: true,
|
||||
active: true,
|
||||
handles: {
|
||||
start: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
allowedOutsideImage: true,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
end: {
|
||||
x: mouseEventData.currentPoints.image.x,
|
||||
y: mouseEventData.currentPoints.image.y,
|
||||
allowedOutsideImage: true,
|
||||
highlight: true,
|
||||
active: false
|
||||
},
|
||||
textBox: {
|
||||
x: mouseEventData.currentPoints.image.x - 50,
|
||||
y: mouseEventData.currentPoints.image.y - 50,
|
||||
active: false,
|
||||
movesIndependently: false,
|
||||
drawnIndependently: true,
|
||||
allowedOutsideImage: true,
|
||||
hasBoundingBox: true
|
||||
}
|
||||
},
|
||||
imageId: imageId,
|
||||
seriesInstanceUid: seriesInstanceUid,
|
||||
studyInstanceUid: studyInstanceUid,
|
||||
patientId: patientId,
|
||||
response: response,
|
||||
isTarget: true,
|
||||
toolType: toolType
|
||||
};
|
||||
|
||||
return measurementData;
|
||||
}
|
||||
///////// END ACTIVE TOOL ///////
|
||||
|
||||
function pointNearTool(element, data, coords) {
|
||||
var lineSegment = {
|
||||
start: cornerstone.pixelToCanvas(element, data.handles.start),
|
||||
end: cornerstone.pixelToCanvas(element, data.handles.end)
|
||||
};
|
||||
var distanceToPoint = cornerstoneMath.lineSegment.distanceToPoint(lineSegment, coords);
|
||||
|
||||
if (cornerstoneTools.pointInsideBoundingBox(data.handles.textBox, coords)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
function drawDottedArrow(context, start, end, color, lineWidth) {
|
||||
//variables to be used when creating the arrow
|
||||
var headLength = 10;
|
||||
|
||||
var angle = Math.atan2(end.y - start.y, end.x - start.x);
|
||||
|
||||
//starting path of the arrow from the start square to the end square and drawing the stroke
|
||||
context.beginPath();
|
||||
context.moveTo(start.x, start.y);
|
||||
context.lineTo(end.x, end.y);
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
//context.setLineDash([ 2, 3 ]);
|
||||
context.stroke();
|
||||
|
||||
//starting a new path from the head of the arrow to one of the sides of the point
|
||||
context.beginPath();
|
||||
context.moveTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//path from the side point of the arrow, to the other side point
|
||||
context.lineTo(end.x - headLength * Math.cos(angle + Math.PI / 7), end.y - headLength * Math.sin(angle + Math.PI / 7));
|
||||
|
||||
//path from the side point back to the tip of the arrow, and then again to the opposite side point
|
||||
context.lineTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//draws the paths created above
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.stroke();
|
||||
context.fillStyle = color;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = config.shadowColor || '#000000';
|
||||
context.shadowOffsetX = config.shadowOffsetX || 1;
|
||||
context.shadowOffsetY = config.shadowOffsetY || 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
drawDottedArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.start], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.end], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.measurementNumber) {
|
||||
// Draw linked line as dashed
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([2, 3]);
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
var textLine = `Target ${data.measurementNumber}`;
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, textLine, canvasTextLocation.x, canvasTextLocation.y, color, config.textBox);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getMeasurementLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeMeasurementLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toolInterface.mouse = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
toolInterface.touch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
return toolInterface;
|
||||
return distanceToPoint < 25;
|
||||
}
|
||||
|
||||
var targetCRInterface = createQualitativeTargetTool('targetCR');
|
||||
cornerstoneTools.targetCR = targetCRInterface.mouse;
|
||||
cornerstoneTools.targetCR.setConfiguration(configuration);
|
||||
cornerstoneTools.targetCRTouch = targetCRInterface.touch;
|
||||
function drawDottedArrow(context, start, end, color, lineWidth) {
|
||||
//variables to be used when creating the arrow
|
||||
var headLength = 10;
|
||||
|
||||
var targetUNInterface = createQualitativeTargetTool('targetUN');
|
||||
cornerstoneTools.targetUN = targetUNInterface.mouse;
|
||||
cornerstoneTools.targetUN.setConfiguration(configuration);
|
||||
cornerstoneTools.targetUNTouch = targetUNInterface.touch;
|
||||
var angle = Math.atan2(end.y - start.y, end.x - start.x);
|
||||
|
||||
var targetEXInterface = createQualitativeTargetTool('targetEX');
|
||||
cornerstoneTools.targetEX = targetEXInterface.mouse;
|
||||
cornerstoneTools.targetEX.setConfiguration(configuration);
|
||||
cornerstoneTools.targetEXTouch = targetEXInterface.touch;
|
||||
//starting path of the arrow from the start square to the end square and drawing the stroke
|
||||
context.beginPath();
|
||||
context.moveTo(start.x, start.y);
|
||||
context.lineTo(end.x, end.y);
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
//context.setLineDash([ 2, 3 ]);
|
||||
context.stroke();
|
||||
|
||||
})($, cornerstone, cornerstoneMath, cornerstoneTools);
|
||||
//starting a new path from the head of the arrow to one of the sides of the point
|
||||
context.beginPath();
|
||||
context.moveTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//path from the side point of the arrow, to the other side point
|
||||
context.lineTo(end.x - headLength * Math.cos(angle + Math.PI / 7), end.y - headLength * Math.sin(angle + Math.PI / 7));
|
||||
|
||||
//path from the side point back to the tip of the arrow, and then again to the opposite side point
|
||||
context.lineTo(end.x, end.y);
|
||||
context.lineTo(end.x - headLength * Math.cos(angle - Math.PI / 7), end.y - headLength * Math.sin(angle - Math.PI / 7));
|
||||
|
||||
//draws the paths created above
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.stroke();
|
||||
context.fillStyle = color;
|
||||
context.fill();
|
||||
}
|
||||
|
||||
///////// BEGIN IMAGE RENDERING ///////
|
||||
function onImageRendered(e, eventData) {
|
||||
var element = eventData.element;
|
||||
|
||||
// if we have no toolData for this element, return immediately as there is nothing to do
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we have tool data for this element - iterate over each one and draw it
|
||||
var context = eventData.canvasContext.canvas.getContext('2d');
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
var color;
|
||||
var lineWidth = cornerstoneTools.toolStyle.getToolWidth();
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
var data = toolData.data[i];
|
||||
|
||||
context.save();
|
||||
|
||||
// configurable shadow from CornerstoneTools
|
||||
if (config && config.shadow) {
|
||||
context.shadowColor = config.shadowColor || '#000000';
|
||||
context.shadowOffsetX = config.shadowOffsetX || 1;
|
||||
context.shadowOffsetY = config.shadowOffsetY || 1;
|
||||
}
|
||||
|
||||
if (data.active) {
|
||||
color = cornerstoneTools.toolColors.getActiveColor();
|
||||
} else {
|
||||
color = cornerstoneTools.toolColors.getToolColor();
|
||||
}
|
||||
|
||||
// Draw the arrow
|
||||
var handleStartCanvas = cornerstone.pixelToCanvas(element, data.handles.start);
|
||||
var handleEndCanvas = cornerstone.pixelToCanvas(element, data.handles.end);
|
||||
var canvasTextLocation = cornerstone.pixelToCanvas(element, data.handles.textBox);
|
||||
|
||||
drawDottedArrow(context, handleEndCanvas, handleStartCanvas, color, lineWidth);
|
||||
|
||||
if (config.drawHandles) {
|
||||
cornerstoneTools.drawHandles(context, eventData, data.handles, color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.start.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.start], color);
|
||||
} else if (config.drawHandlesOnHover && data.handles.end.active) {
|
||||
cornerstoneTools.drawHandles(context, eventData, [data.handles.end], color);
|
||||
}
|
||||
|
||||
// Draw the text
|
||||
if (data.measurementNumber) {
|
||||
// Draw linked line as dashed
|
||||
var mid = {
|
||||
x: (handleStartCanvas.x + handleEndCanvas.x) / 2,
|
||||
y: (handleStartCanvas.y + handleEndCanvas.y) / 2
|
||||
};
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = color;
|
||||
context.lineWidth = lineWidth;
|
||||
context.setLineDash([2, 3]);
|
||||
|
||||
context.moveTo(mid.x, mid.y);
|
||||
context.lineTo(canvasTextLocation.x + 20, canvasTextLocation.y + 20);
|
||||
context.stroke();
|
||||
|
||||
var textLine = `Target ${data.measurementNumber}`;
|
||||
var boundingBox = cornerstoneTools.drawTextBox(context, textLine, canvasTextLocation.x, canvasTextLocation.y, color, config.textBox);
|
||||
data.handles.textBox.boundingBox = boundingBox;
|
||||
}
|
||||
|
||||
context.restore();
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Touch tool ----
|
||||
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(touchEventData);
|
||||
cornerstoneTools.addToolState(element, toolType, measurementData);
|
||||
$(element).off('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).off('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).off('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
cornerstoneTools.moveNewHandleTouch(touchEventData, toolType, measurementData, measurementData.handles.end, function() {
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
if (cornerstoneTools.anyHandlesOutsideImage(touchEventData, measurementData.handles)) {
|
||||
// delete the measurement
|
||||
cornerstoneTools.removeToolState(element, toolType, measurementData);
|
||||
}
|
||||
|
||||
config.getMeasurementLocationCallback(measurementData, touchEventData, doneCallback);
|
||||
|
||||
$(element).on('CornerstoneToolsTouchDrag', cornerstoneTools[toolType + "Touch"].touchMoveHandle);
|
||||
$(element).on('CornerstoneToolsDragStartActive', cornerstoneTools[toolType + "Touch"].touchDownActivateCallback);
|
||||
$(element).on('CornerstoneToolsTap', cornerstoneTools[toolType + "Touch"].tapCallback);
|
||||
});
|
||||
}
|
||||
|
||||
function doubleClickCallback(e, eventData) {
|
||||
var element = eventData.element;
|
||||
var data;
|
||||
|
||||
function doneCallback(data, deleteTool) {
|
||||
if (deleteTool === true) {
|
||||
cornerstoneTools.removeToolState(element, toolType, data);
|
||||
cornerstone.updateImage(element);
|
||||
return;
|
||||
}
|
||||
|
||||
data.active = false;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
if (e.data && e.data.mouseButtonMask && !cornerstoneTools.isMouseButtonEnabled(eventData.which, e.data.mouseButtonMask)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var config = cornerstoneTools[toolType].getConfiguration();
|
||||
|
||||
var coords = eventData.currentPoints.canvas;
|
||||
var toolData = cornerstoneTools.getToolState(element, toolType);
|
||||
|
||||
// now check to see if there is a handle we can move
|
||||
if (!toolData) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < toolData.data.length; i++) {
|
||||
data = toolData.data[i];
|
||||
if (pointNearTool(element, data, coords)) {
|
||||
data.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
// Allow relabelling via a callback
|
||||
config.changeMeasurementLocationCallback(data, eventData, doneCallback);
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
toolInterface.mouse = cornerstoneTools.mouseButtonTool({
|
||||
addNewMeasurement: addNewMeasurement,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType,
|
||||
mouseDoubleClickCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
toolInterface.touch = cornerstoneTools.touchTool({
|
||||
addNewMeasurement: addNewMeasurementTouch,
|
||||
createNewMeasurement: createNewMeasurement,
|
||||
onImageRendered: onImageRendered,
|
||||
pointNearTool: pointNearTool,
|
||||
toolType: toolType
|
||||
// pressCallback: doubleClickCallback
|
||||
});
|
||||
|
||||
return toolInterface;
|
||||
}
|
||||
|
||||
var targetCRInterface = createQualitativeTargetTool('targetCR');
|
||||
cornerstoneTools.targetCR = targetCRInterface.mouse;
|
||||
cornerstoneTools.targetCR.setConfiguration(configuration);
|
||||
cornerstoneTools.targetCRTouch = targetCRInterface.touch;
|
||||
|
||||
var targetUNInterface = createQualitativeTargetTool('targetUN');
|
||||
cornerstoneTools.targetUN = targetUNInterface.mouse;
|
||||
cornerstoneTools.targetUN.setConfiguration(configuration);
|
||||
cornerstoneTools.targetUNTouch = targetUNInterface.touch;
|
||||
|
||||
var targetEXInterface = createQualitativeTargetTool('targetEX');
|
||||
cornerstoneTools.targetEX = targetEXInterface.mouse;
|
||||
cornerstoneTools.targetEX.setConfiguration(configuration);
|
||||
cornerstoneTools.targetEXTouch = targetEXInterface.touch;
|
||||
@@ -7,7 +7,6 @@ Meteor.startup(function() {
|
||||
OHIF.studylist.callbacks.middleClickOnStudy = dblClickOnStudy;
|
||||
|
||||
OHIF.studylist.timepointApi = new OHIF.measurements.TimepointApi();
|
||||
OHIF.studylist.timepointApi.retrieveTimepoints({});
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,8 +13,13 @@ const Timepoints = new Mongo.Collection('timepoints');
|
||||
Timepoints._debugName = 'Timepoints';
|
||||
|
||||
Timepoints.find().observe({
|
||||
remove() {
|
||||
console.warn('REMOVED');
|
||||
added(document) {
|
||||
console.warn('TIMEPOINT ADDED')
|
||||
console.warn(document);
|
||||
},
|
||||
remove(docId) {
|
||||
console.warn('TIMEPOINT REMOVED');
|
||||
console.warn(docId);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { loglevel } from 'meteor/practicalmeteor:loglevel';
|
||||
import loglevel from 'loglevel';
|
||||
|
||||
const defaultLevel = Meteor.isProduction ? 'error' : 'trace';
|
||||
const defaultLevel = Meteor.isProduction ? 'ERROR' : 'TRACE';
|
||||
|
||||
// Create package logger using loglevel
|
||||
OHIF.log = loglevel.createLogger('', defaultLevel);
|
||||
OHIF.log = loglevel.getLogger('OHIF');
|
||||
OHIF.log.setLevel(defaultLevel);
|
||||
@@ -4,15 +4,16 @@ Package.describe({
|
||||
version: '0.0.1'
|
||||
});
|
||||
|
||||
Npm.depends({
|
||||
loglevel: '1.4.1'
|
||||
});
|
||||
|
||||
Package.onUse(function(api) {
|
||||
api.versionsFrom('1.4');
|
||||
|
||||
api.use('ecmascript');
|
||||
api.use('standard-app-packages');
|
||||
|
||||
// Control over logging
|
||||
api.use('practicalmeteor:loglevel');
|
||||
|
||||
// Our custom packages
|
||||
api.use('ohif:core');
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
import { schema as TimepointSchema } from 'meteor/ohif:measurements/both/schema/timepoints';
|
||||
|
||||
let configuration = {};
|
||||
const configuration = {};
|
||||
|
||||
class TimepointApi {
|
||||
static setConfiguration(config) {
|
||||
@@ -29,19 +29,30 @@ class TimepointApi {
|
||||
retrieveTimepoints(filter) {
|
||||
const retrievalFn = configuration.dataExchange.retrieve;
|
||||
if (!_.isFunction(retrievalFn)) {
|
||||
OHIF.log.error('Timepoint retrieval function has not been configured.')
|
||||
return;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
retrievalFn(filter).then(timepointData => {
|
||||
OHIF.log.info('Timepoint data retrieval');
|
||||
OHIF.log.info(timepointData);
|
||||
|
||||
_.each(timepointData, timepoint => {
|
||||
delete timepoint._id;
|
||||
this.timepoints.insert(timepoint);
|
||||
const query = {
|
||||
timepointId: timepoint.timepointId
|
||||
};
|
||||
|
||||
this.timepoints.update(query, {
|
||||
$set: timepoint
|
||||
}, {
|
||||
upsert: true
|
||||
});
|
||||
});
|
||||
|
||||
resolve();
|
||||
}).catch(reason => {
|
||||
OHIF.log.error(`Timepoint retrieval function failed: ${reason}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+1
@@ -65,6 +65,7 @@ $bodyCellHeight = 30px
|
||||
&.timepointOptions
|
||||
label
|
||||
font-weight: 200
|
||||
cursor: pointer
|
||||
|
||||
input
|
||||
margin: 0 3px
|
||||
|
||||
@@ -27,7 +27,7 @@ Template.caseProgress.onCreated(() => {
|
||||
promise.then(successHandler).catch(errorHandler);
|
||||
OHIF.ui.showDialog('dialogLoading', {
|
||||
promise,
|
||||
text: 'Saving measurements data'
|
||||
text: 'Saving measurement data'
|
||||
});
|
||||
|
||||
return promise;
|
||||
|
||||
@@ -107,6 +107,7 @@ class MeasurementHandlers {
|
||||
Collection._c2._simpleSchema.clean(measurement);
|
||||
|
||||
// Insert the new measurement into the collection
|
||||
console.log(measurement);
|
||||
Collection.update(measurementId, {
|
||||
$set: measurement
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Npm.depends({
|
||||
ajv: '4.10.4',
|
||||
jspdf: '1.3.2'
|
||||
jspdf: '1.3.3'
|
||||
});
|
||||
|
||||
Package.describe({
|
||||
|
||||
+3
-2
@@ -138,8 +138,8 @@ function search() {
|
||||
patientId: getFilter($('input#patientId').val()),
|
||||
accessionNumber: getFilter($('input#accessionNumber').val()),
|
||||
studyDescription: getFilter($('input#studyDescription').val()),
|
||||
studyDateFrom: studyDateFrom,
|
||||
studyDateTo: studyDateTo,
|
||||
studyDateFrom,
|
||||
studyDateTo,
|
||||
modalitiesInStudy: $('input#modality').val() ? $('input#modality').val() : ''
|
||||
};
|
||||
|
||||
@@ -161,6 +161,7 @@ function search() {
|
||||
Session.set('showLoadingText', false);
|
||||
|
||||
if (!studies) {
|
||||
OHIF.log.warn('No studies found');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Blaze } from 'meteor/blaze';
|
||||
import * as Hammer from 'hammerjs';
|
||||
import Hammer from 'hammerjs';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
// Clear all selected studies
|
||||
|
||||
@@ -33,6 +33,17 @@ OHIF.studylist.retrieveStudyMetadata = studyInstanceUid => {
|
||||
Meteor.call('GetStudyMetadata', studyInstanceUid, function(error, study) {
|
||||
console.timeEnd('retrieveStudyMetadata');
|
||||
|
||||
if (error) {
|
||||
OHIF.log.error(error);
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!study) {
|
||||
reject(`GetStudyMetadata: No study data returned from server: ${studyInstanceUid}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.HipaaLogger && Meteor.user && Meteor.user()) {
|
||||
window.HipaaLogger.logEvent({
|
||||
eventType: 'viewed',
|
||||
@@ -45,16 +56,6 @@ OHIF.studylist.retrieveStudyMetadata = studyInstanceUid => {
|
||||
});
|
||||
}
|
||||
|
||||
if (error) {
|
||||
OHIF.log.warn(error);
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!study) {
|
||||
throw new Meteor.Error('GetStudyMetadata', 'No study data returned from server');
|
||||
}
|
||||
|
||||
// Once the data was retrieved, the series are sorted by series and instance number
|
||||
OHIF.viewerbase.sortStudy(study);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Package.describe({
|
||||
});
|
||||
|
||||
Npm.depends({
|
||||
hammerjs: '2.0.6'
|
||||
hammerjs: '2.0.8'
|
||||
});
|
||||
|
||||
Package.onUse(function(api) {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<template name="errorText">
|
||||
<div class="errorTextDiv">
|
||||
Error: {{ error }}
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,4 @@
|
||||
.errorTextDiv
|
||||
font-weight: 300
|
||||
padding: 30px
|
||||
text-align: center
|
||||
+3
-4
@@ -35,6 +35,7 @@ Template.imageThumbnail.onRendered(() => {
|
||||
const element = $element.get(0);
|
||||
|
||||
instance.refreshImage = () => {
|
||||
console.log('imageThumbnail refreshImage');
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
@@ -84,16 +85,14 @@ Template.imageThumbnail.onRendered(() => {
|
||||
});
|
||||
|
||||
Template.imageThumbnail.onDestroyed(() => {
|
||||
console.log('imagethumbnail onDestroyed');
|
||||
const instance = Template.instance();
|
||||
|
||||
// Declare DOM and jQuery objects
|
||||
const $parent = instance.$('.imageThumbnail');
|
||||
const $element = $parent.find('.imageThumbnailCanvas');
|
||||
const element = $element.get(0);
|
||||
|
||||
if (element) {
|
||||
cornerstone.disable(element);
|
||||
}
|
||||
cornerstone.disable(element);
|
||||
});
|
||||
|
||||
Template.imageThumbnail.helpers({
|
||||
|
||||
@@ -26,8 +26,8 @@ function createAndAddStack(stackMap, study, displaySet) {
|
||||
const metaData = {
|
||||
instance: image, // in this context, instance will be the data of the InstanceMetadata object...
|
||||
series: displaySet, // TODO: Check this
|
||||
study: study,
|
||||
numImages: numImages,
|
||||
study,
|
||||
numImages,
|
||||
imageIndex: imageIndex + 1
|
||||
};
|
||||
|
||||
@@ -40,8 +40,7 @@ function createAndAddStack(stackMap, study, displaySet) {
|
||||
imageIds.push(imageId);
|
||||
metadataProvider.addMetadata(imageId, metaData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
imageId = getImageId(image);
|
||||
imageIds.push(imageId);
|
||||
metadataProvider.addMetadata(imageId, metaData);
|
||||
@@ -50,7 +49,7 @@ function createAndAddStack(stackMap, study, displaySet) {
|
||||
|
||||
const stack = {
|
||||
displaySetInstanceUid: displaySet.displaySetInstanceUid,
|
||||
imageIds: imageIds,
|
||||
imageIds,
|
||||
frameRate: displaySet.frameRate,
|
||||
isClip: displaySet.isClip
|
||||
};
|
||||
@@ -61,7 +60,7 @@ function createAndAddStack(stackMap, study, displaySet) {
|
||||
}
|
||||
|
||||
configuration = {
|
||||
createAndAddStack: createAndAddStack
|
||||
createAndAddStack
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import { getInstanceClassDefaultViewport } from '../instanceClassSpecificViewpor
|
||||
export class ResizeViewportManager {
|
||||
constructor() {
|
||||
this._resizeHandler = null;
|
||||
OHIF.log.info('ResizeViewportManager');
|
||||
}
|
||||
|
||||
// Reposition Study Series Quick Switch based whether side bars are opened or not
|
||||
|
||||
@@ -118,12 +118,12 @@ class DICOMFileLoadingListener extends BaseLoadingListener {
|
||||
|
||||
this.stopListening();
|
||||
|
||||
$(cornerstone).on(imageLoadProgressEventName, imageLoadProgressEventHandle);
|
||||
$(cornerstone.events).on(imageLoadProgressEventName, imageLoadProgressEventHandle);
|
||||
}
|
||||
|
||||
stopListening() {
|
||||
const imageLoadProgressEventName = this._getImageLoadProgressEventName();
|
||||
$(cornerstone).off(imageLoadProgressEventName);
|
||||
$(cornerstone.events).off(imageLoadProgressEventName);
|
||||
}
|
||||
|
||||
_imageLoadProgressEventHandle(e, eventData) {
|
||||
@@ -241,16 +241,16 @@ class StackLoadingListener extends BaseLoadingListener {
|
||||
|
||||
this.stopListening();
|
||||
|
||||
$(cornerstone).on(imageLoadedEventName, imageLoadedEventHandle);
|
||||
$(cornerstone).on(imageCachePromiseRemovedEventName, imageCachePromiseRemovedEventHandle);
|
||||
$(cornerstone.events).on(imageLoadedEventName, imageLoadedEventHandle);
|
||||
$(cornerstone.events).on(imageCachePromiseRemovedEventName, imageCachePromiseRemovedEventHandle);
|
||||
}
|
||||
|
||||
stopListening() {
|
||||
const imageLoadedEventName = this._getImageLoadedEventName();
|
||||
const imageCachePromiseRemovedEventName = this._getImageCachePromiseRemoveEventName();
|
||||
|
||||
$(cornerstone).off(imageLoadedEventName);
|
||||
$(cornerstone).off(imageCachePromiseRemovedEventName);
|
||||
$(cornerstone.events).off(imageLoadedEventName);
|
||||
$(cornerstone.events).off(imageCachePromiseRemovedEventName);
|
||||
}
|
||||
|
||||
_updateFrameStatus(imageId, loaded) {
|
||||
|
||||
@@ -13,12 +13,12 @@ export class StudyPrefetcher {
|
||||
this.prefetchDisplaySetsTimeout = 300;
|
||||
this.lastActiveViewportElement = null;
|
||||
|
||||
$(cornerstone).on('CornerstoneImageCacheFull.StudyPrefetcher', _.bind(this.cacheFullHandler, this));
|
||||
$(cornerstone.events).on('CornerstoneImageCacheFull.StudyPrefetcher', _.bind(this.cacheFullHandler, this));
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.stopPrefetching();
|
||||
$(cornerstone).off('CornerstoneImageCacheFull.StudyPrefetcher');
|
||||
$(cornerstone.events).off('CornerstoneImageCacheFull.StudyPrefetcher');
|
||||
}
|
||||
|
||||
static getInstance() {
|
||||
@@ -162,7 +162,7 @@ export class StudyPrefetcher {
|
||||
|
||||
getStudy(image) {
|
||||
const studyMetadata = cornerstoneTools.metaData.get('study', image.imageId);
|
||||
return _.find(this.studies, study => study.studyInstanceUid === studyMetadata.studyInstanceUid);
|
||||
return OHIF.viewer.Studies.find(study => study.studyInstanceUid === studyMetadata.studyInstanceUid);
|
||||
}
|
||||
|
||||
getSeries(study, image) {
|
||||
@@ -191,6 +191,10 @@ export class StudyPrefetcher {
|
||||
}
|
||||
|
||||
const study = this.getStudy(image);
|
||||
if (!study.seriesList || !study.seriesList.length) {
|
||||
console.error(study);
|
||||
}
|
||||
|
||||
const series = this.getSeries(study, image);
|
||||
const instance = this.getInstance(series, image);
|
||||
const displaySets = study.displaySets;
|
||||
|
||||
@@ -22,5 +22,12 @@ export const renderViewer = (context, params, layoutTemplate='app') => {
|
||||
studies
|
||||
}
|
||||
});
|
||||
}).catch(error => {
|
||||
context.render(layoutTemplate, {
|
||||
data: {
|
||||
template: 'errorText',
|
||||
error
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -235,8 +235,8 @@ export const toolManager = {
|
||||
// Whenever the CornerstoneImageLoadProgress is fired, identify which viewports
|
||||
// the "in-progress" image is to be displayed in. Then pass the percent complete
|
||||
// via the Meteor Session to the other templates to be displayed in the relevant viewports.
|
||||
$(cornerstone).on('CornerstoneImageLoadProgress', (e, eventData) => {
|
||||
const viewportIndices = this.getKeysByValue(window.ViewportLoading, eventData.imageId);
|
||||
$(cornerstone.events).on('CornerstoneImageLoadProgress', (e, eventData) => {
|
||||
viewportIndices = this.getKeysByValue(window.ViewportLoading, eventData.imageId);
|
||||
viewportIndices.forEach(viewportIndex => {
|
||||
Session.set('CornerstoneLoadProgress' + viewportIndex, eventData.percentComplete);
|
||||
});
|
||||
|
||||
@@ -95,6 +95,8 @@ Package.onUse(function(api) {
|
||||
api.addFiles('client/components/basic/layout/layout.styl', 'client');
|
||||
api.addFiles('client/components/basic/loadingText/loadingText.html', 'client');
|
||||
api.addFiles('client/components/basic/loadingText/loadingText.styl', 'client');
|
||||
api.addFiles('client/components/basic/errorText/errorText.html', 'client');
|
||||
api.addFiles('client/components/basic/errorText/errorText.styl', 'client');
|
||||
|
||||
api.addFiles('client/components/basic/removableBackdrop/removableBackdrop.html', 'client');
|
||||
api.addFiles('client/components/basic/removableBackdrop/removableBackdrop.styl', 'client');
|
||||
|
||||
Reference in new issue
Block a user