11import os
22
3- from trame import change , update_state
3+ from trame import state
44from trame .layouts import SinglePageWithDrawer
55from trame .html import vtk , vuetify , widgets
66
@@ -170,13 +170,13 @@ class LookupTable:
170170# -----------------------------------------------------------------------------
171171
172172
173- @change ("cube_axes_visibility" )
173+ @state . change ("cube_axes_visibility" )
174174def update_cube_axes_visibility (cube_axes_visibility , ** kwargs ):
175175 cube_axes .SetVisibility (cube_axes_visibility )
176176 html_view .update ()
177177
178178
179- @change ("local_vs_remote" )
179+ @state . change ("local_vs_remote" )
180180def update_local_vs_remote (local_vs_remote , ** kwargs ):
181181 # Switch html_view
182182 global html_view
@@ -197,11 +197,11 @@ def update_local_vs_remote(local_vs_remote, **kwargs):
197197def actives_change (ids ):
198198 _id = ids [0 ]
199199 if _id == "1" : # Mesh
200- update_state ( " active_ui" , "mesh" )
200+ state . active_ui = "mesh"
201201 elif _id == "2" : # Contour
202- update_state ( " active_ui" , "contour" )
202+ state . active_ui = "contour"
203203 else :
204- update_state ( " active_ui" , "nothing" )
204+ state . active_ui = "nothing"
205205
206206
207207# Visibility Change
@@ -237,13 +237,13 @@ def update_representation(actor, mode):
237237 property .EdgeVisibilityOn ()
238238
239239
240- @change ("mesh_representation" )
240+ @state . change ("mesh_representation" )
241241def update_mesh_representation (mesh_representation , ** kwargs ):
242242 update_representation (mesh_actor , mesh_representation )
243243 html_view .update ()
244244
245245
246- @change ("contour_representation" )
246+ @state . change ("contour_representation" )
247247def update_contour_representation (contour_representation , ** kwargs ):
248248 update_representation (contour_actor , contour_representation )
249249 html_view .update ()
@@ -263,14 +263,14 @@ def color_by_array(actor, array):
263263 mapper .SetUseLookupTableScalarRange (True )
264264
265265
266- @change ("mesh_color_array_idx" )
266+ @state . change ("mesh_color_array_idx" )
267267def update_mesh_color_by_name (mesh_color_array_idx , ** kwargs ):
268268 array = dataset_arrays [mesh_color_array_idx ]
269269 color_by_array (mesh_actor , array )
270270 html_view .update ()
271271
272272
273- @change ("contour_color_array_idx" )
273+ @state . change ("contour_color_array_idx" )
274274def update_contour_color_by_name (contour_color_array_idx , ** kwargs ):
275275 array = dataset_arrays [contour_color_array_idx ]
276276 color_by_array (contour_actor , array )
@@ -299,33 +299,33 @@ def use_preset(actor, preset):
299299 lut .Build ()
300300
301301
302- @change ("mesh_color_preset" )
302+ @state . change ("mesh_color_preset" )
303303def update_mesh_color_preset (mesh_color_preset , ** kwargs ):
304304 use_preset (mesh_actor , mesh_color_preset )
305305 html_view .update ()
306306
307307
308- @change ("contour_color_preset" )
308+ @state . change ("contour_color_preset" )
309309def update_contour_color_preset (contour_color_preset , ** kwargs ):
310310 use_preset (contour_actor , contour_color_preset )
311311 html_view .update ()
312312
313313
314314# Opacity Callbacks
315- @change ("mesh_opacity" )
315+ @state . change ("mesh_opacity" )
316316def update_mesh_opacity (mesh_opacity , ** kwargs ):
317317 mesh_actor .GetProperty ().SetOpacity (mesh_opacity )
318318 html_view .update ()
319319
320320
321- @change ("contour_opacity" )
321+ @state . change ("contour_opacity" )
322322def update_contour_opacity (contour_opacity , ** kwargs ):
323323 contour_actor .GetProperty ().SetOpacity (contour_opacity )
324324 html_view .update ()
325325
326326
327327# Contour Callbacks
328- @change ("contour_by_array_idx" )
328+ @state . change ("contour_by_array_idx" )
329329def update_contour_by (contour_by_array_idx , ** kwargs ):
330330 array = dataset_arrays [contour_by_array_idx ]
331331 contour_min , contour_max = array .get ("range" )
@@ -335,16 +335,16 @@ def update_contour_by(contour_by_array_idx, **kwargs):
335335 contour .SetValue (0 , contour_value )
336336
337337 # Update UI
338- update_state ( " contour_min" , contour_min )
339- update_state ( " contour_max" , contour_max )
340- update_state ( " contour_value" , contour_value )
341- update_state ( " contour_step" , contour_step )
338+ state . contour_min = contour_min
339+ state . contour_max = contour_max
340+ state . contour_value = contour_value
341+ state . contour_step = contour_step
342342
343343 # Update View
344344 html_view .update ()
345345
346346
347- @change ("contour_value" )
347+ @state . change ("contour_value" )
348348def update_contour_value (contour_value , ** kwargs ):
349349 contour .SetValue (0 , float (contour_value ))
350350 html_view .update ()
0 commit comments