@@ -94,7 +94,9 @@ def _build_ui(self):
9494
9595 # => push picker to client
9696 view .register_vtk_object (self .picker )
97- view .register_vtk_object (self .last_picked_property ) # for pure client edit
97+ view .register_vtk_object (
98+ self .last_picked_property
99+ ) # for pure client edit
98100
99101 # => attach interactor listener
100102 wasm_interactor_id = view .get_wasm_id (self .interactor )
@@ -131,35 +133,39 @@ async def _pick_actor(self, x, y):
131133 if self ._picking_prending :
132134 return
133135
134- self . _picking_prending = True
135- # Trigger a pick on client
136- picked_worked = await self . ctx . wasm_view . invoke (
137- self . picker , "Pick" , ( x , y , 0 ), self .renderer
138- )
139- if not picked_worked :
140- self . _picking_prending = False
141- return
136+ try :
137+ self . _picking_prending = True
138+ # Trigger a pick on client
139+ picked_worked = await self .ctx . wasm_view . invoke (
140+ self . picker , "Pick" , ( x , y , 0 ), self . renderer
141+ )
142+ if not picked_worked :
143+ return
142144
143- # Restore previous state
144- if self .last_picked_actor :
145- self .last_picked_actor .property .DeepCopy (self .last_picked_property )
146- self .last_picked_actor = None
145+ # Restore previous state
146+ if self .last_picked_actor :
147+ self .last_picked_actor .property .DeepCopy (self .last_picked_property )
148+ self .last_picked_actor = None
147149
148- actor_info = await self .ctx .wasm_view .invoke (self .picker , "GetActor" )
149- actor = self .ctx .wasm_view .get_vtk_obj (actor_info .get ("Id" ))
150- actor_prop = actor .property
150+ # trame-vtklocal>=0.13.0 auto unwrap vtk object
151+ actor = await self .ctx .wasm_view .invoke (self .picker , "GetActor" )
152+ if actor is None :
153+ return
151154
152- # Save current state and capture picked actor
153- self .last_picked_property .DeepCopy (actor_prop )
154- self .last_picked_actor = actor
155+ actor_prop = actor .property
155156
156- # Highlight actor
157- actor_prop . color = ( 1 , 0 , 1 )
158- actor_prop . EdgeVisibilityOn ()
157+ # Save current state and capture picked actor
158+ self . last_picked_property . DeepCopy ( actor_prop )
159+ self . last_picked_actor = actor
159160
160- # Render
161- self .ctx .wasm_view .update ()
162- self ._picking_prending = False
161+ # Highlight actor
162+ actor_prop .color = (1 , 0 , 1 )
163+ actor_prop .EdgeVisibilityOn ()
164+
165+ finally :
166+ # Render
167+ self .ctx .wasm_view .update ()
168+ self ._picking_prending = False
163169
164170 # endregion py2wasmCall
165171
0 commit comments