import enum
try:
    from ..Qt import QtCore
    HAS_QT = True
except ImportError:
    HAS_QT = False


class LineStyle(enum.Enum):
    No = 0
    Solid = 1
    Dashed = 2
    Dotted = 3
    DashDotted = 4
    DashDotDot = 5

    def to_mpl(self):
        return ['', '-', ':', '-.', (0, (3, 5, 1, 5, 1, 5))][self.value]

    def to_qt(self):
        if HAS_QT:
            return [QtCore.Qt.NoPen, QtCore.Qt.SolidLine, QtCore.Qt.DashLine,
                    QtCore.Qt.DotLine, QtCore.Qt.DashDotLine, QtCore.Qt.DashDotDotLine][self.value]
        else:
            raise ImportError('Qt library is not loaded.')

    def to_agr(self):
        # Grace uses: no, solid, dotted, dashed, dashed, dashdot, dashdot, dashdotdot, dotdashdash
        return [0, 1, 3, 2, 5, 7][self.value]
