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