LT-291: Allowing changing the non-targets location and response
This commit is contained in:
1 parent
135760659c
commit
630d8df51b
5 files changed
+82
-39
No files matched your search
@@ -1,10 +1,13 @@
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
(function($, cornerstone, cornerstoneMath, cornerstoneTools) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var toolType = 'nonTarget';
|
||||
const toolType = 'nonTarget';
|
||||
|
||||
var configuration = {
|
||||
const configuration = {
|
||||
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
||||
changeMeasurementLocationCallback: changeMeasurementLocationCallback,
|
||||
drawHandles: false,
|
||||
@@ -13,44 +16,60 @@
|
||||
};
|
||||
|
||||
// Used to cancel tool placement
|
||||
var keys = {
|
||||
const keys = {
|
||||
ESC: 27
|
||||
};
|
||||
|
||||
const toolMethods = {
|
||||
removeMeasurement() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const showLocationDialog = settings => {
|
||||
const dialogSettings = _.extend({
|
||||
title: 'Lesion Location',
|
||||
toolMethods
|
||||
}, settings);
|
||||
OHIF.ui.showFormDialog('dialogNonTargetMeasurement', dialogSettings);
|
||||
};
|
||||
|
||||
// Define a callback to get your text annotation
|
||||
// This could be used, e.g. to open a modal
|
||||
function getMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
||||
const dialogSettings = {
|
||||
function getMeasurementLocationCallback(measurementData, eventData) {
|
||||
showLocationDialog({
|
||||
title: 'Select Lesion Location',
|
||||
measurementData,
|
||||
eventData
|
||||
};
|
||||
OHIF.ui.showFormDialog('dialogNonTargetMeasurement', dialogSettings).then(formData => {
|
||||
doneCallback(formData.measurementNumber);
|
||||
});
|
||||
}
|
||||
|
||||
function changeMeasurementLocationCallback(measurementData, eventData, doneCallback) {
|
||||
doneCallback(prompt('Change your measurement location:'));
|
||||
function changeMeasurementLocationCallback(measurementData, eventData) {
|
||||
showLocationDialog({
|
||||
title: 'Select Lesion Location',
|
||||
measurementData,
|
||||
eventData,
|
||||
edit: true
|
||||
});
|
||||
}
|
||||
|
||||
/// --- Mouse Tool --- ///
|
||||
///////// BEGIN ACTIVE TOOL ///////
|
||||
function addNewMeasurement(mouseEventData) {
|
||||
var element = mouseEventData.element;
|
||||
const element = mouseEventData.element;
|
||||
|
||||
function doneCallback(measurementNumber) {
|
||||
measurementData.measurementNumber = measurementNumber;
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
var measurementData = createNewMeasurement(mouseEventData);
|
||||
const measurementData = createNewMeasurement(mouseEventData);
|
||||
|
||||
var eventData = {
|
||||
const eventData = {
|
||||
mouseButtonMask: mouseEventData.which
|
||||
};
|
||||
|
||||
var config = cornerstoneTools.nonTarget.getConfiguration();
|
||||
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);
|
||||
@@ -63,7 +82,7 @@
|
||||
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
|
||||
|
||||
// Add a flag for using Esc to cancel tool placement
|
||||
var cancelled = false;
|
||||
let cancelled = false;
|
||||
function cancelCallback(e) {
|
||||
// If the Esc key was pressed, set the flag to true
|
||||
if (e.which === keys.ESC) {
|
||||
@@ -284,8 +303,7 @@
|
||||
function addNewMeasurementTouch(touchEventData) {
|
||||
var element = touchEventData.element;
|
||||
|
||||
function doneCallback(measurementNumber) {
|
||||
measurementData.measurementNumber = measurementNumber;
|
||||
function doneCallback() {
|
||||
measurementData.active = true;
|
||||
cornerstone.updateImage(element);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<template name="dialogNonTargetMeasurement">
|
||||
{{#dialogForm (extend this dialogClass='modal-sm' schema=(choose this.schema instance.schema))}}
|
||||
{{>inputHidden key='measurementNumber'}}
|
||||
{{>inputSelect labelClass='form-group' key='location' hideSearch=true
|
||||
options=(clone placeholder='Choose a lesion location')}}
|
||||
{{>inputSelect labelClass='form-group' key='response' hideSearch=true
|
||||
|
||||
@@ -9,19 +9,18 @@ Template.dialogNonTargetMeasurement.onCreated(() => {
|
||||
|
||||
instance.schema = new SimpleSchema({
|
||||
location: FieldLesionLocation,
|
||||
response: FieldLesionLocationResponse,
|
||||
measurementNumber: {
|
||||
type: Number
|
||||
}
|
||||
response: FieldLesionLocationResponse
|
||||
});
|
||||
});
|
||||
|
||||
Template.dialogNonTargetMeasurement.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
const element = instance.data.eventData.element;
|
||||
|
||||
const form = instance.$('form').data('component');
|
||||
|
||||
const viewerMain = $(instance.data.eventData.element).closest('.viewerMain')[0];
|
||||
const viewerMain = $(element).closest('.viewerMain')[0];
|
||||
const viewerData = Blaze.getData(viewerMain);
|
||||
console.warn('>>>>dialogData/viewerData', instance.data, viewerData);
|
||||
|
||||
@@ -36,17 +35,27 @@ Template.dialogNonTargetMeasurement.onRendered(() => {
|
||||
_id: measurementData._id
|
||||
});
|
||||
|
||||
// Set the data that is already defined
|
||||
form.value(currentMeasurement);
|
||||
|
||||
// Synchronize the measurement number with the one inserted in the collection
|
||||
measurementData.measurementNumber = currentMeasurement.measurementNumber;
|
||||
|
||||
// Delete the measurement if dialog is closed
|
||||
// Refresh the image with the measurement number
|
||||
cornerstone.updateImage(element);
|
||||
|
||||
// Delete the measurement from collection when dialog is closed and not on edit mode
|
||||
instance.data.promise.catch(() => {
|
||||
if (instance.data.edit) {
|
||||
return;
|
||||
}
|
||||
|
||||
viewerData.measurementApi.deleteMeasurements('nonTargets', {
|
||||
_id: measurementData._id
|
||||
});
|
||||
|
||||
// Repaint the images on all viewports without the removed measurements
|
||||
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));
|
||||
// Refresh the image with the measurement removed
|
||||
cornerstone.updateImage(element);
|
||||
});
|
||||
|
||||
// Update the location and response after confirming the dialog data
|
||||
@@ -61,9 +70,4 @@ Template.dialogNonTargetMeasurement.onRendered(() => {
|
||||
});
|
||||
});
|
||||
|
||||
// Inject the measurement number in form data to enable the tool from getting the value
|
||||
form.value({
|
||||
measurementNumber: currentMeasurement.measurementNumber
|
||||
});
|
||||
|
||||
});
|
||||
Reference in new issue
Block a user