Skip to content

Commit

Permalink
Merge pull request #297 from ivmartel/294-add-save-annot
Browse files Browse the repository at this point in the history
294 add save annot
  • Loading branch information
ivmartel authored Jan 8, 2025
2 parents e29acef + e8fea79 commit 20ab2ec
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion resources/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "Geschichte",
"image": "Bild",
"info": "Info",
"downloadState": "Zustand herunterladen",
"downloadAnnotations": "Herunterladen",
"drawList": "Vermerke",
"search": "Suche",
"id": "ID",
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "History",
"image": "Image",
"info": "Info",
"downloadState": "Download state",
"downloadAnnotations": "Download",
"drawList": "Annotations",
"search": "Search",
"id": "ID",
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "Historial",
"image": "Imagen",
"info": "Información",
"downloadState": "Estado de la descarga",
"downloadAnnotations": "Descargar",
"drawList": "Anotaciones",
"search": "Búsqueda",
"id": "ID",
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "Historique",
"image": "Image",
"info": "Info",
"downloadState": "Télécharger state",
"downloadAnnotations": "Télécharger",
"drawList": "Annotations",
"search": "Recherche",
"id": "ID",
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "Storico",
"image": "Immagine",
"info": "Informazioni",
"downloadState": "Stato download",
"downloadAnnotations": "Scaricare",
"drawList": "Annotazioni",
"search": "Cerca",
"id": "ID",
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/jp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "ヒストリー",
"image": "画像",
"info": "情報",
"downloadState": "状態ファイルダウンロード",
"downloadAnnotations": "ダウンロード",
"drawList": "アノテーション",
"search": "検索",
"id": "ID",
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/ro/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "Istorie",
"image": "Imagine",
"info": "Info",
"downloadState": "Statut descărcare",
"downloadAnnotations": "Descărcar",
"drawList": "Adnotări",
"search": "Căutare",
"id": "ID",
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "История",
"image": "Изображение",
"info": "Информация",
"downloadState": "Статус загрузки",
"downloadAnnotations": "Скачать",
"drawList": "Аннотации",
"search": "Поиск",
"id": "ID",
Expand Down
2 changes: 1 addition & 1 deletion resources/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"history": "历史记录",
"image": "图像",
"info": "信息",
"downloadState": "下载状态",
"downloadAnnotations": "下载",
"drawList": "注释",
"search": "搜索",
"id": "ID",
Expand Down
12 changes: 0 additions & 12 deletions src/appgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,6 @@ dwvjq.gui.ToolboxContainer = function (app, infoController) {
infoController.toggleListeners();
};

var toggleSaveState = document.createElement('a');
toggleSaveState.setAttribute(
'class',
buttonClass + ' download-state ui-icon-action'
);
toggleSaveState.onclick = function () {
var blob = new Blob([app.getJsonState()], {type: 'application/json'});
toggleSaveState.href = window.URL.createObjectURL(blob);
};
toggleSaveState.download = 'state.json';

var tags = document.createElement('a');
tags.href = '#tags_page';
tags.setAttribute('class', buttonClass + ' ui-icon-grid');
Expand All @@ -134,7 +123,6 @@ dwvjq.gui.ToolboxContainer = function (app, infoController) {
node.appendChild(undo);
node.appendChild(redo);
node.appendChild(toggleInfo);
node.appendChild(toggleSaveState);
node.appendChild(tags);
node.appendChild(drawList);
dwvjq.gui.refreshElement(node);
Expand Down
32 changes: 31 additions & 1 deletion src/gui/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ dwvjq.gui.DrawList = function (app) {
* Initialise.
*/
this.init = function () {
app.addEventListener('dataadd', update);
app.addEventListener('drawlayeradd', update);
app.addEventListener('annotationadd', update);
app.addEventListener('annotationupdate', update);
app.addEventListener('annotationremove', update);
Expand Down 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.downloadAnnotations'))
);
node.appendChild(saveButton);

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

0 comments on commit 20ab2ec

Please sign in to comment.