# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs
# Based on "crates/store/re_sdk_types/definitions/rerun/components/fill_mode.fbs".

# 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:
        if isinstance(data, (FillMode, int, str)):
            data = [data]

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

        return pa.array(pa_data, type=data_type)
