LT-291: Allowing changing the non-targets location and response

This commit is contained in:
Bruno Alves de Faria 2016-11-14 16:59:28 -02:00 committed by Erik Ziegler
parent 135760659c
commit 630d8df51b
5 changed files with 82 additions and 39 deletions

View File

@ -51,6 +51,9 @@ label.form-group
-ms-user-select: none -ms-user-select: none
user-select: none user-select: none
.btn
transition(background-color 0.3s ease)
.modal-dialog .modal-dialog
.modal-content .modal-content
theme('background', '$primaryBackgroundColor') theme('background', '$primaryBackgroundColor')
@ -63,3 +66,15 @@ label.form-group
button.close button.close
theme('color', '$textSecondaryColor') theme('color', '$textSecondaryColor')
opacity: 1 opacity: 1
overflow: hidden
text-align: center
text-shadow: none
width: 20px
span
display: block
line-height: 20px
transition(transform 0.3s ease)
&:hover span
transform(rotate(180deg))

View File

@ -3,13 +3,19 @@
// TODO: [design] can't we use colors that are already in common pallete? // TODO: [design] can't we use colors that are already in common pallete?
$gray1 = #C3C3C3 $gray1 = #C3C3C3
$gray2 = #B6B6B6 $gray2 = #B6B6B6
$gray3 = #676767 $gray3 = #A6A6A6
$gray4 = #3E3E3E $gray4 = #676767
$gray5 = #3E3E3E
$borderRadius = 2px $borderRadius = 2px
span.select2.select2-container span.select2.select2-container
font-weight: normal font-weight: normal
span.select2-selection
&:hover, &:focus
span.select2-selection__arrow
background-color: $gray3
span.select2-selection span.select2-selection
border: 0 border: 0
border-radius: $borderRadius border-radius: $borderRadius
@ -28,6 +34,7 @@ span.select2.select2-container
border-bottom-right-radius: $borderRadius border-bottom-right-radius: $borderRadius
right: 0 right: 0
top: 0 top: 0
transition(background-color 0.3s ease)
width: 20px width: 20px
b b
@ -38,20 +45,20 @@ span.select2.select2-container
min-height: 30px min-height: 30px
input.select2-search__field input.select2-search__field
color: $gray4 color: $gray5
placeholder-color($gray4) placeholder-color($gray5)
li.select2-selection__choice li.select2-selection__choice
theme('border-color', '$uiGray') theme('border-color', '$uiGray')
background-color: #FFF background-color: #FFF
border-radius: $borderRadius border-radius: $borderRadius
color: $gray4 color: $gray5
font-size: 12px font-size: 12px
line-height: 22px line-height: 22px
margin-top: 3px margin-top: 3px
span.select2-selection__choice__remove span.select2-selection__choice__remove
color: $gray3 color: $gray4
float: right float: right
font-size: 20px font-size: 20px
font-weight: 300 font-weight: 300

View File

@ -1,10 +1,13 @@
import { _ } from 'meteor/underscore';
import { OHIF } from 'meteor/ohif:core';
(function($, cornerstone, cornerstoneMath, cornerstoneTools) { (function($, cornerstone, cornerstoneMath, cornerstoneTools) {
'use strict'; 'use strict';
var toolType = 'nonTarget'; const toolType = 'nonTarget';
var configuration = { const configuration = {
getMeasurementLocationCallback: getMeasurementLocationCallback, getMeasurementLocationCallback: getMeasurementLocationCallback,
changeMeasurementLocationCallback: changeMeasurementLocationCallback, changeMeasurementLocationCallback: changeMeasurementLocationCallback,
drawHandles: false, drawHandles: false,
@ -13,44 +16,60 @@
}; };
// Used to cancel tool placement // Used to cancel tool placement
var keys = { const keys = {
ESC: 27 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 // Define a callback to get your text annotation
// This could be used, e.g. to open a modal // This could be used, e.g. to open a modal
function getMeasurementLocationCallback(measurementData, eventData, doneCallback) { function getMeasurementLocationCallback(measurementData, eventData) {
const dialogSettings = { showLocationDialog({
title: 'Select Lesion Location', title: 'Select Lesion Location',
measurementData, measurementData,
eventData eventData
};
OHIF.ui.showFormDialog('dialogNonTargetMeasurement', dialogSettings).then(formData => {
doneCallback(formData.measurementNumber);
}); });
} }
function changeMeasurementLocationCallback(measurementData, eventData, doneCallback) { function changeMeasurementLocationCallback(measurementData, eventData) {
doneCallback(prompt('Change your measurement location:')); showLocationDialog({
title: 'Select Lesion Location',
measurementData,
eventData,
edit: true
});
} }
/// --- Mouse Tool --- /// /// --- Mouse Tool --- ///
///////// BEGIN ACTIVE TOOL /////// ///////// BEGIN ACTIVE TOOL ///////
function addNewMeasurement(mouseEventData) { function addNewMeasurement(mouseEventData) {
var element = mouseEventData.element; const element = mouseEventData.element;
function doneCallback(measurementNumber) { function doneCallback() {
measurementData.measurementNumber = measurementNumber;
measurementData.active = true; measurementData.active = true;
cornerstone.updateImage(element); cornerstone.updateImage(element);
} }
var measurementData = createNewMeasurement(mouseEventData); const measurementData = createNewMeasurement(mouseEventData);
var eventData = { const eventData = {
mouseButtonMask: mouseEventData.which 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 // associate this data with this imageId so we can render it and manipulate it
cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData); cornerstoneTools.addToolState(mouseEventData.element, toolType, measurementData);
@ -63,7 +82,7 @@
$(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback); $(element).off('CornerstoneToolsMouseDoubleClick', doubleClickCallback);
// Add a flag for using Esc to cancel tool placement // Add a flag for using Esc to cancel tool placement
var cancelled = false; let cancelled = false;
function cancelCallback(e) { function cancelCallback(e) {
// If the Esc key was pressed, set the flag to true // If the Esc key was pressed, set the flag to true
if (e.which === keys.ESC) { if (e.which === keys.ESC) {
@ -284,8 +303,7 @@
function addNewMeasurementTouch(touchEventData) { function addNewMeasurementTouch(touchEventData) {
var element = touchEventData.element; var element = touchEventData.element;
function doneCallback(measurementNumber) { function doneCallback() {
measurementData.measurementNumber = measurementNumber;
measurementData.active = true; measurementData.active = true;
cornerstone.updateImage(element); cornerstone.updateImage(element);
} }

View File

@ -1,6 +1,5 @@
<template name="dialogNonTargetMeasurement"> <template name="dialogNonTargetMeasurement">
{{#dialogForm (extend this dialogClass='modal-sm' schema=(choose this.schema instance.schema))}} {{#dialogForm (extend this dialogClass='modal-sm' schema=(choose this.schema instance.schema))}}
{{>inputHidden key='measurementNumber'}}
{{>inputSelect labelClass='form-group' key='location' hideSearch=true {{>inputSelect labelClass='form-group' key='location' hideSearch=true
options=(clone placeholder='Choose a lesion location')}} options=(clone placeholder='Choose a lesion location')}}
{{>inputSelect labelClass='form-group' key='response' hideSearch=true {{>inputSelect labelClass='form-group' key='response' hideSearch=true

View File

@ -9,19 +9,18 @@ Template.dialogNonTargetMeasurement.onCreated(() => {
instance.schema = new SimpleSchema({ instance.schema = new SimpleSchema({
location: FieldLesionLocation, location: FieldLesionLocation,
response: FieldLesionLocationResponse, response: FieldLesionLocationResponse
measurementNumber: {
type: Number
}
}); });
}); });
Template.dialogNonTargetMeasurement.onRendered(() => { Template.dialogNonTargetMeasurement.onRendered(() => {
const instance = Template.instance(); const instance = Template.instance();
const element = instance.data.eventData.element;
const form = instance.$('form').data('component'); 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); const viewerData = Blaze.getData(viewerMain);
console.warn('>>>>dialogData/viewerData', instance.data, viewerData); console.warn('>>>>dialogData/viewerData', instance.data, viewerData);
@ -36,17 +35,27 @@ Template.dialogNonTargetMeasurement.onRendered(() => {
_id: measurementData._id _id: measurementData._id
}); });
// Set the data that is already defined
form.value(currentMeasurement);
// Synchronize the measurement number with the one inserted in the collection // Synchronize the measurement number with the one inserted in the collection
measurementData.measurementNumber = currentMeasurement.measurementNumber; 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(() => { instance.data.promise.catch(() => {
if (instance.data.edit) {
return;
}
viewerData.measurementApi.deleteMeasurements('nonTargets', { viewerData.measurementApi.deleteMeasurements('nonTargets', {
_id: measurementData._id _id: measurementData._id
}); });
// Repaint the images on all viewports without the removed measurements // Refresh the image with the measurement removed
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element)); cornerstone.updateImage(element);
}); });
// Update the location and response after confirming the dialog data // 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
});
}); });