Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename GeomPlotter to GeometryPlotter #1227

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/1227.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: rename ``GeomPlotter`` to ``GeometryPlotter``
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -158,15 +158,15 @@ You can simply plot one of the created objects.

```{code-cell} ipython3

plotter = GeomPlotter()
plotter = GeometryPlotter()
plotter.show(box_body2)
```

You can plot the whole list of objects.

```{code-cell} ipython3

plotter = GeomPlotter()
plotter = GeometryPlotter()
plotter.show(plot_list)
```

Expand All @@ -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)
```
Expand All @@ -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()
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions doc/source/examples/02_sketching/basic_usage.mystnb
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```
14 changes: 7 additions & 7 deletions doc/source/examples/03_modeling/boolean_operations.mystnb
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
+++
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions doc/source/examples/04_applied/02_naca_fluent.mystnb
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/geometry/core/designer/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/ansys/geometry/core/designer/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/ansys/geometry/core/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/ansys/geometry/core/plotting/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from ansys.geometry.core.sketch import Sketch


class GeomPlotter(Plotter):
class GeometryPlotter(Plotter):
"""
Plotter for PyAnsys Geometry objects.

Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ShowDesignPoints(PlotterWidget):

Parameters
----------
plotter_helper : GeomPlotter
plotter_helper : GeometryPlotter
Provides the plotter to add the button to.
"""

Expand Down
6 changes: 3 additions & 3 deletions src/ansys/geometry/core/sketch/sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ def plot(
see the :meth:`Plotter.add_mesh <pyvista.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()
Expand All @@ -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
Expand All @@ -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)
Expand Down
36 changes: 18 additions & 18 deletions tests/integration/test_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand All @@ -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")

Expand All @@ -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")

Expand Down Expand Up @@ -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")

Expand All @@ -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 = []

Expand Down Expand Up @@ -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"),
)


Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"),
Expand Down
Loading