Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Trame + Pyvista: add_point_labels doesn't work at all in "client" rendering mode.  #6674

@MouseAndKeyboard

Description

@MouseAndKeyboard

Describe the bug, what's wrong, and what you expected.

From the documentation: https://docs.pyvista.org/examples/02-plot/labels.html

The code below should render a cloud of labels + their points. However, when you run it, it renders the points but does not show the labels. The behavior is different when we use mode='server' it functions as-expected -- showing the labels.

Therefore, there the issue must be due to a difference in the rendering pipeline for mode='client' and mode='server'..

Steps to reproduce the bug.

from __future__ import annotations
import numpy as np
import pyvista as pv
from pyvista.trame.ui import plotter_ui
from trame.app import get_server
from trame_vuetify.ui.vuetify3 import SinglePageLayout

pv.OFF_SCREEN = True

server = get_server(client_type="vue3")
state, ctrl = server.state, server.controller

# Make some random points. Seed the rng for reproducibility.
rng = np.random.default_rng(seed=0)
poly = pv.PolyData(rng.random((10, 3)))
poly["My Labels"] = [f"Label {i}" for i in range(poly.n_points)]
plotter = pv.Plotter()
plotter.add_point_labels(poly, "My Labels", point_size=20, font_size=36)

with SinglePageLayout(server) as layout:
    with layout.content as body:
        view = plotter_ui(plotter, mode='client')
        ctrl.view_update = view.update
        ctrl.view_update_image = view.update_image
        ctrl.reset_camera = view.reset_camera

if __name__ == "__main__":
    server.start()

System Information

--------------------------------------------------------------------------------
  Date: Mon Sep 23 14:14:53 2024 AWST

                OS : Linux (Ubuntu 23.10)
            CPU(s) : 8
           Machine : x86_64
      Architecture : 64bit
       Environment : Python
        GPU Vendor : Intel
      GPU Renderer : Mesa Intel(R) UHD Graphics (CML GT2)
       GPU Version : 4.6 (Core Profile) Mesa 23.2.1-1ubuntu3.1
  MathText Support : True

  Python 3.11.6 (main, Apr 10 2024, 17:26:07) [GCC 13.2.0]

           pyvista : 0.44.1
               vtk : 9.3.1
             numpy : 2.1.1
        matplotlib : 3.9.2
            scooby : 0.10.0
             pooch : 1.8.2
            pillow : 10.4.0
             trame : 3.6.5
      trame_client : 3.2.5
      trame_server : 3.2.0
         trame_vtk : 2.8.10
     trame_vuetify : 2.7.1
--------------------------------------------------------------------------------

Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUh-oh! Something isn't working as expected.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions