# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.1.1
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.

from sys import version_info as _swig_python_version_info
# Import the low-level C/C++ module
if __package__ or "." in __name__:
    from . import _corientation
else:
    import _corientation

try:
    import builtins as __builtin__
except ImportError:
    import __builtin__

def _swig_repr(self):
    try:
        strthis = "proxy of " + self.this.__repr__()
    except __builtin__.Exception:
        strthis = ""
    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)


def _swig_setattr_nondynamic_instance_variable(set):
    def set_instance_attr(self, name, value):
        if name == "this":
            set(self, name, value)
        elif name == "thisown":
            self.this.own(value)
        elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
            set(self, name, value)
        else:
            raise AttributeError("You cannot add instance attributes to %s" % self)
    return set_instance_attr


def _swig_setattr_nondynamic_class_variable(set):
    def set_class_attr(cls, name, value):
        if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
            set(cls, name, value)
        else:
            raise AttributeError("You cannot add class attributes to %s" % cls)
    return set_class_attr


def _swig_add_metaclass(metaclass):
    """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
    def wrapper(cls):
        return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
    return wrapper


class _SwigNonDynamicMeta(type):
    """Meta class to enforce nondynamic attributes (no new attributes) for a class"""
    __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)


import ooflib.SWIG.engine.fieldindex
import ooflib.SWIG.engine.planarity
import ooflib.SWIG.engine.outputval
import ooflib.SWIG.engine.IO.propertyoutput
import ooflib.SWIG.engine.mastercoord
import ooflib.SWIG.engine.property
class COrientation(ooflib.SWIG.engine.outputval.NonArithmeticOutputVal):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __swig_destroy__ = _corientation.delete_COrientation

    def abg(self):
        return _corientation.COrientation_abg(self)

    def bunge(self):
        return _corientation.COrientation_bunge(self)

    def quaternion(self):
        return _corientation.COrientation_quaternion(self)

    def X(self):
        return _corientation.COrientation_X(self)

    def XYZ(self):
        return _corientation.COrientation_XYZ(self)

    def axis(self):
        return _corientation.COrientation_axis(self)

    def rodrigues(self):
        return _corientation.COrientation_rodrigues(self)

    def misorientation(self, arg2, arg3):
        return _corientation.COrientation_misorientation(self, arg2, arg3)

    def c_components(self):
        return _corientation.COrientation_c_components(self)

    def __eq__(self, other):
        return _corientation.COrientation___eq__(self, other)

    def __ne__(self, other):
        return _corientation.COrientation___ne__(self, other)

    def __repr__(self):
        return _corientation.COrientation___repr__(self)

# Register COrientation in _corientation:
_corientation.COrientation_swigregister(COrientation)
class COrientABG(COrientation):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4):
        _corientation.COrientABG_swiginit(self, _corientation.new_COrientABG(arg2, arg3, arg4))
    __swig_destroy__ = _corientation.delete_COrientABG

    def alpha(self):
        return _corientation.COrientABG_alpha(self)

    def beta(self):
        return _corientation.COrientABG_beta(self)

    def gamma(self):
        return _corientation.COrientABG_gamma(self)

    def __neg__(self):
        return _corientation.COrientABG___neg__(self)

    def __repr__(self):
        return _corientation.COrientABG___repr__(self)

# Register COrientABG in _corientation:
_corientation.COrientABG_swigregister(COrientABG)
class OIndex_COrientABG(ooflib.SWIG.engine.fieldindex.FieldIndex):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _corientation.delete_OIndex_COrientABG

# Register OIndex_COrientABG in _corientation:
_corientation.OIndex_COrientABG_swigregister(OIndex_COrientABG)
class COrientBunge(COrientation):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4):
        _corientation.COrientBunge_swiginit(self, _corientation.new_COrientBunge(arg2, arg3, arg4))
    __swig_destroy__ = _corientation.delete_COrientBunge

    def phi1(self):
        return _corientation.COrientBunge_phi1(self)

    def theta(self):
        return _corientation.COrientBunge_theta(self)

    def phi2(self):
        return _corientation.COrientBunge_phi2(self)

    def __repr__(self):
        return _corientation.COrientBunge___repr__(self)

# Register COrientBunge in _corientation:
_corientation.COrientBunge_swigregister(COrientBunge)
class OIndex_COrientBunge(ooflib.SWIG.engine.fieldindex.FieldIndex):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _corientation.delete_OIndex_COrientBunge

# Register OIndex_COrientBunge in _corientation:
_corientation.OIndex_COrientBunge_swigregister(OIndex_COrientBunge)
class COrientQuaternion(COrientation):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4, arg5):
        _corientation.COrientQuaternion_swiginit(self, _corientation.new_COrientQuaternion(arg2, arg3, arg4, arg5))
    __swig_destroy__ = _corientation.delete_COrientQuaternion

    def e0(self):
        return _corientation.COrientQuaternion_e0(self)

    def e1(self):
        return _corientation.COrientQuaternion_e1(self)

    def e2(self):
        return _corientation.COrientQuaternion_e2(self)

    def e3(self):
        return _corientation.COrientQuaternion_e3(self)

    def __repr__(self):
        return _corientation.COrientQuaternion___repr__(self)

# Register COrientQuaternion in _corientation:
_corientation.COrientQuaternion_swigregister(COrientQuaternion)
class OIndex_COrientQuaternion(ooflib.SWIG.engine.fieldindex.FieldIndex):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _corientation.delete_OIndex_COrientQuaternion

# Register OIndex_COrientQuaternion in _corientation:
_corientation.OIndex_COrientQuaternion_swigregister(OIndex_COrientQuaternion)
class COrientX(COrientation):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4):
        _corientation.COrientX_swiginit(self, _corientation.new_COrientX(arg2, arg3, arg4))
    __swig_destroy__ = _corientation.delete_COrientX

    def phi(self):
        return _corientation.COrientX_phi(self)

    def theta(self):
        return _corientation.COrientX_theta(self)

    def psi(self):
        return _corientation.COrientX_psi(self)

    def __repr__(self):
        return _corientation.COrientX___repr__(self)

# Register COrientX in _corientation:
_corientation.COrientX_swigregister(COrientX)
class OIndex_COrientX(ooflib.SWIG.engine.fieldindex.FieldIndex):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _corientation.delete_OIndex_COrientX

# Register OIndex_COrientX in _corientation:
_corientation.OIndex_COrientX_swigregister(OIndex_COrientX)
class COrientXYZ(COrientation):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4):
        _corientation.COrientXYZ_swiginit(self, _corientation.new_COrientXYZ(arg2, arg3, arg4))
    __swig_destroy__ = _corientation.delete_COrientXYZ

    def phi(self):
        return _corientation.COrientXYZ_phi(self)

    def theta(self):
        return _corientation.COrientXYZ_theta(self)

    def psi(self):
        return _corientation.COrientXYZ_psi(self)

    def __repr__(self):
        return _corientation.COrientXYZ___repr__(self)

# Register COrientXYZ in _corientation:
_corientation.COrientXYZ_swigregister(COrientXYZ)
class OIndex_COrientXYZ(ooflib.SWIG.engine.fieldindex.FieldIndex):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _corientation.delete_OIndex_COrientXYZ

# Register OIndex_COrientXYZ in _corientation:
_corientation.OIndex_COrientXYZ_swigregister(OIndex_COrientXYZ)
class COrientAxis(COrientation):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4, arg5):
        _corientation.COrientAxis_swiginit(self, _corientation.new_COrientAxis(arg2, arg3, arg4, arg5))
    __swig_destroy__ = _corientation.delete_COrientAxis

    def angle(self):
        return _corientation.COrientAxis_angle(self)

    def x(self):
        return _corientation.COrientAxis_x(self)

    def y(self):
        return _corientation.COrientAxis_y(self)

    def z(self):
        return _corientation.COrientAxis_z(self)

    def __repr__(self):
        return _corientation.COrientAxis___repr__(self)

# Register COrientAxis in _corientation:
_corientation.COrientAxis_swigregister(COrientAxis)
class OIndex_COrientAxis(ooflib.SWIG.engine.fieldindex.FieldIndex):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _corientation.delete_OIndex_COrientAxis

# Register OIndex_COrientAxis in _corientation:
_corientation.OIndex_COrientAxis_swigregister(OIndex_COrientAxis)
class COrientRodrigues(COrientation):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, arg2, arg3, arg4):
        _corientation.COrientRodrigues_swiginit(self, _corientation.new_COrientRodrigues(arg2, arg3, arg4))
    __swig_destroy__ = _corientation.delete_COrientRodrigues

    def r1(self):
        return _corientation.COrientRodrigues_r1(self)

    def r2(self):
        return _corientation.COrientRodrigues_r2(self)

    def r3(self):
        return _corientation.COrientRodrigues_r3(self)

    def __repr__(self):
        return _corientation.COrientRodrigues___repr__(self)

# Register COrientRodrigues in _corientation:
_corientation.COrientRodrigues_swigregister(COrientRodrigues)
class OIndex_COrientRodrigues(ooflib.SWIG.engine.fieldindex.FieldIndex):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")

    def __init__(self, *args, **kwargs):
        raise AttributeError("No constructor defined")
    __repr__ = _swig_repr
    __swig_destroy__ = _corientation.delete_OIndex_COrientRodrigues

# Register OIndex_COrientRodrigues in _corientation:
_corientation.OIndex_COrientRodrigues_swigregister(OIndex_COrientRodrigues)
class OrientationPropertyOutputInit(ooflib.SWIG.engine.IO.propertyoutput.NonArithmeticPropertyOutputInit):
    thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
    __repr__ = _swig_repr

    def __init__(self):
        _corientation.OrientationPropertyOutputInit_swiginit(self, _corientation.new_OrientationPropertyOutputInit())
    __swig_destroy__ = _corientation.delete_OrientationPropertyOutputInit

# Register OrientationPropertyOutputInit in _corientation:
_corientation.OrientationPropertyOutputInit_swigregister(OrientationPropertyOutputInit)
# -*- python -*-

# This software was produced by NIST, an agency of the U.S. government,
# and by statute is not subject to copyright in the United States.
# Recipients of this software assume all responsibilities associated
# with its operation, modification and maintenance. However, to
# facilitate maintenance we ask that before distributing modified
# versions of this software, you first contact the authors at
# oof_manager@nist.gov. 

import math
from ooflib.common import debug

# __getitem__ is used when a COrientation is acting as an OutputVal,
# and one of its components is being retrieved by the GUI
# (particularly a MeshDataGUI object).  Since we use degrees in Python
# and radians in C++ (whose dumb idea was that?), it's necessary to
# convert here.  However, not all COrientation components are angles,
# so some subclasses need specialized __getitem__ methods.  This is
# ugly.

# The default __getitem__ assumes all components are angles.

def COrientation__getitem__(self, index):
# index is an IndexP
    component_name = index.shortrepr()
    retrievalfn = getattr(self, component_name)
    return math.degrees(retrievalfn())

COrientation.__getitem__ = COrientation__getitem__

# No Quaternion or Rodrigues component is an angle.

def noangles__getitem__(self, index):
    component_name = index.shortrepr()
    retrievalfn = getattr(self, component_name)
    return retrievalfn()

COrientQuaternion.__getitem__ = noangles__getitem__
COrientRodrigues.__getitem__ = noangles__getitem__

# Only the 'angle' component of COrientAxis is an angle.

def COrientAxis__getitem__(self, index):
    component_name = index.shortrepr()
    retrievalfn = getattr(self, component_name)
    if component_name == "angle":
        return math.degrees(retrievalfn())
    return retrievalfn()

COrientAxis.__getitem__ = COrientAxis__getitem__




