@@ -681,24 +681,18 @@ class VolumeImageViewer {
681681 /** DICOM Pixel Spacing has millimeter unit while the projection has
682682 * has meter unit.
683683 */
684- const spacing = getPixelSpacing ( image . pyramidMetadata [ image . pyramidMetadata . length - 1 ] ) [ 0 ] / 10 ** 3
685- return pixelRes * spacing
684+ const spacing = getPixelSpacing (
685+ image . pyramidMetadata [ image . pyramidMetadata . length - 1 ]
686+ ) [ 0 ]
687+ return pixelRes * spacing / 10 ** 3
686688 }
687689 } )
688690
689- /*
690- * TODO: Register custom projection:
691- * - http://openlayers.org/en/latest/apidoc/ol.proj.html
692- * - http://openlayers.org/en/latest/apidoc/module-ol_proj.html#~ProjectionLike
693- * Direction cosines could be handled via projection rather
694- * than specifying a rotation
695- */
696691 /*
697692 * We need to specify the tile grid, since DICOM allows tiles to
698693 * have different sizes at each resolution level and a different zoom
699694 * factor between individual levels.
700695 */
701-
702696 this [ _tileGrid ] = new TileGrid ( {
703697 extent : this [ _referenceExtents ] ,
704698 origins : this [ _referenceOrigins ] ,
@@ -707,10 +701,8 @@ class VolumeImageViewer {
707701 tileSizes : this [ _referenceTileSizes ]
708702 } )
709703
710- console . log ( this [ _referenceExtents ] )
711704 const view = new View ( {
712705 center : getCenter ( this [ _referenceExtents ] ) ,
713- extent : this [ _referenceExtents ] ,
714706 projection : this [ _projection ] ,
715707 resolutions : this [ _tileGrid ] . getResolutions ( ) ,
716708 rotation : this [ _rotation ] ,
@@ -857,7 +849,6 @@ class VolumeImageViewer {
857849 for ( const control in this [ _controls ] ) {
858850 this [ _map ] . addControl ( this [ _controls ] [ control ] )
859851 }
860- this [ _map ] . getView ( ) . fit ( this [ _referenceExtents ] )
861852
862853 this [ _annotationManager ] = new _AnnotationManager ( {
863854 map : this [ _map ] ,
@@ -1298,7 +1289,9 @@ class VolumeImageViewer {
12981289 return false
12991290 }
13001291
1301- return ! ! this [ _map ] . getLayers ( ) . getArray ( ) . find ( layer => layer === channel . tileLayer )
1292+ return ! ! this [ _map ] . getLayers ( ) . getArray ( ) . find ( layer => {
1293+ return layer === channel . tileLayer
1294+ } )
13021295 }
13031296
13041297 /**
@@ -1330,6 +1323,9 @@ class VolumeImageViewer {
13301323 console . error ( 'container must be provided for rendering images' )
13311324 }
13321325 this [ _map ] . setTarget ( options . container )
1326+ const view = this [ _map ] . getView ( )
1327+ const projection = view . getProjection ( )
1328+ view . fit ( projection . getExtent ( ) , this [ _map ] . getSize ( ) )
13331329
13341330 // Style scale element (overriding default Openlayers CSS "ol-scale-line")
13351331 const scaleElement = this [ _controls ] . scale . element
@@ -2261,8 +2257,6 @@ class _NonVolumeImageViewer {
22612257 controls : [ ] ,
22622258 keyboardEventTarget : document
22632259 } )
2264-
2265- this [ _map ] . getView ( ) . fit ( extent )
22662260 }
22672261
22682262 /** Renders the image in the specified viewport container.
@@ -2274,6 +2268,9 @@ class _NonVolumeImageViewer {
22742268 console . error ( 'container must be provided for rendering images' )
22752269 }
22762270 this [ _map ] . setTarget ( options . container )
2271+ const view = this [ _map ] . getView ( )
2272+ const projection = view . getProjection ( )
2273+ view . fit ( projection . getExtent ( ) , this [ _map ] . getSize ( ) )
22772274
22782275 this [ _map ] . getInteractions ( ) . forEach ( ( interaction ) => {
22792276 this [ _map ] . removeInteraction ( interaction )
0 commit comments