-
Notifications
You must be signed in to change notification settings - Fork 35
/
annotations__AnnotationManager.js.html
239 lines (197 loc) · 8.85 KB
/
annotations__AnnotationManager.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: annotations/_AnnotationManager.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: annotations/_AnnotationManager.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import dcmjs from 'dcmjs'
import _MarkupManager from './markups/_MarkupManager'
/** Enums */
import Enums from '../enums'
/** Markers */
import ArrowMarker, { _format as arrowFormat } from './markers/arrow'
/** Markups */
import MeasurementMarkup, {
_format as measurementFormat
} from './markups/measurement'
import TextEvaluationMarkup, {
_format as textFormat
} from './markups/textEvaluation'
/** Utils */
import { areCodedConceptsEqual, getContentItemNameCodedConcept } from '../utils'
const { Marker, Markup } = Enums
class _AnnotationManager {
constructor ({ map, pyramid, affine, drawingSource } = {}) {
const markupManager = new _MarkupManager({
map,
pyramid,
affine,
drawingSource,
formatters: {
[Marker.Arrow]: arrowFormat,
[Markup.Measurement]: measurementFormat,
[Markup.TextEvaluation]: textFormat
}
})
this.props = {
map,
pyramid,
affine,
markupManager
}
/** Markups */
this[Markup.Measurement] = MeasurementMarkup(this.props)
this[Markup.TextEvaluation] = TextEvaluationMarkup(this.props)
/** Markers */
this[Marker.Arrow] = ArrowMarker(this.props)
}
/**
* Add markup properties based on ROI
* measurements and evaluations.
*
* @param {Feature} feature The feature
*/
_addMeasurementsAndEvaluationsProperties (feature) {
const { measurements, evaluations } = feature.getProperties()
if (measurements && measurements.length) {
return measurements.some((measurement) => {// eslint-disable-line
const SUPPORTED_MEASUREMENTS_CODED_CONCEPTS = [
new dcmjs.sr.coding.CodedConcept({
meaning: 'Area',
value: '42798000',
schemeDesignator: 'SCT'
}),
new dcmjs.sr.coding.CodedConcept({
meaning: 'Length',
value: '410668003',
schemeDesignator: 'SCT'
})
]
const measurementCodedConcept = getContentItemNameCodedConcept(
measurement
)
if (
SUPPORTED_MEASUREMENTS_CODED_CONCEPTS.some((codedConcept) =>
areCodedConceptsEqual(measurementCodedConcept, codedConcept)
)
) {
feature.set(
Enums.InternalProperties.Markup,
Enums.Markup.Measurement
)
}
})
}
if (evaluations && evaluations.length) {
return evaluations.some((evaluation) => {// eslint-disable-line
const SUPPORTED_EVALUATIONS_CODED_CONCEPTS = [
new dcmjs.sr.coding.CodedConcept({
value: '112039',
meaning: 'Tracking Identifier',
schemeDesignator: 'DCM'
})
]
const evaluationCodedConcept = getContentItemNameCodedConcept(
evaluation
)
if (
SUPPORTED_EVALUATIONS_CODED_CONCEPTS.some((codedConcept) =>
areCodedConceptsEqual(codedConcept, evaluationCodedConcept)
)
) {
feature.set(
Enums.InternalProperties.Markup,
Enums.Markup.TextEvaluation
)
}
})
}
}
/**
* Sets annotations visibility.
*
* @param {boolean} isVisible
*/
setVisible (isVisible) {
this.props.markupManager.setVisible(isVisible)
}
/**
* Set markup visibility.
*
* @param {string} id The markup id
* @param {boolean} isVisible The markup visibility
*/
setMarkupVisibility (id, isVisible) {
this.props.markupManager.setVisibility(id, isVisible)
}
onAdd (feature) {
/**
* Add properties to ROI feature before triggering
* markup and markers callbacks to keep UI in sync.
*/
this._addMeasurementsAndEvaluationsProperties(feature)
this[Marker.Arrow].onAdd(feature)
this[Markup.Measurement].onAdd(feature)
this[Markup.TextEvaluation].onAdd(feature)
}
onFailure (uid) {
this[Marker.Arrow].onFailure(uid)
this[Markup.Measurement].onFailure(uid)
this[Markup.TextEvaluation].onFailure(uid)
}
onRemove (feature) {
this[Marker.Arrow].onRemove(feature)
this[Markup.Measurement].onRemove(feature)
this[Markup.TextEvaluation].onRemove(feature)
}
onUpdate (feature) {
this[Marker.Arrow].onUpdate(feature)
this[Markup.Measurement].onUpdate(feature)
this[Markup.TextEvaluation].onUpdate(feature)
}
onDrawStart (event) {
this[Marker.Arrow].onDrawStart(event)
this[Markup.Measurement].onDrawStart(event)
this[Markup.TextEvaluation].onDrawStart(event)
}
onDrawEnd (event) {
this[Marker.Arrow].onDrawEnd(event)
this[Markup.Measurement].onDrawEnd(event)
this[Markup.TextEvaluation].onDrawEnd(event)
this.props.markupManager.onDrawEnd(event)
}
onDrawAbort (event) {
this[Marker.Arrow].onDrawAbort(event)
this[Markup.Measurement].onDrawAbort(event)
this[Markup.TextEvaluation].onDrawAbort(event)
this.props.markupManager.onDrawAbort(event)
}
}
export default _AnnotationManager
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="annotation.html">annotation</a></li><li><a href="api.html">api</a></li><li><a href="color.html">color</a></li><li><a href="events.html">events</a></li><li><a href="mapping.html">mapping</a></li><li><a href="metadata.html">metadata</a></li><li><a href="opticalPath.html">opticalPath</a></li><li><a href="roi.html">roi</a></li><li><a href="scoord3d.html">scoord3d</a></li><li><a href="segment.html">segment</a></li><li><a href="utils.html">utils</a></li><li><a href="viewer.html">viewer</a></li></ul><h3>Classes</h3><ul><li><a href="annotation.AnnotationGroup.html">AnnotationGroup</a></li><li><a href="color.PaletteColorLookupTable.html">PaletteColorLookupTable</a></li><li><a href="mapping.ParameterMapping.html">ParameterMapping</a></li><li><a href="mapping.Transformation.html">Transformation</a></li><li><a href="metadata.Comprehensive3DSR.html">Comprehensive3DSR</a></li><li><a href="metadata.MicroscopyBulkSimpleAnnotations.html">MicroscopyBulkSimpleAnnotations</a></li><li><a href="metadata.ParametricMap.html">ParametricMap</a></li><li><a href="metadata.Segmentation.html">Segmentation</a></li><li><a href="metadata.SOPClass.html">SOPClass</a></li><li><a href="metadata.VLWholeSlideMicroscopyImage.html">VLWholeSlideMicroscopyImage</a></li><li><a href="module.exports_module.exports.html">exports</a></li><li><a href="opticalPath.OpticalPath.html">OpticalPath</a></li><li><a href="roi.ROI.html">ROI</a></li><li><a href="scoord3d.Ellipse.html">Ellipse</a></li><li><a href="scoord3d.Ellipsoid.html">Ellipsoid</a></li><li><a href="scoord3d.Multipoint.html">Multipoint</a></li><li><a href="scoord3d.Point.html">Point</a></li><li><a href="scoord3d.Polygon.html">Polygon</a></li><li><a href="scoord3d.Polyline.html">Polyline</a></li><li><a href="scoord3d.Scoord3D.html">Scoord3D</a></li><li><a href="segment.Segment.html">Segment</a></li><li><a href="viewer.LabelImageViewer.html">LabelImageViewer</a></li><li><a href="viewer.OverviewImageViewer.html">OverviewImageViewer</a></li><li><a href="viewer.VolumeImageViewer.html">VolumeImageViewer</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addTask">addTask</a></li><li><a href="global.html#cancelTask">cancelTask</a></li><li><a href="global.html#decode">decode</a></li><li><a href="global.html#getStatistics">getStatistics</a></li><li><a href="global.html#handleMessageFromWorker">handleMessageFromWorker</a></li><li><a href="global.html#initialize">initialize</a></li><li><a href="global.html#loadWebWorkerTask">loadWebWorkerTask</a></li><li><a href="global.html#setTaskPriority">setTaskPriority</a></li><li><a href="global.html#spawnWebWorker">spawnWebWorker</a></li><li><a href="global.html#startTaskOnWebWorker">startTaskOnWebWorker</a></li><li><a href="global.html#terminateAllWebWorkers">terminateAllWebWorkers</a></li><li><a href="global.html#transform">transform</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Mon Sep 12 2022 22:55:18 GMT-0400 (Eastern Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>