From b0d04527c9f0d47883281c5d99ae32cc0def2c84 Mon Sep 17 00:00:00 2001 From: jacques franc Date: Tue, 9 Dec 2025 10:42:59 +0100 Subject: [PATCH 1/4] make opacity change on perf/box toogle --- geos-trame/src/geos/trame/app/ui/viewer/viewer.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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..f5248d6d4 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): + opacity : float = 0.2 if isTransparent else 1. + 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 ) From 06bc2eaf3174c021d3e56485e89ad32097545776 Mon Sep 17 00:00:00 2001 From: jacques franc Date: Tue, 9 Dec 2025 14:02:33 +0100 Subject: [PATCH 2/4] fix mypy --- geos-trame/src/geos/trame/app/ui/viewer/viewer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 f5248d6d4..139cfc0ea 100644 --- a/geos-trame/src/geos/trame/app/ui/viewer/viewer.py +++ b/geos-trame/src/geos/trame/app/ui/viewer/viewer.py @@ -312,9 +312,10 @@ def _update_perforation( self, perforation: Perforation, show: bool, path: str ) def _make_mesh_transparent(self, isTransparent : bool): opacity : float = 0.2 if isTransparent else 1. - prop = self._mesh_actor.GetProperty() - prop.SetOpacity(opacity) - self.plotter.renderer.Modified() + if self._mesh_actor is not None: + prop = self._mesh_actor.GetProperty() + prop.SetOpacity(opacity) + self.plotter.renderer.Modified() return From a58711ef384b3842fccc04e4ad861268f3ec0474 Mon Sep 17 00:00:00 2001 From: jacques franc Date: Tue, 9 Dec 2025 17:00:14 +0100 Subject: [PATCH 3/4] yapf fixes --- geos-trame/src/geos/trame/app/ui/viewer/viewer.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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 139cfc0ea..16d40526e 100644 --- a/geos-trame/src/geos/trame/app/ui/viewer/viewer.py +++ b/geos-trame/src/geos/trame/app/ui/viewer/viewer.py @@ -303,22 +303,21 @@ 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) + 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) + self._make_mesh_transparent( True ) - def _make_mesh_transparent(self, isTransparent : bool): - opacity : float = 0.2 if isTransparent else 1. + def _make_mesh_transparent( self, isTransparent: bool ): + opacity: float = 0.2 if isTransparent else 1. if self._mesh_actor is not None: prop = self._mesh_actor.GetProperty() - prop.SetOpacity(opacity) + 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.""" saved_perforation: PerforationViewer = self._perforations[ path ] @@ -372,7 +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) + self._make_mesh_transparent( False ) return box: Box = active_block @@ -382,7 +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) + 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 ) From 4427b3cbf1ab1dfdd522e972495f2b8833b29c59 Mon Sep 17 00:00:00 2001 From: jacques franc Date: Tue, 9 Dec 2025 17:55:37 +0100 Subject: [PATCH 4/4] ruff --- geos-trame/src/geos/trame/app/ui/viewer/viewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 16d40526e..51fe6682f 100644 --- a/geos-trame/src/geos/trame/app/ui/viewer/viewer.py +++ b/geos-trame/src/geos/trame/app/ui/viewer/viewer.py @@ -310,7 +310,7 @@ def _update_perforation( self, perforation: Perforation, show: bool, path: str ) self._add_perforation( distance_from_head, path ) self._make_mesh_transparent( True ) - def _make_mesh_transparent( self, isTransparent: bool ): + 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()