Fix uilists showing data names translated (reported on bf-translations ML by Satoshi...
[blender.git] / release / scripts / startup / bl_ui / space_clip.py
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-80 compliant>
20
21 import bpy
22 from bpy.types import Panel, Header, Menu, UIList
23
24
25 class CLIP_UL_tracking_objects(UIList):
26     def draw_item(self, context, layout, data, item, icon,
27                   active_data, active_propname, index):
28         # assert(isinstance(item, bpy.types.MovieTrackingObject)
29         tobj = item
30         if self.layout_type in {'DEFAULT', 'COMPACT'}:
31             layout.label(text=tobj.name, translate=False, icon='CAMERA_DATA' if tobj.is_camera else 'OBJECT_DATA')
32         elif self.layout_type in {'GRID'}:
33             layout.alignment = 'CENTER'
34             layout.label(text="", icon='CAMERA_DATA' if tobj.is_camera else 'OBJECT_DATA')
35
36
37 class CLIP_HT_header(Header):
38     bl_space_type = 'CLIP_EDITOR'
39
40     def _draw_tracking(self, context):
41         layout = self.layout
42
43         sc = context.space_data
44         clip = sc.clip
45
46         row = layout.row(align=True)
47         row.template_header()
48
49         if context.area.show_menus:
50             sub = row.row(align=True)
51             sub.menu("CLIP_MT_view")
52
53             if sc.view == 'CLIP':
54                 if clip:
55                     sub.menu("CLIP_MT_select")
56                     sub.menu("CLIP_MT_clip")
57                     sub.menu("CLIP_MT_track")
58                     sub.menu("CLIP_MT_reconstruction")
59                 else:
60                     sub.menu("CLIP_MT_clip")
61
62         row = layout.row()
63         row.template_ID(sc, "clip", open="clip.open")
64
65         if clip:
66             tracking = clip.tracking
67             active_object = tracking.objects.active
68
69             if sc.view == 'CLIP':
70                 layout.prop(sc, "mode", text="")
71                 layout.prop(sc, "view", text="", expand=True)
72                 layout.prop(sc, "pivot_point", text="", icon_only=True)
73
74                 r = active_object.reconstruction
75
76                 if r.is_valid and sc.view == 'CLIP':
77                     layout.label(text="Solve error: %.4f" %
78                                  (r.average_error))
79             elif sc.view == 'GRAPH':
80                 layout.prop(sc, "view", text="", expand=True)
81
82                 row = layout.row(align=True)
83                 row.prop(sc, "show_graph_only_selected", text="")
84                 row.prop(sc, "show_graph_hidden", text="")
85
86                 row = layout.row(align=True)
87
88                 if sc.show_filters:
89                     row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN',
90                              text="Filters")
91
92                     sub = row.column()
93                     sub.active = clip.tracking.reconstruction.is_valid
94                     sub.prop(sc, "show_graph_frames", icon='SEQUENCE', text="")
95
96                     row.prop(sc, "show_graph_tracks", icon='ANIM', text="")
97                 else:
98                     row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT',
99                              text="Filters")
100             elif sc.view == 'DOPESHEET':
101                 dopesheet = tracking.dopesheet
102                 layout.prop(sc, "view", text="", expand=True)
103
104                 row = layout.row(align=True)
105                 row.prop(dopesheet, "show_only_selected", text="")
106                 row.prop(dopesheet, "show_hidden", text="")
107
108                 row = layout.row(align=True)
109                 row.prop(dopesheet, "sort_method", text="")
110                 row.prop(dopesheet, "use_invert_sort",
111                          text="Invert", toggle=True)
112         else:
113             layout.prop(sc, "view", text="", expand=True)
114
115     def _draw_masking(self, context):
116         layout = self.layout
117
118         toolsettings = context.tool_settings
119         sc = context.space_data
120         clip = sc.clip
121
122         row = layout.row(align=True)
123         row.template_header()
124
125         if context.area.show_menus:
126             sub = row.row(align=True)
127             sub.menu("CLIP_MT_view")
128
129             if clip:
130                 sub.menu("MASK_MT_select")
131                 sub.menu("CLIP_MT_clip")  # XXX - remove?
132                 sub.menu("MASK_MT_mask")
133             else:
134                 sub.menu("CLIP_MT_clip")  # XXX - remove?
135
136         row = layout.row()
137         row.template_ID(sc, "clip", open="clip.open")
138
139         layout.prop(sc, "mode", text="")
140
141         row = layout.row()
142         row.template_ID(sc, "mask", new="mask.new")
143
144         layout.prop(sc, "pivot_point", text="", icon_only=True)
145
146         row = layout.row(align=True)
147         row.prop(toolsettings, "use_proportional_edit_mask",
148                  text="", icon_only=True)
149         if toolsettings.use_proportional_edit_mask:
150             row.prop(toolsettings, "proportional_edit_falloff",
151                      text="", icon_only=True)
152
153     def draw(self, context):
154         layout = self.layout
155
156         sc = context.space_data
157
158         if sc.mode in {'TRACKING', 'RECONSTRUCTION', 'DISTORTION'}:
159             self._draw_tracking(context)
160         else:
161             self._draw_masking(context)
162
163         layout.template_running_jobs()
164
165
166 class CLIP_PT_clip_view_panel:
167
168     @classmethod
169     def poll(cls, context):
170         sc = context.space_data
171         clip = sc.clip
172
173         return clip and sc.view == 'CLIP'
174
175
176 class CLIP_PT_tracking_panel:
177
178     @classmethod
179     def poll(cls, context):
180         sc = context.space_data
181         clip = sc.clip
182
183         return clip and sc.mode == 'TRACKING' and sc.view == 'CLIP'
184
185
186 class CLIP_PT_reconstruction_panel:
187
188     @classmethod
189     def poll(cls, context):
190         sc = context.space_data
191         clip = sc.clip
192
193         return clip and sc.mode == 'RECONSTRUCTION' and sc.view == 'CLIP'
194
195
196 class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel):
197     bl_space_type = 'CLIP_EDITOR'
198     bl_region_type = 'TOOLS'
199     bl_label = "Marker"
200
201     def draw(self, context):
202         layout = self.layout
203
204         sc = context.space_data
205         clip = sc.clip
206         settings = clip.tracking.settings
207
208         col = layout.column(align=True)
209         col.operator("clip.add_marker_move")
210         col.operator("clip.detect_features")
211         col.operator("clip.delete_track")
212
213         box = layout.box()
214         row = box.row(align=True)
215         row.prop(settings, "show_default_expanded", text="", emboss=False)
216         row.label(text="Tracking Settings")
217
218         if settings.show_default_expanded:
219             col = box.column()
220             row = col.row(align=True)
221             label = CLIP_MT_tracking_settings_presets.bl_label
222             row.menu('CLIP_MT_tracking_settings_presets', text=label)
223             row.operator("clip.tracking_settings_preset_add",
224                          text="", icon='ZOOMIN')
225             props = row.operator("clip.tracking_settings_preset_add",
226                                  text="", icon='ZOOMOUT')
227             props.remove_active = True
228
229             col.separator()
230
231             row = col.row(align=True)
232             row.prop(settings, "use_default_red_channel",
233                      text="R", toggle=True)
234             row.prop(settings, "use_default_green_channel",
235                      text="G", toggle=True)
236             row.prop(settings, "use_default_blue_channel",
237                      text="B", toggle=True)
238
239             col.separator()
240
241             sub = col.column(align=True)
242             sub.prop(settings, "default_pattern_size")
243             sub.prop(settings, "default_search_size")
244
245             col.label(text="Tracker:")
246             col.prop(settings, "default_motion_model")
247             col.prop(settings, "use_default_brute")
248             col.prop(settings, "use_default_normalization")
249             col.prop(settings, "use_default_mask")
250             col.prop(settings, "default_correlation_min")
251
252             col.separator()
253
254             sub = col.column(align=True)
255             sub.prop(settings, "default_frames_limit")
256             sub.prop(settings, "default_margin")
257
258             col.label(text="Match:")
259             col.prop(settings, "default_pattern_match", text="")
260
261             col.separator()
262             col.operator("clip.track_settings_as_default",
263                          text="Copy From Active Track")
264
265
266 class CLIP_PT_tools_tracking(CLIP_PT_tracking_panel, Panel):
267     bl_space_type = 'CLIP_EDITOR'
268     bl_region_type = 'TOOLS'
269     bl_label = "Track"
270
271     def draw(self, context):
272         layout = self.layout
273
274         row = layout.row(align=True)
275
276         props = row.operator("clip.track_markers", text="", icon='FRAME_PREV')
277         props.backwards = True
278         props.sequence = False
279         props = row.operator("clip.track_markers", text="",
280                              icon='PLAY_REVERSE')
281         props.backwards = True
282         props.sequence = True
283         props = row.operator("clip.track_markers", text="", icon='PLAY')
284         props.backwards = False
285         props.sequence = True
286         props = row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
287         props.backwards = False
288         props.sequence = False
289
290         col = layout.column(align=True)
291         props = col.operator("clip.clear_track_path", text="Clear After")
292         props.action = 'REMAINED'
293
294         props = col.operator("clip.clear_track_path", text="Clear Before")
295         props.action = 'UPTO'
296         col.operator("clip.clear_track_path", text="Clear").action = 'ALL'
297
298         layout.operator("clip.join_tracks", text="Join")
299
300
301 class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
302     bl_space_type = 'CLIP_EDITOR'
303     bl_region_type = 'TOOLS'
304     bl_label = "Solve"
305
306     def draw(self, context):
307         layout = self.layout
308
309         clip = context.space_data.clip
310         tracking = clip.tracking
311         settings = tracking.settings
312         tracking_object = tracking.objects.active
313
314         col = layout.column(align=True)
315
316         col.operator("clip.solve_camera",
317                      text="Camera Motion" if tracking_object.is_camera
318                      else "Object Motion")
319         col.operator("clip.clear_solution")
320
321         col = layout.column()
322         col.prop(settings, "use_tripod_solver")
323
324         col = layout.column(align=True)
325         col.active = not settings.use_tripod_solver
326         col.prop(tracking_object, "keyframe_a")
327         col.prop(tracking_object, "keyframe_b")
328
329         col = layout.column(align=True)
330         col.active = (tracking_object.is_camera and
331                       not settings.use_tripod_solver)
332         col.label(text="Refine:")
333         col.prop(settings, "refine_intrinsics", text="")
334
335         col = layout.column(align=True)
336         col.active = not settings.use_tripod_solver
337         col.prop(settings, "use_fallback_reconstruction",
338                  text="Allow Fallback")
339         sub = col.column()
340         sub.active = settings.use_fallback_reconstruction
341         sub.prop(settings, "reconstruction_success_threshold")
342
343
344 class CLIP_PT_tools_cleanup(CLIP_PT_tracking_panel, Panel):
345     bl_space_type = 'CLIP_EDITOR'
346     bl_region_type = 'TOOLS'
347     bl_label = "Clean up"
348
349     def draw(self, context):
350         layout = self.layout
351         clip = context.space_data.clip
352         settings = clip.tracking.settings
353
354         layout.operator("clip.clean_tracks")
355
356         layout.prop(settings, "clean_frames", text="Frames")
357         layout.prop(settings, "clean_error", text="Error")
358         layout.prop(settings, "clean_action", text="")
359
360
361 class CLIP_PT_tools_geometry(CLIP_PT_reconstruction_panel, Panel):
362     bl_space_type = 'CLIP_EDITOR'
363     bl_region_type = 'TOOLS'
364     bl_label = "Geometry"
365
366     def draw(self, context):
367         layout = self.layout
368
369         layout.operator("clip.bundles_to_mesh")
370         layout.operator("clip.track_to_empty")
371
372
373 class CLIP_PT_tools_orientation(CLIP_PT_reconstruction_panel, Panel):
374     bl_space_type = 'CLIP_EDITOR'
375     bl_region_type = 'TOOLS'
376     bl_label = "Orientation"
377
378     def draw(self, context):
379         sc = context.space_data
380         layout = self.layout
381         settings = sc.clip.tracking.settings
382
383         col = layout.column(align=True)
384         row = col.row()
385         props = row.operator("clip.set_plane", text="Floor")
386         props.plane = 'FLOOR'
387         props = row.operator("clip.set_plane", text="Wall")
388         props.plane = 'WALL'
389         col.operator("clip.set_origin")
390
391         row = col.row()
392         row.operator("clip.set_axis", text="Set X Axis").axis = 'X'
393         row.operator("clip.set_axis", text="Set Y Axis").axis = 'Y'
394
395         layout.separator()
396
397         col = layout.column()
398         col.operator("clip.set_scale")
399         col.prop(settings, "distance")
400
401
402 class CLIP_PT_tools_object(CLIP_PT_reconstruction_panel, Panel):
403     bl_space_type = 'CLIP_EDITOR'
404     bl_region_type = 'TOOLS'
405     bl_label = "Object"
406
407     @classmethod
408     def poll(cls, context):
409         if CLIP_PT_reconstruction_panel.poll(context):
410             sc = context.space_data
411             clip = sc.clip
412
413             tracking_object = clip.tracking.objects.active
414
415             return not tracking_object.is_camera
416
417         return False
418
419     def draw(self, context):
420         layout = self.layout
421
422         sc = context.space_data
423         clip = sc.clip
424         tracking_object = clip.tracking.objects.active
425         settings = sc.clip.tracking.settings
426
427         col = layout.column()
428
429         col.prop(tracking_object, "scale")
430
431         col.separator()
432
433         col.operator("clip.set_solution_scale", text="Set Scale")
434         col.prop(settings, "object_distance")
435
436
437 class CLIP_PT_tools_grease_pencil(Panel):
438     bl_space_type = 'CLIP_EDITOR'
439     bl_region_type = 'TOOLS'
440     bl_label = "Grease Pencil"
441
442     @classmethod
443     def poll(cls, context):
444         sc = context.space_data
445         clip = sc.clip
446
447         if not clip:
448             return False
449
450         if sc.mode == 'DISTORTION':
451             return sc.view == 'CLIP'
452         elif sc.mode == 'MASK':
453             return True
454
455         return False
456
457     def draw(self, context):
458         layout = self.layout
459
460         col = layout.column(align=True)
461
462         row = col.row(align=True)
463         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
464         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
465
466         row = col.row(align=True)
467         row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
468         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
469
470         row = col.row()
471         row.prop(context.tool_settings, "use_grease_pencil_sessions")
472
473
474 class CLIP_PT_objects(CLIP_PT_clip_view_panel, Panel):
475     bl_space_type = 'CLIP_EDITOR'
476     bl_region_type = 'UI'
477     bl_label = "Objects"
478     bl_options = {'DEFAULT_CLOSED'}
479
480     def draw(self, context):
481         layout = self.layout
482
483         sc = context.space_data
484         tracking = sc.clip.tracking
485
486         row = layout.row()
487         row.template_list("CLIP_UL_tracking_objects", "", tracking, "objects",
488                           tracking, "active_object_index", rows=3)
489
490         sub = row.column(align=True)
491
492         sub.operator("clip.tracking_object_new", icon='ZOOMIN', text="")
493         sub.operator("clip.tracking_object_remove", icon='ZOOMOUT', text="")
494
495         active = tracking.objects.active
496         if active:
497             layout.prop(active, "name")
498
499
500 class CLIP_PT_track(CLIP_PT_tracking_panel, Panel):
501     bl_space_type = 'CLIP_EDITOR'
502     bl_region_type = 'UI'
503     bl_label = "Track"
504
505     def draw(self, context):
506         layout = self.layout
507
508         sc = context.space_data
509         clip = context.space_data.clip
510         act_track = clip.tracking.tracks.active
511
512         if not act_track:
513             layout.active = False
514             layout.label(text="No active track")
515             return
516
517         row = layout.row()
518         row.prop(act_track, "name", text="")
519
520         sub = row.row(align=True)
521
522         sub.template_marker(sc, "clip", sc.clip_user, act_track, True)
523
524         icon = 'LOCKED' if act_track.lock else 'UNLOCKED'
525         sub.prop(act_track, "lock", text="", icon=icon)
526
527         layout.template_track(sc, "scopes")
528
529         row = layout.row(align=True)
530         sub = row.row()
531         sub.prop(act_track, "use_red_channel", text="R", toggle=True)
532         sub.prop(act_track, "use_green_channel", text="G", toggle=True)
533         sub.prop(act_track, "use_blue_channel", text="B", toggle=True)
534
535         row.separator()
536
537         sub = row.row()
538         sub.prop(act_track, "use_grayscale_preview", text="B/W", toggle=True)
539
540         row.separator()
541         sub = row.row()
542         sub.prop(act_track, "use_alpha_preview",
543                  text="", toggle=True, icon='IMAGE_ALPHA')
544
545         layout.separator()
546
547         row = layout.row(align=True)
548         label = bpy.types.CLIP_MT_track_color_presets.bl_label
549         row.menu('CLIP_MT_track_color_presets', text=label)
550         row.menu('CLIP_MT_track_color_specials', text="", icon='DOWNARROW_HLT')
551         row.operator("clip.track_color_preset_add", text="", icon='ZOOMIN')
552         props = row.operator("clip.track_color_preset_add",
553                              text="", icon='ZOOMOUT')
554         props.remove_active = True
555
556         row = layout.row()
557         row.prop(act_track, "use_custom_color")
558         if act_track.use_custom_color:
559             row.prop(act_track, "color", text="")
560
561         if act_track.has_bundle:
562             label_text = "Average Error: %.4f" % (act_track.average_error)
563             layout.label(text=label_text)
564
565
566 class CLIP_PT_track_settings(CLIP_PT_tracking_panel, Panel):
567     bl_space_type = 'CLIP_EDITOR'
568     bl_region_type = 'UI'
569     bl_label = "Tracking Settings"
570     bl_options = {'DEFAULT_CLOSED'}
571
572     def draw(self, context):
573         layout = self.layout
574
575         clip = context.space_data.clip
576         settings = clip.tracking.settings
577
578         col = layout.column()
579
580         active = clip.tracking.tracks.active
581         if active:
582             col.prop(active, "motion_model")
583             col.prop(active, "use_brute")
584             col.prop(active, "use_normalization")
585             col.prop(active, "use_mask")
586             col.prop(active, "correlation_min")
587
588             col.separator()
589             col.prop(active, "frames_limit")
590             col.prop(active, "margin")
591             col.prop(active, "pattern_match", text="Match")
592
593         col.prop(settings, "speed")
594
595
596 class CLIP_PT_tracking_camera(Panel):
597     bl_space_type = 'CLIP_EDITOR'
598     bl_region_type = 'UI'
599     bl_label = "Camera Data"
600     bl_options = {'DEFAULT_CLOSED'}
601
602     @classmethod
603     def poll(cls, context):
604         if CLIP_PT_clip_view_panel.poll(context):
605             sc = context.space_data
606
607             return sc.mode in {'TRACKING', 'DISTORTION'} and sc.clip
608
609         return False
610
611     def draw(self, context):
612         layout = self.layout
613
614         sc = context.space_data
615         clip = sc.clip
616
617         row = layout.row(align=True)
618         label = bpy.types.CLIP_MT_camera_presets.bl_label
619         row.menu('CLIP_MT_camera_presets', text=label)
620         row.operator("clip.camera_preset_add", text="", icon='ZOOMIN')
621         props = row.operator("clip.camera_preset_add", text="", icon='ZOOMOUT')
622         props.remove_active = True
623
624         row = layout.row(align=True)
625         sub = row.split(percentage=0.65)
626         if clip.tracking.camera.units == 'MILLIMETERS':
627             sub.prop(clip.tracking.camera, "focal_length")
628         else:
629             sub.prop(clip.tracking.camera, "focal_length_pixels")
630         sub.prop(clip.tracking.camera, "units", text="")
631
632         col = layout.column(align=True)
633         col.label(text="Sensor:")
634         col.prop(clip.tracking.camera, "sensor_width", text="Width")
635         col.prop(clip.tracking.camera, "pixel_aspect")
636
637         col = layout.column()
638         col.label(text="Optical Center:")
639         row = col.row()
640         row.prop(clip.tracking.camera, "principal", text="")
641         col.operator("clip.set_center_principal", text="Center")
642
643         col = layout.column(align=True)
644         col.label(text="Lens Distortion:")
645         col.prop(clip.tracking.camera, "k1")
646         col.prop(clip.tracking.camera, "k2")
647         col.prop(clip.tracking.camera, "k3")
648
649
650 class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
651     bl_space_type = 'CLIP_EDITOR'
652     bl_region_type = 'UI'
653     bl_label = "Display"
654
655     def draw(self, context):
656         layout = self.layout
657         sc = context.space_data
658
659         row = layout.row(align=True)
660         sub = row.row()
661         sub.prop(sc, "show_red_channel", text="R", toggle=True)
662         sub.prop(sc, "show_green_channel", text="G", toggle=True)
663         sub.prop(sc, "show_blue_channel", text="B", toggle=True)
664
665         row.separator()
666
667         sub = row.row()
668         sub.prop(sc, "use_grayscale_preview", text="B/W", toggle=True)
669
670         col = layout.column(align=True)
671
672         col.prop(sc, "show_disabled", "Disabled Tracks")
673         col.prop(sc, "show_names", text="Names and Status")
674         col.prop(sc, "show_bundles", text="3D Markers")
675
676         col.prop(sc, "use_mute_footage", text="Mute Footage")
677         col.prop(sc, "lock_selection")
678
679         if sc.view == 'GRAPH':
680             col.prop(sc, "lock_time_cursor")
681
682         if sc.mode == 'DISTORTION':
683             col.prop(sc, "show_grid", text="Grid")
684             col.prop(sc, "use_manual_calibration")
685         elif sc.mode == 'RECONSTRUCTION':
686             col.prop(sc, "show_stable", text="Stable")
687
688         clip = sc.clip
689         if clip:
690             col.label(text="Display Aspect Ratio:")
691             row = col.row()
692             row.prop(clip, "display_aspect", text="")
693
694
695 class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel):
696     bl_space_type = 'CLIP_EDITOR'
697     bl_region_type = 'UI'
698     bl_label = "Marker Display"
699
700     @classmethod
701     def poll(cls, context):
702         sc = context.space_data
703
704         return sc.mode != 'MASK'
705
706     def draw(self, context):
707         layout = self.layout
708         sc = context.space_data
709
710         col = layout.column(align=True)
711
712         row = col.row()
713         row.prop(sc, "show_marker_pattern", text="Pattern")
714         row.prop(sc, "show_marker_search", text="Search")
715
716         col.prop(sc, "show_tiny_markers", text="Thin Markers")
717         col.prop(sc, "show_track_path", text="Path")
718
719         row = col.row()
720         row.active = sc.show_track_path
721         row.prop(sc, "path_length", text="Length")
722
723
724 class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel):
725     bl_space_type = 'CLIP_EDITOR'
726     bl_region_type = 'UI'
727     bl_label = "2D Stabilization"
728     bl_options = {'DEFAULT_CLOSED'}
729
730     def draw_header(self, context):
731         stab = context.space_data.clip.tracking.stabilization
732
733         self.layout.prop(stab, "use_2d_stabilization", text="")
734
735     def draw(self, context):
736         layout = self.layout
737
738         tracking = context.space_data.clip.tracking
739         stab = tracking.stabilization
740
741         layout.active = stab.use_2d_stabilization
742
743         row = layout.row()
744         row.template_list("UI_UL_list", "", stab, "tracks",
745                           stab, "active_track_index", rows=3)
746
747         sub = row.column(align=True)
748
749         sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="")
750         sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="")
751
752         sub.menu('CLIP_MT_stabilize_2d_specials', text="",
753                  icon='DOWNARROW_HLT')
754
755         layout.prop(stab, "influence_location")
756
757         layout.prop(stab, "use_autoscale")
758         col = layout.column()
759         col.active = stab.use_autoscale
760         col.prop(stab, "scale_max")
761         col.prop(stab, "influence_scale")
762
763         layout.prop(stab, "use_stabilize_rotation")
764         col = layout.column()
765         col.active = stab.use_stabilize_rotation
766
767         row = col.row(align=True)
768         row.prop_search(stab, "rotation_track", tracking, "tracks", text="")
769         row.operator("clip.stabilize_2d_set_rotation", text="", icon='ZOOMIN')
770
771         row = col.row()
772         row.active = stab.rotation_track is not None
773         row.prop(stab, "influence_rotation")
774
775         layout.prop(stab, "filter_type")
776
777
778 class CLIP_PT_marker(CLIP_PT_tracking_panel, Panel):
779     bl_space_type = 'CLIP_EDITOR'
780     bl_region_type = 'UI'
781     bl_label = "Marker"
782     bl_options = {'DEFAULT_CLOSED'}
783
784     def draw(self, context):
785         layout = self.layout
786         sc = context.space_data
787         clip = context.space_data.clip
788         act_track = clip.tracking.tracks.active
789
790         if act_track:
791             layout.template_marker(sc, "clip", sc.clip_user, act_track, False)
792         else:
793             layout.active = False
794             layout.label(text="No active track")
795
796
797 class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel):
798     bl_space_type = 'CLIP_EDITOR'
799     bl_region_type = 'UI'
800     bl_label = "Proxy / Timecode"
801     bl_options = {'DEFAULT_CLOSED'}
802
803     def draw_header(self, context):
804         sc = context.space_data
805
806         self.layout.prop(sc.clip, "use_proxy", text="")
807
808     def draw(self, context):
809         layout = self.layout
810
811         sc = context.space_data
812         clip = sc.clip
813
814         col = layout.column()
815         col.active = clip.use_proxy
816
817         col.label(text="Build Original:")
818
819         row = col.row(align=True)
820         row.prop(clip.proxy, "build_25", toggle=True)
821         row.prop(clip.proxy, "build_50", toggle=True)
822         row.prop(clip.proxy, "build_75", toggle=True)
823         row.prop(clip.proxy, "build_100", toggle=True)
824
825         col.label(text="Build Undistorted:")
826
827         row = col.row(align=True)
828         row.prop(clip.proxy, "build_undistorted_25", toggle=True)
829         row.prop(clip.proxy, "build_undistorted_50", toggle=True)
830         row.prop(clip.proxy, "build_undistorted_75", toggle=True)
831         row.prop(clip.proxy, "build_undistorted_100", toggle=True)
832
833         col.prop(clip.proxy, "quality")
834
835         col.prop(clip, "use_proxy_custom_directory")
836         if clip.use_proxy_custom_directory:
837             col.prop(clip.proxy, "directory")
838
839         col.operator("clip.rebuild_proxy", text="Build Proxy")
840
841         if clip.source == 'MOVIE':
842             col2 = col.column()
843
844             col2.label(text="Use timecode index:")
845             col2.prop(clip.proxy, "timecode", text="")
846
847         col2 = col.column()
848         col2.label(text="Proxy render size:")
849
850         col.prop(sc.clip_user, "proxy_render_size", text="")
851
852         col = layout.column()
853         col.prop(sc.clip_user, "use_render_undistorted")
854
855
856 class CLIP_PT_footage(CLIP_PT_clip_view_panel, Panel):
857     bl_space_type = 'CLIP_EDITOR'
858     bl_region_type = 'UI'
859     bl_label = "Footage Settings"
860     bl_options = {'DEFAULT_CLOSED'}
861
862     def draw(self, context):
863         layout = self.layout
864
865         sc = context.space_data
866         clip = sc.clip
867
868         col = layout.column()
869         col.template_movieclip(sc, "clip", compact=True)
870         col.prop(clip, "frame_start")
871         col.prop(clip, "frame_offset")
872
873
874 class CLIP_PT_tools_clip(CLIP_PT_clip_view_panel, Panel):
875     bl_space_type = 'CLIP_EDITOR'
876     bl_region_type = 'TOOLS'
877     bl_label = "Clip"
878
879     def draw(self, context):
880         layout = self.layout
881
882         layout.operator("clip.set_viewport_background")
883         layout.operator("clip.setup_tracking_scene")
884
885
886 class CLIP_MT_view(Menu):
887     bl_label = "View"
888
889     def draw(self, context):
890         layout = self.layout
891
892         sc = context.space_data
893
894         if sc.view == 'CLIP':
895             layout.operator("clip.properties", icon='MENU_PANEL')
896             layout.operator("clip.tools", icon='MENU_PANEL')
897             layout.separator()
898
899             layout.operator("clip.view_selected")
900             layout.operator("clip.view_all")
901
902             layout.separator()
903             layout.operator("clip.view_zoom_in")
904             layout.operator("clip.view_zoom_out")
905
906             layout.separator()
907
908             ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
909
910             for a, b in ratios:
911                 text = "Zoom %d:%d" % (a, b)
912                 layout.operator("clip.view_zoom_ratio",
913                                 text=text).ratio = a / b
914         else:
915             if sc.view == 'GRAPH':
916                 layout.operator_context = 'INVOKE_REGION_PREVIEW'
917                 layout.operator("clip.graph_center_current_frame")
918                 layout.operator("clip.graph_view_all")
919                 layout.operator_context = 'INVOKE_DEFAULT'
920
921             layout.prop(sc, "show_seconds")
922             layout.separator()
923
924         layout.separator()
925         layout.operator("screen.area_dupli")
926         layout.operator("screen.screen_full_area")
927
928
929 class CLIP_MT_clip(Menu):
930     bl_label = "Clip"
931
932     def draw(self, context):
933         layout = self.layout
934
935         sc = context.space_data
936         clip = sc.clip
937
938         layout.operator("clip.open")
939
940         if clip:
941             layout.operator("clip.reload")
942             layout.menu("CLIP_MT_proxy")
943
944
945 class CLIP_MT_proxy(Menu):
946     bl_label = "Proxy"
947
948     def draw(self, context):
949         layout = self.layout
950
951         layout.operator("clip.rebuild_proxy")
952         layout.operator("clip.delete_proxy")
953
954
955 class CLIP_MT_track(Menu):
956     bl_label = "Track"
957
958     def draw(self, context):
959         layout = self.layout
960
961         layout.operator("clip.clear_solution")
962         layout.operator("clip.solve_camera")
963
964         layout.separator()
965         props = layout.operator("clip.clear_track_path", text="Clear After")
966         props.action = 'REMAINED'
967
968         props = layout.operator("clip.clear_track_path", text="Clear Before")
969         props.action = 'UPTO'
970
971         props = layout.operator("clip.clear_track_path",
972                                 text="Clear Track Path")
973         props.action = 'ALL'
974
975         layout.separator()
976         layout.operator("clip.join_tracks")
977
978         layout.separator()
979         layout.operator("clip.clean_tracks")
980
981         layout.separator()
982         layout.operator("clip.copy_tracks")
983         layout.operator("clip.paste_tracks")
984
985         layout.separator()
986         props = layout.operator("clip.track_markers",
987                                 text="Track Frame Backwards")
988         props.backwards = True
989
990         props = layout.operator("clip.track_markers", text="Track Backwards")
991         props.backwards = True
992         props.sequence = True
993
994         props = layout.operator("clip.track_markers", text="Track Forwards")
995         props.sequence = True
996         layout.operator("clip.track_markers", text="Track Frame Forwards")
997
998         layout.separator()
999         layout.operator("clip.delete_track")
1000         layout.operator("clip.delete_marker")
1001
1002         layout.separator()
1003         layout.operator("clip.add_marker_move")
1004
1005         layout.separator()
1006         layout.menu("CLIP_MT_track_visibility")
1007         layout.menu("CLIP_MT_track_transform")
1008
1009
1010 class CLIP_MT_reconstruction(Menu):
1011     bl_label = "Reconstruction"
1012
1013     def draw(self, context):
1014         layout = self.layout
1015
1016         layout.operator("clip.set_origin")
1017         props = layout.operator("clip.set_plane", text="Set Floor")
1018         props.plane = 'FLOOR'
1019         props = layout.operator("clip.set_plane", text="Set Wall")
1020         props.plane = 'WALL'
1021
1022         layout.operator("clip.set_axis", text="Set X Axis").axis = "X"
1023         layout.operator("clip.set_axis", text="Set Y Axis").axis = "Y"
1024
1025         layout.operator("clip.set_scale")
1026
1027         layout.separator()
1028
1029         layout.operator("clip.track_to_empty")
1030         layout.operator("clip.bundles_to_mesh")
1031
1032
1033 class CLIP_MT_track_visibility(Menu):
1034     bl_label = "Show/Hide"
1035
1036     def draw(self, context):
1037         layout = self.layout
1038
1039         layout.operator("clip.hide_tracks_clear", text="Show Hidden")
1040         layout.operator("clip.hide_tracks", text="Hide Selected")
1041
1042         props = layout.operator("clip.hide_tracks", text="Hide Unselected")
1043         props.unselected = True
1044
1045
1046 class CLIP_MT_track_transform(Menu):
1047     bl_label = "Transform"
1048
1049     def draw(self, context):
1050         layout = self.layout
1051
1052         layout.operator("transform.translate")
1053         layout.operator("transform.resize")
1054
1055
1056 class CLIP_MT_select(Menu):
1057     bl_label = "Select"
1058
1059     def draw(self, context):
1060         layout = self.layout
1061
1062         layout.operator("clip.select_border")
1063         layout.operator("clip.select_circle")
1064
1065         layout.separator()
1066
1067         layout.operator("clip.select_all"
1068                         ).action = 'TOGGLE'
1069         layout.operator("clip.select_all",
1070                         text="Inverse").action = 'INVERT'
1071
1072         layout.menu("CLIP_MT_select_grouped")
1073
1074
1075 class CLIP_MT_select_grouped(Menu):
1076     bl_label = "Select Grouped"
1077
1078     def draw(self, context):
1079         layout = self.layout
1080
1081         layout.operator_enum("clip.select_grouped", "group")
1082
1083
1084 class CLIP_MT_tracking_specials(Menu):
1085     bl_label = "Specials"
1086
1087     @classmethod
1088     def poll(cls, context):
1089         return context.space_data.clip
1090
1091     def draw(self, context):
1092         layout = self.layout
1093
1094         props = layout.operator("clip.disable_markers",
1095                                 text="Enable Markers")
1096         props.action = 'ENABLE'
1097
1098         props = layout.operator("clip.disable_markers", text="Disable markers")
1099         props.action = 'DISABLE'
1100
1101         layout.separator()
1102         layout.operator("clip.set_origin")
1103
1104         layout.separator()
1105         layout.operator("clip.hide_tracks")
1106         layout.operator("clip.hide_tracks_clear", text="Show Tracks")
1107
1108         layout.separator()
1109         props = layout.operator("clip.lock_tracks", text="Lock Tracks")
1110         props.action = 'LOCK'
1111
1112         props = layout.operator("clip.lock_tracks", text="Unlock Tracks")
1113         props.action = 'UNLOCK'
1114
1115
1116 class CLIP_MT_select_mode(Menu):
1117     bl_label = "Select Mode"
1118
1119     def draw(self, context):
1120         layout = self.layout
1121
1122         layout.operator_context = 'INVOKE_REGION_WIN'
1123
1124         layout.operator_enum("clip.mode_set", "mode")
1125
1126
1127 class CLIP_MT_camera_presets(Menu):
1128     """Predefined tracking camera intrinsics"""
1129     bl_label = "Camera Presets"
1130     preset_subdir = "tracking_camera"
1131     preset_operator = "script.execute_preset"
1132     draw = Menu.draw_preset
1133
1134
1135 class CLIP_MT_track_color_presets(Menu):
1136     """Predefined track color"""
1137     bl_label = "Color Presets"
1138     preset_subdir = "tracking_track_color"
1139     preset_operator = "script.execute_preset"
1140     draw = Menu.draw_preset
1141
1142
1143 class CLIP_MT_tracking_settings_presets(Menu):
1144     """Predefined tracking settings"""
1145     bl_label = "Tracking Presets"
1146     preset_subdir = "tracking_settings"
1147     preset_operator = "script.execute_preset"
1148     draw = Menu.draw_preset
1149
1150
1151 class CLIP_MT_track_color_specials(Menu):
1152     bl_label = "Track Color Specials"
1153
1154     def draw(self, context):
1155         layout = self.layout
1156
1157         layout.operator("clip.track_copy_color", icon='COPY_ID')
1158
1159
1160 class CLIP_MT_stabilize_2d_specials(Menu):
1161     bl_label = "Track Color Specials"
1162
1163     def draw(self, context):
1164         layout = self.layout
1165
1166         layout.operator("clip.stabilize_2d_select")
1167
1168
1169 # -----------------------------------------------------------------------------
1170 # Mask (similar code in space_image.py, keep in sync)
1171
1172
1173 from bl_ui.properties_mask_common import (MASK_PT_mask,
1174                                           MASK_PT_layers,
1175                                           MASK_PT_spline,
1176                                           MASK_PT_point,
1177                                           MASK_PT_display,
1178                                           MASK_PT_tools)
1179
1180
1181 class CLIP_PT_mask(MASK_PT_mask, Panel):
1182     bl_space_type = 'CLIP_EDITOR'
1183     bl_region_type = 'UI'
1184
1185
1186 class CLIP_PT_mask_layers(MASK_PT_layers, Panel):
1187     bl_space_type = 'CLIP_EDITOR'
1188     bl_region_type = 'UI'
1189
1190
1191 class CLIP_PT_mask_display(MASK_PT_display, Panel):
1192     bl_space_type = 'CLIP_EDITOR'
1193     bl_region_type = 'UI'
1194
1195
1196 class CLIP_PT_active_mask_spline(MASK_PT_spline, Panel):
1197     bl_space_type = 'CLIP_EDITOR'
1198     bl_region_type = 'UI'
1199
1200
1201 class CLIP_PT_active_mask_point(MASK_PT_point, Panel):
1202     bl_space_type = 'CLIP_EDITOR'
1203     bl_region_type = 'UI'
1204
1205
1206 class CLIP_PT_tools_mask(MASK_PT_tools, Panel):
1207     bl_space_type = 'CLIP_EDITOR'
1208     bl_region_type = 'TOOLS'
1209
1210 # --- end mask ---
1211
1212 if __name__ == "__main__":  # only for live edit.
1213     bpy.utils.register_module(__name__)