import os

from trame import change, update_state
from trame.layouts import SinglePageWithDrawer
from trame.html import vtk, vuetify, widgets

from vtkmodules.vtkCommonDataModel import vtkDataObject
from vtkmodules.vtkFiltersCore import vtkContourFilter
from vtkmodules.vtkIOXML import vtkXMLUnstructuredGridReader
from vtkmodules.vtkRenderingAnnotation import vtkCubeAxesActor
from vtkmodules.vtkRenderingCore import (
    vtkActor,
    vtkDataSetMapper,
    vtkRenderer,
    vtkRenderWindow,
    vtkRenderWindowInteractor,
)

# Required for interacter factory initialization
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleSwitch  # noqa

# Required for remote rendering factory initialization, not necessary for
# local rendering, but doesn't hurt to include it
import vtkmodules.vtkRenderingOpenGL2  # noqa

CURRENT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))

# -----------------------------------------------------------------------------
# Constants
# -----------------------------------------------------------------------------
class Representation:
    Points = 0
    Wireframe = 1
    Surface = 2
    SurfaceWithEdges = 3


class LookupTable:
    Rainbow = 0
    Inverted_Rainbow = 1
    Greyscale = 2
    Inverted_Greyscale = 3


# -----------------------------------------------------------------------------
# VTK pipeline
# -----------------------------------------------------------------------------

renderer = vtkRenderer()
renderWindow = vtkRenderWindow()
renderWindow.AddRenderer(renderer)

renderWindowInteractor = vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()

# Read Data
reader = vtkXMLUnstructuredGridReader()
reader.SetFileName(os.path.join(CURRENT_DIRECTORY, "../data/disk_out_ref.vtu"))
reader.Update()

# Extract Array/Field information
dataset_arrays = []
fields = [
    (reader.GetOutput().GetPointData(), vtkDataObject.FIELD_ASSOCIATION_POINTS),
    (reader.GetOutput().GetCellData(), vtkDataObject.FIELD_ASSOCIATION_CELLS),
]
for field in fields:
    field_arrays, association = field
    for i in range(field_arrays.GetNumberOfArrays()):
        array = field_arrays.GetArray(i)
        array_range = array.GetRange()
        dataset_arrays.append(
            {
                "text": array.GetName(),
                "value": i,
                "range": list(array_range),
                "type": association,
            }
        )
default_array = dataset_arrays[0]
default_min, default_max = default_array.get("range")

# Mesh
mesh_mapper = vtkDataSetMapper()
mesh_mapper.SetInputConnection(reader.GetOutputPort())
mesh_actor = vtkActor()
mesh_actor.SetMapper(mesh_mapper)
renderer.AddActor(mesh_actor)

# Mesh: Setup default representation to surface
mesh_actor.GetProperty().SetRepresentationToSurface()
mesh_actor.GetProperty().SetPointSize(1)
mesh_actor.GetProperty().EdgeVisibilityOff()

# Mesh: Apply rainbow color map
mesh_lut = mesh_mapper.GetLookupTable()
mesh_lut.SetHueRange(0.666, 0.0)
mesh_lut.SetSaturationRange(1.0, 1.0)
mesh_lut.SetValueRange(1.0, 1.0)
mesh_lut.Build()

# Mesh: Color by default array
mesh_mapper.SelectColorArray(default_array.get("text"))
mesh_mapper.GetLookupTable().SetRange(default_min, default_max)
if default_array.get("type") == vtkDataObject.FIELD_ASSOCIATION_POINTS:
    mesh_mapper.SetScalarModeToUsePointFieldData()
else:
    mesh_mapper.SetScalarModeToUseCellFieldData()
mesh_mapper.SetScalarVisibility(True)
mesh_mapper.SetUseLookupTableScalarRange(True)

# Contour
contour = vtkContourFilter()
contour.SetInputConnection(reader.GetOutputPort())
contour_mapper = vtkDataSetMapper()
contour_mapper.SetInputConnection(contour.GetOutputPort())
contour_actor = vtkActor()
contour_actor.SetMapper(contour_mapper)
renderer.AddActor(contour_actor)

# Contour: ContourBy default array
contour_value = 0.5 * (default_max + default_min)
contour.SetInputArrayToProcess(
    0, 0, 0, default_array.get("type"), default_array.get("text")
)
contour.SetValue(0, contour_value)

# Contour: Setup default representation to surface
contour_actor.GetProperty().SetRepresentationToSurface()
contour_actor.GetProperty().SetPointSize(1)
contour_actor.GetProperty().EdgeVisibilityOff()

# Contour: Apply rainbow color map
contour_lut = contour_mapper.GetLookupTable()
contour_lut.SetHueRange(0.666, 0.0)
contour_lut.SetSaturationRange(1.0, 1.0)
contour_lut.SetValueRange(1.0, 1.0)
contour_lut.Build()

# Contour: Color by default array
contour_mapper.GetLookupTable().SetRange(default_min, default_max)
contour_mapper.SelectColorArray(default_array.get("text"))
if default_array.get("type") == vtkDataObject.FIELD_ASSOCIATION_POINTS:
    contour_mapper.SetScalarModeToUsePointFieldData()
else:
    contour_mapper.SetScalarModeToUseCellFieldData()
contour_mapper.SetScalarVisibility(True)
contour_mapper.SetUseLookupTableScalarRange(True)

# Cube Axes
cube_axes = vtkCubeAxesActor()
renderer.AddActor(cube_axes)

# Cube Axes: Boundaries, camera, and styling
cube_axes.SetBounds(mesh_actor.GetBounds())
cube_axes.SetCamera(renderer.GetActiveCamera())
cube_axes.SetXLabelFormat("%6.1f")
cube_axes.SetYLabelFormat("%6.1f")
cube_axes.SetZLabelFormat("%6.1f")
cube_axes.SetFlyModeToOuterEdges()

renderer.ResetCamera()

# -----------------------------------------------------------------------------
# trame Views
# -----------------------------------------------------------------------------

local_view = vtk.VtkLocalView(renderWindow)
remote_view = vtk.VtkRemoteView(renderWindow, interactive_ratio=(1,))
html_view = local_view

# -----------------------------------------------------------------------------
# Callbacks
# -----------------------------------------------------------------------------


def update_view(**kwargs):
    html_view.update()


# -----------------------------------------------------------------------------
# Toolbar Callbacks
# -----------------------------------------------------------------------------


@change("cube_axes_visibility")
def update_cube_axes_visibility(cube_axes_visibility, **kwargs):
    cube_axes.SetVisibility(cube_axes_visibility)
    update_view()


@change("local_vs_remote")
def update_local_vs_remote(local_vs_remote, **kwargs):
    # Switch html_view
    global html_view
    if local_vs_remote:
        html_view = local_view
    else:
        html_view = remote_view

    # Update layout
    layout.content.children[0].children[0] = html_view
    layout.flush_content()

    # Update View
    update_view()


# -----------------------------------------------------------------------------
# Representation Callbacks
# -----------------------------------------------------------------------------


def update_representation(actor, mode):
    property = actor.GetProperty()
    if mode == Representation.Points:
        property.SetRepresentationToPoints()
        property.SetPointSize(5)
        property.EdgeVisibilityOff()
    elif mode == Representation.Wireframe:
        property.SetRepresentationToWireframe()
        property.SetPointSize(1)
        property.EdgeVisibilityOff()
    elif mode == Representation.Surface:
        property.SetRepresentationToSurface()
        property.SetPointSize(1)
        property.EdgeVisibilityOff()
    elif mode == Representation.SurfaceWithEdges:
        property.SetRepresentationToSurface()
        property.SetPointSize(1)
        property.EdgeVisibilityOn()


@change("mesh_representation")
def update_mesh_representation(mesh_representation, **kwargs):
    update_representation(mesh_actor, mesh_representation)
    update_view()


@change("contour_representation")
def update_contour_representation(contour_representation, **kwargs):
    update_representation(contour_actor, contour_representation)
    update_view()


# -----------------------------------------------------------------------------
# ColorBy Callbacks
# -----------------------------------------------------------------------------


def color_by_array(actor, array):
    _min, _max = array.get("range")
    mapper = actor.GetMapper()
    mapper.SelectColorArray(array.get("text"))
    mapper.GetLookupTable().SetRange(_min, _max)
    if array.get("type") == vtkDataObject.FIELD_ASSOCIATION_POINTS:
        mesh_mapper.SetScalarModeToUsePointFieldData()
    else:
        mesh_mapper.SetScalarModeToUseCellFieldData()
    mapper.SetScalarModeToUsePointFieldData()
    mapper.SetScalarVisibility(True)
    mapper.SetUseLookupTableScalarRange(True)


@change("mesh_color_array_idx")
def update_mesh_color_by_name(mesh_color_array_idx, **kwargs):
    array = dataset_arrays[mesh_color_array_idx]
    color_by_array(mesh_actor, array)
    update_view()


@change("contour_color_array_idx")
def update_contour_color_by_name(contour_color_array_idx, **kwargs):
    array = dataset_arrays[contour_color_array_idx]
    color_by_array(contour_actor, array)
    update_view()


# -----------------------------------------------------------------------------
# ColorMap Callbacks
# -----------------------------------------------------------------------------


def use_preset(actor, preset):
    lut = actor.GetMapper().GetLookupTable()
    if preset == LookupTable.Rainbow:
        lut.SetHueRange(0.666, 0.0)
        lut.SetSaturationRange(1.0, 1.0)
        lut.SetValueRange(1.0, 1.0)
    elif preset == LookupTable.Inverted_Rainbow:
        lut.SetHueRange(0.0, 0.666)
        lut.SetSaturationRange(1.0, 1.0)
        lut.SetValueRange(1.0, 1.0)
    elif preset == LookupTable.Greyscale:
        lut.SetHueRange(0.0, 0.0)
        lut.SetSaturationRange(0.0, 0.0)
        lut.SetValueRange(0.0, 1.0)
    elif preset == LookupTable.Inverted_Greyscale:
        lut.SetHueRange(0.0, 0.666)
        lut.SetSaturationRange(0.0, 0.0)
        lut.SetValueRange(1.0, 0.0)
    lut.Build()


@change("mesh_color_preset")
def update_mesh_color_preset(mesh_color_preset, **kwargs):
    use_preset(mesh_actor, mesh_color_preset)
    update_view()


@change("contour_color_preset")
def update_contour_color_preset(contour_color_preset, **kwargs):
    use_preset(contour_actor, contour_color_preset)
    update_view()


# -----------------------------------------------------------------------------
# Opacity Callbacks
# -----------------------------------------------------------------------------


@change("mesh_opacity")
def update_mesh_opacity(mesh_opacity, **kwargs):
    mesh_actor.GetProperty().SetOpacity(mesh_opacity)
    update_view()


@change("contour_opacity")
def update_contour_opacity(contour_opacity, **kwargs):
    contour_actor.GetProperty().SetOpacity(contour_opacity)
    update_view()


# -----------------------------------------------------------------------------
# Contour Callbacks
# -----------------------------------------------------------------------------


@change("contour_by_array_idx")
def update_contour_by(contour_by_array_idx, **kwargs):
    array = dataset_arrays[contour_by_array_idx]
    contour_min, contour_max = array.get("range")
    contour_step = 0.01 * (contour_max - contour_min)
    contour_value = 0.5 * (contour_max + contour_min)
    contour.SetInputArrayToProcess(0, 0, 0, array.get("type"), array.get("text"))
    contour.SetValue(0, contour_value)

    # Update UI
    update_state("contour_min", contour_min)
    update_state("contour_max", contour_max)
    update_state("contour_value", contour_value)
    update_state("contour_step", contour_step)

    # Update View
    update_view()


@change("contour_value")
def update_contour_value(contour_value, **kwargs):
    contour.SetValue(0, float(contour_value))
    update_view()


# -----------------------------------------------------------------------------
# Pipeline Widget Callbacks
# -----------------------------------------------------------------------------

# Selection Change
def actives_change(ids):
    _id = ids[0]
    if _id == "1":  # Mesh
        update_state("active_ui", "mesh")
    elif _id == "2":  # Contour
        update_state("active_ui", "contour")
    else:
        update_state("active_ui", "nothing")


# Visibility Change
def visibility_change(event):
    _id = event["id"]
    _visibility = event["visible"]

    if _id == "1":  # Mesh
        mesh_actor.SetVisibility(_visibility)
    elif _id == "2":  # Contour
        contour_actor.SetVisibility(_visibility)
    update_view()


# -----------------------------------------------------------------------------
# GUI Toolbar Buttons
# -----------------------------------------------------------------------------


def standard_buttons():
    vuetify.VCheckbox(
        v_model=("cube_axes_visibility", True),
        on_icon="mdi-cube-outline",
        off_icon="mdi-cube-off-outline",
        classes="mx-1",
        hide_details=True,
        dense=True,
    )
    vuetify.VCheckbox(
        v_model="$vuetify.theme.dark",
        on_icon="mdi-lightbulb-off-outline",
        off_icon="mdi-lightbulb-outline",
        classes="mx-1",
        hide_details=True,
        dense=True,
    )
    vuetify.VCheckbox(
        v_model=("local_vs_remote", True),
        on_icon="mdi-lan-disconnect",
        off_icon="mdi-lan-connect",
        classes="mx-1",
        hide_details=True,
        dense=True,
    )
    with vuetify.VBtn(icon=True, click="$refs.view.resetCamera()"):
        vuetify.VIcon("mdi-crop-free")


# -----------------------------------------------------------------------------
# GUI Pipelines Widget
# -----------------------------------------------------------------------------


def pipeline_widget():
    widgets.GitTree(
        sources=(
            "pipeline",
            [
                {"id": "1", "parent": "0", "visible": 1, "name": "Mesh"},
                {"id": "2", "parent": "1", "visible": 1, "name": "Contour"},
            ],
        ),
        actives_change=(actives_change, "[$event]"),
        visibility_change=(visibility_change, "[$event]"),
    )


# -----------------------------------------------------------------------------
# GUI Cards
# -----------------------------------------------------------------------------


def ui_card(title, ui_name):
    with vuetify.VCard(v_show=f"active_ui == '{ui_name}'"):
        vuetify.VCardTitle(
            title,
            classes="grey lighten-1 py-1 grey--text text--darken-3",
            style="user-select: none; cursor: pointer",
            hide_details=True,
            dense=True,
        )
        content = vuetify.VCardText(classes="py-2")
    return content


def mesh_card():
    with ui_card(title="Mesh", ui_name="mesh"):
        vuetify.VSelect(
            v_model=("mesh_representation", Representation.Surface),
            items=(
                "representations",
                [
                    {"text": "Points", "value": 0},
                    {"text": "Wireframe", "value": 1},
                    {"text": "Surface", "value": 2},
                    {"text": "SurfaceWithEdges", "value": 3},
                ],
            ),
            label="Representation",
            hide_details=True,
            dense=True,
            outlined=True,
            classes="pt-1",
        )
        with vuetify.VRow(classes="pt-2", dense=True):
            with vuetify.VCol(cols="6"):
                vuetify.VSelect(
                    label="Color by",
                    v_model=("mesh_color_array_idx", 0),
                    items=("array_list", dataset_arrays),
                    hide_details=True,
                    dense=True,
                    outlined=True,
                    classes="pt-1",
                )
            with vuetify.VCol(cols="6"):
                vuetify.VSelect(
                    label="Colormap",
                    v_model=("mesh_color_preset", LookupTable.Rainbow),
                    items=(
                        "colormaps",
                        [
                            {"text": "Rainbow", "value": 0},
                            {"text": "Inv Rainbow", "value": 1},
                            {"text": "Greyscale", "value": 2},
                            {"text": "Inv Greyscale", "value": 3},
                        ],
                    ),
                    hide_details=True,
                    dense=True,
                    outlined=True,
                    classes="pt-1",
                )
        vuetify.VSlider(
            v_model=("mesh_opacity", 1.0),
            min=0,
            max=1,
            step=0.1,
            label="Opacity",
            classes="mt-1",
            hide_details=True,
            dense=True,
        )


def contour_card():
    with ui_card(title="Contour", ui_name="contour"):
        vuetify.VSelect(
            label="Contour by",
            v_model=("contour_by_array_idx", 0),
            items=("array_list", dataset_arrays),
            hide_details=True,
            dense=True,
            outlined=True,
            classes="pt-1",
        )
        vuetify.VSlider(
            v_model=("contour_value", contour_value),
            min=("contour_min", default_min),
            max=("contour_max", default_max),
            step=("contour_step", 0.01 * (default_max - default_min)),
            label="Value",
            classes="my-1",
            hide_details=True,
            dense=True,
        )
        vuetify.VSelect(
            v_model=("contour_representation", Representation.Surface),
            items=(
                "representations",
                [
                    {"text": "Points", "value": 0},
                    {"text": "Wireframe", "value": 1},
                    {"text": "Surface", "value": 2},
                    {"text": "SurfaceWithEdges", "value": 3},
                ],
            ),
            label="Representation",
            hide_details=True,
            dense=True,
            outlined=True,
            classes="pt-1",
        )
        with vuetify.VRow(classes="pt-2", dense=True):
            with vuetify.VCol(cols="6"):
                vuetify.VSelect(
                    label="Color by",
                    v_model=("contour_color_array_idx", 0),
                    items=("array_list", dataset_arrays),
                    hide_details=True,
                    dense=True,
                    outlined=True,
                    classes="pt-1",
                )
            with vuetify.VCol(cols="6"):
                vuetify.VSelect(
                    label="Colormap",
                    v_model=("contour_color_preset", LookupTable.Rainbow),
                    items=(
                        "colormaps",
                        [
                            {"text": "Rainbow", "value": 0},
                            {"text": "Inv Rainbow", "value": 1},
                            {"text": "Greyscale", "value": 2},
                            {"text": "Inv Greyscale", "value": 3},
                        ],
                    ),
                    hide_details=True,
                    dense=True,
                    outlined=True,
                    classes="pt-1",
                )
        vuetify.VSlider(
            v_model=("contour_opacity", 1.0),
            min=0,
            max=1,
            step=0.1,
            label="Opacity",
            classes="mt-1",
            hide_details=True,
            dense=True,
        )


# -----------------------------------------------------------------------------
# GUI
# -----------------------------------------------------------------------------

layout = SinglePageWithDrawer("Viewer", on_ready=update_view)
layout.title.set_text("Viewer")

with layout.toolbar:
    # toolbar components
    vuetify.VSpacer()
    vuetify.VDivider(vertical=True, classes="mx-2")
    standard_buttons()

with layout.drawer as drawer:
    # drawer components
    drawer.width = 325
    pipeline_widget()
    vuetify.VDivider(classes="mb-2")
    mesh_card()
    contour_card()

with layout.content:
    # content components
    vuetify.VContainer(
        fluid=True,
        classes="pa-0 fill-height",
        children=[html_view],
    )

# State use to track active ui card
layout.state = {
    "active_ui": None,
}

# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------

if __name__ == "__main__":
    layout.start()

[(49, 'vtkmodules.vtkRenderingCore.vtkRenderer', 'vtkRenderer', ([], {}), False, 'from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper, vtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor\n'), (50, 'vtkmodules.vtkRenderingCore.vtkRenderWindow', 'vtkRenderWindow', ([], {}), False, 'from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper, vtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor\n'), (53, 'vtkmodules.vtkRenderingCore.vtkRenderWindowInteractor', 'vtkRenderWindowInteractor', ([], {}), False, 'from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper, vtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor\n'), (58, 'vtkmodules.vtkIOXML.vtkXMLUnstructuredGridReader', 'vtkXMLUnstructuredGridReader', ([], {}), False, 'from vtkmodules.vtkIOXML import vtkXMLUnstructuredGridReader\n'), (85, 'vtkmodules.vtkRenderingCore.vtkDataSetMapper', 'vtkDataSetMapper', ([], {}), False, 'from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper, vtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor\n'), (87, 'vtkmodules.vtkRenderingCore.vtkActor', 'vtkActor', ([], {}), False, 'from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper, vtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor\n'), (114, 'vtkmodules.vtkFiltersCore.vtkContourFilter', 'vtkContourFilter', ([], {}), False, 'from vtkmodules.vtkFiltersCore import vtkContourFilter\n'), (116, 'vtkmodules.vtkRenderingCore.vtkDataSetMapper', 'vtkDataSetMapper', ([], {}), False, 'from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper, vtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor\n'), (118, 'vtkmodules.vtkRenderingCore.vtkActor', 'vtkActor', ([], {}), False, 'from vtkmodules.vtkRenderingCore import vtkActor, vtkDataSetMapper, vtkRenderer, vtkRenderWindow, vtkRenderWindowInteractor\n'), (152, 'vtkmodules.vtkRenderingAnnotation.vtkCubeAxesActor', 'vtkCubeAxesActor', ([], {}), False, 'from vtkmodules.vtkRenderingAnnotation import vtkCubeAxesActor\n'), (169, 'trame.html.vtk.VtkLocalView', 'vtk.VtkLocalView', (['renderWindow'], {}), False, 'from trame.html import vtk, vuetify, widgets\n'), (170, 'trame.html.vtk.VtkRemoteView', 'vtk.VtkRemoteView', (['renderWindow'], {'interactive_ratio': '(1,)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (187, 'trame.change', 'change', (['"""cube_axes_visibility"""'], {}), False, 'from trame import change, update_state\n'), (193, 'trame.change', 'change', (['"""local_vs_remote"""'], {}), False, 'from trame import change, update_state\n'), (235, 'trame.change', 'change', (['"""mesh_representation"""'], {}), False, 'from trame import change, update_state\n'), (241, 'trame.change', 'change', (['"""contour_representation"""'], {}), False, 'from trame import change, update_state\n'), (266, 'trame.change', 'change', (['"""mesh_color_array_idx"""'], {}), False, 'from trame import change, update_state\n'), (273, 'trame.change', 'change', (['"""contour_color_array_idx"""'], {}), False, 'from trame import change, update_state\n'), (306, 'trame.change', 'change', (['"""mesh_color_preset"""'], {}), False, 'from trame import change, update_state\n'), (312, 'trame.change', 'change', (['"""contour_color_preset"""'], {}), False, 'from trame import change, update_state\n'), (323, 'trame.change', 'change', (['"""mesh_opacity"""'], {}), False, 'from trame import change, update_state\n'), (329, 'trame.change', 'change', (['"""contour_opacity"""'], {}), False, 'from trame import change, update_state\n'), (340, 'trame.change', 'change', (['"""contour_by_array_idx"""'], {}), False, 'from trame import change, update_state\n'), (359, 'trame.change', 'change', (['"""contour_value"""'], {}), False, 'from trame import change, update_state\n'), (606, 'trame.layouts.SinglePageWithDrawer', 'SinglePageWithDrawer', (['"""Viewer"""'], {'on_ready': 'update_view'}), False, 'from trame.layouts import SinglePageWithDrawer\n'), (26, 'os.path.dirname', 'os.path.dirname', (['__file__'], {}), False, 'import os\n'), (59, 'os.path.join', 'os.path.join', (['CURRENT_DIRECTORY', '"""../data/disk_out_ref.vtu"""'], {}), False, 'import os\n'), (350, 'trame.update_state', 'update_state', (['"""contour_min"""', 'contour_min'], {}), False, 'from trame import change, update_state\n'), (351, 'trame.update_state', 'update_state', (['"""contour_max"""', 'contour_max'], {}), False, 'from trame import change, update_state\n'), (352, 'trame.update_state', 'update_state', (['"""contour_value"""', 'contour_value'], {}), False, 'from trame import change, update_state\n'), (353, 'trame.update_state', 'update_state', (['"""contour_step"""', 'contour_step'], {}), False, 'from trame import change, update_state\n'), (398, 'trame.html.vuetify.VCheckbox', 'vuetify.VCheckbox', ([], {'v_model': "('cube_axes_visibility', True)", 'on_icon': '"""mdi-cube-outline"""', 'off_icon': '"""mdi-cube-off-outline"""', 'classes': '"""mx-1"""', 'hide_details': '(True)', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (406, 'trame.html.vuetify.VCheckbox', 'vuetify.VCheckbox', ([], {'v_model': '"""$vuetify.theme.dark"""', 'on_icon': '"""mdi-lightbulb-off-outline"""', 'off_icon': '"""mdi-lightbulb-outline"""', 'classes': '"""mx-1"""', 'hide_details': '(True)', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (414, 'trame.html.vuetify.VCheckbox', 'vuetify.VCheckbox', ([], {'v_model': "('local_vs_remote', True)", 'on_icon': '"""mdi-lan-disconnect"""', 'off_icon': '"""mdi-lan-connect"""', 'classes': '"""mx-1"""', 'hide_details': '(True)', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (432, 'trame.html.widgets.GitTree', 'widgets.GitTree', ([], {'sources': "('pipeline', [{'id': '1', 'parent': '0', 'visible': 1, 'name': 'Mesh'}, {\n    'id': '2', 'parent': '1', 'visible': 1, 'name': 'Contour'}])", 'actives_change': "(actives_change, '[$event]')", 'visibility_change': "(visibility_change, '[$event]')"}), False, 'from trame.html import vtk, vuetify, widgets\n'), (611, 'trame.html.vuetify.VSpacer', 'vuetify.VSpacer', ([], {}), False, 'from trame.html import vtk, vuetify, widgets\n'), (612, 'trame.html.vuetify.VDivider', 'vuetify.VDivider', ([], {'vertical': '(True)', 'classes': '"""mx-2"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (619, 'trame.html.vuetify.VDivider', 'vuetify.VDivider', ([], {'classes': '"""mb-2"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (625, 'trame.html.vuetify.VContainer', 'vuetify.VContainer', ([], {'fluid': '(True)', 'classes': '"""pa-0 fill-height"""', 'children': '[html_view]'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (373, 'trame.update_state', 'update_state', (['"""active_ui"""', '"""mesh"""'], {}), False, 'from trame import change, update_state\n'), (422, 'trame.html.vuetify.VBtn', 'vuetify.VBtn', ([], {'icon': '(True)', 'click': '"""$refs.view.resetCamera()"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (423, 'trame.html.vuetify.VIcon', 'vuetify.VIcon', (['"""mdi-crop-free"""'], {}), False, 'from trame.html import vtk, vuetify, widgets\n'), (451, 'trame.html.vuetify.VCard', 'vuetify.VCard', ([], {'v_show': 'f"""active_ui == \'{ui_name}\'"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (452, 'trame.html.vuetify.VCardTitle', 'vuetify.VCardTitle', (['title'], {'classes': '"""grey lighten-1 py-1 grey--text text--darken-3"""', 'style': '"""user-select: none; cursor: pointer"""', 'hide_details': '(True)', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (459, 'trame.html.vuetify.VCardText', 'vuetify.VCardText', ([], {'classes': '"""py-2"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (465, 'trame.html.vuetify.VSelect', 'vuetify.VSelect', ([], {'v_model': "('mesh_representation', Representation.Surface)", 'items': "('representations', [{'text': 'Points', 'value': 0}, {'text': 'Wireframe',\n    'value': 1}, {'text': 'Surface', 'value': 2}, {'text':\n    'SurfaceWithEdges', 'value': 3}])", 'label': '"""Representation"""', 'hide_details': '(True)', 'dense': '(True)', 'outlined': '(True)', 'classes': '"""pt-1"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (511, 'trame.html.vuetify.VSlider', 'vuetify.VSlider', ([], {'v_model': "('mesh_opacity', 1.0)", 'min': '(0)', 'max': '(1)', 'step': '(0.1)', 'label': '"""Opacity"""', 'classes': '"""mt-1"""', 'hide_details': '(True)', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (525, 'trame.html.vuetify.VSelect', 'vuetify.VSelect', ([], {'label': '"""Contour by"""', 'v_model': "('contour_by_array_idx', 0)", 'items': "('array_list', dataset_arrays)", 'hide_details': '(True)', 'dense': '(True)', 'outlined': '(True)', 'classes': '"""pt-1"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (534, 'trame.html.vuetify.VSlider', 'vuetify.VSlider', ([], {'v_model': "('contour_value', contour_value)", 'min': "('contour_min', default_min)", 'max': "('contour_max', default_max)", 'step': "('contour_step', 0.01 * (default_max - default_min))", 'label': '"""Value"""', 'classes': '"""my-1"""', 'hide_details': '(True)', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (544, 'trame.html.vuetify.VSelect', 'vuetify.VSelect', ([], {'v_model': "('contour_representation', Representation.Surface)", 'items': "('representations', [{'text': 'Points', 'value': 0}, {'text': 'Wireframe',\n    'value': 1}, {'text': 'Surface', 'value': 2}, {'text':\n    'SurfaceWithEdges', 'value': 3}])", 'label': '"""Representation"""', 'hide_details': '(True)', 'dense': '(True)', 'outlined': '(True)', 'classes': '"""pt-1"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (590, 'trame.html.vuetify.VSlider', 'vuetify.VSlider', ([], {'v_model': "('contour_opacity', 1.0)", 'min': '(0)', 'max': '(1)', 'step': '(0.1)', 'label': '"""Opacity"""', 'classes': '"""mt-1"""', 'hide_details': '(True)', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (375, 'trame.update_state', 'update_state', (['"""active_ui"""', '"""contour"""'], {}), False, 'from trame import change, update_state\n'), (377, 'trame.update_state', 'update_state', (['"""active_ui"""', '"""nothing"""'], {}), False, 'from trame import change, update_state\n'), (482, 'trame.html.vuetify.VRow', 'vuetify.VRow', ([], {'classes': '"""pt-2"""', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (561, 'trame.html.vuetify.VRow', 'vuetify.VRow', ([], {'classes': '"""pt-2"""', 'dense': '(True)'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (483, 'trame.html.vuetify.VCol', 'vuetify.VCol', ([], {'cols': '"""6"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (484, 'trame.html.vuetify.VSelect', 'vuetify.VSelect', ([], {'label': '"""Color by"""', 'v_model': "('mesh_color_array_idx', 0)", 'items': "('array_list', dataset_arrays)", 'hide_details': '(True)', 'dense': '(True)', 'outlined': '(True)', 'classes': '"""pt-1"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (493, 'trame.html.vuetify.VCol', 'vuetify.VCol', ([], {'cols': '"""6"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (494, 'trame.html.vuetify.VSelect', 'vuetify.VSelect', ([], {'label': '"""Colormap"""', 'v_model': "('mesh_color_preset', LookupTable.Rainbow)", 'items': "('colormaps', [{'text': 'Rainbow', 'value': 0}, {'text': 'Inv Rainbow',\n    'value': 1}, {'text': 'Greyscale', 'value': 2}, {'text':\n    'Inv Greyscale', 'value': 3}])", 'hide_details': '(True)', 'dense': '(True)', 'outlined': '(True)', 'classes': '"""pt-1"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (562, 'trame.html.vuetify.VCol', 'vuetify.VCol', ([], {'cols': '"""6"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (563, 'trame.html.vuetify.VSelect', 'vuetify.VSelect', ([], {'label': '"""Color by"""', 'v_model': "('contour_color_array_idx', 0)", 'items': "('array_list', dataset_arrays)", 'hide_details': '(True)', 'dense': '(True)', 'outlined': '(True)', 'classes': '"""pt-1"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (572, 'trame.html.vuetify.VCol', 'vuetify.VCol', ([], {'cols': '"""6"""'}), False, 'from trame.html import vtk, vuetify, widgets\n'), (573, 'trame.html.vuetify.VSelect', 'vuetify.VSelect', ([], {'label': '"""Colormap"""', 'v_model': "('contour_color_preset', LookupTable.Rainbow)", 'items': "('colormaps', [{'text': 'Rainbow', 'value': 0}, {'text': 'Inv Rainbow',\n    'value': 1}, {'text': 'Greyscale', 'value': 2}, {'text':\n    'Inv Greyscale', 'value': 3}])", 'hide_details': '(True)', 'dense': '(True)', 'outlined': '(True)', 'classes': '"""pt-1"""'}), False, 'from trame.html import vtk, vuetify, widgets\n')]