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
|
'''
Created on Aug 21, 2015
@author: jeremy.ernst
'''
#import statements
from ThirdParty.Qt import QtGui, QtCore, QtWidgets
import maya.cmds as cmds
import System.utils as utils
class ART_MovePickerToTab(object):
def __init__(self, animPickerUI, modulesToAdd, parent = None):
super(ART_MovePickerToTab, self).__init__()
#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.pickerUI = animPickerUI
self.modulesToAdd = modulesToAdd
#assign close event
self.closeEvent = self.closeWin
#build the UI
self.buildUI()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def buildUI(self):
if cmds.window("pyART_movePickerToTabWIN", exists = True):
cmds.deleteUI("pyART_movePickerToTabWIN", wnd = True)
#create the main window
self.mainWin = QtWidgets.QMainWindow(self.pickerUI)
#create the main widget
self.mainWidget = QtWidgets.QWidget()
self.mainWin.setCentralWidget(self.mainWidget)
#create the mainLayout
self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget)
self.layout = QtWidgets.QHBoxLayout()
self.mainLayout.addLayout(self.layout)
#load stylesheet
styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/animPicker.qss")
f = open(styleSheetFile, "r")
self.style = f.read()
f.close()
self.mainWin.setStyleSheet(self.style)
self.mainWin.setMinimumSize(QtCore.QSize( 400, 400 ))
self.mainWin.setMaximumSize(QtCore.QSize( 400, 400 ))
self.mainWin.resize(400, 400)
#set qt object name
self.mainWin.setObjectName("pyART_movePickerToTabWIN")
self.mainWin.setWindowTitle("Move Picker")
#create 2 columns
self.column1 = QtWidgets.QVBoxLayout()
self.layout.addLayout(self.column1)
self.column2 = QtWidgets.QVBoxLayout()
self.layout.addLayout(self.column2)
#create left side list widget, which will house the picker items
self.pickerItemsList = QtWidgets.QListWidget()
self.column1.addWidget(self.pickerItemsList)
self.pickerItemsList.setMinimumSize(180, 300)
self.pickerItemsList.setMaximumSize(180, 300)
#get the current tab index and the widget
index = self.pickerUI.characterTabs.currentIndex()
widget = self.pickerUI.characterTabs.widget(index)
#get the tab text
character = self.pickerUI.characterTabs.tabToolTip(index)
#find character nodes in the scene, and compare namespace to selected tab
characterMods = utils.returnCharacterModules()
nodeNamespace = ""
for each in characterMods:
if cmds.objExists(each + ".namespace"):
namespace = cmds.getAttr(each + ".namespace")
if namespace == character:
nodeNamespace = namespace + ":"
for module in self.modulesToAdd:
if module[2] == None:
modName = cmds.getAttr(nodeNamespace + module[0] + ".moduleName")
else:
modName = module[2]
qlistItem = QtWidgets.QListWidgetItem(modName)
qlistItem.setData(QtCore.Qt.UserRole, module[1])
self.pickerItemsList.addItem(qlistItem)
#create right side list widget, which will house the available tabs
self.tabList = QtWidgets.QListWidget()
self.column2.addWidget(self.tabList)
self.tabList.setMinimumSize(180, 300)
self.tabList.setMaximumSize(180, 300)
tabs = self.findTabs(False)
for tab in tabs:
qlistItem = QtWidgets.QListWidgetItem(tab[0])
qlistItem.setData(QtCore.Qt.UserRole, tab[1])
self.tabList.addItem(qlistItem)
#create button for move selected picker to selected tab
self.movePickerBtn = QtWidgets.QPushButton("Move Selected Picker To Selected Tab")
self.mainLayout.addWidget(self.movePickerBtn)
self.movePickerBtn.setObjectName("blueButton")
self.movePickerBtn.setMinimumHeight(50)
self.movePickerBtn.setMaximumHeight(50)
self.movePickerBtn.clicked.connect(self.moveToTab)
#show ui
self.mainWin.show()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def findTabs(self, moving, newTab = None):
#get the current tab index and the widget
index = self.pickerUI.characterTabs.currentIndex()
widget = self.pickerUI.characterTabs.widget(index)
tabs = []
#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()):
tabName = tab.tabText(i)
tabs.append([tabName, i])
if moving == True:
tab.setCurrentIndex(newTab)
canvasIndex = tab.currentIndex()
canvasWidget = tab.widget(canvasIndex)
canvasChildren = canvasWidget.children()
for canvasChild in canvasChildren:
if type(canvasChild) == QtWidgets.QGraphicsView:
view = canvasChild
scene = view.scene()
if moving:
return scene
else:
return tabs
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def moveToTab(self):
selectedItem = self.pickerItemsList.currentItem()
selectedTab = self.tabList.currentItem()
try:
newTab = selectedTab.data(QtCore.Qt.UserRole)
except:
cmds.warning("Please Select a Tab from the list.")
return
#get selected tab's scene
scene = self.findTabs(True, newTab)
#get data from selectedItem
pickerItem = selectedItem.data(QtCore.Qt.UserRole)
try:
parentXform = pickerItem.parentItem().transform()
except:
parentXform = pickerItem.transform()
#add to scene
scene.addItem(pickerItem)
#=======================================================================
# #mirror if needed
#=======================================================================
if parentXform.m11() == -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())
children = pickerItem.childItems()
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))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
def closeWin(self, event):
cmds.deleteUI("pyART_movePickerToTabWIN", wnd = True)
|