New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VtkLocalView not syncing if actors are removed #3
Comments
If I refresh the whole webpage, this is synced I think? though the view goes white even though the renderer background is black so perhaps something is failing and the view is not shown |
The issue is related when there is an empty renderer. If you have a sphere on top of the cone, the removing of 1 actor will work. |
I'm unable to delete any actor and have it synced: src = vtkSphereSource()
src.Update()
mapper2 = vtkPolyDataMapper()
actor2 = vtkActor()
mapper2.SetInputConnection(src.GetOutputPort())
actor2.SetMapper(mapper2)
renderer.AddActor(actor2)
...
def remove_actor():
renderer.RemoveActor(actor2)
renderer.Modified()
ctrl.view_update()
print('should have been deleted') Screen.Recording.2022-10-17.at.1.31.02.PM.movFull script: r"""
Version for trame 1.x - https://github.com/Kitware/trame/blob/release-v1/examples/VTK/SimpleCone/LocalRendering.py
Delta v1..v2 - https://github.com/Kitware/trame/commit/674f72774228bbcab5689417c1c5642230b1eab8
"""
from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.ui.vuetify import SinglePageLayout
from vtkmodules.vtkFiltersSources import vtkConeSource, vtkSphereSource
from vtkmodules.vtkRenderingCore import (
vtkRenderer,
vtkRenderWindow,
vtkRenderWindowInteractor,
vtkPolyDataMapper,
vtkActor,
)
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleSwitch # noqa
# -----------------------------------------------------------------------------
# Trame initialization
# -----------------------------------------------------------------------------
server = get_server()
state, ctrl = server.state, server.controller
state.trame__title = "VTK Remote View - Local Rendering"
# -----------------------------------------------------------------------------
# VTK pipeline
# -----------------------------------------------------------------------------
DEFAULT_RESOLUTION = 6
renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
cone_source = vtkConeSource()
mapper = vtkPolyDataMapper()
actor = vtkActor()
mapper.SetInputConnection(cone_source.GetOutputPort())
actor.SetMapper(mapper)
renderer.AddActor(actor)
renderer.ResetCamera()
renderWindow.Render()
src = vtkSphereSource()
src.Update()
mapper2 = vtkPolyDataMapper()
actor2 = vtkActor()
mapper2.SetInputConnection(src.GetOutputPort())
actor2.SetMapper(mapper2)
renderer.AddActor(actor2)
# -----------------------------------------------------------------------------
# Callbacks
# -----------------------------------------------------------------------------
@state.change("resolution")
def update_cone(resolution=DEFAULT_RESOLUTION, **kwargs):
cone_source.SetResolution(resolution)
ctrl.view_update()
def update_reset_resolution():
state.resolution = DEFAULT_RESOLUTION
def remove_actor():
renderer.RemoveActor(actor2)
renderer.Modified()
ctrl.view_update()
print('should have been deleted')
# -----------------------------------------------------------------------------
# GUI
# -----------------------------------------------------------------------------
with SinglePageLayout(server) as layout:
layout.icon.click = ctrl.view_reset_camera
layout.title.set_text("Cone Application")
with layout.toolbar:
vuetify.VSpacer()
vuetify.VSlider(
v_model=("resolution", DEFAULT_RESOLUTION),
min=3,
max=60,
step=1,
hide_details=True,
dense=True,
style="max-width: 300px",
)
vuetify.VDivider(vertical=True, classes="mx-2")
with vuetify.VBtn(icon=True, click=update_reset_resolution):
vuetify.VIcon("mdi-undo-variant")
with vuetify.VBtn(icon=True, click=remove_actor):
vuetify.VIcon("mdi-delete")
with layout.content:
with vuetify.VContainer(
fluid=True,
classes="pa-0 fill-height",
):
view = vtk.VtkLocalView(renderWindow, ref="view")
ctrl.view_update = view.update
ctrl.view_reset_camera = view.reset_camera
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
if __name__ == "__main__":
server.start() |
This was referenced Nov 4, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have modified
examples/06_vtk/01_SimpleCone/LocalRendering.py
to have a delete button that will remove the actor from the render window. However, onview.update
, the data being removed is not synced to the client renderer.This is the added code:
and this is the full example:
The text was updated successfully, but these errors were encountered: