Skip to content

Commit

Permalink
Merge pull request #227 from ivmartel/dependabot/npm_and_yarn/dwv-0.34.0
Browse files Browse the repository at this point in the history
Bump dwv from 0.33.1 to 0.34.0
  • Loading branch information
ivmartel authored Nov 22, 2024
2 parents 587f7fc + b9baeb3 commit 66eb7f0
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 63 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions src/applauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ function startApp() {
'Rectangle',
'Roi',
'Ellipse',
'Circle',
'FreeHand'
'Circle'
];

var toolList = {
Expand Down
3 changes: 1 addition & 2 deletions src/gui/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
119 changes: 71 additions & 48 deletions src/gui/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
};

/**
Expand All @@ -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) {
Expand All @@ -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);
}

Expand Down Expand Up @@ -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
Expand All @@ -421,20 +440,24 @@ 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';
}
};
};
// 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
);
};
};

Expand All @@ -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;

Expand All @@ -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 {
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

[email protected]:
Expand Down Expand Up @@ -1194,10 +1194,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"
Expand Down

0 comments on commit 66eb7f0

Please sign in to comment.