Skip to content

Commit 97eac2b

Browse files
committed
Fix coding style issues
1 parent c90f514 commit 97eac2b

File tree

5 files changed

+64
-50
lines changed

5 files changed

+64
-50
lines changed

src/annotation.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
_fetchBulkdata,
3-
getContentItemNameCodedConcept
4-
} from './utils.js'
1+
import { _fetchBulkdata } from './utils.js'
52

63
const _attrs = Symbol('attrs')
74

src/scoord3d.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class Ellipse extends Scoord3D {
367367
]
368368
}
369369
super({
370-
coordinates: coordinates,
370+
coordinates,
371371
frameOfReferenceUID: options.frameOfReferenceUID,
372372
fiducialUID: options.fiducialUID
373373
})

src/scoord3dUtils.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ function _geometry2Scoord3d (feature, pyramid, affine) {
3131
pyramid,
3232
affine
3333
)
34-
return new Point({
35-
coordinates,
36-
frameOfReferenceUID: frameOfReferenceUID
37-
})
34+
return new Point({ coordinates, frameOfReferenceUID })
3835
} else if (type === 'Polygon') {
3936
/*
4037
* The first linear ring of the array defines the outer-boundary (surface).
@@ -43,18 +40,12 @@ function _geometry2Scoord3d (feature, pyramid, affine) {
4340
const coordinates = geometry.getCoordinates()[0].map((c) => {
4441
return _geometryCoordinates2scoord3dCoordinates(c, pyramid, affine)
4542
})
46-
return new Polygon({
47-
coordinates,
48-
frameOfReferenceUID: frameOfReferenceUID
49-
})
43+
return new Polygon({ coordinates, frameOfReferenceUID })
5044
} else if (type === 'LineString') {
5145
const coordinates = geometry.getCoordinates().map((c) => {
5246
return _geometryCoordinates2scoord3dCoordinates(c, pyramid, affine)
5347
})
54-
return new Polyline({
55-
coordinates,
56-
frameOfReferenceUID: frameOfReferenceUID
57-
})
48+
return new Polyline({ coordinates, frameOfReferenceUID })
5849
} else if (type === 'Circle') {
5950
const center = geometry.getCenter()
6051
const radius = geometry.getRadius()
@@ -68,10 +59,7 @@ function _geometry2Scoord3d (feature, pyramid, affine) {
6859
coordinates = coordinates.map((c) => {
6960
return _geometryCoordinates2scoord3dCoordinates(c, pyramid, affine)
7061
})
71-
return new Ellipse({
72-
coordinates,
73-
frameOfReferenceUID: frameOfReferenceUID
74-
})
62+
return new Ellipse({ coordinates, frameOfReferenceUID })
7563
} else {
7664
// TODO: Combine multiple points into MULTIPOINT.
7765
console.error(`unknown geometry type "${type}"`)

src/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function mapPixelCoordToSlideCoord ({ point, offset, orientation, spacing }) {
371371
offset,
372372
spacing
373373
})
374-
return applyTransform({ coordinate: point, affine: affine })
374+
return applyTransform({ coordinate: point, affine })
375375
}
376376

377377
/**
@@ -404,7 +404,7 @@ function mapSlideCoordToPixelCoord ({ point, offset, orientation, spacing }) {
404404
spacing
405405
})
406406

407-
return applyInverseTransform({ coordinate: point, affine: affine })
407+
return applyInverseTransform({ coordinate: point, affine })
408408
}
409409

410410
/**

src/viewer.js

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,14 +1019,14 @@ class VolumeImageViewer {
10191019
}),
10201020
paletteColorLookupTableUID
10211021
}),
1022-
pyramid: pyramid,
1022+
pyramid,
10231023
style: { ...defaultOpticalPathStyle },
10241024
defaultStyle: defaultOpticalPathStyle,
1025-
bitsAllocated: bitsAllocated,
1025+
bitsAllocated,
10261026
minStoredValue,
10271027
maxStoredValue,
10281028
loaderParams: {
1029-
pyramid: pyramid,
1029+
pyramid,
10301030
client: this[_options].client,
10311031
channel: opticalPathIdentifier
10321032
},
@@ -1143,12 +1143,12 @@ class VolumeImageViewer {
11431143
}),
11441144
style: { ...defaultOpticalPathStyle },
11451145
defaultStyle: defaultOpticalPathStyle,
1146-
pyramid: pyramid,
1146+
pyramid,
11471147
bitsAllocated: 8,
11481148
minStoredValue: 0,
11491149
maxStoredValue: 255,
11501150
loaderParams: {
1151-
pyramid: pyramid,
1151+
pyramid,
11521152
client: this[_options].client,
11531153
channel: opticalPathIdentifier
11541154
},
@@ -1399,6 +1399,8 @@ class VolumeImageViewer {
13991399
affine: this[_affine],
14001400
drawingSource: this[_drawingSource]
14011401
})
1402+
1403+
this[_overlays] = {}
14021404
}
14031405

14041406
/**
@@ -1495,10 +1497,7 @@ class VolumeImageViewer {
14951497
opticalPath.overviewLayer.updateStyleVariables(styleVariables)
14961498
}
14971499
} else {
1498-
const styleVariables = {
1499-
windowCenter: windowCenter,
1500-
windowWidth: windowWidth
1501-
}
1500+
const styleVariables = { windowCenter, windowWidth }
15021501
opticalPath.layer.updateStyleVariables(styleVariables)
15031502
opticalPath.overviewLayer.updateStyleVariables(styleVariables)
15041503
}
@@ -2870,21 +2869,51 @@ class VolumeImageViewer {
28702869
/**
28712870
* Add a new viewport overlay.
28722871
*
2873-
* @param {Object} options Overlay options
2874-
* @param {Object} options.element The custom overlay HTML element
2875-
* @param {string} options.className Class to style the overlay container
2876-
* @param {number[]} options.offset Horizontal and vertical offset of the overlay container in pixels
2872+
* @param {Object} options - Overlay options
2873+
* @param {Object} options.element - The custom overlay HTML element
2874+
* @param {number[]} options.coordinates - Offset of the overlay along the X and
2875+
* Y axes of the slide coordinate system
2876+
* @param {bool} [options.coordinates=false] - Whether the viewer should
2877+
* automatically navigate to the element such that it is in focus and fully
2878+
* visible
2879+
* @param {string} [options.className] - Class to style the overlay container
28772880
*/
2878-
addViewportOverlay ({ element, className, offset }) {
2881+
addViewportOverlay ({ element, coordinates, navigate, className }) {
2882+
const offset = _scoord3dCoordinates2geometryCoordinates(
2883+
coordinates,
2884+
this[_pyramid],
2885+
this[_affineInverse]
2886+
)
28792887
const overlay = new Overlay({
28802888
element,
2881-
className,
2889+
className: (
2890+
className != null
2891+
? `ol-overlay-container ol-selectable ${className}`
2892+
: 'ol-overlay-container ol-selectable'
2893+
),
28822894
offset,
2895+
autoPan: navigate != null ? navigate : false,
28832896
stopEvent: false
28842897
})
2898+
this[_overlays][element.id] = overlay
28852899
this[_map].addOverlay(overlay)
28862900
}
28872901

2902+
/**
2903+
* Remove an existing viewport overlay.
2904+
*
2905+
* @param {Object} options - Overlay options
2906+
* @param {Object} options.element - The custom overlay HTML element
2907+
*/
2908+
removeViewportOverlay ({ element }) {
2909+
const id = element.id
2910+
if (id in this[_overlays]) {
2911+
const overlay = this[_overlays][id]
2912+
this[_map].removeOverlay(overlay)
2913+
delete this[_overlays][id]
2914+
}
2915+
}
2916+
28882917
/**
28892918
* Remove an individual regions of interest.
28902919
*
@@ -3720,7 +3749,7 @@ class VolumeImageViewer {
37203749
}
37213750

37223751
const source = new DataTileSource({
3723-
tileGrid: tileGrid,
3752+
tileGrid,
37243753
projection: this[_projection],
37253754
wrapX: false,
37263755
bandCount: 1,
@@ -4189,7 +4218,7 @@ class VolumeImageViewer {
41894218
return element.SOPInstanceUID
41904219
})
41914220
}),
4192-
pyramid: pyramid,
4221+
pyramid,
41934222
overlay: new Overlay({
41944223
element: document.createElement('div'),
41954224
offset: [5 + 100 * index + 2, 5]
@@ -4209,7 +4238,7 @@ class VolumeImageViewer {
42094238
}
42104239

42114240
const source = new DataTileSource({
4212-
tileGrid: tileGrid,
4241+
tileGrid,
42134242
projection: this[_projection],
42144243
wrapX: false,
42154244
bandCount: 1,
@@ -4565,7 +4594,7 @@ class _NonVolumeImageViewer {
45654594
seriesInstanceUID: this[_metadata].SeriesInstanceUID,
45664595
sopInstanceUID: this[_metadata].SOPInstanceUID,
45674596
mediaTypes: [{ mediaType }],
4568-
queryParams: queryParams
4597+
queryParams
45694598
}
45704599
options.client.retrieveInstanceRendered(retrieveOptions).then(
45714600
(thumbnail) => {
@@ -4578,7 +4607,7 @@ class _NonVolumeImageViewer {
45784607
const projection = new Projection({
45794608
code: 'DICOM',
45804609
units: 'metric',
4581-
extent: extent,
4610+
extent,
45824611
getPointResolution: (pixelRes, point) => {
45834612
/*
45844613
* DICOM Pixel Spacing has millimeter unit while the projection has
@@ -4592,12 +4621,12 @@ class _NonVolumeImageViewer {
45924621

45934622
const source = new Static({
45944623
imageExtent: extent,
4595-
projection: projection,
4596-
imageLoadFunction: imageLoadFunction,
4624+
projection,
4625+
imageLoadFunction,
45974626
url: '' // will be set by imageLoadFunction()
45984627
})
45994628

4600-
this[_imageLayer] = new ImageLayer({ source: source })
4629+
this[_imageLayer] = new ImageLayer({ source })
46014630

46024631
// The default rotation is 'horizontal' with the slide label on the right
46034632
let rotation = _getRotation(this[_metadata])
@@ -4608,9 +4637,9 @@ class _NonVolumeImageViewer {
46084637

46094638
const view = new View({
46104639
center: getCenter(extent),
4611-
rotation: rotation,
4612-
projection: projection,
4613-
extent: extent,
4640+
rotation,
4641+
projection,
4642+
extent,
46144643
smoothExtentConstraint: true,
46154644
smoothResolutionConstraint: true,
46164645
showFullExtent: true
@@ -4619,7 +4648,7 @@ class _NonVolumeImageViewer {
46194648
// Creates the map with the defined layers and view and renders it.
46204649
this[_map] = new Map({
46214650
layers: [this[_imageLayer]],
4622-
view: view,
4651+
view,
46234652
controls: [],
46244653
keyboardEventTarget: document
46254654
})

0 commit comments

Comments
 (0)