Skip to content

Commit 411ae1d

Browse files
committed
update trame+viewer doc
1 parent bad48f5 commit 411ae1d

File tree

6 files changed

+40
-19
lines changed

6 files changed

+40
-19
lines changed

docs/.vitepress/config.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default defineConfig({
5252
{
5353
text: 'Introduction',
5454
items: [
55-
{ text: 'Getting started', link: '/guide/index' }
55+
{ text: 'Getting started', link: '/guide/' }
5656
]
5757
},
5858
{
@@ -66,23 +66,23 @@ export default defineConfig({
6666
{
6767
text: 'For JavaScript developers',
6868
items: [
69-
{ text: 'Getting started', link: '/guide/js/index' },
69+
{ text: 'Getting started', link: '/guide/js/' },
7070
{ text: 'Plain JavaScript', link: '/guide/js/plain' },
7171
{ text: 'Building an application', link: '/guide/js/bundler' },
7272
]
7373
},
7474
{
7575
text: 'For trame users',
7676
items: [
77-
{ text: 'Getting started', link: '/guide/trame/index' },
77+
{ text: 'Getting started', link: '/guide/trame/' },
7878
{ text: '3D Widgets', link: '/guide/trame/widget' },
7979
{ text: 'Method call', link: '/guide/trame/picking' },
8080
]
8181
},
8282
{
8383
text: 'As a data viewer',
8484
items: [
85-
{ text: 'Getting started', link: '/guide/viewer/index' },
85+
{ text: 'Getting started', link: '/guide/viewer/' },
8686
{ text: 'Generating data', link: '/guide/viewer/data' },
8787
]
8888
},

docs/guide/trame/picking.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Call to VTK.wasm from Python
22

3-
VTK 3D widgets let you interact with the 3D view in a way that you can drive a processing filter interactively.
4-
5-
In the example below we cover how you can create such widget in plain VTK and how to enable it on the client within the WASM context.
3+
This example capture the usage of a vtkPiker and illustate the usage of method call from Python.
64

75
![Wheel picking](/assets/images/trame/pick1.png)
86

@@ -12,7 +10,7 @@ The code below highlight some important region and logic to understand.
1210
<<< ../../../examples/trame/picking/pick.py#vtk{py:line-numbers=42} [VTK 3D Widget]
1311
<<< ../../../examples/trame/picking/pick.py#trameWidget{py:line-numbers=82} [Trame widget]
1412
<<< ../../../examples/trame/picking/pick.py#trameChange{py:line-numbers=118} [State change]
15-
<<< ../../../examples/trame/picking/pick.py#py2wasmCall{py:line-numbers=128} [Method call]
13+
<<< ../../../examples/trame/picking/pick.py#py2wasmCall{py:line-numbers=129} [Method call]
1614
<<< ../../../examples/trame/picking/pick.py{py:line-numbers} [Full code (pick.py)]
1715
<<< ../../../examples/trame/picking/requirements.txt
1816
:::

docs/guide/viewer/data.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
# VTK.wasm viewer data format
22

3-
Our VTK.wasm view rely on the state...
3+
While the viewer provides a convinient solution for sharing visualizations, it is also important to provide a simple approach for capturing such a scene into a standalone file.
44

5+
The `trame.widget.vtklocal.VtkLocal` widget provides a `save(file_name)` helper method that will ease such file creation. You can even see its usage within our trame examples. Once things stabilize, we may promote such method on the vtkObjectManager directly to ease access.
56

6-
<div style="width: 100%; height: 50vh; border-radius: 12px; overflow: hidden; margin: 1rem 0;">
7+
::: code-group
8+
<<< ../../../examples/trame/widget/clip.py#export{py} [Clipping]
9+
<<< ../../../examples/trame/picking/pick.py#export{py} [Picking]
10+
:::
11+
12+
<div style="width: 100%; height: 25vh; border-radius: 12px; overflow: hidden; margin: 1rem 0;">
713
<iframe src="/vtk-wasm/demo/viewer-basic.html" style="width: 100%; height: 100%; border: none;">
814
</iframe>
915
</div>
1016

11-
<div style="width: 100%; height: 50vh; border-radius: 12px; overflow: hidden; margin: 1rem 0;">
17+
<div style="width: 100%; height: 25vh; border-radius: 12px; overflow: hidden; margin: 1rem 0;">
1218
<iframe src="/vtk-wasm/demo/viewer-porsche.html" style="width: 100%; height: 100%; border: none;">
1319
</iframe>
1420
</div>
1521

16-
<div style="width: 100%; height: 50vh; border-radius: 12px; overflow: hidden; margin: 1rem 0;">
22+
<div style="width: 100%; height: 25vh; border-radius: 12px; overflow: hidden; margin: 1rem 0;">
1723
<iframe src="/vtk-wasm/demo/viewer-starfighter.html" style="width: 100%; height: 100%; border: none;">
1824
</iframe>
1925
</div>

docs/guide/viewer/index.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# VTK.wasm viewer
22

3-
Thanks to VTK.wasm we are getting close to full parity with what is available in VTK C++ and therefore can create viewers that display scenes equivalent to what you can produce with ParaView or any VTK based application.
3+
Thanks to VTK.wasm we are getting close to full parity with what is available in VTK C++ and therefore we can create viewers that display scenes equivalent to what you can produce with ParaView or VTK.
44

5-
<div style="width: 100%; height: 50vh; border-radius: 12px; overflow: hidden; margin: 1rem 0;">
5+
The code snippet available below show you how you can embed a static 3D scene inside a web page.
6+
7+
<<< ../../public/demo/viewer-basic.html
8+
9+
The `createViewer` method give you the opportunity to fill a DOM element using a selector and the path of the data to load. Additionally, you can provide the path to the WASM library to load unless it is imported as a script. Finally, you can configure your running by setting the rendering backend and execution mode.
10+
11+
Below is the result of the code above.
12+
13+
<div style="width: 100%; height: 25vh; border-radius: 12px; overflow: hidden; margin: 1rem 0;">
614
<iframe src="/vtk-wasm/demo/viewer-basic.html" style="width: 100%; height: 100%; border: none;">
715
</iframe>
816
</div>
9-
10-
<<< ../../public/demo/viewer-basic.html

examples/trame/picking/pick.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def apply_settings(property):
3434
class Pick(TrameApp):
3535
def __init__(self, server=None):
3636
super().__init__(server)
37+
self._picking_prending = False
3738
self._setup_vtk()
3839
self._build_ui()
3940

@@ -100,8 +101,7 @@ def _build_ui(self):
100101
"wasm_listeners",
101102
{
102103
wasm_interactor_id: {
103-
# Use "MouseMoveEvent" for more flashy interaction
104-
"LeftButtonPressEvent": {
104+
"LeftButtonPressEvent": { # LeftButtonPressEvent, MouseMoveEvent
105105
"clicked_pos": {
106106
"x": (wasm_interactor_id, "EventPosition", 0),
107107
"y": (wasm_interactor_id, "EventPosition", 1),
@@ -120,17 +120,23 @@ def on_click(self, clicked_pos, **_):
120120
if clicked_pos is None:
121121
return
122122

123-
asynchronous.create_task(self._pick_actor(**clicked_pos))
123+
if not self._picking_prending:
124+
asynchronous.create_task(self._pick_actor(**clicked_pos))
124125

125126
# endregion trameChange
126127

127128
# region py2wasmCall
128129
async def _pick_actor(self, x, y):
130+
if self._picking_prending:
131+
return
132+
133+
self._picking_prending = True
129134
# Trigger a pick on client
130135
picked_worked = await self.ctx.wasm_view.invoke(
131136
self.picker, "Pick", (x, y, 0), self.renderer
132137
)
133138
if not picked_worked:
139+
self._picking_prending = False
134140
return
135141

136142
# Restore previous state
@@ -152,18 +158,21 @@ async def _pick_actor(self, x, y):
152158

153159
# Render
154160
self.ctx.wasm_view.update()
161+
self._picking_prending = False
155162

156163
# endregion py2wasmCall
157164

158165

159166
def main():
167+
# region export
160168
import sys
161169

162170
app = Pick()
163171
if "--export" in sys.argv:
164172
app.ctx.wasm_view.save("porsche.wazex")
165173

166174
app.server.start()
175+
# endregion export
167176

168177

169178
if __name__ == "__main__":

examples/trame/widget/clip.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,15 @@ def on_plane_widget(self, plane_widget, **_):
182182

183183

184184
def main():
185+
# region export
185186
import sys
186187

187188
app = Clip()
188189
if "--export" in sys.argv:
189190
app.ctx.wasm_view.save("star-fighter.wazex")
190191

191192
app.server.start()
193+
# endregion export
192194

193195

194196
if __name__ == "__main__":

0 commit comments

Comments
 (0)