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