diff --git a/geos-trame/src/geos/trame/app/ui/viewer/viewer.py b/geos-trame/src/geos/trame/app/ui/viewer/viewer.py index 252e793e2..51fe6682f 100644 --- a/geos-trame/src/geos/trame/app/ui/viewer/viewer.py +++ b/geos-trame/src/geos/trame/app/ui/viewer/viewer.py @@ -303,10 +303,20 @@ def _update_perforation( self, perforation: Perforation, show: bool, path: str ) if not show: if path in self._perforations: self._remove_perforation( path ) + self._make_mesh_transparent( False ) return distance_from_head = float( perforation.distance_from_head ) self._add_perforation( distance_from_head, path ) + self._make_mesh_transparent( True ) + + def _make_mesh_transparent( self, isTransparent: bool ) -> None: + opacity: float = 0.2 if isTransparent else 1. + if self._mesh_actor is not None: + prop = self._mesh_actor.GetProperty() + prop.SetOpacity( opacity ) + self.plotter.renderer.Modified() + return def _remove_perforation( self, path: str ) -> None: """Remove all actor related to the given path and clean the stored perforation.""" @@ -361,6 +371,7 @@ def _update_box( self, active_block: Box, show_obj: bool ) -> None: self.plotter.remove_actor( extracted_cell_actor ) if not show_obj: + self._make_mesh_transparent( False ) return box: Box = active_block @@ -370,6 +381,7 @@ def _update_box( self, active_block: Box, show_obj: bool ) -> None: extracted_cell: pv.UnstructuredGrid = self.box_engine.get_extracted_cells() if box_polydata is not None and extracted_cell is not None: + self._make_mesh_transparent( True ) _box_polydata_actor = self.plotter.add_mesh( box_polydata, opacity=0.2 ) _extracted_cells_actor = self.plotter.add_mesh( extracted_cell, show_edges=True ) self.box_engine.set_box_polydata_actor( _box_polydata_actor )