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