PWV-2: Exposing ohif:measurements package's lib functions on OHIF namespace

This commit is contained in:
Bruno Alves de Faria authored and Erik Ziegler committed 2016-11-15 08:21:46 +01:00
1 parent 60aa1d0982
commit 5c5c2afb42
23 files changed
+254 -344

No files matched your search

@@ -1,4 +1,4 @@
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
import { OHIF } from 'meteor/ohif:core';
function closeHandler(dialog) {
// Hide the lesion dialog
@@ -12,7 +12,6 @@ function closeHandler(dialog) {
}
// This event sets lesion number for new lesion
function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, timepointApi) {
return (measurementData, eventData, doneCallback) => {
// Get the current element's timepointId from the study date metadata
@@ -35,12 +34,12 @@ function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, t
// exists at a different timepoint
const timepointId = timepoint.timepointId;
const collection = measurementApi[measurementTypeId];
const measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
const measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
measurementData.measurementNumber = measurementNumber;
// Set lesion number
doneCallback(measurementNumber);
}
};
}
// This event determines whether or not to show the lesion dialog
@@ -71,7 +70,7 @@ function getLesionLocationCallback(measurementData, eventData) {
// Find out if this lesion number is already added in the lesion manager for another timepoint
// If it is, stop here because we don't need the dialog.
var locationUID = MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
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';
@@ -123,9 +122,9 @@ changeLesionLocationCallback = function(measurementData, eventData, doneCallback
// Show/Hide Convert To NonTarget option in measurementLocationRelabelDialog
if (measurementData.toolType === 'bidirectional') {
dialog.find("#convertToNonTarget").css("visibility", "visible");
dialog.find('#convertToNonTarget').css('visibility', 'visible');
} else {
dialog.find("#convertToNonTarget").css("visibility", "hidden");
dialog.find('#convertToNonTarget').css('visibility', 'hidden');
}
Template.measurementLocationDialog.dialog = dialog;
@@ -189,7 +188,6 @@ changeLesionLocationCallback = function(measurementData, eventData, doneCallback
});
};
Template.measurementLocationDialog.onCreated(() => {
const instance = Template.instance();
const measurementTypeId = 'targets';
@@ -268,7 +266,7 @@ Template.measurementLocationDialog.events({
var measurementData = Template.measurementLocationDialog.measurementData;
var dialog = Template.measurementLocationDialog.dialog;
const instance = Template.instance()
const instance = Template.instance();
const measurementApi = instance.data.measurementApi;
convertToNonTarget(measurementApi, measurementData);
@@ -290,7 +288,7 @@ Template.measurementLocationDialog.events({
});
Template.measurementLocationDialog.helpers({
measurementLocations: function() {
measurementLocations() {
return LesionLocations.find();
}
});
@@ -1,4 +1,4 @@
import { MeasurementManager } from 'meteor/ohif:measurements/client/lib/MeasurementManager';
import { OHIF } from 'meteor/ohif:core';
function closeHandler(dialog) {
// Hide the lesion dialog
@@ -31,12 +31,12 @@ function getSetLesionNumberCallbackFunction(measurementTypeId, measurementApi, t
// exists at a different timepoint
const timepointId = timepoint.timepointId;
const collection = measurementApi[measurementTypeId];
const measurementNumber = MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
const measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, collection, timepointApi);
measurementData.measurementNumber = measurementNumber;
// Set lesion number
doneCallback(measurementNumber);
}
};
}
function selectNonTargetResponse(responseCode) {
@@ -104,7 +104,7 @@ function getLesionLocationCallback(measurementData, eventData) {
// Find out if this lesion number is already added in the lesion manager for another timepoint
// If it is, disable selector location
var locationId = MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
var locationId = OHIF.measurements.MeasurementManager.getLocationIdIfMeasurementExists(measurementData);
if (locationId) {
// Add an ID value to the tool data to link it to the Measurements collection
measurementData.id = 'notready';
@@ -120,11 +120,11 @@ function getLesionLocationCallback(measurementData, eventData) {
var locationObject = LesionLocations.findOne({
id: locationId
});
if (!locationObject) {
return;
}
selectorLocation.find('option[value="' + locationObject._id + '"]').prop('selected', true);
selectorLocation.prop('disabled', true);
}
@@ -238,7 +238,6 @@ changeNonTargetLocationCallback = function(measurementData, eventData, doneCallb
selectNonTargetResponse(response);
};
Template.nonTargetLesionDialog.onCreated(() => {
const instance = Template.instance();
const measurementTypeId = 'nonTargets';
@@ -297,7 +296,9 @@ Template.nonTargetLesionDialog.events({
measurementData.isTarget = false;
// Response is set from location response list
measurementData.response = LocationResponses.findOne({selected: true}).code;
measurementData.response = LocationResponses.findOne({
selected: true
}).code;
// Adds lesion data to timepoints array
LesionManager.updateLesionData(measurementData);
@@ -1,18 +0,0 @@
/**
* Returns timepoint object given a specified imageId
*
* @param imageId
* @returns {*|{}} Timepoint object
*/
getTimepointObject = function(imageId) {
var study = cornerstoneTools.metaData.get('study', imageId);
if (!study) {
return;
}
return Timepoints.findOne({
studyInstanceUids: {
$in: [study.studyInstanceUid]
}
});
};
@@ -1,62 +0,0 @@
import { OHIF } from 'meteor/ohif:core';
function toolDataExists(toolState, imageId, toolType) {
const currentToolState = toolState[imageId][toolType];
return (currentToolState && currentToolState.data && currentToolState.data.length);
}
syncMeasurementAndToolData = function(measurement) {
OHIF.log.info('syncMeasurementAndToolData');
const toolState = cornerstoneTools.globalImageIdSpecificToolStateManager.toolState;
const imageId = measurement.imageId;
const toolType = measurement.toolType;
// If no tool state exists for this imageId, create an empty object to store it
if (!toolState[imageId]) {
toolState[imageId] = {};
}
// Check if we already have toolData for this imageId and toolType
if (toolDataExists(toolState, imageId, toolType)) {
// If we have toolData, we should search it for any toolData
// related to the current Measurement
const toolData = toolState[imageId][toolType].data;
// Create a flag so we know if we have successfully updated
// this Measurement's in the toolData
let alreadyExists = false;
// Loop through the toolData to search for this Measurement
toolData.forEach(function(tool) {
// Break the loop if this isn't the Measurement we are looking for
if (tool._id !== measurement._id) {
return;
}
// If we have found the Measurement, set the flag to True
alreadyExists = true;
// Update the toolData from the Measurement data
$.extend(tool, measurement);
return false;
});
// If we have found the Measurement we intended to update, we can stop
// this function here
if (alreadyExists === true) {
return;
}
} else {
// If no toolData exists for this toolType, create an empty array to hold some
toolState[imageId][toolType] = {
data: []
};
}
// If we have reached this point, it means we haven't found the Measurement we are
// looking for in the current toolData. This means we need to add it.
// Add the MeasurementData into the toolData for this imageId
toolState[imageId][toolType].data.push(measurement);
};
-3
View File
@@ -94,11 +94,8 @@ Package.onUse(function(api) {
api.addFiles('lib/convertToNonTarget.js', 'client');
api.addFiles('lib/convertNonTarget.js', 'client');
api.addFiles('lib/syncMeasurementAndToolData.js', 'client');
// Export global functions
api.export('pixelSpacingAutorunCheck', 'client');
api.export('syncMeasurementAndToolData', 'client');
api.export('syncImageMeasurementAndToolData', 'client');
api.export('openNewTabWithTimepoint', 'client');
api.export('toggleLesionTrackerTools', 'client');