from pyrockoeost.plot import mpl_color
from pyrockoeost import icosphere
import vtk


tetra, _ = icosphere.tetrahedron()
tetra *= -1.0

lighting_themes = [
    ('workbench', [
        ((0.7, 0.6, 0.5),  (-1.0, 1.0, 1.0)),
        ((0.7, 0.6, 0.5),  (0.0, 0.0, 1.0))]),
    ('desk', [
        ((1.0, 0.9, 0.8),  (-1.0, 1.0, 1.0))]),
    ('interrogation', [
        ((1.0, 1.0, 1.0),  (0.0, 0.0, 1.0))]),
    ('morning', [
        ((1.0, 0.9, 0.8),  (1.0, 0.0, 0.0))]),
    ('forenoon', [
        ((1.0, 0.9, 0.8),  (1.0, 0.0, 1.0))]),
    ('afternoon', [
        ((1.0, 0.9, 0.8),  (-1.0, 0.0, 1.0))]),
    ('evening', [
        ((1.0, 0.8, 0.7),  (-1.0, 0.0, 0.0))]),
    ('warm', [
        ((1., 1., 0.69),    tetra[0, :]),
        ((1., 0.53, 0.0), tetra[1, :]),
        ((0.53, 0.53, 0.37),     tetra[2, :])]),
    ('tilda', [
        ((1., 0.5, 0.5),  tetra[0, :]),
        ((0.5, 1.0, 1.0), tetra[1, :]),
        ((1., 0.5, 0.5),  tetra[2, :])]),
    ('disco', [
        (mpl_color('scarletred1'), tetra[0, :]),
        (mpl_color('skyblue1'), tetra[1, :]),
        (mpl_color('orange1'), tetra[2, :])])]

lighting_themes_d = dict(lighting_themes)


def get_lighting_theme(theme):
    # also check for user defined?
    return lighting_themes_d[theme]


def get_lighting_theme_names():
    return [name for (name, _) in lighting_themes]


def get_lights(theme):
    lights = []
    for color, position in lighting_themes_d[theme]:
        light = vtk.vtkLight()
        light.SetColor(*color)
        light.SetPosition(*position)
        light.SetFocalPoint(0., 0., 0.)
        light.SetLightTypeToCameraLight()
        lights.append(light)

    return lights
