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