Skip to content

Commit

Permalink
Add save annotation button
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Jan 8, 2025
1 parent 3043e98 commit 4d41058
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/gui/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,36 @@ dwvjq.gui.DrawList = function (app) {
// draw list table
node.appendChild(table);

// save draw button
var saveButton = document.createElement('button');
saveButton.onclick = function () {
var factory = new dwv.AnnotationGroupFactory();
var dicomElements = factory.toDicom(annotationGroup);
// write
var writer = new dwv.DicomWriter();
let dicomBuffer = null;
try {
dicomBuffer = writer.getBuffer(dicomElements);
} catch (error) {
console.error(error);
alert(error.message);
}
var blob = new Blob([dicomBuffer], {type: 'application/dicom'});

// temporary link to download
var element = document.createElement('a');
element.href = window.URL.createObjectURL(blob);
element.download = 'dicom-sr-' + dataId + '.dcm';
// trigger download
element.click();
URL.revokeObjectURL(element.href);
};
saveButton.setAttribute('class', 'ui-btn ui-btn-inline');
saveButton.appendChild(
document.createTextNode(dwvjq.i18n.t('basics.saveDraws'))
);
node.appendChild(saveButton);

// delete draw button
var deleteButton = document.createElement('button');
deleteButton.onclick = function () {
Expand Down

0 comments on commit 4d41058

Please sign in to comment.