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