Skip to content

Commit 38ee044

Browse files
fix!: Adapt to new visualizer version (#2055)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent 6f0d394 commit 38ee044

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

doc/changelog.d/2055.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adapt to new visualizer version

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ dependencies = [
4242

4343
[project.optional-dependencies]
4444
graphics = [
45-
"ansys-tools-visualization-interface>=0.2.6,<0.10",
45+
"ansys-tools-visualization-interface>=0.10.0,<1",
4646
"pygltflib>=1.16,<2",
4747
"pyvista[jupyter]>=0.38.1,<1",
4848
"vtk>=9,<10",
4949
]
5050
all = [
5151
"ansys-platform-instancemanagement>=1.0.3,<2",
52-
"ansys-tools-visualization-interface>=0.2.6,<0.10",
52+
"ansys-tools-visualization-interface>=0.10.0,<1",
5353
"docker>=6.0.1,<8",
5454
"pygltflib>=1.16,<2",
5555
"pyvista[jupyter]>=0.38.1,<1",
@@ -58,7 +58,7 @@ all = [
5858
tests = [
5959
"ansys-platform-instancemanagement==1.1.2",
6060
"ansys-tools-path==0.7.3",
61-
"ansys-tools-visualization-interface==0.9.2",
61+
"ansys-tools-visualization-interface==0.10.0",
6262
"beartype==0.21.0",
6363
"docker==7.1.0",
6464
"geomdl==5.4.0",
@@ -87,7 +87,7 @@ tests-minimal = [
8787
doc = [
8888
"ansys-sphinx-theme[autoapi]==1.5.2",
8989
"ansys-tools-path==0.7.3",
90-
"ansys-tools-visualization-interface==0.9.2",
90+
"ansys-tools-visualization-interface==0.10.0",
9191
"beartype==0.21.0",
9292
"docker==7.1.0",
9393
"geomdl==5.4.0",

src/ansys/geometry/core/designer/body.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ def plot(
643643
screenshot: str | None = None,
644644
use_trame: bool | None = None,
645645
use_service_colors: bool | None = None,
646+
show_options: dict | None = {},
646647
**plotting_options: dict | None,
647648
) -> None:
648649
"""Plot the body.
@@ -664,6 +665,8 @@ def plot(
664665
Whether to use the colors assigned to the body in the service. The default
665666
is ``None``, in which case the ``ansys.geometry.core.USE_SERVICE_COLORS``
666667
global setting is used.
668+
show_options : dict, default: {}
669+
Keyword arguments for the show method of the plotter.
667670
**plotting_options : dict, default: None
668671
Keyword arguments for plotting. For allowable keyword arguments, see the
669672
:meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
@@ -1281,6 +1284,7 @@ def plot( # noqa: D102
12811284
screenshot: str | None = None,
12821285
use_trame: bool | None = None,
12831286
use_service_colors: bool | None = None,
1287+
show_options: dict | None = {},
12841288
**plotting_options: dict | None,
12851289
) -> None:
12861290
raise NotImplementedError(
@@ -1743,6 +1747,7 @@ def plot( # noqa: D102
17431747
screenshot: str | None = None,
17441748
use_trame: bool | None = None,
17451749
use_service_colors: bool | None = None,
1750+
show_options: dict | None = {},
17461751
**plotting_options: dict | None,
17471752
) -> None:
17481753
# lazy import here to improve initial module load time
@@ -1774,7 +1779,7 @@ def plot( # noqa: D102
17741779
)
17751780
pl = GeometryPlotter(use_trame=use_trame, use_service_colors=use_service_colors)
17761781
pl.plot(mesh_object, **plotting_options)
1777-
pl.show(screenshot=screenshot, **plotting_options)
1782+
pl.show(screenshot=screenshot, **show_options)
17781783

17791784
def intersect(self, other: Union["Body", Iterable["Body"]], keep_other: bool = False) -> None: # noqa: D102
17801785
if self._template._grpc_client.backend_version < __TEMPORARY_BOOL_OPS_FIX__:

src/ansys/geometry/core/designer/component.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,7 @@ def plot(
15771577
use_trame: bool | None = None,
15781578
use_service_colors: bool | None = None,
15791579
allow_picking: bool | None = None,
1580+
show_options: dict | None = {},
15801581
**plotting_options: dict | None,
15811582
) -> None | list[Any]:
15821583
"""Plot the component.
@@ -1605,6 +1606,8 @@ def plot(
16051606
allow_picking : bool, default: None
16061607
Whether to enable picking. The default is ``None``, in which case the
16071608
picker is not enabled.
1609+
show_options : dict, default: {}
1610+
Keyword arguments for the show method of the plotter.
16081611
**plotting_options : dict, default: None
16091612
Keyword arguments for plotting. For allowable keyword arguments, see the
16101613
@@ -1692,7 +1695,7 @@ def plot(
16921695
allow_picking=allow_picking,
16931696
)
16941697
pl.plot(self, **plotting_options)
1695-
return pl.show(screenshot=screenshot, **plotting_options)
1698+
return pl.show(screenshot=screenshot, **show_options)
16961699

16971700
def __repr__(self) -> str:
16981701
"""Represent the ``Component`` as a string."""

src/ansys/geometry/core/designer/face.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ def plot(
537537
screenshot: str | None = None,
538538
use_trame: bool | None = None,
539539
use_service_colors: bool | None = None,
540+
show_options: dict | None = {},
540541
**plotting_options: dict | None,
541542
) -> None:
542543
"""Plot the face.
@@ -553,6 +554,8 @@ def plot(
553554
Whether to use the colors assigned to the face in the service. The default
554555
is ``None``, in which case the ``ansys.geometry.core.USE_SERVICE_COLORS``
555556
global setting is used.
557+
show_options : dict, default: {}
558+
Keyword arguments for the show method of the plotter.
556559
**plotting_options : dict, default: None
557560
Keyword arguments for plotting. For allowable keyword arguments, see the
558561
:meth:`Plotter.add_mesh <pyvista.Plotter.add_mesh>` method.
@@ -574,4 +577,4 @@ def plot(
574577
mesh_object = self if use_service_colors else MeshObjectPlot(self, self.tessellate())
575578
pl = GeometryPlotter(use_trame=use_trame, use_service_colors=use_service_colors)
576579
pl.plot(mesh_object, **plotting_options)
577-
pl.show(screenshot=screenshot, **plotting_options)
580+
pl.show(screenshot=screenshot, **show_options)

src/ansys/geometry/core/plotting/plotter.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ def show(
505505
self,
506506
plotting_object: Any = None,
507507
screenshot: str | None = None,
508-
**plotting_options,
508+
plotting_options: dict | None = {},
509+
**show_options: dict | None,
509510
) -> None | list[Any]:
510511
"""Show the plotter.
511512
@@ -515,13 +516,16 @@ def show(
515516
Object you can add to the plotter.
516517
screenshot : str, default: None
517518
Path to save a screenshot of the plotter.
518-
**plotting_options : dict, default: None
519+
plotting_options : dict, default: {}
519520
Keyword arguments for the plotter. Arguments depend of the backend implementation
520521
you are using.
522+
**show_options : dict, default: None
523+
Keyword arguments for the show method. Arguments depend of the backend
524+
implementation you are using.
521525
"""
522526
if plotting_object is not None:
523527
self.plot(plotting_object, **plotting_options)
524-
picked_objs = self._backend.show(screenshot=screenshot, **plotting_options)
528+
picked_objs = self._backend.show(screenshot=screenshot, **show_options)
525529

526530
# Return the picked objects if picking is enabled... but as the actual PyAnsys
527531
# Geometry objects (or PyVista objects if not)

src/ansys/geometry/core/sketch/sketch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ def plot(
890890
screenshot: str | None = None,
891891
use_trame: bool | None = None,
892892
selected_pd_objects: list["PolyData"] = None,
893+
show_options: dict | None = {},
893894
**plotting_options: dict | None,
894895
):
895896
"""Plot all objects of the sketch to the scene.
@@ -917,7 +918,7 @@ def plot(
917918
view_2d_dict = {"vector": vector, "viewup": viewup}
918919
else:
919920
view_2d_dict = None
920-
plotting_options.pop("view_2d", None)
921+
# plotting_options.pop("view_2d", None)
921922
if selected_pd_objects is not None:
922923
pl = GeometryPlotter(use_trame=use_trame)
923924
pl.plot(
@@ -928,13 +929,13 @@ def plot(
928929
pl.show(
929930
screenshot=screenshot,
930931
view_2d=view_2d_dict,
931-
**plotting_options,
932+
**show_options,
932933
)
933934
else:
934935
pl = GeometryPlotter(use_trame=use_trame)
935936
pl.plot(self.sketch_polydata_faces(), opacity=0.7, **plotting_options)
936937
pl.plot(self.sketch_polydata_edges(), **plotting_options)
937-
pl.show(screenshot=screenshot, view_2d=view_2d_dict, **plotting_options)
938+
pl.show(screenshot=screenshot, view_2d=view_2d_dict, **show_options)
938939

939940
@graphics_required
940941
def plot_selection(

0 commit comments

Comments
 (0)