@@ -765,6 +765,9 @@ const _rotation = Symbol('rotation')
765765const _tileGrid = Symbol ( 'tileGrid' )
766766const _updateOverviewMapSize = Symbol ( 'updateOverviewMapSize' )
767767const _annotationOptions = Symbol ( 'annotationOptions' )
768+ const _isICCProfilesEnabled = Symbol ( 'isICCProfilesEnabled' )
769+ const _iccProfiles = Symbol ( 'iccProfiles' )
770+ const _container = Symbol ( 'container' )
768771
769772/**
770773 * Interactive viewer for DICOM VL Whole Slide Microscopy Image instances
@@ -810,8 +813,11 @@ class VolumeImageViewer {
810813 this [ _options ] = options
811814 this [ _retrievedBulkdata ] = { }
812815 this [ _annotationOptions ] = { }
813-
816+ this [ _isICCProfilesEnabled ] = true
817+ this [ _container ] = null
814818 this [ _clients ] = { }
819+ this [ _iccProfiles ] = [ ]
820+
815821 if ( this [ _options ] . client ) {
816822 this [ _clients ] . default = this [ _options ] . client
817823 } else {
@@ -1614,7 +1620,6 @@ class VolumeImageViewer {
16141620 }
16151621 if ( this [ _options ] . controls . has ( 'position' ) ) {
16161622 this [ _controls ] . position = new MousePosition ( {
1617- projection : this [ _projection ] ,
16181623 coordinateFormat : ( imageCoordinates ) => {
16191624 const slideCoordinates = _geometryCoordinates2scoord3dCoordinates (
16201625 imageCoordinates ,
@@ -1963,6 +1968,59 @@ class VolumeImageViewer {
19631968 }
19641969 }
19651970
1971+ /**
1972+ * Get ICC profiles.
1973+ *
1974+ * @returns {any[] } ICC profiles
1975+ */
1976+ getICCProfiles ( ) {
1977+ return this [ _iccProfiles ] || [ ]
1978+ }
1979+
1980+ /**
1981+ * Toggle ICC profiles.
1982+ *
1983+ * @returns {void }
1984+ */
1985+ toggleICCProfiles ( ) {
1986+ console . debug ( 'toggle ICC profiles:' , this [ _isICCProfilesEnabled ] )
1987+ const itemsRequiringDecodersAndTransformers = [
1988+ ...Object . values ( this [ _opticalPaths ] ) ,
1989+ ...Object . values ( this [ _segments ] ) ,
1990+ ...Object . values ( this [ _mappings ] )
1991+ ]
1992+
1993+ itemsRequiringDecodersAndTransformers . forEach ( item => {
1994+ const metadata = item . pyramid . metadata
1995+ const client = _getClient (
1996+ this [ _clients ] ,
1997+ Enums . SOPClassUIDs . VL_WHOLE_SLIDE_MICROSCOPY_IMAGE
1998+ )
1999+ _getIccProfiles ( metadata , client ) . then ( profiles => {
2000+ this [ _iccProfiles ] = profiles
2001+ const source = item . layer . getSource ( )
2002+ if ( ! source ) {
2003+ return
2004+ }
2005+ const loaderWithICCProfiles = _createTileLoadFunction ( {
2006+ targetElement : this [ _container ] ,
2007+ iccProfiles : profiles ,
2008+ ...item . loaderParams
2009+ } )
2010+ const loaderWithoutICCProfiles = _createTileLoadFunction ( {
2011+ targetElement : this [ _container ] ,
2012+ ...item . loaderParams
2013+ } )
2014+ const loader = this [ _isICCProfilesEnabled ] ? loaderWithICCProfiles : loaderWithoutICCProfiles
2015+ source . setLoader ( loader )
2016+ source . refresh ( )
2017+ item . hasLoader = true
2018+ } )
2019+ } )
2020+
2021+ this [ _isICCProfilesEnabled ] = ! this [ _isICCProfilesEnabled ]
2022+ }
2023+
19662024 /**
19672025 * Show an optical path.
19682026 *
@@ -1996,6 +2054,8 @@ class VolumeImageViewer {
19962054 Enums . SOPClassUIDs . VL_WHOLE_SLIDE_MICROSCOPY_IMAGE
19972055 )
19982056 _getIccProfiles ( metadata , client ) . then ( profiles => {
2057+ console . debug ( 'icc profiles (optical path):' , profiles )
2058+ this [ _iccProfiles ] = profiles
19992059 const loader = _createTileLoadFunction ( {
20002060 targetElement : container ,
20012061 iccProfiles : profiles ,
@@ -2111,13 +2171,17 @@ class VolumeImageViewer {
21112171 * @param {(string|HTMLElement) } options.container - HTML Element in which the viewer should be injected.
21122172 */
21132173 render ( { container } ) {
2174+ window . toggleICCProfiles = this . toggleICCProfiles . bind ( this )
2175+ window . getICCProfiles = this . getICCProfiles . bind ( this )
21142176 window . cleanup = this . cleanup . bind ( this )
21152177
21162178 if ( container == null ) {
21172179 console . error ( 'container must be provided for rendering images' )
21182180 return
21192181 }
21202182
2183+ this [ _container ] = container
2184+
21212185 const itemsRequiringDecodersAndTransformers = [
21222186 ...Object . values ( this [ _opticalPaths ] ) ,
21232187 ...Object . values ( this [ _segments ] ) ,
@@ -2138,13 +2202,14 @@ class VolumeImageViewer {
21382202 Enums . SOPClassUIDs . VL_WHOLE_SLIDE_MICROSCOPY_IMAGE
21392203 )
21402204 _getIccProfiles ( metadata , client ) . then ( profiles => {
2205+ this [ _iccProfiles ] = profiles
21412206 const source = item . layer . getSource ( )
21422207 if ( ! source ) {
21432208 return
21442209 }
21452210 const loader = _createTileLoadFunction ( {
21462211 targetElement : container ,
2147- iccProfiles : profiles ,
2212+ iccProfiles : this [ _isICCProfilesEnabled ] ? profiles : null ,
21482213 ...item . loaderParams
21492214 } )
21502215 source . setLoader ( loader )
0 commit comments