Replies: 2 comments 17 replies
-
Yes, you just need to code it that way. It could be easier for us if you share a small subset of what you are doing so we can point you to what you are missing. |
Beta Was this translation helpful? Give feedback.
5 replies
-
Here is a simple example with PyVista: from trame.app import get_server
from trame.ui.vuetify import SinglePageLayout
from trame.widgets import vuetify
import pyvista as pv
from pyvista import examples
from pyvista.trame.ui import plotter_ui
# -----------------------------------------------------------------------------
# Trame initialization
# -----------------------------------------------------------------------------
pv.OFF_SCREEN = True
server = get_server()
state, ctrl = server.state, server.controller
state.trame__title = "Modify Scalar Range"
ctrl.on_server_ready.add(ctrl.view_update)
# -----------------------------------------------------------------------------
# Plotting
# -----------------------------------------------------------------------------
mesh = pv.Wavelet()
pl = pv.Plotter()
actor = pl.add_mesh(mesh)
# -----------------------------------------------------------------------------
# Callbacks
# -----------------------------------------------------------------------------
@state.change("scalar_range")
def set_scalar_range(scalar_range=mesh.get_data_range(), **kwargs):
actor.mapper.scalar_range = scalar_range
ctrl.view_update()
# -----------------------------------------------------------------------------
# GUI
# -----------------------------------------------------------------------------
with SinglePageLayout(server) as layout:
layout.title.set_text("Scalar Selection")
layout.icon.click = ctrl.view_reset_camera
with layout.toolbar:
vuetify.VSpacer()
vuetify.VRangeSlider(
thumb_size=16,
thumb_label=True,
label="Range",
v_model=("scalar_range", [0, 300]),
min=('0',),
max=('500',),
dense=True,
hide_details=True,
style="max-width: 400px",
)
with layout.content:
with vuetify.VContainer(
fluid=True,
classes="pa-0 fill-height",
):
# Use PyVista UI template for Plotters
view = plotter_ui(pl, default_server_rendering=True)
ctrl.view_update = view.update
server.start() Screen.Recording.2023-07-06.at.8.58.38.AM.mov |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Is it possible to modify colors of a mesh dynamically according to the scalar's bar ?
I want to choose the limit of the scalar bar and that in return the mesh update the color.
Like if I have many mesh on a vue, the scalars bar range would be the max and the min of the entire mesh. But if I want to choose the range of the color, can I do it ? For examples, the initial range would be from 10 to 4000. But this range would saturated on the small value like 10, 20 and 50 for example. So I want to update the scalar bar range and the color of meshs so I can see the difference between 10,20 and 50, for example the new range could be [10, 100]. Obviously, it will be saturated on the high value, but it is not a problem if it is reversible. Can it be dynamic in the pyvista vue ?
I find the way to change the range on the scalar bar but it doesnot match the mesh after.
Thanks for your help !
Beta Was this translation helpful? Give feedback.
All reactions