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