From 6637fa3cc0a78a5e141786a5f8163dc68dd2d890 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:53:24 +0000 Subject: [PATCH 1/2] Bump dwv from 0.33.1 to 0.34.0 Bumps [dwv](https://github.com/ivmartel/dwv) from 0.33.1 to 0.34.0. - [Release notes](https://github.com/ivmartel/dwv/releases) - [Changelog](https://github.com/ivmartel/dwv/blob/develop/changelog.md) - [Commits](https://github.com/ivmartel/dwv/compare/v0.33.1...v0.34.0) --- updated-dependencies: - dependency-name: dwv dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 5e2302ba..759f0e74 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "url": "git://github.com/ivmartel/dwv-jqui.git" }, "dependencies": { - "dwv": "0.33.1", + "dwv": "0.34.0", "i18next": "~23.16.0", "i18next-browser-languagedetector": "~8.0.0", "i18next-http-backend": "~2.6.0", diff --git a/yarn.lock b/yarn.lock index 4abebbff..326e44bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -400,13 +400,13 @@ detect-file@^1.0.0: resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= -dwv@0.33.1: - version "0.33.1" - resolved "https://registry.yarnpkg.com/dwv/-/dwv-0.33.1.tgz#4285fe43f85c10c29c6d6f187ed6575e76082bf0" - integrity sha512-o8yT1sFlQOO5joNf7EvKDTyx57GjwgbLKrTZ1Eh79PEQlJd4DdOvzFnyKHT1ZYouHltnP/Fivp77TabYY+lA6g== +dwv@0.34.0: + version "0.34.0" + resolved "https://registry.yarnpkg.com/dwv/-/dwv-0.34.0.tgz#d4b5a137fa72bfb2c4d30ae1bb0bcb5f7778e1b7" + integrity sha512-58ta1yJuWvD7lYPHnP1qqYhI33zdM5UxrJvhG2EbWa/+Nf1XvKY//T0NfY5zT5J/OEIltMPKG0YwOwx+iR7jOw== dependencies: jszip "^3.10.1" - konva "~8.4.2" + konva "~9.3.16" magic-wand-tool "~1.1.7" ee-first@1.1.1: @@ -1195,10 +1195,10 @@ kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== -konva@~8.4.2: - version "8.4.3" - resolved "https://registry.yarnpkg.com/konva/-/konva-8.4.3.tgz#d6754fdb53e69295c24dbdfe967a27f92da51e47" - integrity sha512-ARqdgAbdNIougRlOKvkQwHlGhXPRBV4KvhCP+qoPpGoVQwwiJe4Hkdu4HHdRPb9rGUp04jDTAxBzEwBsE272pg== +konva@~9.3.16: + version "9.3.16" + resolved "https://registry.yarnpkg.com/konva/-/konva-9.3.16.tgz#0e8b52e8cb20c80c5e4cb98d0babd89ff6f95a2c" + integrity sha512-qa47cefGDDHzkToGRGDsy24f/Njrz7EHP56jQ8mlDcjAPO7vkfTDeoBDIfmF7PZtpfzDdooafQmEUJMDU2F7FQ== levn@^0.4.1: version "0.4.1" From b9baeb339e8508eb1657d90a4393e5bd429e20cf Mon Sep 17 00:00:00 2001 From: ivmartel Date: Fri, 22 Nov 2024 16:09:38 +0100 Subject: [PATCH 2/2] Update to dwv 0.34 --- src/applauncher.js | 3 +- src/gui/custom.js | 3 +- src/gui/generic.js | 119 +++++++++++++++++++++++++++------------------ src/gui/tools.js | 2 +- 4 files changed, 74 insertions(+), 53 deletions(-) diff --git a/src/applauncher.js b/src/applauncher.js index a7cf5b07..112b5cbc 100644 --- a/src/applauncher.js +++ b/src/applauncher.js @@ -23,8 +23,7 @@ function startApp() { 'Rectangle', 'Roi', 'Ellipse', - 'Circle', - 'FreeHand' + 'Circle' ]; var toolList = { diff --git a/src/gui/custom.js b/src/gui/custom.js index 9b0cf685..5ae3b6f0 100644 --- a/src/gui/custom.js +++ b/src/gui/custom.js @@ -46,10 +46,9 @@ dwvjq.gui.Slider = function (app) { */ this.initialise = function () { var dataId0 = app.getDataIds()[0]; - var dataRange = app.getImage(dataId0).getDataRange(); + var dataRange = app.getData(dataId0).image.getDataRange(); var min = dataRange.min; var max = dataRange.max; - console.log(min, max); // jquery-ui slider $('#thresholdLi').slider({ diff --git a/src/gui/generic.js b/src/gui/generic.js index 30b7505b..4e8c3a9a 100644 --- a/src/gui/generic.js +++ b/src/gui/generic.js @@ -291,6 +291,10 @@ dwvjq.gui.MetaData = function () { }; }; // class dwvjq.gui.DicomTags +function capitalizeFirstLetter(str) { + return str.charAt(0).toUpperCase() + str.slice(1); +} + /** * Drawing list base gui. * @param {Object} app The associated application. @@ -306,10 +310,10 @@ dwvjq.gui.DrawList = function (app) { * Initialise. */ this.init = function () { - app.addEventListener('positionchange', update); - app.addEventListener('drawcreate', update); - app.addEventListener('drawchange', update); - app.addEventListener('drawdelete', update); + app.addEventListener('dataadd', update); + app.addEventListener('annotationadd', update); + app.addEventListener('annotationupdate', update); + app.addEventListener('annotationremove', update); }; /** @@ -323,6 +327,24 @@ dwvjq.gui.DrawList = function (app) { isEditable = event.editable; } + // find annotationGroup + var dataIds = app.getDataIds(); + var annotationGroup; + var dataId; + for (var j = 0; j < dataIds.length; ++j) { + var ag = app.getData(dataIds[j]).annotationGroup; + if (typeof ag !== 'undefined') { + annotationGroup = ag; + dataId = dataIds[j]; + } + } + if (typeof annotationGroup === 'undefined') { + return; + } + + // draw layer + const drawLayer = app.getDrawLayersByDataId(dataId)[0]; + // HTML node var node = document.getElementById('dwv-drawList'); if (node === null) { @@ -334,37 +356,22 @@ dwvjq.gui.DrawList = function (app) { node.removeChild(node.firstChild); } - // draw controller - var drawLayer = app.getActiveLayerGroup().getActiveDrawLayer(); - var drawController = drawLayer.getDrawController(); - - // drawing details - var drawDisplayDetails = drawController.getDrawDisplayDetails(); - - // exit if no details - if (drawDisplayDetails.length === 0) { + var annotations = annotationGroup.getList(); + if (annotations.length === 0) { return; } // simpler details var simpleDetails = []; - for (var i = 0; i < drawDisplayDetails.length; ++i) { - var detail = drawDisplayDetails[i]; - var keys = Object.keys(detail); - var simpleDetail = {}; - for (var k = 0; k < keys.length; ++k) { - var key = keys[k]; - // copy all but meta - if (key !== 'meta') { - simpleDetail[key] = detail[key]; - } - // shorten id - if (key === 'id') { - simpleDetail[key] = detail[key].substring(0, 5); - } - } - // add description - simpleDetail.description = detail.meta.textExpr; + for (var i = 0; i < annotations.length; ++i) { + var annotation = annotations[i]; + var simpleDetail = { + id: annotation.id, + position: '', + type: capitalizeFirstLetter(annotation.getFactory().getName()), + color: annotation.colour, + description: annotation.textExpr + }; simpleDetails.push(simpleDetail); } @@ -393,17 +400,29 @@ dwvjq.gui.DrawList = function (app) { dwvjq.html.translateTableColumn(table, shapeCellIndex, 'shape', 'name'); // create a color onkeyup handler - var createColorOnKeyUp = function (details) { + var createColorOnKeyUp = function (annot) { return function () { - details.color = this.value; - drawController.updateDraw(details); + annot.colour = this.value; + const drawController = new dwv.DrawController(annotationGroup); + drawController.updateAnnotationWithCommand( + annot.id, + {colour: annotation.colour}, + {colour: this.value}, + app.addToUndoStack + ); }; }; // create a text onkeyup handler - var createDescriptionOnKeyUp = function (details) { + var createDescriptionOnKeyUp = function (annot) { return function () { - details.meta.textExpr = this.value; - drawController.updateDraw(details); + annot.textExpr = this.value; + const drawController = new dwv.DrawController(annotationGroup); + drawController.updateAnnotationWithCommand( + annot.id, + {textExpr: annotation.textExpr}, + {textExpr: this.value}, + app.addToUndoStack + ); }; }; // create a row onclick handler @@ -421,10 +440,10 @@ dwvjq.gui.DrawList = function (app) { }; // create visibility handler - var createVisibleOnClick = function (details, element) { + var createVisibleOnClick = function (ann, element) { return function () { - drawLayer.toggleGroupVisibility(details.id); - if (drawLayer.isGroupVisible(details.id)) { + drawLayer.setAnnotationVisibility(ann.id); + if (drawLayer.isAnnotationVisible(ann.id)) { element.className = 'text-button checked'; } else { element.className = 'text-button unchecked'; @@ -432,9 +451,13 @@ dwvjq.gui.DrawList = function (app) { }; }; // delete handler - var createDeleteOnClick = function (details) { + var createDeleteOnClick = function (annot) { return function () { - drawLayer.deleteDraw(details.id, app.addToUndoStack); + const drawController = new dwv.DrawController(annotationGroup); + drawController.removeAnnotationWithCommand( + annot.id, + app.addToUndoStack + ); }; }; @@ -446,7 +469,7 @@ dwvjq.gui.DrawList = function (app) { // loop through rows for (var r = 1; r < table.rows.length; ++r) { var drawId = r - 1; - var drawDetails = drawDisplayDetails[drawId]; + var annot = annotations[drawId]; var row = table.rows.item(r); var cells = row.cells; @@ -457,14 +480,14 @@ dwvjq.gui.DrawList = function (app) { if (c === colorCellIndex) { dwvjq.html.makeCellEditable( cells[c], - createColorOnKeyUp(drawDetails), + createColorOnKeyUp(annot), 'color' ); } else if (c === descCellIndex) { // text dwvjq.html.makeCellEditable( cells[c], - createDescriptionOnKeyUp(drawDetails) + createDescriptionOnKeyUp(annot) ); } } else { @@ -485,20 +508,20 @@ dwvjq.gui.DrawList = function (app) { var cell0 = row.insertCell(0); // visibility var visibilitySpan = document.createElement('span'); - if (drawLayer.isGroupVisible(drawDetails.id)) { + if (drawLayer.isAnnotationVisible(annot.id)) { visibilitySpan.className = 'text-button checked'; } else { visibilitySpan.className = 'text-button unchecked'; } visibilitySpan.appendChild(document.createTextNode('\u{1F441}')); // eye visibilitySpan.onclick = - createVisibleOnClick(drawDetails, visibilitySpan); + createVisibleOnClick(annot, visibilitySpan); cell0.appendChild(visibilitySpan); // delete var deleteSpan = document.createElement('span'); deleteSpan.className = 'text-button checked'; - deleteSpan.appendChild(document.createTextNode('\u2715')); // cross - deleteSpan.onclick = createDeleteOnClick(drawDetails, deleteSpan); + deleteSpan.appendChild(document.createTextNode('\u{274C}')); // cross + deleteSpan.onclick = createDeleteOnClick(annot, deleteSpan); cell0.appendChild(deleteSpan); } diff --git a/src/gui/tools.js b/src/gui/tools.js index 04da205f..b95782e9 100644 --- a/src/gui/tools.js +++ b/src/gui/tools.js @@ -242,7 +242,7 @@ dwvjq.gui.WindowLevel = function (app) { var cmSelector = document.getElementById('colourMapSelect'); cmSelector.selectedIndex = 0; // special monochrome1 case - if (app.getImage(0).getPhotometricInterpretation() === 'MONOCHROME1') { + if (app.getData(0).image.getPhotometricInterpretation() === 'MONOCHROME1') { cmSelector.selectedIndex = 1; } // refresh