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