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