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