@@ -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