Skip to content

Commit a74474a

Browse files
committed
Prevent duplication of rois
1 parent 6814e70 commit a74474a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/viewer.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2733,7 +2733,20 @@ class VolumeImageViewer {
27332733
* @param {number[]} styleOptions.fill.color - RGBA color of the body
27342734
*/
27352735
addROI (roi, styleOptions = {}) {
2736-
console.info(`add ROI ${roi.uid}`)
2736+
console.info(`add ROI "${roi.uid}"`)
2737+
2738+
// Avoid insertion of duplicates
2739+
let exists = false
2740+
for (let i = 0; i < this[_features].getLength(); i++) {
2741+
const feature = this[_features].item(i)
2742+
if (feature.getId() === roi.uid) {
2743+
exists = true
2744+
break
2745+
}
2746+
}
2747+
if (exists) {
2748+
console.warn(`ROI "${roi.uid}" not added because it already exists`)
2749+
}
27372750

27382751
const frameOfReferenceUID = this[_pyramid].metadata.FrameOfReferenceUID
27392752
if (roi.frameOfReferenceUID !== frameOfReferenceUID) {

0 commit comments

Comments
 (0)