Skip to content

Commit

Permalink
docs(vtk): Rename trame.widgets.vtk to not confuse with vtk import
Browse files Browse the repository at this point in the history
fix #127
  • Loading branch information
jourdain committed Oct 16, 2022
1 parent 7790cd1 commit b480332
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 63 deletions.
8 changes: 4 additions & 4 deletions examples/06_vtk/00_ClientOnly/client-side-cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets

# -----------------------------------------------------------------------------
# Trame setup
Expand All @@ -23,9 +23,9 @@
with SinglePageLayout(server) as layout:
with layout.content:
with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
with vtk.VtkView(ref="view"):
with vtk.VtkGeometryRepresentation():
vtk.VtkAlgorithm(
with vtk_widgets.VtkView(ref="view"):
with vtk_widgets.VtkGeometryRepresentation():
vtk_widgets.VtkAlgorithm(
vtkClass="vtkConeSource", state=("{ resolution }",)
)

Expand Down
10 changes: 6 additions & 4 deletions examples/06_vtk/01_SimpleCone/ClientView.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkFiltersSources import vtkConeSource
Expand Down Expand Up @@ -67,10 +67,12 @@ def update_reset_resolution():

with layout.content:
with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
with vtk.VtkView() as view:
with vtk_widgets.VtkView() as view:
ctrl.view_reset_camera = view.reset_camera
with vtk.VtkGeometryRepresentation():
html_polydata = vtk.VtkPolyData("cone", dataset=cone_generator)
with vtk_widgets.VtkGeometryRepresentation():
html_polydata = vtk_widgets.VtkPolyData(
"cone", dataset=cone_generator
)
ctrl.mesh_update = html_polydata.update


Expand Down
4 changes: 2 additions & 2 deletions examples/06_vtk/01_SimpleCone/LocalRendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkFiltersSources import vtkConeSource
Expand Down Expand Up @@ -92,7 +92,7 @@ def update_reset_resolution():
fluid=True,
classes="pa-0 fill-height",
):
view = vtk.VtkLocalView(renderWindow, ref="view")
view = vtk_widgets.VtkLocalView(renderWindow, ref="view")
ctrl.view_update = view.update
ctrl.view_reset_camera = view.reset_camera

Expand Down
4 changes: 2 additions & 2 deletions examples/06_vtk/01_SimpleCone/RemoteRendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkFiltersSources import vtkConeSource
Expand Down Expand Up @@ -146,7 +146,7 @@ def update_reset_resolution():
fluid=True,
classes="pa-0 fill-height",
):
view = vtk.VtkRemoteView(
view = vtk_widgets.VtkRemoteView(
renderWindow,
ref="view",
# For Custom / Advanced event handling
Expand Down
8 changes: 4 additions & 4 deletions examples/06_vtk/02_ContourGeometry/ClientView.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkIOXML import vtkXMLImageDataReader
Expand Down Expand Up @@ -94,10 +94,10 @@ def update_contour(contour_value, **kwargs):

with layout.content:
with vuetify.VContainer(fluid=True, classes="pa-0 fill-height"):
with vtk.VtkView() as view:
with vtk_widgets.VtkView() as view:
layout.icon.click = view.reset_camera
with vtk.VtkGeometryRepresentation():
polydata = vtk.VtkPolyData("contour", dataset=contour)
with vtk_widgets.VtkGeometryRepresentation():
polydata = vtk_widgets.VtkPolyData("contour", dataset=contour)
ctrl.ds_update = polydata.update

# -----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkIOXML import vtkXMLImageDataReader
Expand Down Expand Up @@ -145,7 +145,7 @@ def update_contour(contour_value, **kwargs):
fluid=True,
classes="pa-0 fill-height",
):
view = vtk.VtkRemoteLocalView(
view = vtk_widgets.VtkRemoteLocalView(
renderWindow,
namespace="demo",
# second arg is to force the view to start in "local" mode
Expand Down
6 changes: 3 additions & 3 deletions examples/06_vtk/02_ContourGeometry/RemoteDynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkIOXML import vtkXMLImageDataReader
Expand Down Expand Up @@ -118,8 +118,8 @@ def commit_changes():
# GUI
# -----------------------------------------------------------------------------

html_remote_view = vtk.VtkRemoteView(renderWindow, trame_server=server)
html_local_view = vtk.VtkLocalView(renderWindow, trame_server=server)
html_remote_view = vtk_widgets.VtkRemoteView(renderWindow, trame_server=server)
html_local_view = vtk_widgets.VtkLocalView(renderWindow, trame_server=server)


layout = SinglePageLayout(server)
Expand Down
6 changes: 3 additions & 3 deletions examples/06_vtk/02_ContourGeometry/RemoteRendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkIOXML import vtkXMLImageDataReader
Expand Down Expand Up @@ -133,8 +133,8 @@ def commit_changes():
fluid=True,
classes="pa-0 fill-height",
):
# view = vtk.VtkLocalView(renderWindow)
view = vtk.VtkRemoteView(renderWindow)
# view = vtk_widgets.VtkLocalView(renderWindow)
view = vtk_widgets.VtkRemoteView(renderWindow)
ctrl.view_update = view.update
ctrl.view_reset_camera = view.reset_camera
ctrl.on_server_ready.add(view.update)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkIOXML import vtkXMLImageDataReader
Expand Down Expand Up @@ -133,8 +133,8 @@ def commit_changes():
fluid=True,
classes="pa-0 fill-height",
):
view = vtk.VtkLocalView(renderWindow)
# view = vtk.VtkRemoteView(renderWindow)
view = vtk_widgets.VtkLocalView(renderWindow)
# view = vtk_widgets.VtkRemoteView(renderWindow)
ctrl.view_update = view.update
ctrl.view_reset_camera = view.reset_camera
ctrl.on_server_ready.add(view.update)
Expand Down
6 changes: 4 additions & 2 deletions examples/06_vtk/03_MultiViews/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from trame.app import get_server
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets
from trame.ui.vuetify import SinglePageLayout

from vtkmodules.vtkFiltersSources import vtkConeSource
Expand Down Expand Up @@ -125,7 +125,9 @@ def update_reset_resolution():
)
with container:
with vuetify.VCol(classes="pa-0 ma-0"):
view = vtk.VtkRemoteView(render_window, ref=f"view{idx}")
view = vtk_widgets.VtkRemoteView(
render_window, ref=f"view{idx}"
)
html_views.append(view)
ctrl.update_views.add(view.update)
ctrl.reset_camera.add(view.reset_camera)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vuetify, vtk, trame
from trame.widgets import vuetify, trame, vtk as vtk_widgets

# -----------------------------------------------------------------------------
# Constants
Expand Down Expand Up @@ -304,7 +304,7 @@ def update_tooltip(pick_data, pixel_ratio, **kwargs):
classes="pa-0 fill-height",
style="position: relative",
):
with vtk.VtkView(
with vtk_widgets.VtkView(
ref="view",
background=("[0.8, 0.8, 0.8]",),
hover="pick_data = $event",
Expand All @@ -313,7 +313,7 @@ def update_tooltip(pick_data, pixel_ratio, **kwargs):
) as view:
ctrl.view_update = view.update
ctrl.view_reset_camera = view.reset_camera
with vtk.VtkGeometryRepresentation(
with vtk_widgets.VtkGeometryRepresentation(
v_if=("mesh",),
property=(
"""{
Expand All @@ -323,14 +323,14 @@ def update_tooltip(pick_data, pixel_ratio, **kwargs):
}""",
),
):
mesh = vtk.VtkMesh("mesh", dataset=vtk_grid)
mesh = vtk_widgets.VtkMesh("mesh", dataset=vtk_grid)
ctrl.mesh_update = mesh.update

with vtk.VtkGeometryRepresentation(
with vtk_widgets.VtkGeometryRepresentation(
v_if=("threshold",),
color_data_range=("full_range", [0, 1]),
):
threshold = vtk.VtkMesh(
threshold = vtk_widgets.VtkMesh(
"threshold", dataset=vtk_filter, field_to_keep=field_to_keep
)
ctrl.threshold_update = threshold.update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets

# -----------------------------------------------------------------------------
# Trame setup
Expand Down Expand Up @@ -322,7 +322,7 @@ def reset():
classes="pa-0 fill-height",
style="position: relative",
):
html_view = vtk.VtkLocalView(renderWindow)
html_view = vtk_widgets.VtkLocalView(renderWindow)
ctrl.view_update = html_view.update
ctrl.view_reset_camera = html_view.reset_camera

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vuetify, vtk
from trame.widgets import vuetify, vtk as vtk_widgets

# -----------------------------------------------------------------------------
# Trame setup
Expand Down Expand Up @@ -331,7 +331,7 @@ def reset():
classes="pa-0 fill-height",
style="position: relative",
):
html_view = vtk.VtkRemoteView(
html_view = vtk_widgets.VtkRemoteView(
renderWindow, interactive_ratio=("1",), interactive_quality=(80,)
)
ctrl.view_update = html_view.update
Expand Down
10 changes: 5 additions & 5 deletions examples/06_vtk/Applications/MultiFilter/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from trame.app import get_server
from trame.ui.vuetify import SinglePageWithDrawerLayout
from trame.widgets import vtk, vuetify, trame
from trame.widgets import vuetify, trame, vtk as vtk_widgets

from vtkmodules.vtkCommonDataModel import vtkDataObject
from vtkmodules.vtkFiltersCore import vtkContourFilter
Expand Down Expand Up @@ -64,7 +64,7 @@ class LookupTable:

# Read Data
reader = vtkXMLUnstructuredGridReader()
reader.SetFileName(os.path.join(CURRENT_DIRECTORY, "../data/disk_out_ref.vtu"))
reader.SetFileName(os.path.join(CURRENT_DIRECTORY, "../../../data/disk_out_ref.vtu"))
reader.Update()

# Extract Array/Field information
Expand Down Expand Up @@ -586,9 +586,9 @@ def contour_card():
fluid=True,
classes="pa-0 fill-height",
):
# view = vtk.VtkRemoteView(renderWindow, interactive_ratio=1)
# view = vtk.VtkLocalView(renderWindow)
view = vtk.VtkRemoteLocalView(
# view = vtk_widgets.VtkRemoteView(renderWindow, interactive_ratio=1)
# view = vtk_widgets.VtkLocalView(renderWindow)
view = vtk_widgets.VtkRemoteLocalView(
renderWindow, namespace="view", mode="local", interactive_ratio=1
)
ctrl.view_update = view.update
Expand Down
6 changes: 3 additions & 3 deletions examples/06_vtk/Applications/RemoteSelection/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from trame.app import get_server
from trame.assets.remote import HttpFile
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vuetify, plotly, vtk, trame
from trame.widgets import vuetify, plotly, trame, vtk as vtk_widgets

# VTK imports
from vtkmodules.vtkIOXML import vtkXMLUnstructuredGridReader
Expand Down Expand Up @@ -299,13 +299,13 @@ def on_box_selection_change(selection):
classes="pa-0",
style="border-right: 1px solid #ccc; position: relative;",
):
view = vtk.VtkRemoteView(
view = vtk_widgets.VtkRemoteView(
render_window,
box_selection=("vtk_selection",),
box_selection_change=(on_box_selection_change, "[$event]"),
**VTK_VIEW_SETTINGS,
)
# view = vtk.VtkLocalView(
# view = vtk_widgets.VtkLocalView(
# render_window,
# box_selection=("vtk_selection",),
# box_selection_change=(on_box_selection_change, "[$event]"),
Expand Down
Loading

0 comments on commit b480332

Please sign in to comment.