Skip to content

Commit 8118675

Browse files
AlejandroFernandezLucespre-commit-ci[bot]pyansys-ci-bot
authored
fix: Mesh slider unclick makes buttons disappear (#362)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent aca293d commit 8118675

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix: Mesh slider unclick makes buttons disappear

src/ansys/tools/visualization_interface/backends/pyvista/widgets/mesh_slider.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ def callback(self, state: bool) -> None:
8585
self.plotter_helper._pl.scene.clear_plane_widgets()
8686
for actor in self._mesh_actor_list:
8787
self.plotter_helper._pl.scene.add_actor(actor)
88+
89+
# Reset all buttons because the slicer removes all actors for some reason
90+
for widget in self.plotter_helper._widgets:
91+
widget._button.Off()
92+
widget._button.GetRepresentation().SetVisibility(0)
93+
widget._button.On()
94+
widget._button.GetRepresentation().SetVisibility(1)
95+
8896
else:
8997
self._mb = pv.MultiBlock(self.plotter_helper._pl.scene.meshes).combine()
9098
self._widget_actor = self.plotter_helper._pl.scene.add_mesh_clip_plane(
@@ -99,7 +107,8 @@ def callback(self, state: bool) -> None:
99107
mesh_id = "MultiBlock(" + mesh.memory_address + ")"
100108
elif isinstance(mesh, pv.StructuredGrid):
101109
mesh_id = "StructuredGrid(" + mesh.memory_address + ")"
102-
self._mesh_actor_list.append(self.plotter_helper._pl.scene.actors[mesh_id])
110+
if mesh_id in self.plotter_helper._pl.scene.actors:
111+
self._mesh_actor_list.append(self.plotter_helper._pl.scene.actors[mesh_id])
103112
self.plotter_helper._pl.scene.remove_actor(mesh_id)
104113

105114
def update(self) -> None:

0 commit comments

Comments
 (0)