Fixing issues with PDF report

This commit is contained in:
Bruno Alves de Faria 2017-03-02 13:40:01 -03:00
parent d2dfe10513
commit f91fc1c897

View File

@ -1,5 +1,6 @@
import { OHIF } from 'meteor/ohif:core'; import { OHIF } from 'meteor/ohif:core';
import { MeasurementReport } from 'meteor/ohif:measurements/client/reports/measurement'; import { MeasurementReport } from 'meteor/ohif:measurements/client/reports/measurement';
import { $ } from 'meteor/jquery';
OHIF.measurements.exportPdf = (measurementApi, timepointApi) => { OHIF.measurements.exportPdf = (measurementApi, timepointApi) => {
const currentTimepoint = timepointApi.current(); const currentTimepoint = timepointApi.current();
@ -45,8 +46,10 @@ OHIF.measurements.exportPdf = (measurementApi, timepointApi) => {
const measurement = current.value; const measurement = current.value;
cornerstone.loadImage(measurement.imageId).then(image => { cornerstone.loadImage(measurement.imageId).then(image => {
const state = Object.assign({}, measurement, { active: true });
cornerstoneTools.clearToolState(element, measurement.toolType);
cornerstone.displayImage(element, image); cornerstone.displayImage(element, image);
cornerstoneTools.addToolState(element, measurement.toolType, measurement); cornerstoneTools.addToolState(element, measurement.toolType, state);
cornerstoneTools[measurement.toolType].enable(element); cornerstoneTools[measurement.toolType].enable(element);
const series = cornerstoneTools.metaData.get('series', measurement.imageId); const series = cornerstoneTools.metaData.get('series', measurement.imageId);
@ -66,16 +69,17 @@ OHIF.measurements.exportPdf = (measurementApi, timepointApi) => {
let type = measurementApi.toolsGroupsMap[measurement.toolType]; let type = measurementApi.toolsGroupsMap[measurement.toolType];
type = type === 'targets' ? 'Target' : 'Non-target'; type = type === 'targets' ? 'Target' : 'Non-target';
report.printMeasurement({ $element.one('CornerstoneImageRendered', () => {
type, report.printMeasurement({
number: measurement.measurementNumber, type,
location: OHIF.measurements.getLocationLabel(measurement.location) || '', number: measurement.measurementNumber,
info, location: OHIF.measurements.getLocationLabel(measurement.location) || '',
image: enabledElement.canvas.toDataURL('image/jpeg', 0.85) info,
image: enabledElement.canvas.toDataURL('image/jpeg', 0.85)
});
}); });
cornerstoneTools.clearToolState(element, measurement.toolType);
printMeasurements(callback); setTimeout(() => printMeasurements(callback));
}); });
}; };