Tweaks to plane track
[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, UIList
23 from bpy.app.translations import pgettext_iface as iface_
24
25
26 class CLIP_UL_tracking_objects(UIList):
27     def draw_item(self, context, layout, data, item, icon,
28                   active_data, active_propname, index):
29         # assert(isinstance(item, bpy.types.MovieTrackingObject)
30         tobj = item
31         if self.layout_type in {'DEFAULT', 'COMPACT'}:
32             layout.label(text=tobj.name, translate=False,
33                          icon='CAMERA_DATA' if tobj.is_camera
34                          else 'OBJECT_DATA')
35         elif self.layout_type in {'GRID'}:
36             layout.alignment = 'CENTER'
37             layout.label(text="",
38                          icon='CAMERA_DATA' if tobj.is_camera
39                          else 'OBJECT_DATA')
40
41
42 class CLIP_HT_header(Header):
43     bl_space_type = 'CLIP_EDITOR'
44
45     def _draw_tracking(self, context):
46         layout = self.layout
47
48         sc = context.space_data
49         clip = sc.clip
50
51         row = layout.row(align=True)
52         row.template_header()
53
54         if context.area.show_menus:
55             sub = row.row(align=True)
56             sub.menu("CLIP_MT_view")
57
58             if sc.view == 'CLIP':
59                 if clip:
60                     sub.menu("CLIP_MT_select")
61                     sub.menu("CLIP_MT_clip")
62                     sub.menu("CLIP_MT_track")
63                     sub.menu("CLIP_MT_reconstruction")
64                 else:
65                     sub.menu("CLIP_MT_clip")
66
67         row = layout.row()
68         row.template_ID(sc, "clip", open="clip.open")
69
70         if clip:
71             tracking = clip.tracking
72             active_object = tracking.objects.active
73
74             if sc.view == 'CLIP':
75                 layout.prop(sc, "mode", text="")
76                 layout.prop(sc, "view", text="", expand=True)
77                 layout.prop(sc, "pivot_point", text="", icon_only=True)
78
79                 r = active_object.reconstruction
80
81                 if r.is_valid and sc.view == 'CLIP':
82                     layout.label(text="Solve error: %.4f" %
83                                  (r.average_error))
84             elif sc.view == 'GRAPH':
85                 layout.prop(sc, "view", text="", expand=True)
86
87                 row = layout.row(align=True)
88                 row.prop(sc, "show_graph_only_selected", text="")
89                 row.prop(sc, "show_graph_hidden", text="")
90
91                 row = layout.row(align=True)
92
93                 if sc.show_filters:
94                     row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_DOWN',
95                              text="Filters")
96
97                     sub = row.row(align=True)
98                     sub.active = clip.tracking.reconstruction.is_valid
99                     sub.prop(sc, "show_graph_frames", icon='SEQUENCE', text="")
100
101                     row.prop(sc, "show_graph_tracks", icon='ANIM', text="")
102                 else:
103                     row.prop(sc, "show_filters", icon='DISCLOSURE_TRI_RIGHT',
104                              text="Filters")
105             elif sc.view == 'DOPESHEET':
106                 dopesheet = tracking.dopesheet
107                 layout.prop(sc, "view", text="", expand=True)
108
109                 row = layout.row(align=True)
110                 row.prop(dopesheet, "show_only_selected", text="")
111                 row.prop(dopesheet, "show_hidden", text="")
112
113                 row = layout.row(align=True)
114                 row.prop(dopesheet, "sort_method", text="")
115                 row.prop(dopesheet, "use_invert_sort",
116                          text="Invert", toggle=True)
117         else:
118             layout.prop(sc, "view", text="", expand=True)
119
120     def _draw_masking(self, context):
121         layout = self.layout
122
123         toolsettings = context.tool_settings
124         sc = context.space_data
125         clip = sc.clip
126
127         row = layout.row(align=True)
128         row.template_header()
129
130         if context.area.show_menus:
131             sub = row.row(align=True)
132             sub.menu("CLIP_MT_view")
133
134             if clip:
135                 sub.menu("MASK_MT_select")
136                 sub.menu("CLIP_MT_clip")  # XXX - remove?
137                 sub.menu("MASK_MT_mask")
138             else:
139                 sub.menu("CLIP_MT_clip")  # XXX - remove?
140
141         row = layout.row()
142         row.template_ID(sc, "clip", open="clip.open")
143
144         layout.prop(sc, "mode", text="")
145
146         row = layout.row()
147         row.template_ID(sc, "mask", new="mask.new")
148
149         layout.prop(sc, "pivot_point", text="", icon_only=True)
150
151         row = layout.row(align=True)
152         row.prop(toolsettings, "use_proportional_edit_mask",
153                  text="", icon_only=True)
154         if toolsettings.use_proportional_edit_mask:
155             row.prop(toolsettings, "proportional_edit_falloff",
156                      text="", icon_only=True)
157
158     def draw(self, context):
159         layout = self.layout
160
161         sc = context.space_data
162
163         if sc.mode in {'TRACKING', 'RECONSTRUCTION', 'DISTORTION'}:
164             self._draw_tracking(context)
165         else:
166             self._draw_masking(context)
167
168         layout.template_running_jobs()
169
170
171 class CLIP_PT_clip_view_panel:
172
173     @classmethod
174     def poll(cls, context):
175         sc = context.space_data
176         clip = sc.clip
177
178         return clip and sc.view == 'CLIP'
179
180
181 class CLIP_PT_tracking_panel:
182
183     @classmethod
184     def poll(cls, context):
185         sc = context.space_data
186         clip = sc.clip
187
188         return clip and sc.mode == 'TRACKING' and sc.view == 'CLIP'
189
190
191 class CLIP_PT_reconstruction_panel:
192
193     @classmethod
194     def poll(cls, context):
195         sc = context.space_data
196         clip = sc.clip
197
198         return clip and sc.mode == 'RECONSTRUCTION' and sc.view == 'CLIP'
199
200
201 class CLIP_PT_tools_marker(CLIP_PT_tracking_panel, Panel):
202     bl_space_type = 'CLIP_EDITOR'
203     bl_region_type = 'TOOLS'
204     bl_label = "Marker"
205
206     def draw(self, context):
207         layout = self.layout
208
209         sc = context.space_data
210         clip = sc.clip
211         settings = clip.tracking.settings
212
213         col = layout.column(align=True)
214         col.operator("clip.add_marker_at_click", text="Add Marker")
215         col.operator("clip.detect_features")
216         col.operator("clip.delete_track")
217
218         box = layout.box()
219         row = box.row(align=True)
220         row.prop(settings, "show_default_expanded", text="", emboss=False)
221         row.label(text="Tracking Settings")
222
223         if settings.show_default_expanded:
224             col = box.column()
225             row = col.row(align=True)
226             label = CLIP_MT_tracking_settings_presets.bl_label
227             row.menu('CLIP_MT_tracking_settings_presets', text=label)
228             row.operator("clip.tracking_settings_preset_add",
229                          text="", icon='ZOOMIN')
230             row.operator("clip.tracking_settings_preset_add",
231                          text="", icon='ZOOMOUT').remove_active = True
232
233             col.separator()
234
235             row = col.row(align=True)
236             row.prop(settings, "use_default_red_channel",
237                      text="R", toggle=True)
238             row.prop(settings, "use_default_green_channel",
239                      text="G", toggle=True)
240             row.prop(settings, "use_default_blue_channel",
241                      text="B", toggle=True)
242
243             col.separator()
244
245             sub = col.column(align=True)
246             sub.prop(settings, "default_pattern_size")
247             sub.prop(settings, "default_search_size")
248
249             col.label(text="Tracker:")
250             col.prop(settings, "default_motion_model")
251             col.prop(settings, "use_default_brute")
252             col.prop(settings, "use_default_normalization")
253             col.prop(settings, "use_default_mask")
254             col.prop(settings, "default_correlation_min")
255
256             col.separator()
257
258             sub = col.column(align=True)
259             sub.prop(settings, "default_frames_limit")
260             sub.prop(settings, "default_margin")
261
262             col.label(text="Match:")
263             col.prop(settings, "default_pattern_match", text="")
264
265             col.separator()
266             col.operator("clip.track_settings_as_default",
267                          text="Copy From Active Track")
268
269
270 class CLIP_PT_tools_tracking(CLIP_PT_tracking_panel, Panel):
271     bl_space_type = 'CLIP_EDITOR'
272     bl_region_type = 'TOOLS'
273     bl_label = "Track"
274
275     def draw(self, context):
276         layout = self.layout
277
278         row = layout.row(align=True)
279
280         props = row.operator("clip.track_markers", text="", icon='FRAME_PREV')
281         props.backwards = True
282         props.sequence = False
283         props = row.operator("clip.track_markers", text="",
284                              icon='PLAY_REVERSE')
285         props.backwards = True
286         props.sequence = True
287         props = row.operator("clip.track_markers", text="", icon='PLAY')
288         props.backwards = False
289         props.sequence = True
290         props = row.operator("clip.track_markers", text="", icon='FRAME_NEXT')
291         props.backwards = False
292         props.sequence = False
293
294         col = layout.column()
295         col.label(text="Refine:")
296         row = col.row(align=True)
297         row.operator("clip.refine_markers", text="Backwards").backwards = True
298         row.operator("clip.refine_markers", text="Forwards").backwards = False
299
300         col = layout.column()
301         col.label(text="Clear:")
302         row = col.row(align=True)
303         row.operator("clip.clear_track_path", text="Before").action = 'UPTO'
304         row.operator("clip.clear_track_path", text="After").action = 'REMAINED'
305
306         layout.operator("clip.join_tracks", text="Join")
307
308
309 class CLIP_PT_tools_plane_tracking(CLIP_PT_tracking_panel, Panel):
310     bl_space_type = 'CLIP_EDITOR'
311     bl_region_type = 'TOOLS'
312     bl_label = "Plane Track"
313     bl_options = {'DEFAULT_CLOSED'}
314
315     def draw(self, context):
316         layout = self.layout
317         layout.operator("clip.create_plane_track")
318
319
320 class CLIP_PT_tools_solve(CLIP_PT_tracking_panel, Panel):
321     bl_space_type = 'CLIP_EDITOR'
322     bl_region_type = 'TOOLS'
323     bl_label = "Solve"
324
325     def draw(self, context):
326         layout = self.layout
327
328         clip = context.space_data.clip
329         tracking = clip.tracking
330         settings = tracking.settings
331         tracking_object = tracking.objects.active
332
333         col = layout.column(align=True)
334
335         col.operator("clip.solve_camera",
336                      text="Camera Motion" if tracking_object.is_camera
337                      else "Object Motion")
338         col.operator("clip.clear_solution")
339
340         col = layout.column()
341         col.prop(settings, "use_tripod_solver")
342         col.prop(settings, "use_keyframe_selection")
343
344         col = layout.column(align=True)
345         col.active = (not settings.use_tripod_solver and
346                       not settings.use_keyframe_selection)
347         col.prop(tracking_object, "keyframe_a")
348         col.prop(tracking_object, "keyframe_b")
349
350         col = layout.column(align=True)
351         col.active = tracking_object.is_camera
352         col.label(text="Refine:")
353         col.prop(settings, "refine_intrinsics", text="")
354
355         col = layout.column(align=True)
356         col.active = not settings.use_tripod_solver
357         col.prop(settings, "use_fallback_reconstruction",
358                  text="Allow Fallback")
359         sub = col.column(align=True)
360         sub.active = settings.use_fallback_reconstruction
361         sub.prop(settings, "reconstruction_success_threshold")
362
363
364 class CLIP_PT_tools_cleanup(CLIP_PT_tracking_panel, Panel):
365     bl_space_type = 'CLIP_EDITOR'
366     bl_region_type = 'TOOLS'
367     bl_label = "Clean up"
368
369     def draw(self, context):
370         layout = self.layout
371         clip = context.space_data.clip
372         settings = clip.tracking.settings
373
374         layout.operator("clip.clean_tracks")
375
376         layout.prop(settings, "clean_frames", text="Frames")
377         layout.prop(settings, "clean_error", text="Error")
378         layout.prop(settings, "clean_action", text="")
379
380
381 class CLIP_PT_tools_geometry(CLIP_PT_reconstruction_panel, Panel):
382     bl_space_type = 'CLIP_EDITOR'
383     bl_region_type = 'TOOLS'
384     bl_label = "Geometry"
385
386     def draw(self, context):
387         layout = self.layout
388
389         layout.operator("clip.bundles_to_mesh")
390         layout.operator("clip.track_to_empty")
391
392
393 class CLIP_PT_tools_orientation(CLIP_PT_reconstruction_panel, Panel):
394     bl_space_type = 'CLIP_EDITOR'
395     bl_region_type = 'TOOLS'
396     bl_label = "Orientation"
397
398     def draw(self, context):
399         sc = context.space_data
400         layout = self.layout
401         settings = sc.clip.tracking.settings
402
403         col = layout.column(align=True)
404         row = col.row(align=True)
405         row.operator("clip.set_plane", text="Floor").plane = 'FLOOR'
406         row.operator("clip.set_plane", text="Wall").plane = 'WALL'
407
408         col.operator("clip.set_origin")
409
410         row = col.row(align=True)
411         row.operator("clip.set_axis", text="Set X Axis").axis = 'X'
412         row.operator("clip.set_axis", text="Set Y Axis").axis = 'Y'
413
414         layout.separator()
415
416         col = layout.column()
417         row = col.row(align=True)
418         row.operator("clip.set_scale")
419         row.operator("clip.apply_solution_scale", text="Apply Scale")
420
421         col.prop(settings, "distance")
422
423
424 class CLIP_PT_tools_object(CLIP_PT_reconstruction_panel, Panel):
425     bl_space_type = 'CLIP_EDITOR'
426     bl_region_type = 'TOOLS'
427     bl_label = "Object"
428
429     @classmethod
430     def poll(cls, context):
431         if CLIP_PT_reconstruction_panel.poll(context):
432             sc = context.space_data
433             clip = sc.clip
434
435             tracking_object = clip.tracking.objects.active
436
437             return not tracking_object.is_camera
438
439         return False
440
441     def draw(self, context):
442         layout = self.layout
443
444         sc = context.space_data
445         clip = sc.clip
446         tracking_object = clip.tracking.objects.active
447         settings = sc.clip.tracking.settings
448
449         col = layout.column()
450
451         col.prop(tracking_object, "scale")
452
453         col.separator()
454
455         col.operator("clip.set_solution_scale", text="Set Scale")
456         col.prop(settings, "object_distance")
457
458
459 class CLIP_PT_tools_grease_pencil(Panel):
460     bl_space_type = 'CLIP_EDITOR'
461     bl_region_type = 'TOOLS'
462     bl_label = "Grease Pencil"
463
464     @classmethod
465     def poll(cls, context):
466         sc = context.space_data
467         clip = sc.clip
468
469         if not clip:
470             return False
471
472         if sc.mode == 'DISTORTION':
473             return sc.view == 'CLIP'
474         elif sc.mode == 'MASK':
475             return True
476
477         return False
478
479     def draw(self, context):
480         layout = self.layout
481
482         col = layout.column(align=True)
483
484         row = col.row(align=True)
485         row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
486         row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
487
488         row = col.row(align=True)
489         row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
490         row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
491
492         row = col.row(align=True)
493         row.prop(context.tool_settings, "use_grease_pencil_sessions")
494
495
496 class CLIP_PT_objects(CLIP_PT_clip_view_panel, Panel):
497     bl_space_type = 'CLIP_EDITOR'
498     bl_region_type = 'UI'
499     bl_label = "Objects"
500     bl_options = {'DEFAULT_CLOSED'}
501
502     def draw(self, context):
503         layout = self.layout
504
505         sc = context.space_data
506         tracking = sc.clip.tracking
507
508         row = layout.row()
509         row.template_list("CLIP_UL_tracking_objects", "", tracking, "objects",
510                           tracking, "active_object_index", rows=3)
511
512         sub = row.column(align=True)
513
514         sub.operator("clip.tracking_object_new", icon='ZOOMIN', text="")
515         sub.operator("clip.tracking_object_remove", icon='ZOOMOUT', text="")
516
517         active = tracking.objects.active
518         if active:
519             layout.prop(active, "name")
520
521
522 class CLIP_PT_track(CLIP_PT_tracking_panel, Panel):
523     bl_space_type = 'CLIP_EDITOR'
524     bl_region_type = 'UI'
525     bl_label = "Track"
526
527     def draw(self, context):
528         layout = self.layout
529
530         sc = context.space_data
531         clip = context.space_data.clip
532         act_track = clip.tracking.tracks.active
533
534         if not act_track:
535             layout.active = False
536             layout.label(text="No active track")
537             return
538
539         row = layout.row()
540         row.prop(act_track, "name", text="")
541
542         sub = row.row(align=True)
543
544         sub.template_marker(sc, "clip", sc.clip_user, act_track, True)
545
546         icon = 'LOCKED' if act_track.lock else 'UNLOCKED'
547         sub.prop(act_track, "lock", text="", icon=icon)
548
549         layout.template_track(sc, "scopes")
550
551         row = layout.row(align=True)
552         sub = row.row(align=True)
553         sub.prop(act_track, "use_red_channel", text="R", toggle=True)
554         sub.prop(act_track, "use_green_channel", text="G", toggle=True)
555         sub.prop(act_track, "use_blue_channel", text="B", toggle=True)
556
557         row.separator()
558
559         row.prop(act_track, "use_grayscale_preview", text="B/W", toggle=True)
560
561         row.separator()
562         row.prop(act_track, "use_alpha_preview",
563                  text="", toggle=True, icon='IMAGE_ALPHA')
564
565         layout.separator()
566
567         row = layout.row(align=True)
568         label = bpy.types.CLIP_MT_track_color_presets.bl_label
569         row.menu('CLIP_MT_track_color_presets', text=label)
570         row.menu('CLIP_MT_track_color_specials', text="", icon='DOWNARROW_HLT')
571         row.operator("clip.track_color_preset_add", text="", icon='ZOOMIN')
572         row.operator("clip.track_color_preset_add",
573                      text="", icon='ZOOMOUT').remove_active = True
574
575         row = layout.row()
576         row.prop(act_track, "use_custom_color")
577         if act_track.use_custom_color:
578             row.prop(act_track, "color", text="")
579
580         if act_track.has_bundle:
581             label_text = "Average Error: %.4f" % (act_track.average_error)
582             layout.label(text=label_text)
583
584
585 class CLIP_PT_plane_track(CLIP_PT_tracking_panel, Panel):
586     bl_space_type = 'CLIP_EDITOR'
587     bl_region_type = 'UI'
588     bl_label = "Plane Track"
589     bl_options = {'DEFAULT_CLOSED'}
590
591     def draw(self, context):
592         layout = self.layout
593
594         sc = context.space_data
595         clip = context.space_data.clip
596         active_track = clip.tracking.plane_tracks.active
597
598         if not active_track:
599             layout.active = False
600             layout.label(text="No active plane track")
601             return
602
603         layout.prop(active_track, "name")
604         layout.prop(active_track, "use_auto_keying")
605
606
607 class CLIP_PT_track_settings(CLIP_PT_tracking_panel, Panel):
608     bl_space_type = 'CLIP_EDITOR'
609     bl_region_type = 'UI'
610     bl_label = "Tracking Settings"
611     bl_options = {'DEFAULT_CLOSED'}
612
613     def draw(self, context):
614         layout = self.layout
615
616         clip = context.space_data.clip
617         settings = clip.tracking.settings
618
619         col = layout.column()
620
621         active = clip.tracking.tracks.active
622         if active:
623             col.prop(active, "motion_model")
624             col.prop(active, "use_brute")
625             col.prop(active, "use_normalization")
626             col.prop(active, "use_mask")
627             col.prop(active, "correlation_min")
628
629             col.separator()
630             col.prop(active, "frames_limit")
631             col.prop(active, "margin")
632             col.prop(active, "pattern_match", text="Match")
633
634         col.prop(settings, "speed")
635
636
637 class CLIP_PT_tracking_camera(Panel):
638     bl_space_type = 'CLIP_EDITOR'
639     bl_region_type = 'UI'
640     bl_label = "Camera Data"
641     bl_options = {'DEFAULT_CLOSED'}
642
643     @classmethod
644     def poll(cls, context):
645         if CLIP_PT_clip_view_panel.poll(context):
646             sc = context.space_data
647
648             return sc.mode in {'TRACKING', 'DISTORTION'} and sc.clip
649
650         return False
651
652     def draw(self, context):
653         layout = self.layout
654
655         sc = context.space_data
656         clip = sc.clip
657
658         row = layout.row(align=True)
659         label = bpy.types.CLIP_MT_camera_presets.bl_label
660         row.menu('CLIP_MT_camera_presets', text=label)
661         row.operator("clip.camera_preset_add", text="", icon='ZOOMIN')
662         row.operator("clip.camera_preset_add", text="",
663                      icon='ZOOMOUT').remove_active = True
664
665         row = layout.row(align=True)
666         sub = row.split(percentage=0.65, align=True)
667         if clip.tracking.camera.units == 'MILLIMETERS':
668             sub.prop(clip.tracking.camera, "focal_length")
669         else:
670             sub.prop(clip.tracking.camera, "focal_length_pixels")
671         sub.prop(clip.tracking.camera, "units", text="")
672
673         col = layout.column(align=True)
674         col.label(text="Sensor:")
675         col.prop(clip.tracking.camera, "sensor_width", text="Width")
676         col.prop(clip.tracking.camera, "pixel_aspect")
677
678         col = layout.column()
679         col.label(text="Optical Center:")
680         row = col.row()
681         row.prop(clip.tracking.camera, "principal", text="")
682         col.operator("clip.set_center_principal", text="Center")
683
684         col = layout.column(align=True)
685         col.label(text="Lens Distortion:")
686         col.prop(clip.tracking.camera, "k1")
687         col.prop(clip.tracking.camera, "k2")
688         col.prop(clip.tracking.camera, "k3")
689
690
691 class CLIP_PT_display(CLIP_PT_clip_view_panel, Panel):
692     bl_space_type = 'CLIP_EDITOR'
693     bl_region_type = 'UI'
694     bl_label = "Display"
695
696     def draw(self, context):
697         layout = self.layout
698         sc = context.space_data
699
700         row = layout.row(align=True)
701         sub = row.row(align=True)
702         sub.prop(sc, "show_red_channel", text="R", toggle=True)
703         sub.prop(sc, "show_green_channel", text="G", toggle=True)
704         sub.prop(sc, "show_blue_channel", text="B", toggle=True)
705
706         row.separator()
707
708         row.prop(sc, "use_grayscale_preview", text="B/W", toggle=True)
709
710         col = layout.column(align=True)
711
712         col.prop(sc, "show_disabled", "Disabled Tracks")
713         col.prop(sc, "show_names", text="Names and Status")
714         if sc.mode != 'MASK':
715             col.prop(sc, "show_bundles", text="3D Markers")
716
717         col.prop(sc, "use_mute_footage", text="Mute Footage")
718         col.prop(sc, "lock_selection")
719
720         if sc.view == 'GRAPH':
721             col.prop(sc, "lock_time_cursor")
722
723         if sc.mode == 'DISTORTION':
724             col.prop(sc, "show_grid", text="Grid")
725             col.prop(sc, "use_manual_calibration")
726         elif sc.mode == 'RECONSTRUCTION':
727             col.prop(sc, "show_stable", text="Stable")
728
729         clip = sc.clip
730         if clip:
731             col.label(text="Display Aspect Ratio:")
732             row = col.row()
733             row.prop(clip, "display_aspect", text="")
734
735
736 class CLIP_PT_marker_display(CLIP_PT_clip_view_panel, Panel):
737     bl_space_type = 'CLIP_EDITOR'
738     bl_region_type = 'UI'
739     bl_label = "Marker Display"
740
741     @classmethod
742     def poll(cls, context):
743         sc = context.space_data
744
745         return sc.mode != 'MASK'
746
747     def draw(self, context):
748         layout = self.layout
749         sc = context.space_data
750
751         col = layout.column(align=True)
752
753         row = col.row(align=True)
754         row.prop(sc, "show_marker_pattern", text="Pattern")
755         row.prop(sc, "show_marker_search", text="Search")
756
757         col.prop(sc, "show_tiny_markers", text="Thin Markers")
758         col.prop(sc, "show_track_path", text="Path")
759
760         row = col.row(align=True)
761         row.active = sc.show_track_path
762         row.prop(sc, "path_length", text="Length")
763
764
765 class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel):
766     bl_space_type = 'CLIP_EDITOR'
767     bl_region_type = 'UI'
768     bl_label = "2D Stabilization"
769     bl_options = {'DEFAULT_CLOSED'}
770
771     def draw_header(self, context):
772         stab = context.space_data.clip.tracking.stabilization
773
774         self.layout.prop(stab, "use_2d_stabilization", text="")
775
776     def draw(self, context):
777         layout = self.layout
778
779         tracking = context.space_data.clip.tracking
780         stab = tracking.stabilization
781
782         layout.active = stab.use_2d_stabilization
783
784         row = layout.row()
785         row.template_list("UI_UL_list", "stabilization_tracks", stab, "tracks",
786                           stab, "active_track_index", rows=3)
787
788         sub = row.column(align=True)
789
790         sub.operator("clip.stabilize_2d_add", icon='ZOOMIN', text="")
791         sub.operator("clip.stabilize_2d_remove", icon='ZOOMOUT', text="")
792
793         sub.menu('CLIP_MT_stabilize_2d_specials', text="",
794                  icon='DOWNARROW_HLT')
795
796         layout.prop(stab, "influence_location")
797
798         layout.prop(stab, "use_autoscale")
799         col = layout.column()
800         col.active = stab.use_autoscale
801         col.prop(stab, "scale_max")
802         col.prop(stab, "influence_scale")
803
804         layout.prop(stab, "use_stabilize_rotation")
805         col = layout.column()
806         col.active = stab.use_stabilize_rotation
807
808         row = col.row(align=True)
809         row.prop_search(stab, "rotation_track", tracking, "tracks", text="")
810         row.operator("clip.stabilize_2d_set_rotation", text="", icon='ZOOMIN')
811
812         row = col.row()
813         row.active = stab.rotation_track is not None
814         row.prop(stab, "influence_rotation")
815
816         layout.prop(stab, "filter_type")
817
818
819 class CLIP_PT_marker(CLIP_PT_tracking_panel, Panel):
820     bl_space_type = 'CLIP_EDITOR'
821     bl_region_type = 'UI'
822     bl_label = "Marker"
823     bl_options = {'DEFAULT_CLOSED'}
824
825     def draw(self, context):
826         layout = self.layout
827         sc = context.space_data
828         clip = context.space_data.clip
829         act_track = clip.tracking.tracks.active
830
831         if act_track:
832             layout.template_marker(sc, "clip", sc.clip_user, act_track, False)
833         else:
834             layout.active = False
835             layout.label(text="No active track")
836
837
838 class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel):
839     bl_space_type = 'CLIP_EDITOR'
840     bl_region_type = 'UI'
841     bl_label = "Proxy / Timecode"
842     bl_options = {'DEFAULT_CLOSED'}
843
844     def draw_header(self, context):
845         sc = context.space_data
846
847         self.layout.prop(sc.clip, "use_proxy", text="")
848
849     def draw(self, context):
850         layout = self.layout
851
852         sc = context.space_data
853         clip = sc.clip
854
855         col = layout.column()
856         col.active = clip.use_proxy
857
858         col.label(text="Build Original:")
859
860         row = col.row(align=True)
861         row.prop(clip.proxy, "build_25", toggle=True)
862         row.prop(clip.proxy, "build_50", toggle=True)
863         row.prop(clip.proxy, "build_75", toggle=True)
864         row.prop(clip.proxy, "build_100", toggle=True)
865
866         col.label(text="Build Undistorted:")
867
868         row = col.row(align=True)
869         row.prop(clip.proxy, "build_undistorted_25", toggle=True)
870         row.prop(clip.proxy, "build_undistorted_50", toggle=True)
871         row.prop(clip.proxy, "build_undistorted_75", toggle=True)
872         row.prop(clip.proxy, "build_undistorted_100", toggle=True)
873
874         col.prop(clip.proxy, "quality")
875
876         col.prop(clip, "use_proxy_custom_directory")
877         if clip.use_proxy_custom_directory:
878             col.prop(clip.proxy, "directory")
879
880         col.operator("clip.rebuild_proxy", text="Build Proxy")
881
882         if clip.source == 'MOVIE':
883             col2 = col.column()
884
885             col2.label(text="Use timecode index:")
886             col2.prop(clip.proxy, "timecode", text="")
887
888         col2 = col.column()
889         col2.label(text="Proxy render size:")
890
891         col.prop(sc.clip_user, "proxy_render_size", text="")
892
893         col = layout.column()
894         col.prop(sc.clip_user, "use_render_undistorted")
895
896
897 class CLIP_PT_footage(CLIP_PT_clip_view_panel, Panel):
898     bl_space_type = 'CLIP_EDITOR'
899     bl_region_type = 'UI'
900     bl_label = "Footage Settings"
901     bl_options = {'DEFAULT_CLOSED'}
902
903     def draw(self, context):
904         layout = self.layout
905
906         sc = context.space_data
907         clip = sc.clip
908
909         col = layout.column()
910         col.template_movieclip(sc, "clip", compact=True)
911         col.prop(clip, "frame_start")
912         col.prop(clip, "frame_offset")
913
914
915 class CLIP_PT_footage_info(CLIP_PT_clip_view_panel, Panel):
916     bl_space_type = 'CLIP_EDITOR'
917     bl_region_type = 'UI'
918     bl_label = "Footage Information"
919     bl_options = {'DEFAULT_CLOSED'}
920
921     def draw(self, context):
922         layout = self.layout
923
924         sc = context.space_data
925         clip = sc.clip
926
927         col = layout.column()
928         col.template_movieclip_information(sc, "clip", sc.clip_user)
929
930
931 class CLIP_PT_tools_clip(CLIP_PT_clip_view_panel, Panel):
932     bl_space_type = 'CLIP_EDITOR'
933     bl_region_type = 'TOOLS'
934     bl_label = "Clip"
935     bl_translation_context = bpy.app.translations.contexts.id_movieclip
936
937     def draw(self, context):
938         layout = self.layout
939
940         layout.operator("clip.set_viewport_background")
941         layout.operator("clip.setup_tracking_scene")
942         layout.operator("clip.prefetch")
943         layout.operator("clip.set_scene_frames")
944
945
946 class CLIP_MT_view(Menu):
947     bl_label = "View"
948
949     def draw(self, context):
950         layout = self.layout
951
952         sc = context.space_data
953
954         if sc.view == 'CLIP':
955             layout.operator("clip.properties", icon='MENU_PANEL')
956             layout.operator("clip.tools", icon='MENU_PANEL')
957             layout.separator()
958
959             layout.operator("clip.view_selected")
960             layout.operator("clip.view_all")
961
962             layout.separator()
963             layout.operator("clip.view_zoom_in")
964             layout.operator("clip.view_zoom_out")
965
966             layout.separator()
967
968             ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
969
970             text = iface_("Zoom %d:%d")
971             for a, b in ratios:
972                 layout.operator("clip.view_zoom_ratio",
973                                 text=text % (a, b),
974                                 translate=False).ratio = a / b
975         else:
976             if sc.view == 'GRAPH':
977                 layout.operator_context = 'INVOKE_REGION_PREVIEW'
978                 layout.operator("clip.graph_center_current_frame")
979                 layout.operator("clip.graph_view_all")
980                 layout.operator_context = 'INVOKE_DEFAULT'
981
982             layout.prop(sc, "show_seconds")
983             layout.separator()
984
985         layout.separator()
986         layout.operator("screen.area_dupli")
987         layout.operator("screen.screen_full_area")
988
989
990 class CLIP_MT_clip(Menu):
991     bl_label = "Clip"
992     bl_translation_context = bpy.app.translations.contexts.id_movieclip
993
994     def draw(self, context):
995         layout = self.layout
996
997         sc = context.space_data
998         clip = sc.clip
999
1000         layout.operator("clip.open")
1001
1002         if clip:
1003             layout.operator("clip.prefetch")
1004             layout.operator("clip.reload")
1005             layout.menu("CLIP_MT_proxy")
1006
1007
1008 class CLIP_MT_proxy(Menu):
1009     bl_label = "Proxy"
1010
1011     def draw(self, context):
1012         layout = self.layout
1013
1014         layout.operator("clip.rebuild_proxy")
1015         layout.operator("clip.delete_proxy")
1016
1017
1018 class CLIP_MT_track(Menu):
1019     bl_label = "Track"
1020
1021     def draw(self, context):
1022         layout = self.layout
1023
1024         layout.operator("clip.clear_solution")
1025         layout.operator("clip.solve_camera")
1026
1027         layout.separator()
1028         layout.operator("clip.clear_track_path",
1029                         text="Clear After").action = 'REMAINED'
1030
1031         layout.operator("clip.clear_track_path",
1032                         text="Clear Before").action = 'UPTO'
1033
1034         layout.operator("clip.clear_track_path",
1035                         text="Clear Track Path").action = 'ALL'
1036
1037         layout.separator()
1038         layout.operator("clip.join_tracks")
1039
1040         layout.separator()
1041         layout.operator("clip.clean_tracks")
1042
1043         layout.separator()
1044         layout.operator("clip.copy_tracks")
1045         layout.operator("clip.paste_tracks")
1046
1047         layout.separator()
1048         layout.operator("clip.track_markers",
1049                         text="Track Frame Backwards").backwards = True
1050
1051         props = layout.operator("clip.track_markers", text="Track Backwards")
1052         props.backwards = True
1053         props.sequence = True
1054
1055         layout.operator("clip.track_markers",
1056                         text="Track Forwards").sequence = True
1057         layout.operator("clip.track_markers", text="Track Frame Forwards")
1058
1059         layout.separator()
1060         layout.operator("clip.delete_track")
1061         layout.operator("clip.delete_marker")
1062
1063         layout.separator()
1064         layout.operator("clip.add_marker_move")
1065
1066         layout.separator()
1067         layout.menu("CLIP_MT_track_visibility")
1068         layout.menu("CLIP_MT_track_transform")
1069
1070
1071 class CLIP_MT_reconstruction(Menu):
1072     bl_label = "Reconstruction"
1073
1074     def draw(self, context):
1075         layout = self.layout
1076
1077         layout.operator("clip.set_origin")
1078         layout.operator("clip.set_plane", text="Set Floor").plane = 'FLOOR'
1079         layout.operator("clip.set_plane", text="Set Wall").plane = 'WALL'
1080
1081         layout.operator("clip.set_axis", text="Set X Axis").axis = "X"
1082         layout.operator("clip.set_axis", text="Set Y Axis").axis = "Y"
1083
1084         layout.operator("clip.set_scale")
1085
1086         layout.separator()
1087
1088         layout.operator("clip.track_to_empty")
1089         layout.operator("clip.bundles_to_mesh")
1090
1091
1092 class CLIP_MT_track_visibility(Menu):
1093     bl_label = "Show/Hide"
1094
1095     def draw(self, context):
1096         layout = self.layout
1097
1098         layout.operator("clip.hide_tracks_clear", text="Show Hidden")
1099         layout.operator("clip.hide_tracks", text="Hide Selected")
1100
1101         layout.operator("clip.hide_tracks",
1102                         text="Hide Unselected").unselected = True
1103
1104
1105 class CLIP_MT_track_transform(Menu):
1106     bl_label = "Transform"
1107
1108     def draw(self, context):
1109         layout = self.layout
1110
1111         layout.operator("transform.translate")
1112         layout.operator("transform.resize")
1113
1114
1115 class CLIP_MT_select(Menu):
1116     bl_label = "Select"
1117
1118     def draw(self, context):
1119         layout = self.layout
1120
1121         layout.operator("clip.select_border")
1122         layout.operator("clip.select_circle")
1123
1124         layout.separator()
1125
1126         layout.operator("clip.select_all"
1127                         ).action = 'TOGGLE'
1128         layout.operator("clip.select_all",
1129                         text="Inverse").action = 'INVERT'
1130
1131         layout.menu("CLIP_MT_select_grouped")
1132
1133
1134 class CLIP_MT_select_grouped(Menu):
1135     bl_label = "Select Grouped"
1136
1137     def draw(self, context):
1138         layout = self.layout
1139
1140         layout.operator_enum("clip.select_grouped", "group")
1141
1142
1143 class CLIP_MT_tracking_specials(Menu):
1144     bl_label = "Specials"
1145
1146     @classmethod
1147     def poll(cls, context):
1148         return context.space_data.clip
1149
1150     def draw(self, context):
1151         layout = self.layout
1152
1153         layout.operator("clip.disable_markers",
1154                         text="Enable Markers").action = 'ENABLE'
1155
1156         layout.operator("clip.disable_markers",
1157                         text="Disable markers").action = 'DISABLE'
1158
1159         layout.separator()
1160         layout.operator("clip.set_origin")
1161
1162         layout.separator()
1163         layout.operator("clip.hide_tracks")
1164         layout.operator("clip.hide_tracks_clear", text="Show Tracks")
1165
1166         layout.separator()
1167         layout.operator("clip.lock_tracks", text="Lock Tracks").action = 'LOCK'
1168
1169         layout.operator("clip.lock_tracks",
1170                         text="Unlock Tracks").action = 'UNLOCK'
1171
1172
1173 class CLIP_MT_select_mode(Menu):
1174     bl_label = "Select Mode"
1175
1176     def draw(self, context):
1177         layout = self.layout
1178
1179         layout.operator_context = 'INVOKE_REGION_WIN'
1180
1181         layout.operator_enum("clip.mode_set", "mode")
1182
1183
1184 class CLIP_MT_camera_presets(Menu):
1185     """Predefined tracking camera intrinsics"""
1186     bl_label = "Camera Presets"
1187     preset_subdir = "tracking_camera"
1188     preset_operator = "script.execute_preset"
1189     draw = Menu.draw_preset
1190
1191
1192 class CLIP_MT_track_color_presets(Menu):
1193     """Predefined track color"""
1194     bl_label = "Color Presets"
1195     preset_subdir = "tracking_track_color"
1196     preset_operator = "script.execute_preset"
1197     draw = Menu.draw_preset
1198
1199
1200 class CLIP_MT_tracking_settings_presets(Menu):
1201     """Predefined tracking settings"""
1202     bl_label = "Tracking Presets"
1203     preset_subdir = "tracking_settings"
1204     preset_operator = "script.execute_preset"
1205     draw = Menu.draw_preset
1206
1207
1208 class CLIP_MT_track_color_specials(Menu):
1209     bl_label = "Track Color Specials"
1210
1211     def draw(self, context):
1212         layout = self.layout
1213
1214         layout.operator("clip.track_copy_color", icon='COPY_ID')
1215
1216
1217 class CLIP_MT_stabilize_2d_specials(Menu):
1218     bl_label = "Track Color Specials"
1219
1220     def draw(self, context):
1221         layout = self.layout
1222
1223         layout.operator("clip.stabilize_2d_select")
1224
1225
1226 # -----------------------------------------------------------------------------
1227 # Mask (similar code in space_image.py, keep in sync)
1228
1229
1230 from bl_ui.properties_mask_common import (MASK_PT_mask,
1231                                           MASK_PT_layers,
1232                                           MASK_PT_spline,
1233                                           MASK_PT_point,
1234                                           MASK_PT_display,
1235                                           MASK_PT_tools)
1236
1237
1238 class CLIP_PT_mask(MASK_PT_mask, Panel):
1239     bl_space_type = 'CLIP_EDITOR'
1240     bl_region_type = 'UI'
1241
1242
1243 class CLIP_PT_mask_layers(MASK_PT_layers, Panel):
1244     bl_space_type = 'CLIP_EDITOR'
1245     bl_region_type = 'UI'
1246
1247
1248 class CLIP_PT_mask_display(MASK_PT_display, Panel):
1249     bl_space_type = 'CLIP_EDITOR'
1250     bl_region_type = 'UI'
1251
1252
1253 class CLIP_PT_active_mask_spline(MASK_PT_spline, Panel):
1254     bl_space_type = 'CLIP_EDITOR'
1255     bl_region_type = 'UI'
1256
1257
1258 class CLIP_PT_active_mask_point(MASK_PT_point, Panel):
1259     bl_space_type = 'CLIP_EDITOR'
1260     bl_region_type = 'UI'
1261
1262
1263 class CLIP_PT_tools_mask(MASK_PT_tools, Panel):
1264     bl_space_type = 'CLIP_EDITOR'
1265     bl_region_type = 'TOOLS'
1266
1267 # --- end mask ---
1268
1269 if __name__ == "__main__":  # only for live edit.
1270     bpy.utils.register_module(__name__)