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