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