11import vtkRenderWindowInteractor from '@kitware/vtk.js/Rendering/Core/RenderWindowInteractor' ;
22import vtkInteractorStyleRemoteMouse from '../utils/interactorStyle' ;
33
4- const { inject, provide, ref, toRefs, onMounted, onBeforeUnmount } = window . Vue ;
5- import { EventThrottle } from '../utils/EventThrottle' ;
4+ const { inject, provide, ref, toRefs, onMounted, onBeforeUnmount, watch } =
5+ window . Vue ;
6+ import { FunctionThrottle , EventThrottle } from '../utils/EventThrottle' ;
67
78const RESOLVED_PROMISED = Promise . resolve ( true ) ;
89
@@ -28,15 +29,30 @@ export default {
2829 type : Number ,
2930 default : 25 ,
3031 } ,
32+ resizeThrottleMs : {
33+ type : Number ,
34+ default : 100 ,
35+ } ,
3136 imageStyle : {
3237 type : Object ,
3338 default : ( ) => ( { width : '100%' } ) ,
3439 } ,
40+ monitor : {
41+ type : Number ,
42+ default : 0 ,
43+ } ,
3544 } ,
3645 setup ( props ) {
3746 const rootElem = ref ( null ) ;
3847 const trame = inject ( 'trame' ) ;
3948
49+ // Resizing throttle
50+ const throttleSize = new FunctionThrottle (
51+ _pushSize ,
52+ props . resizeThrottleMs
53+ ) ;
54+ watch ( props . resizeThrottleMs , ( v ) => ( throttleSize . delay = v ) ) ;
55+
4056 // Event throttle
4157 const throttle = new EventThrottle ( ( event ) => {
4258 return trame . client
@@ -147,6 +163,10 @@ export default {
147163 } ) ;
148164
149165 function pushSize ( addOn ) {
166+ throttleSize . run ( addOn ) ;
167+ }
168+
169+ function _pushSize ( addOn ) {
150170 if ( trame ) {
151171 if ( readySizeUpdate ) {
152172 readySizeUpdate = false ;
@@ -194,7 +214,7 @@ export default {
194214 template : `
195215 <div ref="rootElem" style="margin: 0; padding: 0; position: relative; width: 100%; height: 100%;">
196216 <div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;">
197- <display-area :display="display" :name="name" :origin="origin" :imageStyle="imageStyle" />
217+ <display-area :display="display" :name="name" :origin="origin" :imageStyle="imageStyle" :monitor="monitor" @stats="$emit('stats', $event)" />
198218 <slot></slot>
199219 </div>
200220 </div>
0 commit comments