Skip to content

Commit a6a1c2f

Browse files
Address annotation issues (#100)
* Update links to imagingdatacommons * Address annotation issues: Sticky draw start and modify not updating label position
1 parent d73be21 commit a6a1c2f

File tree

7 files changed

+54
-51
lines changed

7 files changed

+54
-51
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The library is intended to provide a lightweight and standard-compliant viewer for microscopy images in DICOM format.
66

7-
The viewer relies on [Openlayers](http://openlayers.org/) for rendering pyramid images and dynamically retrieves pyramid tiles (image frames) via [DICOMweb WADO-RS](https://www.dicomstandard.org/dicomweb/retrieve-wado-rs-and-wado-uri/) using [dicomweb-client](https://github.com/herrmannlab/dicomweb-client).
7+
The viewer relies on [Openlayers](http://openlayers.org/) for rendering pyramid images and dynamically retrieves pyramid tiles (image frames) via [DICOMweb WADO-RS](https://www.dicomstandard.org/dicomweb/retrieve-wado-rs-and-wado-uri/) using [dicomweb-client](https://github.com/dcmjs-org/dicomweb-client).
88
However, the viewer API fully abstracts the underlying rendering library and doesn't expose the lower level Openlayers API directly, such that another rendering library could in principle be used in the future if this would be of advantage.
99

1010
A central design choice was to not expose any Openlayers objects or functions via the public API, but always provide an abstraction layer.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://github.com/herrmannlab/dicom-microscopy-viewer/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/herrmannlab/dicom-microscopy-viewer/actions)
1+
[![Build Status](https://github.com/imagingdatacommons/dicom-microscopy-viewer/actions/workflows/run_unit_tests.yml/badge.svg)](https://github.com/imagingdatacommons/dicom-microscopy-viewer/actions)
22
[![NPM version](https://badge.fury.io/js/dicom-microscopy-viewer.svg)](http://badge.fury.io/js/dicom-microscopy-viewer)
33
![NPM downloads per month](https://img.shields.io/npm/dm/dicom-microscopy-viewer?color=blue)
44

@@ -114,7 +114,7 @@ We use [Babel](https://babeljs.io/) to compile (transpile), [webpack](https://we
114114
Get the source code by cloning the git repository:
115115

116116
```None
117-
git clone https://github.com/herrmannlab/dicom-microscopy-viewer
117+
git clone https://github.com/imagingdatacommons/dicom-microscopy-viewer
118118
cd dicom-microscopy-viewer
119119
```
120120

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
{
22
"name": "dicom-microscopy-viewer",
3-
"version": "0.45.0",
3+
"version": "0.45.0",
4+
"license": "MIT",
5+
"author": "ImagingDataCommons",
6+
"homepage": "https://github.com/imagingdatacommons/dicom-microscopy-viewer#readme",
47
"description": "Interactive web-based viewer for DICOM Microscopy Images",
8+
"bugs": {
9+
"url": "https://github.com/imagingdatacommons/dicom-microscopy-viewer/issues"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/imagingdatacommons/dicom-microscopy-viewer.git"
14+
},
15+
"keywords": [
16+
"dicom",
17+
"dcmjs",
18+
"dicomweb",
19+
"microscopy"
20+
],
521
"main": "./src/dicom-microscopy-viewer.js",
622
"standard": {
723
"ignore": [
@@ -33,22 +49,6 @@
3349
"webpack:dynamic-import:watch": "webpack --progress --watch --config ./config/webpack/webpack-dynamic-import",
3450
"webpack:watch": "webpack --progress --watch --config ./config/webpack"
3551
},
36-
"repository": {
37-
"type": "git",
38-
"url": "git+https://github.com/herrmannlab/dicom-microscopy-viewer.git"
39-
},
40-
"keywords": [
41-
"dicom",
42-
"dcmjs",
43-
"dicomweb",
44-
"microscopy"
45-
],
46-
"author": "Markus D. Herrmann",
47-
"license": "MIT",
48-
"bugs": {
49-
"url": "https://github.com/herrmannlab/dicom-microscopy-viewer/issues"
50-
},
51-
"homepage": "https://github.com/herrmannlab/dicom-microscopy-viewer#readme",
5252
"devDependencies": {
5353
"@babel/core": "^7.17",
5454
"@babel/plugin-proposal-object-rest-spread": "^7.14.7",

src/annotations/markups/_MarkupManager.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class _MarkupManager {
160160

161161
if (this._listeners.get(id)) {
162162
this._listeners.delete(id)
163+
console.debug('deleting feature listener')
163164
}
164165

165166
return id
@@ -213,6 +214,9 @@ class _MarkupManager {
213214

214215
if (this.has(id)) {
215216
console.warn('Markup for feature already exists', id)
217+
/** Wire events again so they are not lost (closure of this function) */
218+
this._drawLink(feature)
219+
this._wireInternalEvents(feature)
216220
return this.get(id)
217221
}
218222

@@ -256,6 +260,7 @@ class _MarkupManager {
256260
const listener = feature.on(
257261
Enums.FeatureEvents.CHANGE,
258262
(event) => {
263+
console.debug('feature changed', id)
259264
if (this.has(id)) {
260265
const view = this._map.getView()
261266
const unitSuffix = _getUnitSuffix(view)
@@ -266,15 +271,17 @@ class _MarkupManager {
266271
this._pyramid,
267272
this._affine
268273
)
274+
const geometry = event.target.getGeometry()
269275
this.update({
270276
feature,
271277
value: output,
272-
coordinate: event.target.getGeometry().getLastCoordinate()
278+
coordinate: geometry.getLastCoordinate()
273279
})
274280
this._drawLink(feature)
275281
}
276282
}
277283
)
284+
278285
this._listeners.set(id, listener)
279286

280287
this._styleTooltip(feature)
@@ -283,6 +290,7 @@ class _MarkupManager {
283290
feature.on(
284291
Enums.FeatureEvents.PROPERTY_CHANGE,
285292
({ key: property, target: feature }) => {
293+
console.debug('feature property changed')
286294
if (property === Enums.InternalProperties.StyleOptions) {
287295
this._styleTooltip(feature)
288296
}
@@ -291,6 +299,7 @@ class _MarkupManager {
291299

292300
/** Update markup style on feature geometry change */
293301
feature.getGeometry().on(Enums.FeatureGeometryEvents.CHANGE, () => {
302+
console.debug('feature geometry changed')
294303
this._styleTooltip(feature)
295304
})
296305

src/annotations/markups/measurement.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,20 @@ const MeasurementMarkup = ({ map, pyramid, affine, markupManager }) => {
6565
}
6666
},
6767
onRemove: (feature) => {
68-
if (_isMeasurement(feature)) {
69-
const featureId = feature.getId()
70-
markupManager.remove(featureId)
71-
}
68+
const featureId = feature.getId()
69+
markupManager.remove(featureId)
7270
},
7371
onDrawStart: ({ feature }) => {
7472
if (_isMeasurement(feature)) {
75-
markupManager.create({ feature })
73+
const view = map.getView()
74+
const unitSuffix = _getUnitSuffix(view)
75+
markupManager.create({
76+
feature,
77+
value: _format(feature, unitSuffix, pyramid, affine)
78+
})
7679
}
7780
},
78-
onUpdate: (feature) => {
79-
const view = map.getView()
80-
const unitSuffix = _getUnitSuffix(view)
81-
const id = feature.getId()
82-
const markup = markupManager.get(id)
83-
markupManager.update({
84-
feature,
85-
value: _format(feature, unitSuffix, pyramid, affine),
86-
coordinate: markup.overlay.getPosition()
87-
})
88-
},
81+
onUpdate: (feature) => {},
8982
onDrawEnd: ({ feature }) => {},
9083
onDrawAbort: ({ feature }) => {}
9184
}

src/enums.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const Markup = {
1818

1919
export const FeatureEvents = {
2020
CHANGE: 'change',
21+
GEOMETRY_CHANGE: 'change:geometry',
2122
PROPERTY_CHANGE: 'propertychange'
2223
}
2324

src/viewer.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -422,13 +422,11 @@ function _updateFeatureMeasurements (map, feature, pyramid, affine) {
422422
schemeDesignator: 'SCT'
423423
}),
424424
value: area,
425-
unit: [
426-
new dcmjs.sr.coding.CodedConcept({
427-
value: unitCodedConceptValue,
428-
meaning: unitCodedConceptMeaning,
429-
schemeDesignator: 'SCT'
430-
})
431-
]
425+
unit: new dcmjs.sr.coding.CodedConcept({
426+
value: unitCodedConceptValue,
427+
meaning: unitCodedConceptMeaning,
428+
schemeDesignator: 'SCT'
429+
})
432430
})
433431
}
434432

@@ -442,13 +440,11 @@ function _updateFeatureMeasurements (map, feature, pyramid, affine) {
442440
schemeDesignator: 'SCT'
443441
}),
444442
value: length,
445-
unit: [
446-
new dcmjs.sr.coding.CodedConcept({
447-
value: unitCodedConceptValue,
448-
meaning: unitCodedConceptMeaning,
449-
schemeDesignator: 'SCT'
450-
})
451-
]
443+
unit: new dcmjs.sr.coding.CodedConcept({
444+
value: unitCodedConceptValue,
445+
meaning: unitCodedConceptMeaning,
446+
schemeDesignator: 'SCT'
447+
})
452448
})
453449
}
454450

@@ -1902,6 +1898,9 @@ class VolumeImageViewer {
19021898
)
19031899
_getIccProfiles(metadata, client).then(profiles => {
19041900
const source = item.layer.getSource()
1901+
if (!source) {
1902+
return
1903+
}
19051904
const loader = _createTileLoadFunction({
19061905
targetElement: container,
19071906
iccProfiles: profiles,
@@ -2972,6 +2971,7 @@ class VolumeImageViewer {
29722971

29732972
if (feature) {
29742973
this[_features].remove(feature)
2974+
this[_annotationManager].onRemove(feature)
29752975
return
29762976
}
29772977

0 commit comments

Comments
 (0)