@@ -187,7 +187,7 @@ class CornerstoneViewport extends Component {
187187 cornerstone . displayImage ( this . element , image ) ;
188188
189189 if ( isStackPrefetchEnabled ) {
190- _enableStackPrefetching ( this . element ) ;
190+ cornerstoneTools . stackPrefetch . enable ( this . element ) ;
191191 }
192192
193193 if ( isPlaying ) {
@@ -254,10 +254,7 @@ class CornerstoneViewport extends Component {
254254
255255 // Need to stop/start to pickup stack changes in prefetcher
256256 if ( shouldStopStartStackPrefetch ) {
257- const clear = true ;
258-
259- _enableStackPrefetching ( this . element , clear ) ;
260- _enableStackPrefetching ( this . element ) ;
257+ cornerstoneTools . stackPrefetch . enable ( this . element ) ;
261258 }
262259
263260 // ~~ ACTIVE TOOL
@@ -319,7 +316,7 @@ class CornerstoneViewport extends Component {
319316 this . _setupLoadHandlers ( clear ) ;
320317
321318 if ( this . props . isStackPrefetchEnabled ) {
322- _enableStackPrefetching ( this . element , clear ) ;
319+ cornerstoneTools . stackPrefetch . disable ( this . element ) ;
323320 }
324321
325322 cornerstoneTools . clearToolState ( this . element , 'stackPrefetch' ) ;
@@ -714,85 +711,6 @@ class CornerstoneViewport extends Component {
714711 this . setViewportActive ( ) ;
715712
716713 scrollToIndex ( this . element , value ) ;
717-
718- this . resetPrefetching ( value ) ;
719- } ;
720-
721- resetPrefetching = imageIdIndex => {
722- cornerstoneTools . stackPrefetch . setConfiguration ( {
723- maxImagesToPrefetch : Infinity ,
724- preserveExistingPool : false ,
725- maxSimultaneousRequests : 6 ,
726- } ) ;
727-
728- const { imageIds } = this . props ;
729-
730- const minImageIdIndex = 0 ;
731- const maxImageIdIndex = imageIds . length - 1 ;
732-
733- let lowerImageIdIndex = imageIdIndex ;
734- let upperImageIdIndex = imageIdIndex ;
735-
736- // Build up an array of images to prefetch, starting with the current image.
737- let imageIdsToPrefetch = [ imageIds [ imageIdIndex ] ] ;
738-
739- // 0: From current stack position down to minimum.
740- // 1: From current stack position up to maximum.
741-
742- const prefetchQueuedFilled = [ false , false ] ;
743-
744- // Check if on edges and some criteria is already fulfilled
745-
746- if ( imageIdIndex === minImageIdIndex ) {
747- prefetchQueuedFilled [ 0 ] = true ;
748- } else if ( imageIdIndex === maxImageIdIndex ) {
749- prefetchQueuedFilled [ 1 ] = true ;
750- }
751-
752- while (
753- prefetchQueuedFilled [ 0 ] === false ||
754- prefetchQueuedFilled [ 1 ] === false
755- ) {
756- if ( prefetchQueuedFilled [ 0 ] === false ) {
757- // Add imageId bellow
758- lowerImageIdIndex -- ;
759- imageIdsToPrefetch . push ( imageIds [ lowerImageIdIndex ] ) ;
760-
761- if ( lowerImageIdIndex === minImageIdIndex ) {
762- prefetchQueuedFilled [ 0 ] = true ;
763- }
764- }
765-
766- if ( prefetchQueuedFilled [ 1 ] === false ) {
767- // Add imageId above
768- upperImageIdIndex ++ ;
769- imageIdsToPrefetch . push ( imageIds [ upperImageIdIndex ] ) ;
770-
771- if ( upperImageIdIndex === maxImageIdIndex ) {
772- prefetchQueuedFilled [ 1 ] = true ;
773- }
774- }
775- }
776-
777- const requestPoolManager = cornerstoneTools . requestPoolManager ;
778- const requestType = 'prefetch' ;
779- const preventCache = false ;
780- const noop = ( ) => { } ;
781-
782- requestPoolManager . clearRequestStack ( 'prefetch' ) ;
783-
784- imageIdsToPrefetch . forEach ( imageId => {
785- requestPoolManager . addRequest (
786- { } ,
787- imageId ,
788- requestType ,
789- preventCache ,
790- noop ,
791- noop
792- ) ;
793- } ) ;
794-
795- requestPoolManager . startGrabbing ( ) ;
796714 } ;
797715
798716 setViewportActive = ( ) => {
@@ -886,14 +804,6 @@ function _trySetActiveTool(element, activeToolName) {
886804 } ) ;
887805}
888806
889- function _enableStackPrefetching ( element , clear = false ) {
890- if ( clear ) {
891- cornerstoneTools . stackPrefetch . disable ( element ) ;
892- } else {
893- cornerstoneTools . stackPrefetch . enable ( element ) ;
894- }
895- }
896-
897807/**
898808 * Iterate over the provided tools; Add each tool to the target element
899809 *
0 commit comments