Skip to content
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

How to add the slider? #1140

Open
hanjiahe1999 opened this issue Jun 11, 2024 · 1 comment
Open

How to add the slider? #1140

hanjiahe1999 opened this issue Jun 11, 2024 · 1 comment

Comments

@hanjiahe1999
Copy link

from vedo import *

vol = Volume(dataurl+'embryo.tif')

vol.crop(back=0.50) # crop 50% from neg. y

# show lego blocks whose value is between vmin and vmax
lego = vol.legosurface(vmin=20, vmax=None, boundary=False)
lego.cmap('seismic', vmin=0, vmax=127).add_scalarbar()

show(lego, __doc__, axes=1, viewup='z').close()

When I study this case, I want to try to add a slider to control the Lego display range. Do you have any good suggestions?

Thank you for your help!!

@marcomusy
Copy link
Owner

Have a look at examples/basic/sliders*.py

from vedo import *

settings.default_font = "Calco"

def slider_func(widget, event):
    value = widget.value
    lego = vol.legosurface(vmin=20, vmax=value, boundary=False)
    if lego.ncells:
        lego.cmap('seismic', vmin=0, vmax=value).add_scalarbar()
        # lego.linewidth(0).lighting('off').alpha(0.5)
    lego.name = "LegoSurface"
    plt.remove("LegoSurface").add(lego)
    plt.render()

vol = Volume(dataurl+'embryo.tif')
vol.crop(back=0.50) # crop 50% from neg. y

plt = Plotter()
plt.add_slider(
    slider_func,
    xmin=0,
    xmax=127,
    value=100,
    pos="bottom-left",
    title="value",
    # delayed=True,
)
plt += Axes(vol)
plt.show(viewup='z').close()

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants