Exemple #1
0
    def execute(self, iren, event):
        '''instruction block executed when a TimerEvent is captured by the vtkRotateActorAroundAxis.

        If the time is not in [start, end] nothing is done. Otherwise the
        transform matrix corresponding to the 3D rotation is applied to the actor.
        '''
        do = vtkAnimation.pre_execute(self)
        if not do:
            return
        t1 = self.time_anim_starts
        t2 = self.time_anim_ends
        angle = (self.scene.timer_count - t1) / float(t2 - t1) * self.angle
        from pymicro.crystal.microstructure import Orientation
        om = Orientation.Axis2OrientationMatrix(self.axis, angle)
        m = vtk.vtkMatrix4x4()  # row major order, 16 elements matrix
        m.Identity()
        for j in range(3):
            for i in range(3):
                m.SetElement(j, i, om[i, j])
        t = vtk.vtkTransform()
        #t.SetMatrix(self.user_transform_matrix)
        t.SetMatrix(self.actor.GetUserTransform().GetMatrix())
        t.Concatenate(m)
        self.actor.SetUserTransform(t)
        vtkAnimation.post_execute(self, iren, event)
Exemple #2
0
    def execute(self, iren, event):
        """instruction block executed when a TimerEvent is captured by the vtkRotateActorAroundAxis.

        If the time is not in [start, end] nothing is done. Otherwise the transform matrix corresponding
        to the 3D rotation is applied to the actor.

        The transform matrix for this increment is the result of the multiplication of the rotation matrix
        for the current angle with the initial 4x4 matrix before any rotation (we keep a record of this in
        the `user_transform_matrix` attribute).

        :param vtkRenderWindowInteractor iren: the vtk render window interactor.
        :param event: the captures event.
        """
        do = vtkAnimation.pre_execute(self)
        if not do:
            return
        t1 = self.time_anim_starts
        t2 = self.time_anim_ends
        angle = (self.scene.timer_count - t1) / float(t2 - t1) * self.angle
        from pymicro.crystal.microstructure import Orientation
        om = Orientation.Axis2OrientationMatrix(self.axis, angle)
        m = vtk.vtkMatrix4x4()  # row major order, 16 elements matrix
        m.Identity()
        for j in range(3):
            for i in range(3):
                m.SetElement(j, i, om[i, j])
        # compute the transformation matrix for this increment
        t = vtk.vtkTransform()
        t.SetMatrix(self.user_transform_matrix)
        t.Concatenate(m)
        self._actor.SetUserTransform(t)
        vtkAnimation.post_execute(self, iren, event)