LT-305: Small fixes related to find/replace and target measurement functions being pulled from old code. Temporarily removed CR/UN/EX tools
This commit is contained in:
1 parent
16f7b39b44
commit
adb8e76aef
8 files changed
+43
-256
No files matched your search
+19
-212
@@ -1,16 +1,7 @@
|
||||
// Note: This component is not in use, but the functions below are still being used. This
|
||||
// is in the process of being moved into another location
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
function closeHandler(dialog) {
|
||||
// Hide the measurement dialog
|
||||
$(dialog).css('display', 'none');
|
||||
|
||||
// Remove the backdrop
|
||||
$('.removableBackdrop').remove();
|
||||
|
||||
// Restore the focus to the active viewport
|
||||
setFocusToActiveViewport();
|
||||
}
|
||||
|
||||
// This event sets measurement number for new measurement
|
||||
function getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
|
||||
return (measurementData, eventData, doneCallback) => {
|
||||
@@ -42,162 +33,28 @@ function getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementA
|
||||
};
|
||||
}
|
||||
|
||||
// This event determines whether or not to show the measurement dialog
|
||||
// If there already exists a measurement with this specific measurement number,
|
||||
// related to the chosen location.
|
||||
function getMeasurementLocationCallback(measurementData, eventData) {
|
||||
return;
|
||||
Template.measurementLocationDialog.measurementData = measurementData;
|
||||
|
||||
// Reset the doneCallback saved in the template so we don't call the change event's done callback
|
||||
Template.measurementLocationDialog.doneCallback = undefined;
|
||||
|
||||
// Get the measurement location dialog
|
||||
var dialog = $('#measurementLocationDialog');
|
||||
Template.measurementLocationDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||
closeHandler(dialog);
|
||||
});
|
||||
|
||||
// Select the first option for now
|
||||
var selector = dialog.find('select.selectMeasurementLocation');
|
||||
selector.find('option:first').prop('selected', true);
|
||||
|
||||
// Find out if this measurement number is already added in the measurement manager for another timepoint
|
||||
// If it is, stop here because we don't need the dialog.
|
||||
var locationUID = OHIF.measurements.MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
|
||||
if (locationUID) {
|
||||
// Add an ID value to the tool data to link it to the Measurements collection
|
||||
measurementData.id = 'notready';
|
||||
|
||||
measurementData.locationUID = locationUID;
|
||||
MeasurementManager.updateMeasurementData(measurementData);
|
||||
closeHandler();
|
||||
return;
|
||||
}
|
||||
// If it isn't, continue to open the dialog and have the user choose a measurement location
|
||||
|
||||
// Show the measurement location dialog above
|
||||
var dialogProperty = {
|
||||
top: eventData.currentPoints.page.y - dialog.outerHeight() - 40,
|
||||
left: eventData.currentPoints.page.x - dialog.outerWidth() / 2,
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
var pageHeight = $(window).height();
|
||||
dialogProperty.top = Math.max(dialogProperty.top, 0);
|
||||
dialogProperty.top = Math.min(dialogProperty.top, pageHeight - dialog.outerHeight());
|
||||
|
||||
var pageWidth = $(window).width();
|
||||
dialogProperty.left = Math.max(dialogProperty.left, 0);
|
||||
dialogProperty.left = Math.min(dialogProperty.left, pageWidth - dialog.outerWidth());
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass('dialogMobile');
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
dialog.focus();
|
||||
}
|
||||
|
||||
changeMeasurementLocationCallback = function(measurementData, eventData, doneCallback) {
|
||||
return;
|
||||
Template.measurementLocationDialog.measurementData = measurementData;
|
||||
Template.measurementLocationDialog.doneCallback = doneCallback;
|
||||
|
||||
// Get the measurement location dialog
|
||||
var dialog = $('#measurementLocationRelabelDialog');
|
||||
|
||||
// Show/Hide Convert To NonTarget option in measurementLocationRelabelDialog
|
||||
if (measurementData.toolType === 'bidirectional') {
|
||||
dialog.find('#convertToNonTarget').css('visibility', 'visible');
|
||||
} else {
|
||||
dialog.find('#convertToNonTarget').css('visibility', 'hidden');
|
||||
}
|
||||
|
||||
Template.measurementLocationDialog.dialog = dialog;
|
||||
|
||||
// Show the backdrop
|
||||
UI.render(Template.removableBackdrop, document.body);
|
||||
|
||||
// Make sure the context menu is closed when the user clicks away
|
||||
$('.removableBackdrop').one('mousedown touchstart', function() {
|
||||
closeHandler(dialog);
|
||||
});
|
||||
|
||||
// Show the measurement location dialog above
|
||||
var dialogProperty = {
|
||||
display: 'block'
|
||||
};
|
||||
|
||||
// Device is touch device or not
|
||||
// If device is touch device, set position center of screen vertically and horizontally
|
||||
if (!eventData || isTouchDevice()) {
|
||||
// add dialogMobile class to provide a black,transparent background
|
||||
dialog.addClass('dialogMobile');
|
||||
dialogProperty.top = 0;
|
||||
dialogProperty.left = 0;
|
||||
dialogProperty.right = 0;
|
||||
dialogProperty.bottom = 0;
|
||||
} else {
|
||||
dialogProperty.top = eventData.currentPoints.page.y - dialog.outerHeight() - 40;
|
||||
dialogProperty.left = eventData.currentPoints.page.x - dialog.outerWidth() / 2;
|
||||
}
|
||||
|
||||
dialog.css(dialogProperty);
|
||||
dialog.focus();
|
||||
|
||||
var measurement = Measurements.findOne(measurementData.id);
|
||||
if (!measurement) {
|
||||
return;
|
||||
}
|
||||
|
||||
MeasurementLocations.update({},
|
||||
{
|
||||
$set: {
|
||||
selected: false
|
||||
}
|
||||
}, {
|
||||
multi: true
|
||||
});
|
||||
|
||||
var currentLocation = MeasurementLocations.findOne({
|
||||
id: measurement.locationId
|
||||
});
|
||||
|
||||
if (!currentLocation) {
|
||||
return;
|
||||
}
|
||||
|
||||
MeasurementLocations.update(currentLocation._id, {
|
||||
$set: {
|
||||
selected: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Template.measurementLocationDialog.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const measurementTypeId = 'targets';
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
const timepointApi = instance.data.timepointApi;
|
||||
|
||||
const toggleLabel = (measurementData, eventdata, doneCallback) => {
|
||||
OHIF.measurements.toggleLabelButton({
|
||||
instance,
|
||||
measurementId: measurementData._id,
|
||||
toolType: measurementData.toolType,
|
||||
element: eventdata.element,
|
||||
measurementApi: instance.data.measurementApi,
|
||||
position: eventdata.currentPoints.page
|
||||
});
|
||||
};
|
||||
|
||||
const config = {
|
||||
setMeasurementNumberCallback: getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi),
|
||||
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
||||
changeMeasurementLocationCallback: changeMeasurementLocationCallback
|
||||
// TODO: Check the position for these, the Add Label button position seems very awkward
|
||||
getMeasurementLocationCallback: toggleLabel,
|
||||
changeMeasurementLocationCallback: toggleLabel,
|
||||
};
|
||||
|
||||
cornerstoneTools.bidirectional.setConfiguration(config);
|
||||
@@ -209,39 +66,8 @@ Template.measurementLocationDialog.onCreated(() => {
|
||||
|
||||
});
|
||||
|
||||
// Note: None of these events work anymore
|
||||
Template.measurementLocationDialog.events({
|
||||
'change .selectMeasurementLocation': function(e) {
|
||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||
var doneCallback = Template.measurementLocationDialog.doneCallback;
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
// Get the current value of the selector
|
||||
var selectedOptionId = e.currentTarget.value;
|
||||
|
||||
// If the selected option is still the default (-1)
|
||||
// then stop here
|
||||
if (selectedOptionId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get selected location data
|
||||
var locationObj = MeasurementLocations.findOne({
|
||||
_id: selectedOptionId
|
||||
});
|
||||
|
||||
Measurements.update(measurementData.id, {
|
||||
$set: {
|
||||
locationId: locationObj.id,
|
||||
}
|
||||
});
|
||||
|
||||
// Close the dialog
|
||||
closeHandler(dialog);
|
||||
|
||||
if (doneCallback && typeof doneCallback === 'function') {
|
||||
doneCallback(measurementData);
|
||||
}
|
||||
},
|
||||
'click #removeMeasurement': function() {
|
||||
var measurementData = Template.measurementLocationDialog.measurementData;
|
||||
var doneCallback = Template.measurementLocationDialog.doneCallback;
|
||||
@@ -268,27 +94,8 @@ Template.measurementLocationDialog.events({
|
||||
|
||||
const instance = Template.instance();
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
OHIF.measurementtracker.convertToNonTarget(measurementApi, measurementData);
|
||||
OHIF.measurementTracker.convertToNonTarget(measurementApi, measurementData);
|
||||
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'click #btnCloseMeasurementPopup': function() {
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
closeHandler(dialog);
|
||||
},
|
||||
'keydown #measurementLocationDialog, keydown #measurementLocationRelabelDialog': function(e) {
|
||||
var dialog = Template.measurementLocationDialog.dialog;
|
||||
|
||||
// If Esc or Enter are pressed, close the dialog
|
||||
if (e.which === keys.ESC || e.which === keys.ENTER) {
|
||||
closeHandler(dialog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.measurementLocationDialog.helpers({
|
||||
measurementLocations() {
|
||||
return MeasurementLocations.find();
|
||||
}
|
||||
});
|
||||
});
|
||||
+2
-2
@@ -247,10 +247,10 @@ Template.nonTargetMeasurementDialog.onCreated(() => {
|
||||
const config = {
|
||||
setMeasurementNumberCallback: getSetMeasurementNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi),
|
||||
getMeasurementLocationCallback: getMeasurementLocationCallback,
|
||||
changeMeasurementLocationCallback: changeMeasurementLocationCallback
|
||||
changeMeasurementLocationCallback: () => {}
|
||||
};
|
||||
|
||||
//cornerstoneTools.nonTarget.setConfiguration(config);
|
||||
cornerstoneTools.nonTarget.setConfiguration(config);
|
||||
});
|
||||
|
||||
Template.nonTargetMeasurementDialog.events({
|
||||
|
||||
Reference in new issue
Block a user