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