Updates to save viewport data across sessions / while switching tabs
This commit is contained in:
1 parent
56417df385
commit
4721400b34
27 files changed
+585
-204
No files matched your search
@@ -0,0 +1,57 @@
|
||||
// Example usage for something like RECIST
|
||||
var tumourLengthMeasurementManager = cornerstoneTools.MeasurementManager;
|
||||
function singleValidator(measurement) {
|
||||
var result = {
|
||||
isValid: true
|
||||
};
|
||||
if (measurement.distance < 10) {
|
||||
result.isValid = false;
|
||||
result.details = 'Measurement distance must be less than 10 mm';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function setValidator(measurements) {
|
||||
var result = {
|
||||
isValid: true
|
||||
};
|
||||
if (measurements.length > 2) {
|
||||
result.isValid = false;
|
||||
result.details = 'The number of measurements per image must be less than 2';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Or a remote call
|
||||
function remoteSetValidator(measurements) {
|
||||
var deferred = $.Deferred;
|
||||
|
||||
var result = {
|
||||
isValid: true,
|
||||
promise: deferred.promise()
|
||||
};
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
if (xhr.status == 200) {
|
||||
var response = JSON.parse(xhr.response);
|
||||
if (response.isValid) {
|
||||
deferred.resolve(xhr.responseText);
|
||||
} else {
|
||||
deferred.reject(xhr.responseText);
|
||||
}
|
||||
} else {
|
||||
// The request didn't succeed
|
||||
deferred.reject(xhr.responseText);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.open("POST", "/urlToValidateRECIST", true);
|
||||
xhr.send(measurements);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
tumourLengthMeasurementManager.setSingleMeasurementValidator(singleValidator);
|
||||
tumourLengthMeasurementManager.setMeasurementSetValidator(setValidator);
|
||||
Reference in new issue
Block a user