aboutsummaryrefslogtreecommitdiff
path: root/Core/Scripts/Interfaces/ART_MovePickerToTabUI.py
diff options
context:
space:
mode:
authorMobileMachine\jeremy <[email protected]>2017-06-06 22:59:03 -0400
committerMobileMachine\jeremy <[email protected]>2017-06-06 22:59:03 -0400
commit24725fa8681f906ab44d80687c09fecc171a2896 (patch)
tree312a601df29aca7f8db9f44082d96ebc7a679138 /Core/Scripts/Interfaces/ART_MovePickerToTabUI.py
parentInitial commit (diff)
downloadartv2-24725fa8681f906ab44d80687c09fecc171a2896.tar.xz
artv2-24725fa8681f906ab44d80687c09fecc171a2896.zip
Initial Submission
First submission of current state of ARTv2. Currently considered to be in Alpha. There are a couple of animation tools not implemented yet, and one module not implemented yet, as well as incomplete documentation.
Diffstat (limited to 'Core/Scripts/Interfaces/ART_MovePickerToTabUI.py')
-rw-r--r--Core/Scripts/Interfaces/ART_MovePickerToTabUI.py244
1 files changed, 244 insertions, 0 deletions
diff --git a/Core/Scripts/Interfaces/ART_MovePickerToTabUI.py b/Core/Scripts/Interfaces/ART_MovePickerToTabUI.py
new file mode 100644
index 0000000..4831046
--- /dev/null
+++ b/Core/Scripts/Interfaces/ART_MovePickerToTabUI.py
@@ -0,0 +1,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)