Kitware / vtk-js

Visualization Toolkit for the Web
https://kitware.github.io/vtk-js/
BSD 3-Clause "New" or "Revised" License
1.24k stars 373 forks source link

Temporary disabling ViewProxy rendering #1416

Closed BotellaA closed 4 years ago

BotellaA commented 4 years ago

I have a ViewProxy with some representations. I would like to stop rendering them but only for a given time (between two given events). One way to do it is to remove all the representations from the ViewProxy. But I will have to add them again once I want to render them again.

Is there a way (or work around) to "pause" the rendering without loosing all its configuration?

jourdain commented 4 years ago
view.SuppressRendering = 1
BotellaA commented 4 years ago

So simple.. But where is it implemented? I did not find any reference to this option.

jourdain commented 4 years ago

It is a Proxy Property on the View itself. print(proxy.ListProperties())

BotellaA commented 4 years ago

Here is my output of console.log(view) where view is a ViewProxy

activate: ƒ ()
addRepresentation: ƒ (representation)
captureImage: ƒ ()
clearKeystore: ƒ ()
delete: ƒ ()
deleteKey: ƒ (key)
focusTo: ƒ ()
gcPropertyLinks: ƒ (type)
get: ƒ ()
getAllKeys: ƒ ()
getAnnotationOpacity: ƒ ()
getBackground: ƒ ()
getCamera: ƒ ()
getCameraFocalPoint: ƒ ()
getCameraPosition: ƒ ()
getCameraViewUp: ƒ ()
getClassName: ƒ ()
getContainer: ƒ ()
getCornerAnnotation: ƒ ()
getDisableAnimation: ƒ ()
getInteractor: ƒ ()
getInteractorStyle2D: ƒ ()
getInteractorStyle3D: ƒ ()
getKey: ƒ (key)
getMTime: ƒ ()
getName: ƒ ()
getOpenglRenderWindow: ƒ ()
getOrientationAxesCorner: ƒ ()
getOrientationAxesSize: ƒ ()
getOrientationAxesType: ƒ ()
getOrientationAxesVisibility: ƒ ()
getPresetToOrientationAxes: ƒ ()
getPropertyByName: ƒ (name)
getPropertyDomainByName: ƒ (name)
getPropertyLink: ƒ (id)
getProxyGroup: ƒ ()
getProxyId: ƒ ()
getProxyManager: ƒ ()
getProxyName: ƒ ()
getProxySection: ƒ ()
getReferenceByName: ƒ (val)
getRenderWindow: ƒ ()
getRenderer: ƒ ()
getRepresentations: ƒ ()
getState: ƒ ()
getUseParallelRendering: ƒ ()
invokeResize: ƒ invoke()
isA: ƒ (className)
isDeleted: ƒ ()
listOrientationAxis: ƒ ()
listPropertyNames: ƒ ()
modified: ƒ (otherMTime)
moveCamera: ƒ (focalPoint, position, viewUp)
onModified: ƒ (callback)
onResize: ƒ (callback)
openCaptureImage: ƒ ()
registerOrientationAxis: ƒ (name, actor)
registerPropertyLinkForGC: ƒ (otherLink, type)
removeRepresentation: ƒ (representation)
renderLater: ƒ ()
resetCamera: ƒ ()
resetOrientation: ƒ ()
resize: ƒ ()
rotate: ƒ (angle)
set: ƒ ()
setAnimation: ƒ (enable)
setAnnotationOpacity: ƒ (opacity)
setBackground: ƒ ()
setCameraFocalPoint: ƒ (x, y, z)
setCameraPosition: ƒ (x, y, z)
setCameraViewUp: ƒ ()
setContainer: ƒ (container)
setCornerAnnotation: ƒ (corner, templateString)
setCornerAnnotations: ƒ (annotations)
setDisableAnimation: ƒ setter(value)
setKey: ƒ (key, value)
setName: ƒ setter(value)
setOrientationAxesCorner: ƒ (corner)
setOrientationAxesSize: ƒ (sizeFactor)
setOrientationAxesType: ƒ (type)
setOrientationAxesVisibility: ƒ (enabling)
setPresetToInteractor2D: ƒ (nameOrDefinitions)
setPresetToInteractor3D: ƒ (nameOrDefinitions)
setPresetToOrientationAxes: ƒ (nameOrDefinitions)
setProxyManager: ƒ setter(value)
shallowCopy: ƒ (other)
unregisterOrientationAxis: ƒ (name)
updateCornerAnnotation: ƒ (meta)
updateOrientation: ƒ (axisIndex, orientation, viewUp)
updateProxyProperty: ƒ (propertyName, propUI)
updateUI: ƒ (ui)
__proto__

I tried to call view.listPropertyNames() but it is an empty array.

jourdain commented 4 years ago

Oups, I thought it was on ParaViewWeb... (Sorry I did not read where the message came from).

I don't think there is anything in place. You just need to control where/when render get called and guard it via a global lock/var.

Sorry about the miss-leading direction.

BotellaA commented 4 years ago

Ok, don't worry!! You are always so helpful!

Is there a way to add this guard without modifying vtk-js? I do not really want to fork your project.

This guard will control the rendering process. Is there a way to clear/hide what was already render?

jourdain commented 4 years ago

I don't think you will need to edit vtk.js itself (but it might be done via a small PR). But could you describe what is your process that trigger render when you want to wait for later?

A way to hide could be just CSS (display/none|opacity: 0) or if is is just the content, set the actor visibility to false for each representation.

My guess is that when you edit the proxyManager (create/edit/delete proxy) you want to prevent any render from happening. For that, normally you setup a pxm.onModified(pxm.renderAll); Just guard that call.

BotellaA commented 4 years ago

I have a VTKWeb application and the idea is to have a ligth front end visualization while the camera is moving.

Using the CSS properties is a great way to do it! The drawback of this solution is the OrientationWidget that is also hidden in the process. I would like it always displayed. (I know I maybe want too much...).

BotellaA commented 4 years ago

I went for the view.getOpenglRenderWindow().setUseOffScreen(x) function. Thanks for your help!