@@ -4,6 +4,7 @@ import { createDirectStore } from 'direct-vuex';
44import Vue from 'vue' ;
55import Vuex from 'vuex' ;
66import vtkProxyManager from 'vtk.js/Sources/Proxy/Core/ProxyManager' ;
7+ import macro from 'vtk.js/Sources/macros' ;
78import { InterpolationType } from 'vtk.js/Sources/Rendering/Core/ImageProperty/Constants' ;
89
910import '../utils/registerReaders' ;
@@ -49,9 +50,12 @@ function prepareProxyManager(proxyManager) {
4950 view . setOrientationAxesVisibility ( false ) ;
5051 view . getRepresentations ( ) . forEach ( ( representation ) => {
5152 representation . setInterpolationType ( InterpolationType . NEAREST ) ;
52- representation . onModified ( ( ) => {
53+ representation . onModified ( macro . debounce ( ( ) => {
5354 view . render ( true ) ;
54- } ) ;
55+ } , 0 ) ) ;
56+ // debounce timer doesn't need a wait time because
57+ // the many onModified changes that it needs to collapse to a single rerender
58+ // all happen simultaneously when the input data is changed.
5559 } ) ;
5660 } ) ;
5761 }
@@ -755,38 +759,39 @@ const {
755759 } ,
756760 async swapToFrame ( {
757761 state, dispatch, getters, commit,
758- } , { frame, onDownloadProgress = null } ) {
762+ } , { frame, onDownloadProgress = null , loadAll = true } ) {
759763 if ( ! frame ) {
760764 throw new Error ( "frame id doesn't exist" ) ;
761765 }
762766 commit ( 'setLoadingFrame' , true ) ;
763767 commit ( 'setErrorLoadingFrame' , false ) ;
764- const oldScan = getters . currentScan ;
765- const newScan = state . scans [ frame . scan ] ;
766-
767- if ( newScan !== oldScan && newScan ) {
768- queueLoadScan (
769- newScan , 3 ,
770- ) ;
771- }
772768
773- let newProxyManager = false ;
774- if ( oldScan !== newScan && state . proxyManager ) {
775- // If we don't "shrinkProxyManager()" and reinitialize it between
776- // scans, then we can end up with no frame
777- // slices displayed, even though we have the data and attempted
778- // to render it. This may be due to frame extents changing between
779- // scans, which is not the case from one timestep of a single scan
780- // to tne next.
781- shrinkProxyManager ( state . proxyManager ) ;
782- newProxyManager = true ;
783- }
769+ if ( loadAll ) {
770+ const oldScan = getters . currentScan ;
771+ const newScan = state . scans [ frame . scan ] ;
784772
785- if ( ! state . proxyManager || newProxyManager ) {
786- state . proxyManager = vtkProxyManager . newInstance ( {
787- proxyConfiguration : proxy ,
788- } ) ;
789- state . vtkViews = [ ] ;
773+ if ( newScan !== oldScan && newScan ) {
774+ queueLoadScan (
775+ newScan , 3 ,
776+ ) ;
777+ }
778+ let newProxyManager = false ;
779+ if ( oldScan !== newScan && state . proxyManager ) {
780+ // If we don't "shrinkProxyManager()" and reinitialize it between
781+ // scans, then we can end up with no frame
782+ // slices displayed, even though we have the data and attempted
783+ // to render it. This may be due to frame extents changing between
784+ // scans, which is not the case from one timestep of a single scan
785+ // to tne next.
786+ shrinkProxyManager ( state . proxyManager ) ;
787+ newProxyManager = true ;
788+ }
789+ if ( ! state . proxyManager || newProxyManager ) {
790+ state . proxyManager = vtkProxyManager . newInstance ( {
791+ proxyConfiguration : proxy ,
792+ } ) ;
793+ state . vtkViews = [ ] ;
794+ }
790795 }
791796
792797 let sourceProxy = state . proxyManager . getActiveSource ( ) ;
@@ -829,7 +834,7 @@ const {
829834 }
830835
831836 // check for window lock expiry
832- if ( state . windowLocked . lock ) {
837+ if ( loadAll && state . windowLocked . lock ) {
833838 const { currentViewData } = getters ;
834839 const unlock = ( ) => {
835840 commit ( 'setWindowLocked' , {
0 commit comments