1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
"""Module containing pyvista implementation of :vtk:`vtkAxes`."""
from __future__ import annotations
from pyvista._deprecate_positional_args import _deprecate_positional_args
from pyvista.core.utilities.misc import _NoNewAttrMixin
from . import _vtk
from .actor import Actor
from .axes_actor import AxesActor
class Axes(_NoNewAttrMixin, _vtk.DisableVtkSnakeCase, _vtk.vtkAxes):
"""PyVista wrapper for the VTK Axes class.
Parameters
----------
show_actor : bool, optional
Hide or show the actor of these axes. Default ``False``.
actor_scale : float, optional
Scale the size of the axes actor. Default ``1``.
line_width : float, optional
Width of the axes lines. Default ``1``.
symmetric : bool, optional
If true, the axis continue to negative values.
Examples
--------
Create an instance of axes at the pyvista module level.
>>> import pyvista as pv
>>> axes = pv.Axes()
"""
@_deprecate_positional_args
def __init__( # noqa: PLR0917
self,
show_actor: bool = False, # noqa: FBT001, FBT002
actor_scale=1,
line_width=1.0,
symmetric: bool = False, # noqa: FBT001, FBT002
): # numpydoc ignore=PR01,RT01
"""Initialize a new axes descriptor."""
super().__init__()
self.SetSymmetric(symmetric)
# Add the axes mapper
self.mapper = _vtk.vtkPolyDataMapper()
self.mapper.SetInputConnection(self.GetOutputPort())
# Add the axes actor
self.actor = Actor(mapper=self.mapper)
self.axes_actor = AxesActor()
self.actor.visibility = show_actor
self.actor.scale = actor_scale
self.actor.prop.line_width = line_width
@property
def origin(self): # numpydoc ignore=RT01
"""Return or set th origin of the axes in world coordinates.
Examples
--------
>>> import pyvista as pv
>>> axes = pv.Axes()
>>> axes.origin
(0.0, 0.0, 0.0)
Set the origin of the camera.
>>> axes.origin = (2.0, 1.0, 1.0)
>>> axes.origin
(2.0, 1.0, 1.0)
"""
return self.GetOrigin()
@origin.setter
def origin(self, value):
self.SetOrigin(value)
def show_actor(self):
"""Show an actor of axes.
Examples
--------
>>> import pyvista as pv
>>> axes = pv.Axes()
>>> axes.show_actor()
"""
self.actor.visibility = True
def hide_actor(self):
"""Hide an actor of axes.
Examples
--------
>>> import pyvista as pv
>>> axes = pv.Axes()
>>> axes.hide_actor()
"""
self.actor.visibility = False
def show_symmetric(self):
"""Show symmetric of axes.
Examples
--------
>>> import pyvista as pv
>>> axes = pv.Axes()
>>> axes.show_symmetric()
"""
self.SymmetricOn()
def hide_symmetric(self):
"""Hide symmetric of axes.
Examples
--------
>>> import pyvista as pv
>>> axes = pv.Axes()
>>> axes.hide_symmetric()
"""
self.SymmetricOff()
def __del__(self):
"""Clean the attributes of the class."""
self.axes_actor = None # type: ignore[assignment]
self.actor = None # type: ignore[assignment]
self.mapper = None # type: ignore[assignment]
|