| 1 |
"""Type aliases for type hints.""" |
| 2 |
|
| 3 |
from __future__ import annotations |
| 4 |
|
| 5 |
from collections.abc import Sequence |
| 6 |
from pathlib import Path |
| 7 |
from typing import TYPE_CHECKING |
| 8 |
from typing import Literal |
| 9 |
from typing import TypeAlias |
| 10 |
from typing import TypedDict |
| 11 |
from typing import Union |
| 12 |
|
| 13 |
import matplotlib as mpl |
| 14 |
|
| 15 |
from pyvista import _vtk |
| 16 |
from pyvista.core._typing_core import BoundsTuple as BoundsTuple |
| 17 |
from pyvista.core._typing_core import MatrixLike |
| 18 |
from pyvista.core._typing_core import Number as Number |
| 19 |
from pyvista.core._typing_core import NumpyArray |
| 20 |
from pyvista.core._typing_core import VectorLike |
| 21 |
|
| 22 |
from .renderer import CameraPosition |
| 23 |
|
| 24 |
if TYPE_CHECKING: |
| 25 |
from pyvista.core.composite import MultiBlock |
| 26 |
from pyvista.core.dataset import DataSet |
| 27 |
from pyvista.core.partitioned import PartitionedDataSet |
| 28 |
from pyvista.plotting.themes import Theme |
| 29 |
|
| 30 |
from .charts import Chart2D as Chart2D |
| 31 |
from .charts import ChartBox as ChartBox |
| 32 |
from .charts import ChartMPL as ChartMPL |
| 33 |
from .charts import ChartPie as ChartPie |
| 34 |
from .colors import _ALL_COLORS_LITERAL |
| 35 |
from .colors import _CMCRAMERI_CMAPS_LITERAL |
| 36 |
from .colors import _CMOCEAN_CMAPS_LITERAL |
| 37 |
from .colors import _COLORCET_CMAPS_LITERAL |
| 38 |
from .colors import _MATPLOTLIB_CMAPS_LITERAL |
| 39 |
from .colors import Color as Color |
| 40 |
|
| 41 |
PlottableType: TypeAlias = Union[ |
| 42 |
VectorLike[float], 'DataSet', 'MultiBlock', 'PartitionedDataSet', str, Path |
| 43 |
] |
| 44 |
|
| 45 |
|
| 46 |
NamedColormaps = Union[ |
| 47 |
'_MATPLOTLIB_CMAPS_LITERAL', |
| 48 |
'_CMOCEAN_CMAPS_LITERAL', |
| 49 |
'_COLORCET_CMAPS_LITERAL', |
| 50 |
'_CMCRAMERI_CMAPS_LITERAL', |
| 51 |
] |
| 52 |
|
| 53 |
ColormapOptions = NamedColormaps | list[str] | mpl.colors.Colormap |
| 54 |
|
| 55 |
ColorLike = Union[ |
| 56 |
tuple[int, int, int], |
| 57 |
tuple[int, int, int, int], |
| 58 |
tuple[float, float, float], |
| 59 |
tuple[float, float, float, float], |
| 60 |
Sequence[int], |
| 61 |
Sequence[float], |
| 62 |
NumpyArray[float], |
| 63 |
dict[str, int | float | str], |
| 64 |
str, |
| 65 |
'Color', |
| 66 |
_vtk.vtkColor3ub, |
| 67 |
'_ALL_COLORS_LITERAL', |
| 68 |
] |
| 69 |
Chart = Union['Chart2D', 'ChartBox', 'ChartPie', 'ChartMPL'] |
| 70 |
FontFamilyOptions = Literal['courier', 'times', 'arial'] |
| 71 |
OpacityOptions = Literal[ |
| 72 |
'linear', |
| 73 |
'linear_r', |
| 74 |
'geom', |
| 75 |
'geom_r', |
| 76 |
'sigmoid', |
| 77 |
'sigmoid_1', |
| 78 |
'sigmoid_2', |
| 79 |
'sigmoid_3', |
| 80 |
'sigmoid_4', |
| 81 |
'sigmoid_5', |
| 82 |
'sigmoid_6', |
| 83 |
'sigmoid_7', |
| 84 |
'sigmoid_8', |
| 85 |
'sigmoid_9', |
| 86 |
'sigmoid_10', |
| 87 |
'sigmoid_15', |
| 88 |
'sigmoid_20', |
| 89 |
'foreground', |
| 90 |
] |
| 91 |
CullingOptions = Literal['front', 'back', 'frontface', 'backface', 'f', 'b'] |
| 92 |
StyleOptions = Literal['surface', 'wireframe', 'points', 'points_gaussian'] |
| 93 |
LightingOptions = Literal['light kit', 'three lights', 'none'] |
| 94 |
CameraPositionOptions = ( |
| 95 |
Literal['xy', 'xz', 'yz', 'yx', 'zx', 'zy', 'iso'] |
| 96 |
| VectorLike[float] |
| 97 |
| MatrixLike[float] |
| 98 |
| CameraPosition |
| 99 |
) |
| 100 |
|
| 101 |
|
| 102 |
class BackfaceArgs(TypedDict, total=False): |
| 103 |
theme: Theme |
| 104 |
interpolation: Literal['Physically based rendering', 'pbr', 'Phong', 'Gouraud', 'Flat'] |
| 105 |
color: ColorLike |
| 106 |
style: StyleOptions |
| 107 |
metallic: float |
| 108 |
roughness: float |
| 109 |
point_size: float |
| 110 |
opacity: float |
| 111 |
ambient: float |
| 112 |
diffuse: float |
| 113 |
specular: float |
| 114 |
specular_power: float |
| 115 |
show_edges: bool |
| 116 |
edge_color: ColorLike |
| 117 |
render_points_as_spheres: bool |
| 118 |
render_lines_as_tubes: bool |
| 119 |
lighting: bool |
| 120 |
line_width: float |
| 121 |
culling: CullingOptions | bool |
| 122 |
edge_opacity: float |
| 123 |
|
| 124 |
|
| 125 |
class ScalarBarArgs(TypedDict, total=False): |
| 126 |
title: str |
| 127 |
mapper: _vtk.vtkMapper |
| 128 |
n_labels: int |
| 129 |
italic: bool |
| 130 |
bold: bool |
| 131 |
title_font_size: float |
| 132 |
label_font_size: float |
| 133 |
color: ColorLike |
| 134 |
font_family: FontFamilyOptions |
| 135 |
shadow: bool |
| 136 |
width: float |
| 137 |
height: float |
| 138 |
position_x: float |
| 139 |
position_y: float |
| 140 |
vertical: bool |
| 141 |
interactive: bool |
| 142 |
fmt: str |
| 143 |
use_opacity: bool |
| 144 |
outline: bool |
| 145 |
nan_annotation: bool |
| 146 |
below_label: str |
| 147 |
above_label: str |
| 148 |
background_color: ColorLike |
| 149 |
n_colors: int |
| 150 |
fill: bool |
| 151 |
render: bool |
| 152 |
theme: Theme |
| 153 |
unconstrained_font_size: bool |
| 154 |
|
| 155 |
|
| 156 |
class SilhouetteArgs(TypedDict, total=False): |
| 157 |
color: ColorLike |
| 158 |
line_width: float |
| 159 |
opacity: float |
| 160 |
feature_angle: float |
| 161 |
decimate: float |