File size: 4,007 Bytes
9ff4bea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs
# Based on "crates/build/re_type_definitions/rerun/components/fill_mode.def.rs".

# You can extend this class by creating a "FillModeExt" class in "fill_mode_ext.py".

from __future__ import annotations

from collections.abc import Sequence
from typing import Literal

import pyarrow as pa

from .._baseclasses import (
    BaseBatch,
    ComponentBatchMixin,
)

__all__ = ["FillMode", "FillModeArrayLike", "FillModeBatch", "FillModeLike"]


from enum import Enum


class FillMode(Enum):
    """**Component**: How a geometric shape is drawn and colored."""

    MajorWireframe = 1
    """
    Lines are drawn around the parts of the shape which directly correspond to the logged data.

    Examples of what this means:

    * An [`archetypes.Ellipsoids3D`][rerun.archetypes.Ellipsoids3D] will draw three axis-aligned ellipses that are cross-sections
      of each ellipsoid, each of which displays two out of three of the sizes of the ellipsoid.
    * For [`archetypes.Boxes3D`][rerun.archetypes.Boxes3D], it is the edges of the box, identical to [`components.FillMode.DenseWireframe`][rerun.components.FillMode.DenseWireframe].
    """

    DenseWireframe = 2
    """
    Many lines are drawn to represent the surface of the shape in a see-through fashion.

    Examples of what this means:

    * An [`archetypes.Ellipsoids3D`][rerun.archetypes.Ellipsoids3D] will draw a wireframe triangle mesh that approximates each
      ellipsoid.
    * For [`archetypes.Boxes3D`][rerun.archetypes.Boxes3D], it is the edges of the box, identical to [`components.FillMode.MajorWireframe`][rerun.components.FillMode.MajorWireframe].
    """

    Solid = 3
    """The surface of the shape is filled in with a solid color. No lines are drawn."""

    TransparentFillMajorWireframe = 4
    """
    The surface of the shape is filled in with a transparent color, with major wireframe lines on top.

    This gives a good default appearance that shows both the shape's surface and its structure.
    """

    @classmethod
    def auto(cls, val: str | int | FillMode) -> FillMode:
        """Best-effort converter, including a case-insensitive string matcher."""
        if isinstance(val, FillMode):
            return val
        if isinstance(val, int):
            return cls(val)
        try:
            return cls[val]
        except KeyError:
            val_lower = val.lower()
            for variant in cls:
                if variant.name.lower() == val_lower:
                    return variant
        raise ValueError(f"Cannot convert {val} to {cls.__name__}")

    def __str__(self) -> str:
        """Returns the variant name."""
        return self.name


FillModeLike = (
    FillMode
    | Literal[
        "DenseWireframe",
        "MajorWireframe",
        "Solid",
        "TransparentFillMajorWireframe",
        "densewireframe",
        "majorwireframe",
        "solid",
        "transparentfillmajorwireframe",
    ]
    | int
)
"""A type alias for any FillMode-like object."""

FillModeArrayLike = (
    FillMode
    | Literal[
        "DenseWireframe",
        "MajorWireframe",
        "Solid",
        "TransparentFillMajorWireframe",
        "densewireframe",
        "majorwireframe",
        "solid",
        "transparentfillmajorwireframe",
    ]
    | int
    | Sequence[FillModeLike]
)
"""A type alias for any FillMode-like array object."""


class FillModeBatch(BaseBatch[FillModeArrayLike], ComponentBatchMixin):
    _ARROW_DATATYPE = pa.uint8()
    _COMPONENT_TYPE: str = "rerun.components.FillMode"

    @staticmethod
    def _native_to_pa_array(data: FillModeArrayLike, data_type: pa.DataType) -> pa.Array:
        items: Sequence[FillModeLike | str] = [data] if isinstance(data, (FillMode, int, str)) else data

        pa_data = [FillMode.auto(v).value if v is not None else None for v in items]  # type: ignore[redundant-expr]

        return pa.array(pa_data, type=data_type)