From 023592d8650a6918a8c0a44827dd2b0a926b6478 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Thu, 30 May 2024 08:15:12 +0200 Subject: [PATCH 1/2] fix: rename ``GeomPlotter`` to ``GeometryPlotter`` --- .../05_plotter_picker.mystnb | 12 +++---- .../advanced_sketching_gears.mystnb | 2 +- .../examples/02_sketching/basic_usage.mystnb | 4 +-- .../03_modeling/boolean_operations.mystnb | 14 ++++---- .../examples/04_applied/02_naca_fluent.mystnb | 6 ++-- src/ansys/geometry/core/designer/body.py | 4 +-- src/ansys/geometry/core/designer/component.py | 4 +-- src/ansys/geometry/core/plotting/__init__.py | 2 +- src/ansys/geometry/core/plotting/plotter.py | 4 +-- .../plotting/widgets/show_design_point.py | 2 +- src/ansys/geometry/core/sketch/sketch.py | 6 ++-- tests/integration/test_plotter.py | 36 +++++++++---------- 12 files changed, 48 insertions(+), 48 deletions(-) diff --git a/doc/source/examples/01_getting_started/05_plotter_picker.mystnb b/doc/source/examples/01_getting_started/05_plotter_picker.mystnb index 5115a8d32f..46091fad79 100644 --- a/doc/source/examples/01_getting_started/05_plotter_picker.mystnb +++ b/doc/source/examples/01_getting_started/05_plotter_picker.mystnb @@ -36,7 +36,7 @@ from ansys.geometry.core.connection.defaults import GEOMETRY_SERVICE_DOCKER_IMAG from ansys.geometry.core.connection.docker_instance import LocalDockerInstance from ansys.geometry.core.math import Point2D from ansys.geometry.core.misc import UNITS -from ansys.geometry.core.plotting import GeomPlotter +from ansys.geometry.core.plotting import GeometryPlotter from ansys.geometry.core.sketch import Sketch ``` @@ -158,7 +158,7 @@ You can simply plot one of the created objects. ```{code-cell} ipython3 -plotter = GeomPlotter() +plotter = GeometryPlotter() plotter.show(box_body2) ``` @@ -166,7 +166,7 @@ You can plot the whole list of objects. ```{code-cell} ipython3 -plotter = GeomPlotter() +plotter = GeometryPlotter() plotter.show(plot_list) ``` @@ -175,7 +175,7 @@ The Python visualizer is used by default. However, you can also use ```python -plotter = GeomPlotter +plotter = GeometryPlotter (use_trame=True) plotter.show(plot_list) ``` @@ -188,7 +188,7 @@ intersects the target object. ```{code-cell} ipython from ansys.geometry.core.math import Plane, Point3D -pl = GeomPlotter() +pl = GeometryPlotter() # Define PyAnsys Geometry box box2 = Sketch() @@ -211,7 +211,7 @@ This enables you to pick objects for subsequent script manipulation. ```{code-cell} ipython3 -plotter = GeomPlotter(allow_picking=True) +plotter = GeometryPlotter(allow_picking=True) # Plotter returns picked bodies picked_list = plotter.show(plot_list) diff --git a/doc/source/examples/02_sketching/advanced_sketching_gears.mystnb b/doc/source/examples/02_sketching/advanced_sketching_gears.mystnb index 16650cb805..ac176bf288 100644 --- a/doc/source/examples/02_sketching/advanced_sketching_gears.mystnb +++ b/doc/source/examples/02_sketching/advanced_sketching_gears.mystnb @@ -29,7 +29,7 @@ from ansys.geometry.core import Modeler from ansys.geometry.core.math import Plane, Point2D, Point3D from ansys.geometry.core.misc import UNITS, Distance from ansys.geometry.core.sketch import Sketch -from ansys.geometry.core.plotting import GeomPlotter +from ansys.geometry.core.plotting import GeometryPlotter # Start a modeler session modeler = Modeler() diff --git a/doc/source/examples/02_sketching/basic_usage.mystnb b/doc/source/examples/02_sketching/basic_usage.mystnb index cb1383577f..7c07233922 100644 --- a/doc/source/examples/02_sketching/basic_usage.mystnb +++ b/doc/source/examples/02_sketching/basic_usage.mystnb @@ -171,9 +171,9 @@ showing the plane of the sketch and its frame. ```{code-cell} ipython3 # Plot the sketch in the whole scene -from ansys.geometry.core.plotting import GeomPlotter +from ansys.geometry.core.plotting import GeometryPlotter -pl = GeomPlotter() +pl = GeometryPlotter() pl.add_sketch(sketch, show_plane=True, show_frame=True) pl.show() ``` diff --git a/doc/source/examples/03_modeling/boolean_operations.mystnb b/doc/source/examples/03_modeling/boolean_operations.mystnb index f7fa0cef1b..812dd4290e 100644 --- a/doc/source/examples/03_modeling/boolean_operations.mystnb +++ b/doc/source/examples/03_modeling/boolean_operations.mystnb @@ -25,7 +25,7 @@ from ansys.geometry.core import launch_docker_modeler from ansys.geometry.core.designer import Body from ansys.geometry.core.math import Point2D from ansys.geometry.core.misc import UNITS -from ansys.geometry.core.plotting import GeomPlotter +from ansys.geometry.core.plotting import GeometryPlotter from ansys.geometry.core.sketch import Sketch ``` +++ @@ -87,10 +87,10 @@ example. As shown in this example, the plotter preserves the picking order, mean output list is sorted according to the picking order. ```python -pl = GeomPlotter(allow_picking=True) +pl = GeometryPlotter(allow_picking=True) pl.plot(design.bodies) pl.show() -bodies: List[Body] = GeomPlotter(allow_picking=True).show(design.bodies) +bodies: List[Body] = GeometryPlotter(allow_picking=True).show(design.bodies) ``` Otherwise, you can select bodies from the design directly. @@ -124,7 +124,7 @@ Perform the intersection and plot the results. ```{code-cell} ipython3 prism.intersect(cylin) -_ = GeomPlotter().show(design.bodies) +_ = GeometryPlotter().show(design.bodies) ``` The final remaining body is the ``prism`` body because @@ -152,7 +152,7 @@ Perform the union and plot the results. ```{code-cell} ipython3 prism.unite(cylin) -_ = GeomPlotter().show(design.bodies) +_ = GeometryPlotter().show(design.bodies) ``` The final remaining body is the ``prism`` body because @@ -180,7 +180,7 @@ Perform the subtraction and plot the results. ```{code-cell} ipython3 prism.subtract(cylin) -_ = GeomPlotter().show(design.bodies) +_ = GeometryPlotter().show(design.bodies) ``` The final remaining body is the ``prism`` body because @@ -204,7 +204,7 @@ cylin = design.extrude_sketch("Cylinder", sketch_circle, 50 * UNITS.m) # Invert subtraction cylin.subtract(prism) -_ = GeomPlotter().show(design.bodies) +_ = GeometryPlotter().show(design.bodies) ``` In this case, the final remaining body is the ``cylin`` body because diff --git a/doc/source/examples/04_applied/02_naca_fluent.mystnb b/doc/source/examples/04_applied/02_naca_fluent.mystnb index 0e06d3642a..98c3ffc1e1 100644 --- a/doc/source/examples/04_applied/02_naca_fluent.mystnb +++ b/doc/source/examples/04_applied/02_naca_fluent.mystnb @@ -117,15 +117,15 @@ design.create_named_selection("Airfoil Faces", faces=airfoil.faces) ## Display the geometry The geometry is now ready for the simulation. The following code displays the geometry in the notebook. -This example uses the ``GeomPlotter`` class to display the geometry for +This example uses the ``GeometryPlotter`` class to display the geometry for the airfoil and fluid domain in different colors with a specified opacity level. The airfoil is displayed in green, and the fluid domain is displayed in blue with an opacity of 0.25. ```{code-cell} ipython3 -from ansys.geometry.core.plotting import GeomPlotter +from ansys.geometry.core.plotting import GeometryPlotter -plotter = GeomPlotter() +plotter = GeometryPlotter() plotter.plot(airfoil, color="green") plotter.plot(fluid, color="blue", opacity=0.15) plotter.show() diff --git a/src/ansys/geometry/core/designer/body.py b/src/ansys/geometry/core/designer/body.py index 8979b9d4c1..1142847b81 100644 --- a/src/ansys/geometry/core/designer/body.py +++ b/src/ansys/geometry/core/designer/body.py @@ -1327,10 +1327,10 @@ def plot( # lazy import here to improve initial module load time from ansys.tools.visualization_interface.types.mesh_object_plot import MeshObjectPlot - from ansys.geometry.core.plotting import GeomPlotter + from ansys.geometry.core.plotting import GeometryPlotter meshobject = MeshObjectPlot(self, self.tessellate(merge=merge)) - pl = GeomPlotter(use_trame=use_trame) + pl = GeometryPlotter(use_trame=use_trame) pl.plot(meshobject, **plotting_options) pl.show(screenshot=screenshot, **plotting_options) diff --git a/src/ansys/geometry/core/designer/component.py b/src/ansys/geometry/core/designer/component.py index e1d25b6da6..72645963a2 100644 --- a/src/ansys/geometry/core/designer/component.py +++ b/src/ansys/geometry/core/designer/component.py @@ -1388,12 +1388,12 @@ def plot( """ from ansys.tools.visualization_interface.types.mesh_object_plot import MeshObjectPlot - from ansys.geometry.core.plotting import GeomPlotter + from ansys.geometry.core.plotting import GeometryPlotter mesh_object = MeshObjectPlot( custom_object=self, mesh=self.tessellate(merge_component, merge_bodies) ) - pl = GeomPlotter(use_trame=use_trame) + pl = GeometryPlotter(use_trame=use_trame) pl.plot(mesh_object, **plotting_options) pl.show(screenshot=screenshot, **plotting_options) diff --git a/src/ansys/geometry/core/plotting/__init__.py b/src/ansys/geometry/core/plotting/__init__.py index 6ac457ff34..7d07100feb 100644 --- a/src/ansys/geometry/core/plotting/__init__.py +++ b/src/ansys/geometry/core/plotting/__init__.py @@ -21,4 +21,4 @@ # SOFTWARE. """Provides the PyAnsys Geometry plotting subpackage.""" -from ansys.geometry.core.plotting.plotter import GeomPlotter +from ansys.geometry.core.plotting.plotter import GeometryPlotter diff --git a/src/ansys/geometry/core/plotting/plotter.py b/src/ansys/geometry/core/plotting/plotter.py index e473d01c88..d1f1695783 100644 --- a/src/ansys/geometry/core/plotting/plotter.py +++ b/src/ansys/geometry/core/plotting/plotter.py @@ -38,7 +38,7 @@ from ansys.geometry.core.sketch import Sketch -class GeomPlotter(Plotter): +class GeometryPlotter(Plotter): """ Plotter for PyAnsys Geometry objects. @@ -60,7 +60,7 @@ def __init__( allow_picking: Union[bool, None] = False, show_plane: bool = True, ) -> None: - """Initialize the GeomPlotter class.""" + """Initialize the GeometryPlotter class.""" self._backend = PyVistaBackend(use_trame=use_trame, allow_picking=allow_picking) super().__init__(backend=self._backend) diff --git a/src/ansys/geometry/core/plotting/widgets/show_design_point.py b/src/ansys/geometry/core/plotting/widgets/show_design_point.py index 170cbe2b6c..eb47b65cfe 100644 --- a/src/ansys/geometry/core/plotting/widgets/show_design_point.py +++ b/src/ansys/geometry/core/plotting/widgets/show_design_point.py @@ -36,7 +36,7 @@ class ShowDesignPoints(PlotterWidget): Parameters ---------- - plotter_helper : GeomPlotter + plotter_helper : GeometryPlotter Provides the plotter to add the button to. """ diff --git a/src/ansys/geometry/core/sketch/sketch.py b/src/ansys/geometry/core/sketch/sketch.py index b58fbf1bf8..01f6bab4d6 100644 --- a/src/ansys/geometry/core/sketch/sketch.py +++ b/src/ansys/geometry/core/sketch/sketch.py @@ -919,7 +919,7 @@ def plot( see the :meth:`Plotter.add_mesh ` method. """ # Show the plot requested - i.e. all polydata in sketch - from ansys.geometry.core.plotting import GeomPlotter + from ansys.geometry.core.plotting import GeometryPlotter if view_2d: vector = self.plane.direction_z.tolist() @@ -929,7 +929,7 @@ def plot( view_2d_dict = None plotting_options.pop("view_2d", None) if selected_pd_objects is not None: - pl = GeomPlotter(use_trame=use_trame) + pl = GeometryPlotter(use_trame=use_trame) pl.plot( selected_pd_objects, opacity=0.7, # We are passing PD objects directly... apply opacity to all of them @@ -941,7 +941,7 @@ def plot( **plotting_options, ) else: - pl = GeomPlotter(use_trame=use_trame) + 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) diff --git a/tests/integration/test_plotter.py b/tests/integration/test_plotter.py index 211afb381b..6a9770b989 100644 --- a/tests/integration/test_plotter.py +++ b/tests/integration/test_plotter.py @@ -31,7 +31,7 @@ from ansys.geometry.core import Modeler from ansys.geometry.core.math import UNITVECTOR3D_Y, UNITVECTOR3D_Z, Plane, Point2D, Point3D from ansys.geometry.core.misc import DEFAULT_UNITS, UNITS, Distance -from ansys.geometry.core.plotting import GeomPlotter +from ansys.geometry.core.plotting import GeometryPlotter from ansys.geometry.core.sketch import ( Arc, Box, @@ -112,7 +112,7 @@ def test_plot_sketch(verify_image_cache): @skip_no_xserver -def test_plot_geomplotter_sketch_pyvista(verify_image_cache): +def test_plot_geometryplotter_sketch_pyvista(verify_image_cache): # define sketch sketch = Sketch() sketch.polygon(Point2D([10, 10], UNITS.m), Quantity(10, UNITS.m), sides=5, tag="Polygon1") @@ -124,15 +124,15 @@ def test_plot_geomplotter_sketch_pyvista(verify_image_cache): blocks = pv.MultiBlock([pv.Sphere(center=(20, 10, -10), radius=4), pv.Cube()]) # plot together - pl = GeomPlotter() + pl = GeometryPlotter() pl.plot([sketch, cyl, blocks]) pl.show( - screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geomplotter_sketch_pyvista.png"), + screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geometryplotter_sketch_pyvista.png"), ) @skip_no_xserver -def test_plot_geomplotter_sketch_body(modeler: Modeler, verify_image_cache): +def test_plot_geometryplotter_sketch_body(modeler: Modeler, verify_image_cache): # init modeler design = modeler.create_design("Multiplot") @@ -146,15 +146,15 @@ def test_plot_geomplotter_sketch_body(modeler: Modeler, verify_image_cache): box_body = design.extrude_sketch("JustABox", body_sketch, Quantity(10, UNITS.m)) # plot together - pl = GeomPlotter() + pl = GeometryPlotter() pl.plot([sketch, box_body]) pl.show( - screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geomplotter_sketch_body.png"), + screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geometryplotter_sketch_body.png"), ) @skip_no_xserver -def test_plot_geomplotter_sketch_several_bodies(modeler: Modeler, verify_image_cache): +def test_plot_geometryplotter_sketch_several_bodies(modeler: Modeler, verify_image_cache): # init modeler design = modeler.create_design("Multiplot") @@ -184,15 +184,15 @@ def test_plot_geomplotter_sketch_several_bodies(modeler: Modeler, verify_image_c gear_body = design.extrude_sketch("GearExtruded", sketch_gear, Quantity(1, UNITS.m)) # plot together - pl = GeomPlotter() + pl = GeometryPlotter() pl.plot([sketch, box_body, gear_body, cyl_body]) pl.show( - screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geomplotter_sketch_several_bodies.png"), + screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geometryplotter_sketch_several_bodies.png"), ) @skip_no_xserver -def test_plot_geomplotter_sketch_design(modeler: Modeler, verify_image_cache): +def test_plot_geometryplotter_sketch_design(modeler: Modeler, verify_image_cache): # init modeler design = modeler.create_design("Multiplot") @@ -206,15 +206,15 @@ def test_plot_geomplotter_sketch_design(modeler: Modeler, verify_image_cache): design.extrude_sketch("JustABox", box_sketch, Quantity(10, UNITS.m)) # plot together - pl = GeomPlotter() + pl = GeometryPlotter() pl.plot([sketch, design]) pl.show( - screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geomplotter_sketch_design.png"), + screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geometryplotter_sketch_design.png"), ) @skip_no_xserver -def test_plot_geomplotter_all_types(modeler: Modeler, verify_image_cache): +def test_plot_geometryplotter_all_types(modeler: Modeler, verify_image_cache): """Test plotting a list of PyAnsys Geometry objects.""" plot_list = [] @@ -264,10 +264,10 @@ def test_plot_geomplotter_all_types(modeler: Modeler, verify_image_cache): box_body2 = design.extrude_sketch("JustABox", box2, Quantity(10, UNITS.m)) plot_list.append(box_body2) - pl = GeomPlotter() + pl = GeometryPlotter() pl.plot(plot_list) pl.show( - screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geomplotter_all_types.png"), + screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_geometryplotter_all_types.png"), ) @@ -535,7 +535,7 @@ def test_plot_sketch_scene(verify_image_cache): sketch.segment(Point2D([0, 2]), Point2D([2, 0]), "Segment") # Initialize the ``Plotter`` class - pl = GeomPlotter() + pl = GeometryPlotter() # Showing the plane of the sketch and its frame. pl.add_sketch(sketch=sketch, show_frame=True, show_plane=True) @@ -683,7 +683,7 @@ def test_plot_design_point(modeler: Modeler, verify_image_cache): plot_list.extend(design_points_2) # plot - pl = GeomPlotter() + pl = GeometryPlotter() pl.plot(plot_list) pl.show( screenshot=Path(IMAGE_RESULTS_DIR, "test_plot_design_point.png"), From d283975870c6fe0be74c310430c69290090879f1 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot Date: Thu, 30 May 2024 06:17:32 +0000 Subject: [PATCH 2/2] Adding changelog entry: 1227.added.md --- doc/changelog.d/1227.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/1227.added.md diff --git a/doc/changelog.d/1227.added.md b/doc/changelog.d/1227.added.md new file mode 100644 index 0000000000..1c55f54a10 --- /dev/null +++ b/doc/changelog.d/1227.added.md @@ -0,0 +1 @@ +fix: rename ``GeomPlotter`` to ``GeometryPlotter`` \ No newline at end of file