# Path: pymicro/view/vtk_utils.py
# def set_opacity(assembly, opacity):
#     collection = vtk.vtkPropCollection()
#     assembly.GetActors(collection)
#     for i in range(collection.GetNumberOfItems()):
#         collection.GetItemAsObject(i).GetProperty().SetOpacity(opacity)


import vtk
import os
import numpy as np
from pymicro.view.vtk_utils import set_opacity
        from pymicro.crystal.microstructure import Orientation
        vtkAnimation.__init__(self, t)
        self.camera = cam
        self.zoom = zoom
        self.timer_end = t + 10

    def execute(self, iren, event):
        do = vtkAnimation.pre_execute(self)
        if not do: return
        t1 = self.time_anim_starts
        t2 = self.time_anim_ends
        z = 1 + (self.zoom - 1) * (self.scene.timer_count - t1) / float(t2 - t1)
        if self.verbose:
            print('zooming to', z)
        self.camera.Zoom(z)
        vtkAnimation.post_execute(self, iren, event)


class vtkSetVisibility(vtkAnimation):
    def __init__(self, t, actor, visible=1, max_opacity=1, gradually=False):
        vtkAnimation.__init__(self, t)
        self.actor = actor
        self.visible = visible
        self.gradually = gradually
        self.max_opacity = max_opacity

    def execute(self, iren, event):
        do = vtkAnimation.pre_execute(self)
        if not do: return
        if not self.gradually:
            self.actor.SetVisibility(self.visible)

# Path: pymicro/view/vtk_utils.py
# def set_opacity(assembly, opacity):
#     collection = vtk.vtkPropCollection()
#     assembly.GetActors(collection)
#     for i in range(collection.GetNumberOfItems()):
#         collection.GetItemAsObject(i).GetProperty().SetOpacity(opacity)


# Path: pymicro/view/vtk_anim.py
import vtk
import os
import numpy as np
from pymicro.view.vtk_utils import set_opacity
        from pymicro.crystal.microstructure import Orientation

        vtkAnimation.__init__(self, t)
        self.camera = cam
        self.zoom = zoom
        self.timer_end = t + 10

    def execute(self, iren, event):
        do = vtkAnimation.pre_execute(self)
        if not do: return
        t1 = self.time_anim_starts
        t2 = self.time_anim_ends
        z = 1 + (self.zoom - 1) * (self.scene.timer_count - t1) / float(t2 - t1)
        if self.verbose:
            print('zooming to', z)
        self.camera.Zoom(z)
        vtkAnimation.post_execute(self, iren, event)


class vtkSetVisibility(vtkAnimation):
    def __init__(self, t, actor, visible=1, max_opacity=1, gradually=False):
        vtkAnimation.__init__(self, t)
        self.actor = actor
        self.visible = visible
        self.gradually = gradually
        self.max_opacity = max_opacity

    def execute(self, iren, event):
        do = vtkAnimation.pre_execute(self)
        if not do: return
        if not self.gradually:
            self.actor.SetVisibility(self.visible)

            set_opacity(self.actor, 1)