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