LT-55: Generating an image for each measurement
This commit is contained in:
parent
c6a710aacd
commit
cea42aacdd
@ -1,7 +1,7 @@
|
||||
<template name="measurementTableView">
|
||||
<div class="measurementTableView scrollArea">
|
||||
{{#let config=measurementConfiguration measurementGroups=getMeasurementsGroupedByNumber}}
|
||||
{{#each measurementGroup in measurementGroups}}
|
||||
{{#let config=measurementConfiguration}}
|
||||
{{#each measurementGroup in measurementGroups.get}}
|
||||
{{>measurementTableHeaderRow (clone this
|
||||
toolGroup=measurementGroup.toolGroup
|
||||
measurementRows=measurementGroup.measurementRows)}}
|
||||
@ -31,5 +31,6 @@
|
||||
{{/let}}
|
||||
{{/if}}
|
||||
{{/let}}
|
||||
<div class="btn btn-primary js-pdf">Export PDF</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -1,7 +1,27 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
Template.measurementTableView.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
const { measurementApi, timepointApi } = instance.data;
|
||||
|
||||
instance.data.measurementGroups = new ReactiveVar();
|
||||
|
||||
Tracker.autorun(() => {
|
||||
measurementApi.changeObserver.depend();
|
||||
const data = OHIF.measurements.getMeasurementsGroupedByNumber(measurementApi, timepointApi);
|
||||
instance.data.measurementGroups.set(data);
|
||||
});
|
||||
});
|
||||
|
||||
Template.measurementTableView.events({
|
||||
'click .js-pdf'(event, instance) {
|
||||
OHIF.measurements.exportPdf(instance.data.measurementGroups.get());
|
||||
}
|
||||
});
|
||||
|
||||
Template.measurementTableView.helpers({
|
||||
getNewMeasurementType(tool) {
|
||||
// TODO: Check Conformance criteria here.
|
||||
@ -14,11 +34,6 @@ Template.measurementTableView.helpers({
|
||||
};
|
||||
},
|
||||
|
||||
getMeasurementsGroupedByNumber() {
|
||||
const { measurementApi, timepointApi } = Template.instance().data;
|
||||
return OHIF.measurements.getMeasurementsGroupedByNumber(measurementApi, timepointApi);
|
||||
},
|
||||
|
||||
newMeasurements(measurementType) {
|
||||
const instance = Template.instance();
|
||||
const measurementApi = instance.data.measurementApi;
|
||||
|
||||
@ -6,6 +6,49 @@ import html2canvas from 'html2canvas';
|
||||
window.jsPDF = jsPDF;
|
||||
window.html2canvas = html2canvas;
|
||||
|
||||
OHIF.measurements.exportPdf = measurementGroups => {
|
||||
console.warn('>>>>Adding canvas to body', measurementGroups);
|
||||
|
||||
const $element = $('<div></div>').css({
|
||||
border: '1px solid red',
|
||||
height: 1000,
|
||||
left: 0,
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
width: 1000,
|
||||
'z-index': 100000
|
||||
});
|
||||
|
||||
$element.appendTo(document.body);
|
||||
|
||||
const element = $element[0];
|
||||
|
||||
cornerstone.enable(element, { renderer: 'webgl' });
|
||||
|
||||
const measurements = {
|
||||
targets: [],
|
||||
nonTargets: []
|
||||
};
|
||||
measurementGroups.forEach(measurementGroup => {
|
||||
const { toolGroup, measurementRows } = measurementGroup;
|
||||
measurementRows.forEach(rowItem => {
|
||||
rowItem.entries.forEach(entry => measurements[toolGroup.id].push(entry));
|
||||
});
|
||||
});
|
||||
|
||||
let i = 0;
|
||||
measurements.targets.forEach(target => {
|
||||
setTimeout(() => {
|
||||
cornerstone.loadImage(target.imageId).then(image => {
|
||||
cornerstone.displayImage(element, image);
|
||||
});
|
||||
}, i * 1000);
|
||||
i++;
|
||||
});
|
||||
|
||||
setTimeout(() => $element.remove(), i * 1000);
|
||||
};
|
||||
|
||||
// window.exportCanvasToPdf = canvas => {
|
||||
// // only jpeg is supported by jsPDF
|
||||
// const imgData = canvas.toDataURL('image/jpeg', 1.0);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
Npm.depends({
|
||||
ajv: '4.10.4',
|
||||
jspdf: '1.3.2',
|
||||
html2canvas: '0.5.0-beta4'
|
||||
html2canvas: '0.5.0-beta4',
|
||||
pdfmake: '0.1.24'
|
||||
});
|
||||
|
||||
Package.describe({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user