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
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
|
"""
Author: Jeremy Ernst
"""
# import statements
import json
import os
from functools import partial
import maya.cmds as cmds
import System.interfaceUtils as interfaceUtils
import System.utils as utils
from ThirdParty.Qt import QtGui, QtCore, QtWidgets
# maya 2016< maya2017> compatability
try:
import shiboken as shiboken
except:
import shiboken2 as shiboken
_instances = []
def getMainWindow():
"""
Get Maya's window as a QWidget and return the item in memory.
:return: a QWidget of Maya's window
"""
# get maya's window as QWidget
import maya.OpenMayaUI as mui
pointer = mui.MQtUtil.mainWindow()
# pyside QMainWindow takes in a QWidget rather than QObject
return shiboken.wrapInstance(long(pointer), QtWidgets.QWidget)
class ART_AnimationUI(QtWidgets.QMainWindow):
"""
This class creates the main animation interface that houses the control picker and the buttons for the animation
tools. This is the main interface that animators will interact with.
.. image:: /images/animationUI.png
"""
def __init__(self, parent=None):
"""
Instantiates the class, getting the QSettings, writing the stylesheets, and calling on the method to build
the interface.
"""
_instances.append(self)
super(ART_AnimationUI, self).__init__(parent)
# get the directory path of the tools
settings = QtCore.QSettings("Epic Games", "ARTv2")
self.toolsPath = settings.value("toolsPath")
self.iconsPath = settings.value("iconPath")
self.scriptPath = settings.value("scriptPath")
self.projectPath = settings.value("projectPath")
self.center = QtCore.QPointF(210.000000, 287.500000)
self.scale = 1.0
self.selectionScriptJobs = []
# assign close event
self.closeEvent = self.closeEvent
# write out qss based on user settings
stylesheetDir = utils.returnNicePath(self.scriptPath, "Interfaces/StyleSheets/")
stylesheets = os.listdir(stylesheetDir)
for sheet in stylesheets:
interfaceUtils.writeQSS(os.path.join(stylesheetDir, sheet))
# build the UI
self.buildUI()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def buildUI(self):
"""
Builds the animation UI that houses the area for control pickers and a sidebar for animation tools.
"""
# create the main widget
self.mainWidget = QtWidgets.QWidget()
self.setCentralWidget(self.mainWidget)
# create the mainLayout
self.layout = QtWidgets.QVBoxLayout(self.mainWidget)
# load stylesheet
styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/animPicker.qss")
f = open(styleSheetFile, "r")
self.style = f.read()
f.close()
self.setStyleSheet(self.style)
self.setMinimumSize(QtCore.QSize(550, 400))
self.setMaximumSize(QtCore.QSize(550, 750))
self.resize(550, 750)
# set qt object name
self.setObjectName("pyART_AnimTools_Win")
self.setWindowTitle("Animation Tools")
# =======================================================================
# #create the menu bar
# =======================================================================
self.menuBar = QtWidgets.QMenuBar()
self.menuBar.setMaximumHeight(20)
self.layout.addWidget(self.menuBar)
# =======================================================================
# #create the picker toolbar layout
# =======================================================================
self.toolFrame = QtWidgets.QFrame()
self.toolFrame.setObjectName("dark")
self.toolFrame.setMinimumHeight(50)
self.toolFrame.setMaximumHeight(50)
self.layout.addWidget(self.toolFrame)
self.toolbarLayout = QtWidgets.QHBoxLayout(self.toolFrame)
self.toolbarLayout.setDirection(QtWidgets.QBoxLayout.RightToLeft)
self.toolbarLayout.addStretch(0)
self.toolbarLayout.setSpacing(4)
# =======================================================================
# #picker toolbar buttons
# =======================================================================
self.editPickerBtn = QtWidgets.QPushButton("Edit")
self.editPickerBtn.setMinimumSize(QtCore.QSize(90, 30))
self.editPickerBtn.setMaximumSize(QtCore.QSize(90, 30))
self.toolbarLayout.addWidget(self.editPickerBtn)
self.editPickerBtn.setEnabled(False)
self.editPickerBtn.setObjectName("blueButton")
self.editPickerBtn.clicked.connect(self.editPicker)
self.editPickerBtn.setToolTip("Make module pickers editable (move, scale, rotate)")
self.createPickerBtn = QtWidgets.QPushButton("Create")
self.createPickerBtn.setMinimumSize(QtCore.QSize(90, 30))
self.createPickerBtn.setMaximumSize(QtCore.QSize(90, 30))
self.createPickerBtn.setObjectName("blueButton")
self.createPickerBtn.setToolTip("Create a new picker for the given character.")
self.toolbarLayout.addWidget(self.createPickerBtn)
self.createPickerBtn.clicked.connect(self.createNewPicker)
self.removeModBtn = QtWidgets.QPushButton()
self.removeModBtn.setMinimumSize(QtCore.QSize(30, 30))
self.removeModBtn.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/removeModule.png"))
self.removeModBtn.setIconSize(QtCore.QSize(30, 30))
self.removeModBtn.setIcon(icon)
self.toolbarLayout.addWidget(self.removeModBtn)
self.removeModBtn.setEnabled(False)
self.removeModBtn.setObjectName("toolbar")
self.removeModBtn.clicked.connect(partial(self.removeModuleFromPickerUI))
self.removeModBtn.setToolTip("Remove a module's picker from the canvas.")
self.moveModBtn = QtWidgets.QPushButton()
self.moveModBtn.setMinimumSize(QtCore.QSize(30, 30))
self.moveModBtn.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/movePicker.png"))
self.moveModBtn.setIconSize(QtCore.QSize(30, 30))
self.moveModBtn.setIcon(icon)
self.toolbarLayout.addWidget(self.moveModBtn)
self.moveModBtn.setEnabled(False)
self.moveModBtn.setObjectName("toolbar")
self.moveModBtn.clicked.connect(partial(self.movePickerToTab))
self.moveModBtn.setToolTip("Move a picker from one tab to another.")
self.moduleListBtn = QtWidgets.QPushButton()
self.moduleListBtn.setMinimumSize(QtCore.QSize(30, 30))
self.moduleListBtn.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/moduleList.png"))
self.moduleListBtn.setIconSize(QtCore.QSize(30, 30))
self.moduleListBtn.setIcon(icon)
self.toolbarLayout.addWidget(self.moduleListBtn)
self.moduleListBtn.setEnabled(False)
self.moduleListBtn.setObjectName("toolbar")
self.moduleListBtn.clicked.connect(partial(self.addModuleToPickerUI))
self.moduleListBtn.setToolTip("Add a module's picker to the current canvas.")
# background image button
self.backgroundImgBtn = QtWidgets.QPushButton()
self.backgroundImgBtn.setMinimumSize(QtCore.QSize(30, 30))
self.backgroundImgBtn.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/background.png"))
self.backgroundImgBtn.setIconSize(QtCore.QSize(30, 30))
self.backgroundImgBtn.setIcon(icon)
self.toolbarLayout.addWidget(self.backgroundImgBtn)
self.backgroundImgBtn.setEnabled(False)
self.backgroundImgBtn.setObjectName("toolbar")
self.backgroundImgBtn.setToolTip("Change the background of the current picker tab.")
self.backgroundImgBtn.clicked.connect(partial(self.changeBackground))
self.toolbarLayout.addSpacerItem(QtWidgets.QSpacerItem(10, 0))
buttonGrp = QtWidgets.QButtonGroup(self.toolbarLayout)
buttonGrp.setExclusive(True)
self.normalSelectButton = QtWidgets.QPushButton()
self.normalSelectButton.setMinimumSize(QtCore.QSize(30, 30))
self.normalSelectButton.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/normalSelect_On.png"))
self.normalSelectButton.setIconSize(QtCore.QSize(30, 30))
self.normalSelectButton.setIcon(icon)
self.toolbarLayout.addWidget(self.normalSelectButton)
self.normalSelectButton.setCheckable(True)
self.normalSelectButton.setObjectName("toolbar")
self.normalSelectButton.setChecked(True)
self.normalSelectButton.setToolTip("Change picker selection mode to normal selection")
self.normalSelectButton.clicked.connect(self.toggleDragState)
self.dragSelectButton = QtWidgets.QPushButton()
self.dragSelectButton.setMinimumSize(QtCore.QSize(30, 30))
self.dragSelectButton.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/dragSelect.png"))
self.dragSelectButton.setIconSize(QtCore.QSize(30, 30))
self.dragSelectButton.setIcon(icon)
self.toolbarLayout.addWidget(self.dragSelectButton)
self.dragSelectButton.setCheckable(True)
self.dragSelectButton.setObjectName("toolbar")
self.dragSelectButton.setToolTip("Change picker selection mode to drag selection")
self.dragSelectButton.clicked.connect(self.toggleDragState)
self.commentButton = QtWidgets.QPushButton()
self.commentButton.setMinimumSize(QtCore.QSize(30, 30))
self.commentButton.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/commentMode.png"))
self.commentButton.setIconSize(QtCore.QSize(30, 30))
self.commentButton.setIcon(icon)
self.toolbarLayout.addWidget(self.commentButton)
self.commentButton.setCheckable(True)
self.commentButton.setObjectName("toolbar")
self.commentButton.setToolTip("Add Comment Box Mode")
self.commentButton.clicked.connect(self.toggleDragState)
buttonGrp.addButton(self.normalSelectButton)
buttonGrp.addButton(self.dragSelectButton)
buttonGrp.addButton(self.commentButton)
# self.toolbarLayout.addSpacerItem(QtWidgets.QSpacerItem(10, 0))
self.saveTemplateBtn = QtWidgets.QPushButton()
self.saveTemplateBtn.setMinimumSize(QtCore.QSize(30, 30))
self.saveTemplateBtn.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/save.png"))
self.saveTemplateBtn.setIconSize(QtCore.QSize(30, 30))
self.saveTemplateBtn.setIcon(icon)
self.toolbarLayout.addWidget(self.saveTemplateBtn)
self.saveTemplateBtn.setObjectName("toolbar")
self.saveTemplateBtn.clicked.connect(self.savePicker)
self.saveTemplateBtn.setToolTip("Save a picker file")
self.loadTemplateBtn = QtWidgets.QPushButton()
self.loadTemplateBtn.setMinimumSize(QtCore.QSize(30, 30))
self.loadTemplateBtn.setMaximumSize(QtCore.QSize(30, 30))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/load.png"))
self.loadTemplateBtn.setIconSize(QtCore.QSize(30, 30))
self.loadTemplateBtn.setIcon(icon)
self.toolbarLayout.addWidget(self.loadTemplateBtn)
self.loadTemplateBtn.setObjectName("toolbar")
self.loadTemplateBtn.clicked.connect(self.loadPicker)
self.loadTemplateBtn.setToolTip("Load a picker file")
# =======================================================================
# #create the horizontal layout, with the left column giving us the picker canvas area,
# and the right a toolbar for animation tools
# =======================================================================
self.mainLayout = QtWidgets.QHBoxLayout()
self.layout.addLayout(self.mainLayout)
self.mainLeftColumnLayout = QtWidgets.QVBoxLayout()
self.mainLayout.addLayout(self.mainLeftColumnLayout)
self.mainRightColumnLayout = QtWidgets.QVBoxLayout()
self.mainLayout.addLayout(self.mainRightColumnLayout)
# =======================================================================
# #left column - picker canvas
# =======================================================================
"""
the picker canvas will consist of a tab layout at the top, one per character in scene,
and in each of those tabs, another tab layout to hold the pages of the picker
"""
self.pickerMainWidget = QtWidgets.QFrame()
self.pickerMainWidget.setObjectName("epic")
self.mainLeftColumnLayout.addWidget(self.pickerMainWidget)
self.pickerMainWidget.setMinimumSize(470, 700)
self.pickerMainWidget.setMaximumSize(470, 700)
self.characterTabs = QtWidgets.QTabWidget(self.pickerMainWidget)
self.characterTabs.setObjectName("tabVariant")
self.characterTabs.setMinimumSize(450, 670)
self.characterTabs.setMaximumSize(450, 670)
self.characterTabs.setIconSize(QtCore.QSize(75, 75))
# look for characters in scene to create character tabs
charactersFound = self.findCharacters()
if not charactersFound:
cmds.warning("No characters found in scene.")
# =======================================================================
# #right column - toolbar
# =======================================================================
self.animToolsFrame = QtWidgets.QFrame()
self.animToolsFrame.setObjectName("epic2")
self.mainRightColumnLayout.addWidget(self.animToolsFrame)
self.animToolsFrame.setMinimumSize(80, 750)
self.animToolsFrame.setMaximumSize(80, 750)
self.animToolsLayout = QtWidgets.QVBoxLayout(self.animToolsFrame)
self.animToolsLayout.addSpacerItem(QtWidgets.QSpacerItem(75, 75))
# Select Controls
self.selectCtrlBtn = QtWidgets.QPushButton()
self.selectCtrlBtn.setMinimumSize(QtCore.QSize(65, 65))
self.selectCtrlBtn.setMaximumSize(QtCore.QSize(65, 65))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/animSelect.png"))
self.selectCtrlBtn.setIconSize(QtCore.QSize(65, 65))
self.selectCtrlBtn.setIcon(icon)
self.animToolsLayout.addWidget(self.selectCtrlBtn)
self.selectCtrlBtn.setObjectName("toolbar")
self.selectCtrlBtn.clicked.connect(self.selectAllCtrls)
self.selectCtrlBtn.setToolTip("Select All Controls")
# Export Motion
self.exportMotionBtn = QtWidgets.QPushButton()
self.exportMotionBtn.setMinimumSize(QtCore.QSize(65, 65))
self.exportMotionBtn.setMaximumSize(QtCore.QSize(65, 65))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/export.png"))
self.exportMotionBtn.setIconSize(QtCore.QSize(65, 65))
self.exportMotionBtn.setIcon(icon)
self.animToolsLayout.addWidget(self.exportMotionBtn)
self.exportMotionBtn.setObjectName("toolbar")
self.exportMotionBtn.clicked.connect(self.exportMotion)
self.exportMotionBtn.setToolTip("Export Motion")
# Import Motion
self.importMotionBtn = QtWidgets.QPushButton()
self.importMotionBtn.setMinimumSize(QtCore.QSize(65, 65))
self.importMotionBtn.setMaximumSize(QtCore.QSize(65, 65))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/import.png"))
self.importMotionBtn.setIconSize(QtCore.QSize(65, 65))
self.importMotionBtn.setIcon(icon)
self.animToolsLayout.addWidget(self.importMotionBtn)
self.importMotionBtn.setObjectName("toolbar")
self.importMotionBtn.clicked.connect(self.importMotion)
self.importMotionBtn.setToolTip("Import Motion")
# Match Over Frame Range
movie = QtGui.QMovie(utils.returnNicePath(self.iconsPath, "System/matchRange.gif"))
movie.setParent(self)
self.matchRangeBtn = QtWidgets.QPushButton()
self.matchRangeBtn.setMinimumSize(QtCore.QSize(65, 65))
self.matchRangeBtn.setMaximumSize(QtCore.QSize(65, 65))
self.matchRangeBtn.setIconSize(QtCore.QSize(65, 65))
self.animToolsLayout.addWidget(self.matchRangeBtn)
self.matchRangeBtn.setObjectName("toolbar")
self.matchRangeBtn.clicked.connect(self.matchOverRange)
self.matchRangeBtn.setToolTip("Match Over Frame Range")
movie.frameChanged.connect(partial(self.setButtonIcon, movie))
movie.start()
if movie.loopCount() != -1:
movie.finished.connect(movie.start())
# Reset Module
self.resetModuleBtn = QtWidgets.QPushButton()
self.resetModuleBtn.setMinimumSize(QtCore.QSize(65, 65))
self.resetModuleBtn.setMaximumSize(QtCore.QSize(65, 65))
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/animReset.png"))
self.resetModuleBtn.setIconSize(QtCore.QSize(65, 65))
self.resetModuleBtn.setIcon(icon)
self.animToolsLayout.addWidget(self.resetModuleBtn)
self.resetModuleBtn.setObjectName("toolbar")
self.resetModuleBtn.clicked.connect(self.resetRigCtrls)
self.resetModuleBtn.setToolTip("Reset modules tool")
self.animToolsLayout.addSpacerItem(QtWidgets.QSpacerItem(75, 600))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def setButtonIcon(self, movie, *args):
"""
Sets the icon of the matchRangeBtn to the next frame in the passed in movie. Note: This was a test function
to see if animated gifs could be used as buttons.
:param movie: The movie whose frame to change.
"""
self.matchRangeBtn.setIcon(QtGui.QIcon(movie.currentPixmap()))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def findCharacters(self):
"""
Finds all assets in the scene built with ARTv2, and creates a picker tab for each one in the animation UI.
"""
allNodes = cmds.ls(type="network")
characterNodes = []
for node in allNodes:
attrs = cmds.listAttr(node)
if "rigModules" in attrs:
characterNodes.append(node)
if len(characterNodes) == 0:
return False
else:
# go through each node, find the character name, the namespace on the node, and the picker attribute
for node in characterNodes:
try:
namespace = cmds.getAttr(node + ".namespace")
except:
namespace = cmds.getAttr(node + ".name")
picker = False
if cmds.objExists(node + ".pickerFile"):
pickerFile = cmds.getAttr(node + ".pickerFile")
pickerPath = utils.returnNicePath(self.toolsPath, "Core/Pickers/")
picker = True
# create the tab for the given namespace
characterWidget = QtWidgets.QWidget()
characterWidget.setProperty("charNode", node)
characterWidget.setMinimumSize(442, 720)
characterWidget.setMaximumSize(442, 720)
characterWidget.setProperty("namespace", namespace)
# add the icon found on the node's icon path attribute to the tab
iconPath = cmds.getAttr(node + ".iconPath")
iconPath = utils.returnNicePath(self.projectPath, iconPath)
icon = QtGui.QIcon(iconPath)
self.characterTabs.addTab(characterWidget, icon, "")
index = self.characterTabs.indexOf(characterWidget)
self.characterTabs.setTabToolTip(index, namespace)
# if a picker file existed, load it. Otherwise, display an image telling the user to either
# load a file or create a picker
frame = QtWidgets.QFrame(characterWidget)
frame.setMinimumSize(442, 720)
frame.setMaximumSize(442, 720)
frame.setStyleSheet(
"background-image: url(" + utils.returnNicePath(self.iconsPath, "System/noPicker.png") + ");")
layout = QtWidgets.QVBoxLayout(frame)
layout.setContentsMargins(20, 150, 20, 241)
# add help gif
movie_screen = QtWidgets.QLabel(frame)
movie_screen.setStyleSheet("background: transparent;")
layout.addWidget(movie_screen)
moviePath = utils.returnNicePath(self.iconsPath, "Help/createPicker.gif")
movie = QtGui.QMovie(moviePath, QtCore.QByteArray())
movie.setCacheMode(QtGui.QMovie.CacheAll)
movie.setSpeed(100)
movie_screen.setMovie(movie)
movie.start()
if picker:
self.characterTabs.setCurrentIndex(index)
self.loadPicker(utils.returnNicePath(pickerPath, pickerFile))
return True
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def createNewPicker(self, bypass=False):
"""
Create a new control picker for the given character tab. This will remove the help gif and replace it with a
blank canvas that module pickers can be added to (using ART_AddModuleToCanvas).
:param bypass: Whether or not to bypass the QMessageBox confirming the creation of a new picker.
This is used when loading a picker from file. bypass will be set to True.
:return: returns the QTabWidget for this character's picker.
.. seealso:: ART_AddModuleToCanvas
"""
# get the current tab index and the widget
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
closeWidget = widget.children()
# get the tab text
character = self.characterTabs.tabToolTip(index)
if not bypass:
# display a message confirming new picker creation for given character
msgBox = QtWidgets.QMessageBox()
msgBox.setText("Create a New Picker for " + str(character) + " ?")
msgBox.setIcon(QtWidgets.QMessageBox.Question)
msgBox.addButton("Yes", QtWidgets.QMessageBox.YesRole)
msgBox.addButton("Cancel", QtWidgets.QMessageBox.NoRole)
ret = msgBox.exec_()
# if the user selected "Yes", delete the old widget
if ret == 0:
for each in closeWidget:
each.setParent(None)
each.close()
self.update()
if ret == 1:
return
else:
for each in closeWidget:
each.setParent(None)
each.close()
self.update()
# now add a new tab widget to our character tabs, with a new tab named "Main"
pickerTabs = QtWidgets.QTabWidget(widget)
pickerTabs.currentChanged.connect(self.pickerTabChange)
pickerTabs.setMinimumSize(444, 632)
pickerTabs.setMaximumSize(444, 632)
# add 'add tab' button
addTabBtn = QtWidgets.QPushButton("Add Tab")
addTabBtn.setObjectName("blueButton")
addTabBtn.setToolTip("Add Picker Tab")
addTabBtn.clicked.connect(partial(self.addTab, pickerTabs))
pickerTabs.setCornerWidget(addTabBtn, QtCore.Qt.TopRightCorner)
# style sheet
stylesheet = """
QTabBar::tab
{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(19,132,183), stop:1 rgb(30,30,30));
width: 100px;
padding-left: -10px;
}
QTabBar::tab:selected
{
background-color: rgb(14,100,143);
border: 2px solid black;
}
QTabBar::tab:hover
{
background: rgb(19,132,183);
}
QTabBar::tab:!selected
{
margin-top: 5px;
}
QTabWidget::pane
{
border-top: 2px solid rgb(19,132,183);
}
"""
# create the qWidget for this tab of the picker
pickerCanvas = QtWidgets.QWidget()
pickerCanvas.setMinimumSize(442, 600)
pickerCanvas.setMaximumSize(442, 600)
pickerTabs.addTab(pickerCanvas, "Main")
pickerTabs.setStyleSheet(stylesheet)
# create the layout for this page
pageLayout = QtWidgets.QVBoxLayout(pickerCanvas)
# create the graphicsView
gfxView = QtWidgets.QGraphicsView()
pageLayout.addWidget(gfxView)
# create the qgraphicsScene
gfxScene = QtWidgets.QGraphicsScene()
gfxScene.setSceneRect(0, 0, 420, 575)
gfxView.setScene(gfxScene)
gfxView.setDragMode(QtWidgets.QGraphicsView.NoDrag)
# set background image
pixmap = QtGui.QPixmap(utils.returnNicePath(self.iconsPath, "System/canvas.png"))
gfxItem = gfxScene.addPixmap(pixmap)
gfxItem.setZValue(-20)
# show the picker tabs
pickerTabs.show()
# enable module list button
self.backgroundImgBtn.setEnabled(True)
self.moduleListBtn.setEnabled(True)
self.removeModBtn.setEnabled(True)
self.moveModBtn.setEnabled(True)
self.normalSelectButton.setEnabled(False)
self.dragSelectButton.setEnabled(False)
if not bypass:
self.addModuleToPickerUI()
# =======================================================
# #enable edit button
# =======================================================
self.editPickerBtn.setEnabled(True)
return pickerTabs
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def toggleDragState(self):
"""
Toggles selection interaction modes within the QGraphicsScene. The three different modes are normal select,
drag select, and comment box mode. This will set the dragMode of the QGraphicsView to the currently selected
state, along with switching icons to show selection status.
"""
# get the current tab index and the widget
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
views = []
# get the children of the current tab widget
children = widget.children()
for child in children:
# if we find a tab widget, search for the gfxScene
if type(child) == QtWidgets.QTabWidget:
tab = child
selectedTab = tab.currentIndex()
for i in range(tab.count()):
tab.setCurrentIndex(i)
canvasIndex = tab.currentIndex()
canvasWidget = tab.widget(canvasIndex)
canvasChildren = canvasWidget.children()
for canvasChild in canvasChildren:
if type(canvasChild) == QtWidgets.QGraphicsView:
view = canvasChild
views.append(view)
tab.setCurrentIndex(selectedTab)
for view in views:
view.mousePressEvent = partial(self.gfxViewMousePress, view)
view.mouseMoveEvent = partial(self.gfxViewMouseMove, view)
view.mouseReleaseEvent = partial(self.gfxViewMouseRelease, view)
# normal singular select mode
if self.normalSelectButton.isChecked():
for view in views:
view.setDragMode(QtWidgets.QGraphicsView.NoDrag)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/normalSelect_On.png"))
self.normalSelectButton.setIconSize(QtCore.QSize(30, 30))
self.normalSelectButton.setIcon(icon)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/dragSelect.png"))
self.dragSelectButton.setIconSize(QtCore.QSize(30, 30))
self.dragSelectButton.setIcon(icon)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/commentMode.png"))
self.commentButton.setIconSize(QtCore.QSize(30, 30))
self.commentButton.setIcon(icon)
# drag select mode
if self.dragSelectButton.isChecked():
for view in views:
view.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/normalSelect.png"))
self.normalSelectButton.setIconSize(QtCore.QSize(30, 30))
self.normalSelectButton.setIcon(icon)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/dragSelect_On.png"))
self.dragSelectButton.setIconSize(QtCore.QSize(30, 30))
self.dragSelectButton.setIcon(icon)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/commentMode.png"))
self.commentButton.setIconSize(QtCore.QSize(30, 30))
self.commentButton.setIcon(icon)
# create UE4-style comment box mode
if self.commentButton.isChecked():
for view in views:
view.setDragMode(QtWidgets.QGraphicsView.RubberBandDrag)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/normalSelect.png"))
self.normalSelectButton.setIconSize(QtCore.QSize(30, 30))
self.normalSelectButton.setIcon(icon)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/dragSelect.png"))
self.dragSelectButton.setIconSize(QtCore.QSize(30, 30))
self.dragSelectButton.setIcon(icon)
icon = QtGui.QIcon(utils.returnNicePath(self.iconsPath, "System/commentMode_on.png"))
self.commentButton.setIconSize(QtCore.QSize(30, 30))
self.commentButton.setIcon(icon)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def gfxViewMousePress(self, view, event):
"""
Override event that captures a mouse press when in the passed in QGraphicsView and displays the QRubberBand
if in drag select or comment box mode.
:param view: the QGraphicsView to detect mouse press events in.
"""
if self.dragSelectButton.isChecked():
self.origin = event.pos()
self.rubberband = QtWidgets.QRubberBand(QtWidgets.QRubberBand.Rectangle, view)
self.rubberband.setGeometry(QtCore.QRect(self.origin, QtCore.QSize()))
self.rubberband.show()
if self.commentButton.isChecked():
self.origin = event.pos()
self.rubberband = QtWidgets.QRubberBand(QtWidgets.QRubberBand.Rectangle, view)
self.rubberband.setGeometry(QtCore.QRect(self.origin, QtCore.QSize()))
self.rubberband.show()
QtWidgets.QGraphicsView.mousePressEvent(view, event)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def gfxViewMouseMove(self, view, event):
"""
Override event that captures a mouse move when in the passed in QGraphicsView and changes the
displayed size of the QRubberBand based on the origin position and the current position, drawing a QRect (if
in drag select or comment box mode.). It also finds any items inside of that QRect (picker buttons, etc).
:param view: the QGraphicsView to detect mouse move events in and check for items in.
"""
if self.dragSelectButton.isChecked():
try:
self.rubberband.setGeometry(QtCore.QRect(self.origin, event.pos()).normalized())
self.itemsInRect = view.items(QtCore.QRect(self.origin, event.pos()).normalized())
except Exception, e:
pass
if self.commentButton.isChecked():
try:
self.rubberband.setGeometry(QtCore.QRect(self.origin, event.pos()).normalized())
self.itemsInRect = view.items(QtCore.QRect(self.origin, event.pos()).normalized())
except Exception, e:
pass
QtWidgets.QGraphicsView.mouseMoveEvent(view, event)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def gfxViewMouseRelease(self, view, event):
"""
Override event that captures a mouse release when in the passed in QGraphicsView and hides the QRubberBand
if it was visible. If in comment box mode, this release event will also create the comment box with the
dimensions and position of the start point of the mouse press, and the QRect from the mouse move.
:param view: the QGraphicsView to detect mouse release events and to add comment boxes to.
"""
if self.dragSelectButton.isChecked():
self.rubberband.hide()
try:
for item in self.itemsInRect:
try:
if item.classType == "pickerButton":
item.mousePressEventCustom(QtGui.QGraphicsSceneMouseEvent())
except:
pass
except:
pass
if self.commentButton.isChecked():
self.rubberband.hide()
geo = self.rubberband.geometry()
scene = view.scene()
box = interfaceUtils.commentBoxItem(geo.x(), geo.y(), geo.width(), geo.height(), scene, view, self)
scene.addItem(box)
box.setZValue(0)
self.normalSelectButton.setChecked(True)
self.toggleDragState()
QtWidgets.QGraphicsView.mouseReleaseEvent(view, event)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def addTab(self, tabWidget, bypass=False, tabName=None):
"""
Adds a tab to the QTabWidget for a given character to add more module control pickers to. These are sometimes
referred to as "canvases".
:param tabWidget: The QTabWidget to add a tab to.
:param bypass: If not creating the "Main" tab or loading a picker from file, a tab name must be entered.
:param tabName: If creating the "Main" tab or loading a picker from file, the name given to the tab that
will be created.
:return: Index of the created tab in the QTabWidget.
"""
if not bypass:
tabName, ok = QtWidgets.QInputDialog.getText(self, "Tab Name", "Enter Tab Name:")
else:
ok = True
tabName = tabName
if ok:
if tabName != "":
# create the qWidget for this tab of the picker
pickerCanvas = QtWidgets.QWidget()
pickerCanvas.setMinimumSize(442, 600)
pickerCanvas.setMaximumSize(442, 600)
tabWidget.addTab(pickerCanvas, str(tabName))
index = tabWidget.indexOf(pickerCanvas)
# create the layout for this page
pageLayout = QtWidgets.QVBoxLayout(pickerCanvas)
# create the graphicsView
gfxView = QtWidgets.QGraphicsView()
pageLayout.addWidget(gfxView)
# create the qgraphicsScene
gfxScene = QtWidgets.QGraphicsScene()
gfxScene.setSceneRect(0, 0, 420, 575)
gfxView.setScene(gfxScene)
# set background image
pixmap = QtGui.QPixmap(utils.returnNicePath(self.iconsPath, "System/canvas.png"))
gfxScene.addPixmap(pixmap)
return index
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def closeEvent(self, event):
"""
Closes the interface.
"""
for inst in _instances:
if cmds.dockControl("pyART_animToolsDock", q=True, exists=True):
inst.close()
else:
if cmds.window("pyART_AnimTools_Win", exists=True):
inst.close()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def addModuleToPickerUI(self):
"""
Creates an instance of ART_AddModuleToCanvas to bring up that tool, passing in modules valid to add.
"""
modulesToAdd = self.comparePickerToRig(True, False)
import ART_AddModuleToCanvas as am2c
reload(am2c)
am2c.ART_AddModuleToCanvas(self, modulesToAdd)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def removeModuleFromPickerUI(self):
"""
Creates an instance of the ART_RemoveModuleFromCanvas tool, passing in modules valid to remove.
"""
modulesToAdd = self.comparePickerToRig(False, True)
import ART_RemoveModuleFromCanvas as arfc
reload(arfc)
arfc.ART_RemoveModuleFromCanvas(self, modulesToAdd)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def movePickerToTab(self):
"""
Creates an instance of the ART_MovePickerToTabUI tool, passing in all valid module pickers that could be moved.
"""
modulesToAdd = self.findAllPickerItems()
import ART_MovePickerToTabUI as mp2t
reload(mp2t)
mp2t.ART_MovePickerToTab(self, modulesToAdd)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def pickerTabChange(self):
"""
Called on when a tab is changed on a given character's picker, if the remove modules from canvas UI is open,
it will be closed.
.. todo:: This function could eventually be changed to simply refresh that UI with the new information.
"""
if cmds.window("pyART_AddToCanvasWIN", exists=True):
title = cmds.window("pyART_AddToCanvasWIN", q=True, title=True)
if title == "Remove Module From Canvas":
cmds.deleteUI("pyART_AddToCanvasWIN", wnd=True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def editPicker(self):
"""
Makes all picker items editable again, making them selectable, movable, scalable, and rotatable.
"""
data = self.getPickerTabs(False)
comments = self.getComments()
self.backgroundImgBtn.setEnabled(True)
self.moduleListBtn.setEnabled(True)
self.removeModBtn.setEnabled(True)
self.moveModBtn.setEnabled(True)
self.normalSelectButton.setEnabled(False)
self.dragSelectButton.setEnabled(False)
for each in data:
item = each.get("item")
item.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
item.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)
item.setFlag(QtWidgets.QGraphicsItem.ItemIsFocusable, True)
item.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges, True)
for comment in comments:
item = comment.get("item")
item.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, True)
item.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def savePicker(self):
"""
Save the picker data to a .picker file. The main picker data is actually gathered by self.getPickerTabs,
self.getComments, and self.getButtonColors.
.. seealso:: ART_AnimationUI.getPickerTabs, ART_AnimationUI.getComments, ART_AnimationUI.getButtonColors
"""
# get info from current character tab
pickerData = self.getPickerTabs(True)
commentData = self.getComments(True)
buttonData = self.getButtonColors()
jsonData = {}
jsonData["pickerData"] = pickerData
jsonData["commentData"] = commentData
jsonData["buttonData"] = buttonData
# character name
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
characterNode = widget.property("charNode")
if not cmds.objExists(characterNode + ".pickerFile"):
cmds.addAttr(characterNode, ln="pickerFile", dt="string")
# ask for the file name to give the picker
startingDir = utils.returnNicePath(self.toolsPath, "Core/Pickers")
if not os.path.exists(startingDir):
os.makedirs(startingDir)
filename = cmds.fileDialog2(fm=0, okc="Save Picker", dir=startingDir, ff="*.picker")
if filename is not None:
# create the picker file
f = open(filename[0], 'w')
# dump the data with json
json.dump(jsonData, f)
f.close()
# write picker file location to character node
niceFileName = utils.returnFriendlyPath(filename[0])
pickerFile = niceFileName.partition(utils.returnNicePath(self.toolsPath, "Core/Pickers/") + "/")[2]
cmds.setAttr(characterNode + ":.pickerFile", pickerFile, type="string")
# disable module list button
self.backgroundImgBtn.setEnabled(False)
self.moduleListBtn.setEnabled(False)
self.removeModBtn.setEnabled(False)
self.moveModBtn.setEnabled(False)
self.normalSelectButton.setEnabled(True)
self.dragSelectButton.setEnabled(True)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def comparePickerToRig(self, unused, used):
"""
Compares the modules that are on the picker to all modules that make up the character.
:param unused: Whether or not we want a list returned of modules that are not on the picker yet.
:param used: Whether or not we want a list returned of modules that are on the picker.
:return: Returns a list of the modules based on either used or unused args.
"""
# get info from current character tab
jsonData = self.getPickerTabs(False)
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
characterNode = widget.property("charNode")
rigModules = cmds.listConnections(characterNode + ".rigModules")
returnModules = []
pickerModules = []
for data in jsonData:
pickerModules.append(data.get("module"))
if unused:
for module in rigModules:
if module not in pickerModules:
returnModules.append(module)
if used:
returnModules = list(set(pickerModules))
return returnModules
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def findAllPickerItems(self):
"""
Finds all modules on the picker. Used mostly be the load picker function.
:return: Returns a list of picker data that includes for each item, the module the picker is for, the item in
memory, and the nice name.
.. seealso:: ART_AnimationUI.loadPicker
"""
# get the current tab index and the widget
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
returnData = []
# get the children of the current tab widget
children = widget.children()
for child in children:
# if we find a tab widget, search for the gfxScene
if type(child) == QtWidgets.QTabWidget:
tab = child
for i in range(tab.count()):
tab.setCurrentIndex(i)
canvasIndex = tab.currentIndex()
canvasWidget = tab.widget(canvasIndex)
canvasChildren = canvasWidget.children()
for canvasChild in canvasChildren:
if type(canvasChild) == QtWidgets.QGraphicsView:
view = canvasChild
scene = view.scene()
# get all items in the gfxScene
itemsInScene = scene.items()
for item in itemsInScene:
# if we find our top level picker item (the borderItem), get it's data
if type(item) == interfaceUtils.pickerBorderItem or item.type() == 3:
module = item.data(QtCore.Qt.UserRole)
niceName = item.data(2)
returnData.append([module, item, niceName])
return returnData
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def loadPicker(self, filename=None):
"""
Loads a .picker file and builds the picker according to the file data.
:param filename: The path of the picker file to gather data from.
"""
if filename is None:
startingDir = utils.returnNicePath(self.toolsPath, "Core/Pickers")
if os.path.exists(startingDir):
filename = cmds.fileDialog2(fm=1, okc="Load Picker", dir=startingDir, ff="*.picker")
if filename is not None:
filename = filename[0]
borderItems = []
if os.path.exists(filename):
# ===============================================================
# #load the data
# ===============================================================
json_file = open(filename)
data = json.load(json_file)
json_file.close()
# ===============================================================
# #get character node
# ===============================================================
tabIndex = self.characterTabs.currentIndex()
characterWidget = self.characterTabs.widget(tabIndex)
characterNode = characterWidget.property("charNode")
characterNodeModules = cmds.listConnections(characterNode + ".rigModules")
if cmds.objExists(characterNode + ".namespace"):
namespace = cmds.getAttr(characterNode + ".namespace") + ":"
else:
namespace = cmds.getAttr(characterNode + ".name")
# create new picker
tabWidget = self.createNewPicker(True)
# ===============================================================
# #create all tabs
# ===============================================================
existingTabs = []
subPickers = []
for i in range(tabWidget.count()):
tabName = tabWidget.tabText(i)
existingTabs.append(tabName)
# ===============================================================
# #go through data
# ===============================================================
subPickers = []
pickerData = data["pickerData"]
for item in pickerData:
module = item.get("module")
moduleNiceName = item.get("module")
tab = item.get("tab")
transforms = item.get("transforms")
subPicker = item.get("subPicker")
mirrored = item.get("mirrored")
path = item.get("path")
if module is not None:
# if there is a namespace (if the add character for animation tool was used):
if namespace + module in characterNodeModules:
module = namespace + module
else:
namespace = ""
if subPicker is True:
subPickers.append([module, tab, transforms, mirrored, moduleNiceName])
if tab not in existingTabs:
self.addTab(tabWidget, True, tab)
existingTabs.append(tab)
# ===========================================================
# #add the picker to the correct tab
# ===========================================================
buildPicker = False
tabChildren = tabWidget.children()
# get a list of the tabs with their names and index
tabInfo = {}
for i in range(len(tabChildren)):
tabName = tabWidget.tabText(i)
tabInfo[tabName] = i
# now find a matching entry in that list to our tab variable
index = tabInfo.get(tab)
if index is None:
index = 0
# set out tab widget to that index
tabWidget.setCurrentIndex(index)
if subPicker is False:
buildPicker = True
# ===========================================================
# #now that the tab is correct, build the picker for the module
# ===========================================================
if buildPicker:
scene = self.getCurrentScene()
try:
# create picker for the given module
inst = self.getModuleInst(module)
pickerData = inst.pickerUI(self.center, self, module, namespace)
picker = pickerData[0]
scene.addItem(picker)
self.selectionScriptJobs.append(pickerData[2])
borderItems.append([picker, moduleNiceName, module])
# mirror the module's pickerBorderItem if needed
if pickerData[1] == True:
picker.setTransformOriginPoint(picker.boundingRect().center())
picker.setTransform(
QtGui.QTransform(-1.0, 0.0, 0.0, 1.0, picker.boundingRect().width() * 2, 0.0))
children = picker.childItems()
if children is not None:
self.mirrorChildTextItems(children)
# set transformations on the picker
picker.setTransformOriginPoint(picker.boundingRect().center())
picker.setScale(transforms[2])
# when loading a picker, set data(1) to be the scale factor that was possibly saved out.
picker.setData(1, transforms[2])
picker.setTransformOriginPoint(picker.boundingRect().center())
picker.setRotation(transforms[1])
picker.setPos(QtCore.QPointF(transforms[0][0], transforms[0][1]))
picker.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
picker.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
picker.setFlag(QtWidgets.QGraphicsItem.ItemIsFocusable, False)
picker.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges, False)
# =======================================================
# #enable edit button
# =======================================================
self.editPickerBtn.setEnabled(True)
# =======================================================
# #disable canvas, move, and remove buttons
# =======================================================
self.backgroundImgBtn.setEnabled(False)
self.moduleListBtn.setEnabled(False)
self.removeModBtn.setEnabled(False)
self.moveModBtn.setEnabled(False)
self.normalSelectButton.setEnabled(True)
self.dragSelectButton.setEnabled(True)
except Exception, e:
cmds.warning(str(e))
try:
if path is not None:
widget = tabWidget.widget(index)
widgetChildren = widget.children()
for child in widgetChildren:
if type(child) == QtWidgets.QGraphicsView:
gfxView = child
if os.path.exists(utils.returnFriendlyPath(path)):
# set background image
pixmap = QtGui.QPixmap()
pixmap.load(utils.returnFriendlyPath(path))
scene = gfxView.scene()
gfxItem = scene.addPixmap(pixmap)
gfxItem.setZValue(-10)
scene.setProperty("customImg", gfxItem)
scene.setProperty("filePath", filename)
else:
cmds.warning("Tried to load custom background image: " + str(
path) + ", but file not found on disk.")
except Exception, e:
print e
# ===============================================================
# #Handle Sub-Pickers
# ===============================================================
if len(subPickers) > 0:
for info in subPickers:
module = info[4]
tab = info[1]
transforms = info[2]
mirrored = info[3]
pickerItems = self.findAllPickerItems()
# each item in pickerItems has module, item, niceName. use niceName to see if we have a winner
for each in pickerItems:
pickerModule = each[0]
pickerItem = each[1]
pickerNiceName = each[2]
if pickerModule == module:
if pickerNiceName is not None:
# now find a matching entry in that list to our tab variable
index = tabInfo.get(tab)
# set our tab widget to that index
tabWidget.setCurrentIndex(index)
# find current scene
scene = self.getCurrentScene()
scene.addItem(pickerItem)
# set transformations on the picker
pickerItem.setTransformOriginPoint(pickerItem.boundingRect().center())
pickerItem.setScale(transforms[2])
# when loading a picker, set data(1) to be the scale factor that was possibly saved out.
pickerItem.setData(1, transforms[2])
pickerItem.setTransformOriginPoint(pickerItem.boundingRect().center())
pickerItem.setRotation(transforms[1])
pickerItem.setPos(QtCore.QPointF(transforms[0][0], transforms[0][1]))
if mirrored == -1:
pickerItem.setTransformOriginPoint(pickerItem.boundingRect().center())
pickerItem.setTransform(
QtGui.QTransform(-1.0, 0.0, 0.0, 1.0, scene.sceneRect().width(), 0.0))
pickerItem.setTransformOriginPoint(pickerItem.boundingRect().center())
# lock down pickers
pickerItem.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
pickerItem.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
pickerItem.setFlag(QtWidgets.QGraphicsItem.ItemIsFocusable, False)
pickerItem.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges, False)
# ===============================================================
# #Add Comment data
# ===============================================================
commentData = data["commentData"]
for item in commentData:
rect = item.get("rect")
color = item.get("color")
label = item.get("label")
tab = item.get("tab")
tabChildren = tabWidget.children()
# get a list of the tabs with their names and index
tabInfo = {}
for i in range(len(tabChildren)):
tabName = tabWidget.tabText(i)
tabInfo[tabName] = i
# now find a matching entry in that list to our tab variable
index = tabInfo.get(tab)
if index is None:
index = 0
# set out tab widget to that index
tabWidget.setCurrentIndex(index)
view = self.getCurrentView()
scene = self.getCurrentScene()
box = interfaceUtils.commentBoxItem(rect[0], rect[1], rect[2], rect[3], scene, view, self)
box.brush.setColor(QtGui.QColor.fromRgb(color[0], color[1], color[2], color[3]))
box.textLabel.setPlainText(label)
scene.addItem(box)
# ===============================================================
# #Find button color data
# ===============================================================
try:
buttonData = data["buttonData"]
for border in borderItems:
pickerModule = border[1]
picker = border[0]
networkNode = border[2]
for button in buttonData:
module = button.get("module")
color = button.get("color")
control = button.get("control")
if pickerModule == module:
# then we have the correct border item parent and now need to get its button
childItems = picker.childItems()
for child in childItems:
if type(child) == interfaceUtils.pickerButton:
# delete the existing scriptJob
scriptJob = picker.data(5)
cmds.scriptJob(kill=scriptJob)
self.selectionScriptJobs.remove(scriptJob)
# set the button color
child.brush.setColor(QtGui.QColor.fromRgb(color[0], color[1], color[2], color[3]))
inst = self.getModuleInst(networkNode)
# create the new scriptJob
newColor = QtGui.QColor.fromRgb(color[0], color[1], color[2], color[3])
scriptJob = cmds.scriptJob(event=["SelectionChanged",
partial(inst.selectionScriptJob_animUI,
[[child, control, newColor]])],
kws=True)
picker.setData(5, scriptJob)
self.selectionScriptJobs.append(scriptJob)
except Exception, e:
print e
# ===============================================================
# #write picker file location to character node
# ===============================================================
if not cmds.objExists(characterNode + ".pickerFile"):
cmds.addAttr(characterNode, ln="pickerFile", dt="string")
niceFileName = utils.returnFriendlyPath(filename)
pickerFile = niceFileName.partition(utils.returnNicePath(self.toolsPath, "Core/Pickers/") + "/")[2]
cmds.setAttr(characterNode + ".pickerFile", pickerFile, type="string")
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def mirrorChildTextItems(self, children):
"""
Mirrors any QGraphicsSimpleTextItems text if the parent picker was mirrored, so that the text is correct.
:param children: List of child items (QGraphicsSimpleTextItems) of a pickerBorderItem or a pickerButton.
"""
# for mirroring text on any child items of a pickerBorderItem or a pickerButton
for child in children:
if type(child) == QtWidgets.QGraphicsSimpleTextItem:
child.setTransformOriginPoint(child.boundingRect().center())
child.setTransform(QtGui.QTransform(-1.0, 0.0, 0.0, 1.0, child.boundingRect().width(), 0.0))
children = child.childItems()
if children is not None:
self.mirrorChildTextItems(children)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def getCurrentScene(self):
"""
Gets the QGraphicsScene of the current QGraphicsView, which is gotten by calling on self.getCurrentView.
:return: Returns the QGraphicsScene under the current QGraphicsView.
.. seealso:: ART_AnimationUI.getCurrentView
"""
view = self.getCurrentView()
scene = view.scene()
return scene
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def getCurrentView(self):
"""
Gets the current QGraphicsView based on the currently selected character tab, and the currently selected
picker tab of said character.
:return: Returns the QGraphicsView that is currently active.
"""
# get the current tab index and the widget
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
# search through the children of the widget until we find the gfxScene
children = widget.children()
for child in children:
if type(child) == QtWidgets.QTabWidget:
tab = child
canvasIndex = tab.currentIndex()
canvasWidget = tab.widget(canvasIndex)
canvasChildren = canvasWidget.children()
for canvasChild in canvasChildren:
if type(canvasChild) == QtWidgets.QGraphicsView:
view = canvasChild
return view
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def getPickerTabs(self, saving):
"""
Finds and returns all picker item data, like transforms, scale, x/y coordinates, mirrored status, parent tab,
and controlled module.
:param saving: Whether or not this function is being called by savePicker, in which case if it is, it will then
make sure that the picker items are no longer editable.
:rtype: A list of lists, where each inner list has the following data for a picker item:
:return [0]: Name of tab the picker item belongs to
:return [1]: Picker item transforms
:return [2]: Name of module picker belongs to (which module controls it interfaces with)
:return [3]: Whether or not the picker item is mirrored.
:return [4]: Whether or not the picker is a sub-picker, like fingers or toes.
:return [5]: And if not saving, the memory address of the picker item.
"""
# get the current tab index and the widget
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
returnData = []
# get the children of the current tab widget
children = widget.children()
for child in children:
# if we find a tab widget, search for the gfxScene
if type(child) == QtWidgets.QTabWidget:
tab = child
selectedTab = tab.currentIndex()
for i in range(tab.count()):
tab.setCurrentIndex(i)
canvasIndex = tab.currentIndex()
canvasWidget = tab.widget(canvasIndex)
canvasChildren = canvasWidget.children()
for canvasChild in canvasChildren:
if type(canvasChild) == QtWidgets.QGraphicsView:
view = canvasChild
scene = view.scene()
# get all items in the gfxScene
itemsInScene = scene.items()
for item in itemsInScene:
# if we find our top level picker item (the borderItem), get it's data
if type(item) == interfaceUtils.pickerBorderItem or item.type() == 3:
# item.data(1)could have data that is the scale factor, however, if this is
# a fresh picker, it will not.
scaleFactor = item.data(1)
if scaleFactor is None:
scaleFactor = item.scale
# get position, rotation, and find out if the pickerBorderItem has been mirrored
position = item.pos()
position = [position.x(), position.y()]
rotation = item.rotation()
mirrored = item.transform().m11()
itemData = {}
# add data to dictionary
itemData["tab"] = tab.tabText(canvasIndex)
itemData["transforms"] = [position, rotation, scaleFactor]
itemData["module"] = item.data(QtCore.Qt.UserRole)
itemData["mirrored"] = mirrored
if item.data(2) is None:
itemData["subPicker"] = False
else:
itemData["subPicker"] = True
if not saving:
itemData["item"] = item
if saving:
# set flags to False so borderItem is no longer moveable, selectable, etc.
item.setFlag(QtWidgets.QGraphicsItem.ItemIsMovable, False)
item.setFlag(QtWidgets.QGraphicsItem.ItemIsSelectable, False)
item.setFlag(QtWidgets.QGraphicsItem.ItemIsFocusable, False)
item.setFlag(QtWidgets.QGraphicsItem.ItemSendsGeometryChanges, False)
returnData.append(itemData)
if type(item) == QtWidgets.QGraphicsPixmapItem:
customImg = scene.property("customImg")
if item == customImg:
filePath = scene.property("filePath")
itemData = {}
itemData["tab"] = tab.tabText(canvasIndex)
itemData["path"] = filePath
returnData.append(itemData)
tab.setCurrentIndex(selectedTab)
return returnData
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def getComments(self, saving=False):
"""
Gets any comment boxes that were created on any picker tabs and returns a list of those items.
:param saving: Whether or not this function is being called from savePicker, in which case, it will disable
edits.
:rtype: A list of lists where the inner list contains the following data for each comment box found:
:return [0]: The QRect of the comment box, which contains the box dimensions and the x/y coordinates.
:return [1]: The color of the comment box
:return [2]: The name of the tab the comment box is under.
:return [3]: The text label of the comment box.
"""
# get the current tab index and the widget
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
returnData = []
# get the children of the current tab widget
children = widget.children()
for child in children:
# if we find a tab widget, search for the gfxScene
if type(child) == QtWidgets.QTabWidget:
tab = child
selectedTab = tab.currentIndex()
for i in range(tab.count()):
tab.setCurrentIndex(i)
canvasIndex = tab.currentIndex()
canvasWidget = tab.widget(canvasIndex)
canvasChildren = canvasWidget.children()
for canvasChild in canvasChildren:
if type(canvasChild) == QtWidgets.QGraphicsView:
view = canvasChild
scene = view.scene()
# get all items in the gfxScene
itemsInScene = scene.items()
for item in itemsInScene:
if type(item) == interfaceUtils.commentBoxItem:
itemData = {}
if not saving:
itemData["item"] = item
# get comment box position and color
geo = item.boundingRect()
color = item.brush.color().getRgb()
itemData["rect"] = [geo.x(), geo.y(), geo.width(), geo.height()]
itemData["color"] = color
itemData["tab"] = tab.tabText(canvasIndex)
# get comment box text
children = item.childItems()
for each in children:
if type(each) == QtWidgets.QGraphicsTextItem:
label = each.toPlainText()
itemData["label"] = label
returnData.append(itemData)
return returnData
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def getButtonColors(self):
"""
Gets joint module picker button colors, which can be edited by the user.
.. note:: Currently, only the joint module supports users being able to change the button color.
:rtype: A list of lists where the inner list contains the following data for each joint module found:
:return [0]: The name of the module this picker interfaces with.
:return [1]: The color of the picker button.
:return [2]: The name of the control this button selects.
"""
# get the current tab index and the widget
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
returnData = []
# get the children of the current tab widget
children = widget.children()
for child in children:
# if we find a tab widget, search for the gfxScene
if type(child) == QtWidgets.QTabWidget:
tab = child
selectedTab = tab.currentIndex()
for i in range(tab.count()):
tab.setCurrentIndex(i)
canvasIndex = tab.currentIndex()
canvasWidget = tab.widget(canvasIndex)
canvasChildren = canvasWidget.children()
for canvasChild in canvasChildren:
if type(canvasChild) == QtWidgets.QGraphicsView:
view = canvasChild
scene = view.scene()
# get all items in the gfxScene
itemsInScene = scene.items()
for item in itemsInScene:
if type(item) == interfaceUtils.pickerBorderItem or item.type() == 3:
childButtons = item.childItems()
# if the picker button is from a leaf module, get color data (only leaf for now)
for child in childButtons:
if type(child) == interfaceUtils.pickerButton:
moduleType = item.data(QtCore.Qt.UserRole)
if "ART_Leaf_Module" in moduleType:
# get button color
color = child.brush.color().getRgb()
# store module name, button color
itemData = {}
itemData["module"] = moduleType
itemData["color"] = color
itemData["control"] = child.object
returnData.append(itemData)
return returnData
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def getModuleInst(self, module):
"""
Takes the given module and instantiates it, returning the memory address for the created instance.
:param module: The name of the module to instantiate.
:return: The instance of the instantiated module in memory.
"""
modType = cmds.getAttr(module + ".moduleType")
modName = cmds.getAttr(module + ".moduleName")
mod = __import__("RigModules." + modType, {}, {}, [modType])
reload(mod)
# get the class name from that module file (returns Modules.ART_Root.ART_Root for example)
moduleClass = getattr(mod, mod.className)
# find the instance of that module
moduleInst = moduleClass(self, modName)
return moduleInst
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def changeBackground(self):
"""
Creates an interface allowing a user to change the background image of a picker with these dimensions: (442 x
600)
"""
if cmds.window("pyART_changeBackgroundImg_Win", exists=True):
cmds.deleteUI("pyART_changeBackgroundImg_Win", wnd=True)
mainWin = QtWidgets.QMainWindow(self.mainWidget)
mainWin.setStyleSheet(self.style)
mainWin.setMinimumSize(QtCore.QSize(400, 200))
mainWin.setMaximumSize(QtCore.QSize(400, 200))
# set qt object name
mainWin.setObjectName("pyART_changeBackgroundImg_Win")
mainWin.setWindowTitle("Change Background")
# create the main layout
mainWidget = QtWidgets.QFrame()
mainWin.setCentralWidget(mainWidget)
mainLayout = QtWidgets.QVBoxLayout(mainWidget)
# scroll area contents
scrollContents = QtWidgets.QFrame()
scrollContents.setStyleSheet("background: transparent;")
scrollLayout = QtWidgets.QVBoxLayout()
scrollLayout.setSpacing(5)
# find tabs. for each tab, create widget for changing background
tabs = []
index = self.characterTabs.currentIndex()
widget = self.characterTabs.widget(index)
# get the children of the current tab widget
children = widget.children()
for child in children:
# if we find a tab widget, get tab name and item
if type(child) == QtWidgets.QTabWidget:
tab = child
for i in range(tab.count()):
tab.setCurrentIndex(i)
# find tab's graphics view
canvas = tab.widget(i)
canvasChildren = canvas.children()
for child in canvasChildren:
if type(child) == QtWidgets.QGraphicsView:
gfxView = child
tabs.append([tab, tab.tabText(i), gfxView])
for i in range(len(tabs)):
# create the widget for each tab background
layout = QtWidgets.QHBoxLayout()
scrollLayout.addLayout(layout)
# which tab combo box
tabComboBox = QtWidgets.QComboBox()
tabComboBox.setMinimumWidth(100)
tabComboBox.setFixedHeight(35)
layout.addWidget(tabComboBox)
tabComboBox.setStyleSheet(self.style)
tabComboBox.addItem(tabs[i][1])
# path location
pathField = QtWidgets.QLineEdit()
layout.addWidget(pathField)
pathField.setReadOnly(True)
pathField.setFixedHeight(35)
pathField.setStyleSheet(self.style)
pathField.setMinimumWidth(160)
pathField.setPlaceholderText("442 x 600 PNG image file..")
# browse button
button = QtWidgets.QPushButton()
layout.addWidget(button)
button.setMinimumSize(35, 35)
button.setMaximumSize(35, 35)
icon = QtGui.QIcon(os.path.join(self.iconsPath, "System/fileBrowse.png"))
button.setIconSize(QtCore.QSize(30, 30))
button.setIcon(icon)
button.setStyleSheet(self.style)
button.clicked.connect(partial(self.backgroundBrowse, pathField, tabs[i][2]))
# clear button
button = QtWidgets.QPushButton()
layout.addWidget(button)
button.setMinimumSize(35, 35)
button.setMaximumSize(35, 35)
icon = QtGui.QIcon(os.path.join(self.iconsPath, "System/exit.png"))
button.setIconSize(QtCore.QSize(30, 30))
button.setIcon(icon)
button.setToolTip("Clear custom background image, resetting back to default.")
button.setStyleSheet(self.style)
button.clicked.connect(partial(self.clearBackground, tabs[i][2]))
# add everything to the scroll Layout
scrollContents.setLayout(scrollLayout)
scrollArea = QtWidgets.QScrollArea()
mainLayout.addWidget(scrollArea)
scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
scrollArea.setWidgetResizable(False)
scrollArea.setWidget(scrollContents)
# show
mainWin.show()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def backgroundBrowse(self, field, gfxView):
"""
Opens a file browser to select a valid .png background image and then apply it to the specified QGraphicsScene.
:param field: QLineEdit for the path name to be displayed.
:param gfxView: QGraphicsView to add the background image to.
"""
startingDir = utils.returnNicePath(self.toolsPath, "Core/Icons")
if os.path.exists(startingDir):
filename = cmds.fileDialog2(fm=1, okc="Load Picker", dir=startingDir, ff="*.png")
if filename is not None:
filename = filename[0]
field.setText(utils.returnFriendlyPath(filename))
# set background image
pixmap = QtGui.QPixmap()
pixmap.load(utils.returnFriendlyPath(filename))
scene = gfxView.scene()
gfxItem = scene.addPixmap(pixmap)
gfxItem.setZValue(-10)
scene.setProperty("customImg", gfxItem)
scene.setProperty("filePath", filename)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def clearBackground(self, gfxView):
"""
Removes the background image from the given QGraphicsView.
:param gfxView: The QGraphicsView whose background image to remove.
.. seealso:: ART_AnimationUI.changeBackground
"""
scene = gfxView.scene()
items = scene.items()
customImg = scene.property("customImg")
for item in items:
if item == customImg:
scene.removeItem(item)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def exportMotion(self):
"""
Instantiates ART_ExportMotionUI to bring up the tool for exporting animation out to various file formats.
"""
import ART_ExportMotionUI
reload(ART_ExportMotionUI)
ART_ExportMotionUI.ART_ExportMotion(self)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def importMotion(self):
"""
Instantiates ART_ImportMotionUI to bring up the tool for importing FBX animation onto the rig.
"""
import ART_ImportMotionUI
reload(ART_ImportMotionUI)
ART_ImportMotionUI.ART_ImportMotion(self)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def resetRigCtrls(self):
"""
Instantiates ART_ResetModulesUI to bring up the tool for resetting transformations on a selected modules.
Also known as "zeroing out".
"""
import ART_ResetModulesUI
reload(ART_ResetModulesUI)
ART_ResetModulesUI.ART_ResetModules(self)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def selectAllCtrls(self):
"""
Instantiates ART_SelectControlsUI to bring up the tool for selecting specified rig controls for selected
modules.
"""
show = True
mods = cmds.getModifiers()
if (mods & 4) > 0:
show = False
import ART_SelectControlsUI
reload(ART_SelectControlsUI)
ART_SelectControlsUI.ART_SelectControls(self, show)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def matchOverRange(self):
"""
Instantiates ART_MatchOverRangeUI to bring up the tool for matching different rig type over a frame range for
selected modules.
:Example:
Matching the IK leg rig controls to the Fk leg rig controls over a frame range of 0-30.
"""
import ART_MatchOverRangeUI
reload(ART_MatchOverRangeUI)
ART_MatchOverRangeUI.ART_MatchOverRange(self)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def run():
"""
Instantiate the ART_AnimationUI class to build the main interface the animators will interact with.
:return: instance of the ART_AnimationUI in memory.
"""
# create new instance of ART_AnimationUI
gui = ART_AnimationUI(getMainWindow())
# Dock Control
allowedAreas = ["left", "right"]
try:
if cmds.dockControl("pyArtv2AnimToolsDock", q=True, exists=True):
cmds.deleteUI("pyART_AnimTools_Win")
cmds.deleteUI("pyArtv2AnimToolsDock", control=True)
dock = cmds.dockControl("pyArtv2AnimToolsDock", area="right", content="pyART_AnimTools_Win",
allowedArea=allowedAreas, label="Animation Tools", w=450, h=500)
cmds.refresh(force=True)
cmds.dockControl(dock, edit=True, r=True)
except Exception, e:
cmds.warning("UI failed to launch.")
print e
return gui
|