LT-348: Store and reapply window / level values when creating / activating a measurement

This commit is contained in:
Erik Ziegler 2016-11-17 12:32:47 +01:00
parent d48c8508f8
commit a99fe33620
4 changed files with 108 additions and 0 deletions

View File

@ -111,6 +111,7 @@
}
var measurementData = createNewMeasurement(mouseEventData);
measurementData.viewport = cornerstone.getViewport(element);
var eventData = {
mouseButtonMask: mouseEventData.which

View File

@ -59,6 +59,7 @@ import { OHIF } from 'meteor/ohif:core';
}
const measurementData = createNewMeasurement(mouseEventData);
measurementData.viewport = cornerstone.getViewport(element);
const eventData = {
mouseButtonMask: mouseEventData.which

View File

@ -74,6 +74,81 @@ const SeriesLevelMeasurement = new SimpleSchema([
}
]);
const CornerstoneVOI = new SimpleSchema({
windowWidth: {
type: Number,
label: 'Window Width',
decimal: true,
optional: true
},
windowCenter: {
type: Number,
label: 'Window Center',
decimal: true,
optional: true
},
});
const CornerstoneViewportTranslation = new SimpleSchema({
x: {
type: Number,
label: 'X',
decimal: true,
optional: true
},
y: {
type: Number,
label: 'Y',
decimal: true,
optional: true
},
});
const CornerstoneViewport = new SimpleSchema({
scale: {
type: Number,
label: 'Scale',
decimal: true,
optional: true
},
translation: {
type: CornerstoneViewportTranslation,
label: 'Translation',
optional: true
},
voi: {
type: CornerstoneVOI,
label: 'VOI',
optional: true
},
invert: {
type: Boolean,
label: 'Invert',
optional: true
},
pixelReplication: {
type: Boolean,
label: 'Pixel Replication',
optional: true
},
hFlip: {
type: Boolean,
label: 'Horizontal Flip',
optional: true
},
vFlip: {
type: Boolean,
label: 'Vertical Flip',
optional: true
},
rotation: {
type: Number,
label: 'Rotation (degrees)',
decimal: true,
optional: true
}
})
const InstanceLevelMeasurement = new SimpleSchema([
StudyLevelMeasurement,
SeriesLevelMeasurement,
@ -81,6 +156,11 @@ const InstanceLevelMeasurement = new SimpleSchema([
sopInstanceUid: {
type: String,
label: 'SOP Instance UID'
},
viewport: {
type: CornerstoneViewport,
label: 'Viewport Parameters',
optional: true
}
}
]);

View File

@ -31,6 +31,32 @@ function activateTool(measurementData) {
OHIF.measurements.activateMeasurements = (element, measurementData) => {
console.log('activateMeasurements');
// If Cornerstone Viewport information was stored while the measurement was created,
// we should re-apply this data when activating the measurement.
const viewport = cornerstone.getViewport(element);
// TODO: Make this an option somewhere? For now we only want to apply windowWidth and
// windowCenter
const viewportPropertiesToUpdate = ['voi'];
// Check to make sure we actually stored viewport data before trying to apply it
if (measurementData.viewport) {
// For each property which is not undefined, update it's value from the stored
// measurement data
viewportPropertiesToUpdate.forEach(prop => {
const storedPropertyValue = measurementData.viewport[prop];
if (storedPropertyValue === undefined) {
return;
}
viewport[prop] = storedPropertyValue;
});
// Apply the updated viewport parameters to the element
cornerstone.setViewport(element, viewport);
}
// Activate the tool in the tool data
activateTool(measurementData);