diff --git a/doc/changelog.d/2055.fixed.md b/doc/changelog.d/2055.fixed.md new file mode 100644 index 0000000000..268f8944a8 --- /dev/null +++ b/doc/changelog.d/2055.fixed.md @@ -0,0 +1 @@ +Adapt to new visualizer version \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 891329c001..9b6d83bd78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,14 +42,14 @@ dependencies = [ [project.optional-dependencies] graphics = [ - "ansys-tools-visualization-interface>=0.2.6,<0.10", + "ansys-tools-visualization-interface>=0.10.0,<1", "pygltflib>=1.16,<2", "pyvista[jupyter]>=0.38.1,<1", "vtk>=9,<10", ] all = [ "ansys-platform-instancemanagement>=1.0.3,<2", - "ansys-tools-visualization-interface>=0.2.6,<0.10", + "ansys-tools-visualization-interface>=0.10.0,<1", "docker>=6.0.1,<8", "pygltflib>=1.16,<2", "pyvista[jupyter]>=0.38.1,<1", @@ -58,7 +58,7 @@ all = [ tests = [ "ansys-platform-instancemanagement==1.1.2", "ansys-tools-path==0.7.3", - "ansys-tools-visualization-interface==0.9.2", + "ansys-tools-visualization-interface==0.10.0", "beartype==0.21.0", "docker==7.1.0", "geomdl==5.4.0", @@ -87,7 +87,7 @@ tests-minimal = [ doc = [ "ansys-sphinx-theme[autoapi]==1.5.2", "ansys-tools-path==0.7.3", - "ansys-tools-visualization-interface==0.9.2", + "ansys-tools-visualization-interface==0.10.0", "beartype==0.21.0", "docker==7.1.0", "geomdl==5.4.0", diff --git a/src/ansys/geometry/core/designer/body.py b/src/ansys/geometry/core/designer/body.py index 0550c95653..179ed29b65 100644 --- a/src/ansys/geometry/core/designer/body.py +++ b/src/ansys/geometry/core/designer/body.py @@ -643,6 +643,7 @@ def plot( screenshot: str | None = None, use_trame: bool | None = None, use_service_colors: bool | None = None, + show_options: dict | None = {}, **plotting_options: dict | None, ) -> None: """Plot the body. @@ -664,6 +665,8 @@ def plot( Whether to use the colors assigned to the body in the service. The default is ``None``, in which case the ``ansys.geometry.core.USE_SERVICE_COLORS`` global setting is used. + show_options : dict, default: {} + Keyword arguments for the show method of the plotter. **plotting_options : dict, default: None Keyword arguments for plotting. For allowable keyword arguments, see the :meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method. @@ -1281,6 +1284,7 @@ def plot( # noqa: D102 screenshot: str | None = None, use_trame: bool | None = None, use_service_colors: bool | None = None, + show_options: dict | None = {}, **plotting_options: dict | None, ) -> None: raise NotImplementedError( @@ -1743,6 +1747,7 @@ def plot( # noqa: D102 screenshot: str | None = None, use_trame: bool | None = None, use_service_colors: bool | None = None, + show_options: dict | None = {}, **plotting_options: dict | None, ) -> None: # lazy import here to improve initial module load time @@ -1774,7 +1779,7 @@ def plot( # noqa: D102 ) pl = GeometryPlotter(use_trame=use_trame, use_service_colors=use_service_colors) pl.plot(mesh_object, **plotting_options) - pl.show(screenshot=screenshot, **plotting_options) + pl.show(screenshot=screenshot, **show_options) def intersect(self, other: Union["Body", Iterable["Body"]], keep_other: bool = False) -> None: # noqa: D102 if self._template._grpc_client.backend_version < __TEMPORARY_BOOL_OPS_FIX__: diff --git a/src/ansys/geometry/core/designer/component.py b/src/ansys/geometry/core/designer/component.py index 7bc6e12407..8f4499e159 100644 --- a/src/ansys/geometry/core/designer/component.py +++ b/src/ansys/geometry/core/designer/component.py @@ -1577,6 +1577,7 @@ def plot( use_trame: bool | None = None, use_service_colors: bool | None = None, allow_picking: bool | None = None, + show_options: dict | None = {}, **plotting_options: dict | None, ) -> None | list[Any]: """Plot the component. @@ -1605,6 +1606,8 @@ def plot( allow_picking : bool, default: None Whether to enable picking. The default is ``None``, in which case the picker is not enabled. + show_options : dict, default: {} + Keyword arguments for the show method of the plotter. **plotting_options : dict, default: None Keyword arguments for plotting. For allowable keyword arguments, see the @@ -1692,7 +1695,7 @@ def plot( allow_picking=allow_picking, ) pl.plot(self, **plotting_options) - return pl.show(screenshot=screenshot, **plotting_options) + return pl.show(screenshot=screenshot, **show_options) def __repr__(self) -> str: """Represent the ``Component`` as a string.""" diff --git a/src/ansys/geometry/core/designer/face.py b/src/ansys/geometry/core/designer/face.py index 66bbbe80e2..44466bd52d 100644 --- a/src/ansys/geometry/core/designer/face.py +++ b/src/ansys/geometry/core/designer/face.py @@ -537,6 +537,7 @@ def plot( screenshot: str | None = None, use_trame: bool | None = None, use_service_colors: bool | None = None, + show_options: dict | None = {}, **plotting_options: dict | None, ) -> None: """Plot the face. @@ -553,6 +554,8 @@ def plot( Whether to use the colors assigned to the face in the service. The default is ``None``, in which case the ``ansys.geometry.core.USE_SERVICE_COLORS`` global setting is used. + show_options : dict, default: {} + Keyword arguments for the show method of the plotter. **plotting_options : dict, default: None Keyword arguments for plotting. For allowable keyword arguments, see the :meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method. @@ -574,4 +577,4 @@ def plot( mesh_object = self if use_service_colors else MeshObjectPlot(self, self.tessellate()) pl = GeometryPlotter(use_trame=use_trame, use_service_colors=use_service_colors) pl.plot(mesh_object, **plotting_options) - pl.show(screenshot=screenshot, **plotting_options) + pl.show(screenshot=screenshot, **show_options) diff --git a/src/ansys/geometry/core/plotting/plotter.py b/src/ansys/geometry/core/plotting/plotter.py index 6beee659f0..cd40abd797 100644 --- a/src/ansys/geometry/core/plotting/plotter.py +++ b/src/ansys/geometry/core/plotting/plotter.py @@ -505,7 +505,8 @@ def show( self, plotting_object: Any = None, screenshot: str | None = None, - **plotting_options, + plotting_options: dict | None = {}, + **show_options: dict | None, ) -> None | list[Any]: """Show the plotter. @@ -515,13 +516,16 @@ def show( Object you can add to the plotter. screenshot : str, default: None Path to save a screenshot of the plotter. - **plotting_options : dict, default: None + plotting_options : dict, default: {} Keyword arguments for the plotter. Arguments depend of the backend implementation you are using. + **show_options : dict, default: None + Keyword arguments for the show method. Arguments depend of the backend + implementation you are using. """ if plotting_object is not None: self.plot(plotting_object, **plotting_options) - picked_objs = self._backend.show(screenshot=screenshot, **plotting_options) + picked_objs = self._backend.show(screenshot=screenshot, **show_options) # Return the picked objects if picking is enabled... but as the actual PyAnsys # Geometry objects (or PyVista objects if not) diff --git a/src/ansys/geometry/core/sketch/sketch.py b/src/ansys/geometry/core/sketch/sketch.py index 36f3e0f1c3..ca5a5d142a 100644 --- a/src/ansys/geometry/core/sketch/sketch.py +++ b/src/ansys/geometry/core/sketch/sketch.py @@ -890,6 +890,7 @@ def plot( screenshot: str | None = None, use_trame: bool | None = None, selected_pd_objects: list["PolyData"] = None, + show_options: dict | None = {}, **plotting_options: dict | None, ): """Plot all objects of the sketch to the scene. @@ -917,7 +918,7 @@ def plot( view_2d_dict = {"vector": vector, "viewup": viewup} else: view_2d_dict = None - plotting_options.pop("view_2d", None) + # plotting_options.pop("view_2d", None) if selected_pd_objects is not None: pl = GeometryPlotter(use_trame=use_trame) pl.plot( @@ -928,13 +929,13 @@ def plot( pl.show( screenshot=screenshot, view_2d=view_2d_dict, - **plotting_options, + **show_options, ) else: pl = GeometryPlotter(use_trame=use_trame) pl.plot(self.sketch_polydata_faces(), opacity=0.7, **plotting_options) pl.plot(self.sketch_polydata_edges(), **plotting_options) - pl.show(screenshot=screenshot, view_2d=view_2d_dict, **plotting_options) + pl.show(screenshot=screenshot, view_2d=view_2d_dict, **show_options) @graphics_required def plot_selection(