Skip to content

Commit

Permalink
Rename and update log
Browse files Browse the repository at this point in the history
  • Loading branch information
edsaac committed Apr 11, 2024
1 parent 90e1b4f commit 880ebc1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
3 changes: 2 additions & 1 deletion stpyvista/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## [v 0.0.17] - 2024-04-02
## [v 0.0.17] - 2024-04-11
- Rewrite buffer using context manager
- Introduce and experimental viewer based on trame and vanilla vtk-js

## [v 0.0.16] - 2024-03-29
- Add controls help description
Expand Down
31 changes: 24 additions & 7 deletions stpyvista/src/stpyvista/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@

from bokeh.resources import CDN, INLINE

BOKEH_RESOURCES = {"CDN": CDN, "INLINE": INLINE}

pn.extension("vtk", sizing_mode="stretch_both")
BOKEH_RESOURCES = {"CDN": CDN, "INLINE": INLINE}

# Tell streamlit that there is a component called stpyvista,
# and that the code to display that component is in the "frontend" folder

class stpyvistaTypeError(TypeError):
pass
Expand All @@ -26,11 +23,30 @@ class stpyvistaTypeError(TypeError):
class stpyvistaValueError(ValueError):
pass


# Tell streamlit that there is a component called `experimental_vtkjs`,
# and that the code to display that component is in the "vanilla_vtkjs" folder
experimental_frontend_dir = (Path(__file__).parent / "vanilla_vtkjs").absolute()
_exp_component_func = components.declare_component("experimental_vtkjs", path=str(experimental_frontend_dir))
_exp_component_func = components.declare_component(
"experimental_vtkjs", path=str(experimental_frontend_dir)
)

def experimental_vtkjs(vtksz_data: bytes, key: Optional[str] = None):

def experimental_vtkjs(vtksz_data: bytes, key: Optional[str] = None):
"""
Renders an interactive Pyvista Plotter in streamlit.
Parameters
----------
vtksz_data: bytes
Data from a vtksz in zip format.
Returns
-------
dict
A stringified JSON with camera view properties.
"""

base64_str = base64.b64encode(vtksz_data).decode().replace("\n", "")

component_value = _exp_component_func(
Expand All @@ -42,9 +58,10 @@ def experimental_vtkjs(vtksz_data: bytes, key: Optional[str] = None):
return component_value


frontend_dir = (Path(__file__).parent / "frontend").absolute()
frontend_dir = (Path(__file__).parent / "panel_based").absolute()
_component_func = components.declare_component("stpyvista", path=str(frontend_dir))


def stpyvista(
plotter: Plotter,
use_container_width: bool = True,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 880ebc1

Please sign in to comment.