~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/startup/bl_operators/sequencer.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ##### BEGIN GPL LICENSE BLOCK #####
 
2
#
 
3
#  This program is free software; you can redistribute it and/or
 
4
#  modify it under the terms of the GNU General Public License
 
5
#  as published by the Free Software Foundation; either version 2
 
6
#  of the License, or (at your option) any later version.
 
7
#
 
8
#  This program is distributed in the hope that it will be useful,
 
9
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
#  GNU General Public License for more details.
 
12
#
 
13
#  You should have received a copy of the GNU General Public License
 
14
#  along with this program; if not, write to the Free Software Foundation,
 
15
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
16
#
 
17
# ##### END GPL LICENSE BLOCK #####
 
18
 
 
19
# <pep8 compliant>
 
20
 
 
21
import bpy
 
22
from bpy.types import Operator
 
23
 
 
24
from bpy.props import IntProperty
 
25
 
 
26
 
 
27
class SequencerCrossfadeSounds(Operator):
 
28
    '''Do cross-fading volume animation of two selected sound strips'''
 
29
 
 
30
    bl_idname = "sequencer.crossfade_sounds"
 
31
    bl_label = "Crossfade sounds"
 
32
    bl_options = {'REGISTER', 'UNDO'}
 
33
 
 
34
    @classmethod
 
35
    def poll(cls, context):
 
36
        if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip:
 
37
            return context.scene.sequence_editor.active_strip.type == 'SOUND'
 
38
        else:
 
39
            return False
 
40
 
 
41
    def execute(self, context):
 
42
        seq1 = None
 
43
        seq2 = None
 
44
        for s in context.scene.sequence_editor.sequences:
 
45
            if s.select and s.type == 'SOUND':
 
46
                if seq1 is None:
 
47
                    seq1 = s
 
48
                elif seq2 is None:
 
49
                    seq2 = s
 
50
                else:
 
51
                    seq2 = None
 
52
                    break
 
53
        if seq2 is None:
 
54
            self.report({'ERROR'}, "Select 2 sound strips")
 
55
            return {'CANCELLED'}
 
56
        if seq1.frame_final_start > seq2.frame_final_start:
 
57
            s = seq1
 
58
            seq1 = seq2
 
59
            seq2 = s
 
60
        if seq1.frame_final_end > seq2.frame_final_start:
 
61
            tempcfra = context.scene.frame_current
 
62
            context.scene.frame_current = seq2.frame_final_start
 
63
            seq1.keyframe_insert("volume")
 
64
            context.scene.frame_current = seq1.frame_final_end
 
65
            seq1.volume = 0
 
66
            seq1.keyframe_insert("volume")
 
67
            seq2.keyframe_insert("volume")
 
68
            context.scene.frame_current = seq2.frame_final_start
 
69
            seq2.volume = 0
 
70
            seq2.keyframe_insert("volume")
 
71
            context.scene.frame_current = tempcfra
 
72
            return {'FINISHED'}
 
73
        else:
 
74
            self.report({'ERROR'}, "The selected strips don't overlap")
 
75
            return {'CANCELLED'}
 
76
 
 
77
 
 
78
class SequencerCutMulticam(Operator):
 
79
    '''Cut multi-cam strip and select camera'''
 
80
 
 
81
    bl_idname = "sequencer.cut_multicam"
 
82
    bl_label = "Cut multicam"
 
83
    bl_options = {'REGISTER', 'UNDO'}
 
84
 
 
85
    camera = IntProperty(
 
86
            name="Camera",
 
87
            min=1, max=32,
 
88
            soft_min=1, soft_max=32,
 
89
            default=1,
 
90
            )
 
91
 
 
92
    @classmethod
 
93
    def poll(cls, context):
 
94
        if context.scene and context.scene.sequence_editor and context.scene.sequence_editor.active_strip:
 
95
            return context.scene.sequence_editor.active_strip.type == 'MULTICAM'
 
96
        else:
 
97
            return False
 
98
 
 
99
    def execute(self, context):
 
100
        camera = self.camera
 
101
 
 
102
        s = context.scene.sequence_editor.active_strip
 
103
 
 
104
        if s.multicam_source == camera or camera >= s.channel:
 
105
            return {'FINISHED'}
 
106
 
 
107
        if not s.select:
 
108
            s.select = True
 
109
 
 
110
        cfra = context.scene.frame_current
 
111
        bpy.ops.sequencer.cut(frame=cfra, type='SOFT', side='RIGHT')
 
112
        for s in context.scene.sequence_editor.sequences_all:
 
113
            if s.select and s.type == 'MULTICAM' and s.frame_final_start <= cfra and cfra < s.frame_final_end:
 
114
                context.scene.sequence_editor.active_strip = s
 
115
 
 
116
        context.scene.sequence_editor.active_strip.multicam_source = camera
 
117
        return {'FINISHED'}
 
118
 
 
119
 
 
120
class SequencerDeinterlaceSelectedMovies(Operator):
 
121
    '''Deinterlace all selected movie sources'''
 
122
 
 
123
    bl_idname = "sequencer.deinterlace_selected_movies"
 
124
    bl_label = "Deinterlace Movies"
 
125
    bl_options = {'REGISTER', 'UNDO'}
 
126
 
 
127
    @classmethod
 
128
    def poll(cls, context):
 
129
        if context.scene and context.scene.sequence_editor:
 
130
            return True
 
131
        else:
 
132
            return False
 
133
 
 
134
    def execute(self, context):
 
135
        for s in context.scene.sequence_editor.sequences_all:
 
136
            if s.select and s.type == 'MOVIE':
 
137
                s.use_deinterlace = True
 
138
 
 
139
        return {'FINISHED'}