LT-55: Generating an image for each measurement
This commit is contained in:
parent
c6a710aacd
commit
cea42aacdd
@ -1,7 +1,7 @@
|
|||||||
<template name="measurementTableView">
|
<template name="measurementTableView">
|
||||||
<div class="measurementTableView scrollArea">
|
<div class="measurementTableView scrollArea">
|
||||||
{{#let config=measurementConfiguration measurementGroups=getMeasurementsGroupedByNumber}}
|
{{#let config=measurementConfiguration}}
|
||||||
{{#each measurementGroup in measurementGroups}}
|
{{#each measurementGroup in measurementGroups.get}}
|
||||||
{{>measurementTableHeaderRow (clone this
|
{{>measurementTableHeaderRow (clone this
|
||||||
toolGroup=measurementGroup.toolGroup
|
toolGroup=measurementGroup.toolGroup
|
||||||
measurementRows=measurementGroup.measurementRows)}}
|
measurementRows=measurementGroup.measurementRows)}}
|
||||||
@ -31,5 +31,6 @@
|
|||||||
{{/let}}
|
{{/let}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/let}}
|
{{/let}}
|
||||||
|
<div class="btn btn-primary js-pdf">Export PDF</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -1,7 +1,27 @@
|
|||||||
import { Template } from 'meteor/templating';
|
import { Template } from 'meteor/templating';
|
||||||
|
import { Tracker } from 'meteor/tracker';
|
||||||
import { _ } from 'meteor/underscore';
|
import { _ } from 'meteor/underscore';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
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({
|
Template.measurementTableView.helpers({
|
||||||
getNewMeasurementType(tool) {
|
getNewMeasurementType(tool) {
|
||||||
// TODO: Check Conformance criteria here.
|
// 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) {
|
newMeasurements(measurementType) {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
const measurementApi = instance.data.measurementApi;
|
const measurementApi = instance.data.measurementApi;
|
||||||
|
|||||||
@ -6,6 +6,49 @@ import html2canvas from 'html2canvas';
|
|||||||
window.jsPDF = jsPDF;
|
window.jsPDF = jsPDF;
|
||||||
window.html2canvas = html2canvas;
|
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 => {
|
// window.exportCanvasToPdf = canvas => {
|
||||||
// // only jpeg is supported by jsPDF
|
// // only jpeg is supported by jsPDF
|
||||||
// const imgData = canvas.toDataURL('image/jpeg', 1.0);
|
// const imgData = canvas.toDataURL('image/jpeg', 1.0);
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
Npm.depends({
|
Npm.depends({
|
||||||
ajv: '4.10.4',
|
ajv: '4.10.4',
|
||||||
jspdf: '1.3.2',
|
jspdf: '1.3.2',
|
||||||
html2canvas: '0.5.0-beta4'
|
html2canvas: '0.5.0-beta4',
|
||||||
|
pdfmake: '0.1.24'
|
||||||
});
|
});
|
||||||
|
|
||||||
Package.describe({
|
Package.describe({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user