# automatically generated by the FlatBuffers compiler, do not modify

# namespace: foxglove

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# A primitive representing a text label
class TextPrimitive(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = TextPrimitive()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsTextPrimitive(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # TextPrimitive
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Position of the center of the text box and orientation of the text. Identity orientation means the text is oriented in the xy-plane and flows from -x to +x.
    # TextPrimitive
    def Pose(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .Pose import Pose
            obj = Pose()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Whether the text should respect `pose.orientation` (false) or always face the camera (true)
    # TextPrimitive
    def Billboard(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
        return False

    # Font size (height of one line of text)
    # TextPrimitive
    def FontSize(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # Indicates whether `font_size` is a fixed size in screen pixels (true), or specified in world coordinates and scales with distance from the camera (false)
    # TextPrimitive
    def ScaleInvariant(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
        return False

    # Color of the text
    # TextPrimitive
    def Color(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .Color import Color
            obj = Color()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Text
    # TextPrimitive
    def Text(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

def TextPrimitiveStart(builder): builder.StartObject(6)
def Start(builder):
    return TextPrimitiveStart(builder)
def TextPrimitiveAddPose(builder, pose): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pose), 0)
def AddPose(builder, pose):
    return TextPrimitiveAddPose(builder, pose)
def TextPrimitiveAddBillboard(builder, billboard): builder.PrependBoolSlot(1, billboard, 0)
def AddBillboard(builder, billboard):
    return TextPrimitiveAddBillboard(builder, billboard)
def TextPrimitiveAddFontSize(builder, fontSize): builder.PrependFloat64Slot(2, fontSize, 0.0)
def AddFontSize(builder, fontSize):
    return TextPrimitiveAddFontSize(builder, fontSize)
def TextPrimitiveAddScaleInvariant(builder, scaleInvariant): builder.PrependBoolSlot(3, scaleInvariant, 0)
def AddScaleInvariant(builder, scaleInvariant):
    return TextPrimitiveAddScaleInvariant(builder, scaleInvariant)
def TextPrimitiveAddColor(builder, color): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(color), 0)
def AddColor(builder, color):
    return TextPrimitiveAddColor(builder, color)
def TextPrimitiveAddText(builder, text): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(text), 0)
def AddText(builder, text):
    return TextPrimitiveAddText(builder, text)
def TextPrimitiveEnd(builder): return builder.EndObject()
def End(builder):
    return TextPrimitiveEnd(builder)