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