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