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