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
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         col.prop(sc, "use_texture_buffer")
610
611         clip = sc.clip
612         if clip:
613             col.label(text="Display Aspect Ratio:")
614             row = col.row()
615             row.prop(clip, "display_aspect", text="")
616
617
618 class CLIP_PT_marker_display(Panel):
619     bl_space_type = 'CLIP_EDITOR'
620     bl_region_type = 'UI'
621     bl_label = "Marker Display"
622
623     def draw(self, context):
624         layout = self.layout
625         sc = context.space_data
626
627         col = layout.column(align=True)
628
629         row = col.row()
630         row.prop(sc, "show_marker_pattern", text="Pattern")
631         row.prop(sc, "show_marker_search", text="Search")
632
633         col.prop(sc, "show_tiny_markers", text="Thin Markers")
634         col.prop(sc, "show_track_path", text="Path")
635
636         row = col.row()
637         row.active = sc.show_track_path
638         row.prop(sc, "path_length", text="Length")
639
640
641 class CLIP_PT_stabilization(Panel):
642     bl_space_type = 'CLIP_EDITOR'
643     bl_region_type = 'UI'
644     bl_label = "2D Stabilization"
645     bl_options = {'DEFAULT_CLOSED'}
646
647     @classmethod
648     def poll(cls, context):
649         sc = context.space_data
650
651         return sc.mode == 'RECONSTRUCTION' and sc.clip
652
653     def draw_header(self, context):
654         stab = context.space_data.clip.tracking.stabilization
655
656         self.layout.prop(stab, "use_2d_stabilization", text="")
657
658     def draw(self, context):
659         layout = self.layout
660
661         tracking = context.space_data.clip.tracking
662         stab = tracking.stabilization
663
664         layout.active = stab.use_2d_stabilization
665
666         row = layout.row()
667         row.template_list(stab, "tracks", stab, "active_track_index", rows=3)
668
669         sub = row.column(align=True)
670
671         sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="")
672         sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="")
673
674         sub.menu('CLIP_MT_stabilize_2d_specials', text="",
675                  icon='DOWNARROW_HLT')
676
677         layout.prop(stab, "influence_location")
678
679         layout.prop(stab, "use_autoscale")
680         col = layout.column()
681         col.active = stab.use_autoscale
682         col.prop(stab, "scale_max")
683         col.prop(stab, "influence_scale")
684
685         layout.prop(stab, "use_stabilize_rotation")
686         col = layout.column()
687         col.active = stab.use_stabilize_rotation
688
689         row = col.row(align=True)
690         row.prop_search(stab, "rotation_track", tracking, "tracks", text="")
691         row.operator("clip.stabilize_2d_set_rotation", text="", icon='ZOOMIN')
692
693         row = col.row()
694         row.active = stab.rotation_track is not None
695         row.prop(stab, "influence_rotation")
696
697         layout.prop(stab, "filter_type")
698
699
700 class CLIP_PT_marker(Panel):
701     bl_space_type = 'CLIP_EDITOR'
702     bl_region_type = 'UI'
703     bl_label = "Marker"
704     bl_options = {'DEFAULT_CLOSED'}
705
706     @classmethod
707     def poll(cls, context):
708         sc = context.space_data
709         clip = sc.clip
710
711         return sc.mode == 'TRACKING' and clip
712
713     def draw(self, context):
714         layout = self.layout
715         sc = context.space_data
716         clip = context.space_data.clip
717         act_track = clip.tracking.tracks.active
718
719         if act_track:
720             layout.template_marker(sc, "clip", sc.clip_user, act_track, False)
721         else:
722             layout.active = False
723             layout.label(text="No active track")
724
725
726 class CLIP_PT_proxy(Panel):
727     bl_space_type = 'CLIP_EDITOR'
728     bl_region_type = 'UI'
729     bl_label = "Proxy / Timecode"
730     bl_options = {'DEFAULT_CLOSED'}
731
732     @classmethod
733     def poll(cls, context):
734         sc = context.space_data
735
736         return sc.clip
737
738     def draw_header(self, context):
739         sc = context.space_data
740
741         self.layout.prop(sc.clip, "use_proxy", text="")
742
743     def draw(self, context):
744         layout = self.layout
745         sc = context.space_data
746         clip = sc.clip
747
748         layout.active = clip.use_proxy
749
750         layout.label(text="Build Original:")
751
752         row = layout.row(align=True)
753         row.prop(clip.proxy, "build_25", toggle=True)
754         row.prop(clip.proxy, "build_50", toggle=True)
755         row.prop(clip.proxy, "build_75", toggle=True)
756         row.prop(clip.proxy, "build_100", toggle=True)
757
758         layout.label(text="Build Undistorted:")
759
760         row = layout.row(align=True)
761         row.prop(clip.proxy, "build_undistorted_25", toggle=True)
762         row.prop(clip.proxy, "build_undistorted_50", toggle=True)
763         row.prop(clip.proxy, "build_undistorted_75", toggle=True)
764         row.prop(clip.proxy, "build_undistorted_100", toggle=True)
765
766         layout.prop(clip.proxy, "quality")
767
768         layout.prop(clip, 'use_proxy_custom_directory')
769         if clip.use_proxy_custom_directory:
770             layout.prop(clip.proxy, "directory")
771
772         layout.operator("clip.rebuild_proxy", text="Build Proxy")
773
774         if clip.source == 'MOVIE':
775             col = layout.column()
776
777             col.label(text="Use timecode index:")
778             col.prop(clip.proxy, "timecode", text="")
779
780         col = layout.column()
781         col.label(text="Proxy render size:")
782
783         col.prop(sc.clip_user, "proxy_render_size", text="")
784         col.prop(sc.clip_user, "use_render_undistorted")
785
786
787 class CLIP_PT_footage(Panel):
788     bl_space_type = 'CLIP_EDITOR'
789     bl_region_type = 'UI'
790     bl_label = "Footage Settings"
791     bl_options = {'DEFAULT_CLOSED'}
792
793     @classmethod
794     def poll(cls, context):
795         sc = context.space_data
796
797         return sc.clip
798
799     def draw(self, context):
800         layout = self.layout
801
802         sc = context.space_data
803         clip = sc.clip
804
805         if clip:
806             layout.template_movieclip(sc, "clip", compact=True)
807         else:
808             layout.operator("clip.open", icon='FILESEL')
809
810
811 class CLIP_PT_tools_clip(Panel):
812     bl_space_type = 'CLIP_EDITOR'
813     bl_region_type = 'TOOLS'
814     bl_label = "Clip"
815
816     @classmethod
817     def poll(cls, context):
818         sc = context.space_data
819
820         return sc.clip
821
822     def draw(self, context):
823         layout = self.layout
824
825         layout.operator("clip.set_viewport_background")
826         layout.operator("clip.setup_tracking_scene")
827
828
829 class CLIP_MT_view(Menu):
830     bl_label = "View"
831
832     def draw(self, context):
833         layout = self.layout
834
835         layout.operator("clip.properties", icon='MENU_PANEL')
836         layout.operator("clip.tools", icon='MENU_PANEL')
837         layout.separator()
838
839         layout.operator("clip.view_selected")
840         layout.operator("clip.view_all")
841
842         layout.separator()
843         layout.operator("clip.view_zoom_in")
844         layout.operator("clip.view_zoom_out")
845
846         layout.separator()
847
848         ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
849
850         for a, b in ratios:
851             text = "Zoom %d:%d" % (a, b)
852             layout.operator("clip.view_zoom_ratio", text=text).ratio = a / b
853
854         layout.separator()
855         layout.operator("screen.area_dupli")
856         layout.operator("screen.screen_full_area")
857
858
859 class CLIP_MT_clip(Menu):
860     bl_label = "Clip"
861
862     def draw(self, context):
863         layout = self.layout
864
865         sc = context.space_data
866         clip = sc.clip
867
868         layout.operator("clip.open")
869
870         if clip:
871             layout.operator("clip.reload")
872             layout.menu("CLIP_MT_proxy")
873
874
875 class CLIP_MT_proxy(Menu):
876     bl_label = "Proxy"
877
878     def draw(self, context):
879         layout = self.layout
880
881         layout.operator("clip.rebuild_proxy")
882         layout.operator("clip.delete_proxy")
883
884
885 class CLIP_MT_track(Menu):
886     bl_label = "Track"
887
888     def draw(self, context):
889         layout = self.layout
890
891         layout.operator("clip.clear_solution")
892         layout.operator("clip.solve_camera")
893
894         layout.separator()
895         props = layout.operator("clip.clear_track_path", text="Clear After")
896         props.action = 'REMAINED'
897
898         props = layout.operator("clip.clear_track_path", text="Clear Before")
899         props.action = 'UPTO'
900
901         props = layout.operator("clip.clear_track_path",
902             text="Clear Track Path")
903         props.action = 'ALL'
904
905         layout.separator()
906         layout.operator("clip.join_tracks")
907
908         layout.separator()
909         layout.operator("clip.clean_tracks")
910
911         layout.separator()
912         layout.operator("clip.copy_tracks")
913         layout.operator("clip.paste_tracks")
914
915         layout.separator()
916         props = layout.operator("clip.track_markers",
917             text="Track Frame Backwards")
918         props.backwards = True
919
920         props = layout.operator("clip.track_markers", text="Track Backwards")
921         props.backwards = True
922         props.sequence = True
923
924         props = layout.operator("clip.track_markers", text="Track Forwards")
925         props.sequence = True
926         layout.operator("clip.track_markers", text="Track Frame Forwards")
927
928         layout.separator()
929         layout.operator("clip.delete_track")
930         layout.operator("clip.delete_marker")
931
932         layout.separator()
933         layout.operator("clip.add_marker_move")
934
935         layout.separator()
936         layout.menu("CLIP_MT_track_visibility")
937         layout.menu("CLIP_MT_track_transform")
938
939
940 class CLIP_MT_reconstruction(Menu):
941     bl_label = "Reconstruction"
942
943     def draw(self, context):
944         layout = self.layout
945
946         layout.operator("clip.set_origin")
947         props = layout.operator("clip.set_plane", text="Set Floor")
948         props.plane = 'FLOOR'
949         props = layout.operator("clip.set_plane", text="Set Wall")
950         props.plane = 'WALL'
951
952         layout.operator("clip.set_axis", text="Set X Axis").axis = "X"
953         layout.operator("clip.set_axis", text="Set Y Axis").axis = "Y"
954
955         layout.operator("clip.set_scale")
956
957         layout.separator()
958
959         layout.operator("clip.track_to_empty")
960         layout.operator("clip.bundles_to_mesh")
961
962
963 class CLIP_MT_track_visibility(Menu):
964     bl_label = "Show/Hide"
965
966     def draw(self, context):
967         layout = self.layout
968
969         layout.operator("clip.hide_tracks_clear", text="Show Hidden")
970         layout.operator("clip.hide_tracks", text="Hide Selected")
971
972         props = layout.operator("clip.hide_tracks", text="Hide Unselected")
973         props.unselected = True
974
975
976 class CLIP_MT_track_transform(Menu):
977     bl_label = "Transform"
978
979     def draw(self, context):
980         layout = self.layout
981
982         layout.operator("transform.translate")
983         layout.operator("transform.resize")
984
985
986 class CLIP_MT_select(Menu):
987     bl_label = "Select"
988
989     def draw(self, context):
990         layout = self.layout
991
992         layout.operator("clip.select_border")
993         layout.operator("clip.select_circle")
994
995         layout.separator()
996
997         layout.operator("clip.select_all").action = 'TOGGLE'
998         layout.operator("clip.select_all", text="Inverse").action = 'INVERT'
999
1000         layout.menu("CLIP_MT_select_grouped")
1001
1002
1003 class CLIP_MT_select_grouped(Menu):
1004     bl_label = "Select Grouped"
1005
1006     def draw(self, context):
1007         layout = self.layout
1008
1009         layout.operator_enum("clip.select_grouped", "group")
1010
1011
1012 class CLIP_MT_tracking_specials(Menu):
1013     bl_label = "Specials"
1014
1015     @classmethod
1016     def poll(cls, context):
1017         return context.space_data.clip
1018
1019     def draw(self, context):
1020         layout = self.layout
1021
1022         props = layout.operator("clip.disable_markers",
1023                                 text="Enable Markers")
1024         props.action = 'ENABLE'
1025
1026         props = layout.operator("clip.disable_markers", text="Disable markers")
1027         props.action = 'DISABLE'
1028
1029         layout.separator()
1030         layout.operator("clip.set_origin")
1031
1032         layout.separator()
1033         layout.operator("clip.hide_tracks")
1034         layout.operator("clip.hide_tracks_clear", text="Show Tracks")
1035
1036         layout.separator()
1037         props = layout.operator("clip.lock_tracks", text="Lock Tracks")
1038         props.action = 'LOCK'
1039
1040         props = layout.operator("clip.lock_tracks", text="Unlock Tracks")
1041         props.action = 'UNLOCK'
1042
1043
1044 class CLIP_MT_camera_presets(Menu):
1045     """Predefined tracking camera intrinsics"""
1046     bl_label = "Camera Presets"
1047     preset_subdir = "tracking_camera"
1048     preset_operator = "script.execute_preset"
1049     draw = Menu.draw_preset
1050
1051
1052 class CLIP_MT_track_color_presets(Menu):
1053     """Predefined track color"""
1054     bl_label = "Color Presets"
1055     preset_subdir = "tracking_track_color"
1056     preset_operator = "script.execute_preset"
1057     draw = Menu.draw_preset
1058
1059
1060 class CLIP_MT_tracking_settings_presets(Menu):
1061     """Predefined tracking settings"""
1062     bl_label = "Tracking Presets"
1063     preset_subdir = "tracking_settings"
1064     preset_operator = "script.execute_preset"
1065     draw = Menu.draw_preset
1066
1067
1068 class CLIP_MT_track_color_specials(Menu):
1069     bl_label = "Track Color Specials"
1070
1071     def draw(self, context):
1072         layout = self.layout
1073
1074         layout.operator('clip.track_copy_color', icon='COPY_ID')
1075
1076
1077 class CLIP_MT_stabilize_2d_specials(Menu):
1078     bl_label = "Track Color Specials"
1079
1080     def draw(self, context):
1081         layout = self.layout
1082
1083         layout.operator('clip.stabilize_2d_select')
1084
1085 if __name__ == "__main__":  # only for live edit.
1086     bpy.utils.register_module(__name__)