Beispiel #1
0
    def updateBoneCount(self):
        """
        Updates the interface based on new module information. Usually triggered when a module has had its settings
        changed.

        """

        try:
            modules = utils.returnRigModules()
            allBones = []
            for module in modules:
                joints = cmds.getAttr(module + ".Created_Bones")
                splitJoints = joints.split("::")

                for bone in splitJoints:
                    if bone != "":
                        allBones.append(bone)

            # update the spinBox and progress bar
            self.boneCounter.setValue(len(allBones))
            max = self.boneCountBar.maximum()

            if len(allBones) <= max:
                self.boneCountBar.setValue(len(allBones))
                self.boneCountBar.setStyleSheet(self.progBarStyle)
            if len(allBones) > max:
                self.boneCountBar.setValue(max)
                self.boneCountBar.setStyleSheet(self.progBarStyleMax)
        except:
            pass
Beispiel #2
0
    def setMirrorModule(self):

        #get new parent
        mirrorModule = self.moduleList.currentItem().text()


        #update current parent text
        self.modInst.mirrorMod.setText(mirrorModule)

        #update network node parentModuleBone attribute
        networkNode = self.modInst.returnNetworkNode
        cmds.setAttr(networkNode + ".mirrorModule",  lock = False)
        cmds.setAttr(networkNode + ".mirrorModule", mirrorModule, type = "string", lock = True)


        #also do this change to the mirror as well
        modules = utils.returnRigModules()
        for mod in modules:
            modName = cmds.getAttr(mod + ".moduleName")
            if modName == mirrorModule:

                #set the mirrored version
                mirror = cmds.getAttr(networkNode + ".moduleName")

                cmds.setAttr(mod + ".mirrorModule",  lock = False)
                cmds.setAttr(mod + ".mirrorModule", mirror, type = "string", lock = True)


                #get instance of mirror module's class
                modType = cmds.getAttr(mod + ".moduleType")
                modName = cmds.getAttr(mod + ".moduleName")
                module = __import__("RigModules." + modType, {}, {}, [modType])
                reload(module)

                #get the class name from that module file (returns Modules.ART_Root.ART_Root for example)
                moduleClass = getattr(module, module.className)

                #find the instance of that module and call on the skeletonSettings_UI function
                moduleInst = moduleClass(self.rigUiInst, modName)

                #update mirrorModtext
                #find the current groupBox for this module
                for i in range(self.rigUiInst.moduleSettingsLayout.count()):
                    if type(self.rigUiInst.moduleSettingsLayout.itemAt(i).widget()) == QtWidgets.QGroupBox:
                        if self.rigUiInst.moduleSettingsLayout.itemAt(i).widget().title() == modName:
                            self.rigUiInst.moduleSettingsLayout.itemAt(i).widget().setParent(None)

                            #relaunch the skeleton settings UI with new info
                            moduleInst.skeletonSettings_UI(modName)



        #delete the UI
        mayaWindow = interfaceUtils.getMainWindow()
        mayaWindow = mayaWindow.objectName()
        cmds.deleteUI(mayaWindow + "|" + windowObject)
Beispiel #3
0
    def populateTable(self):

        pixmap = QtGui.QPixmap(20, 20)
        pixmap.fill(QtGui.QColor(0, 255, 0))
        iconOn = QtGui.QIcon(pixmap)

        pixmapOff = QtGui.QPixmap(20, 20)
        pixmapOff.fill(QtGui.QColor(255, 0, 0))
        iconOff = QtGui.QIcon(pixmapOff)

        modules = utils.returnRigModules()
        self.modTable.setRowCount(100 + len(modules))
        counter = 0
        for module in modules:

            aimState = False
            pinState = False

            #get module name
            moduleName = cmds.getAttr(module + ".moduleName")

            if cmds.objExists(module + ".aimMode"):
                aimState = cmds.getAttr(module + ".aimMode")
            if cmds.objExists(module + ".pinned"):
                pinState = cmds.getAttr(module + ".pinned")

            moduleItem = QtWidgets.QTableWidgetItem(moduleName)
            self.modTable.setItem(counter, 0, moduleItem)

            if aimState:
                lockItem = QtWidgets.QTableWidgetItem(iconOn, "")
            else:
                lockItem = QtWidgets.QTableWidgetItem(iconOff, "")

            self.modTable.setItem(counter, 2, lockItem)

            if pinState:
                pinItem = QtWidgets.QTableWidgetItem(iconOn, "")
            else:
                pinItem = QtWidgets.QTableWidgetItem(iconOff, "")

            self.modTable.setItem(counter, 1, pinItem)

            counter += 1
Beispiel #4
0
    def symmetryMode_mirror(self):

        #find all items in the list
        items = self.symModeWin_moduleList.findItems('', QtCore.Qt.MatchRegExp)
        for each in items:
            itemWidget = self.symModeWin_moduleList.itemWidget(each)

            try:
                #get the layout of this widget
                layout = itemWidget.findChild(QtWidgets.QHBoxLayout)

                #find the checkbox
                state = False
                for i in range(layout.count()):
                    item = layout.itemAt(i)

                    if type(item.widget()) == QtWidgets.QCheckBox:
                        #get the checkbox state
                        state = item.widget().isChecked()

                    if type(item.widget()) == QtWidgets.QComboBox:
                        if state == True:
                            moduleName = item.widget().currentText()
                            modules = utils.returnRigModules()
                            for mod in modules:
                                modName = cmds.getAttr(mod + ".moduleName")

                                if modName == moduleName:
                                    modType = cmds.getAttr(mod + ".moduleType")
                                    importMod = __import__(
                                        "RigModules." + modType, {}, {},
                                        [modType])
                                    reload(importMod)

                                    moduleClass = getattr(
                                        importMod, importMod.className)
                                    moduleInst = moduleClass(
                                        self.mainUI, modName)
                                    moduleInst.mirrorTransformations()

            except:
                pass
Beispiel #5
0
    def applyModuleParentChange(self):
        """
        Gets the new parent from the selected ListWidgetItem text and then checks to make sure the selected parent
        isn't a bone that is part of the module we're trying to change the parent on. Then updates text and attribute
        values where needed.

        .. note::
            The following things get updated:
                  * Current Parent text item in the Skeleton Settings UI
                  * Network Node .parentModuleBone attribute
                  * Constrains nodes based on new parenting relationship

        """

        # get new parent
        newParent = self.boneList.currentItem().text()

        # check to make sure new parent is not in this module's created bones list
        createdBones = self.modInst.returnCreatedJoints

        if newParent in createdBones:
            cmds.confirmDialog(
                title="Error",
                icon="critical",
                message=
                "Cannot parent a module to a bone created by the module.")
            return

        # update current parent text
        self.modInst.currentParent.setText(newParent)

        # update network node parentModuleBone attribute
        networkNode = self.modInst.returnNetworkNode
        cmds.setAttr(networkNode + ".parentModuleBone", lock=False)
        cmds.setAttr(networkNode + ".parentModuleBone",
                     newParent,
                     type="string",
                     lock=True)

        # delete the existing bone connection and reparent to the new parent and recreate the bone connection
        if cmds.objExists(self.modInst.name + "_parentGrp"):
            cmds.delete(self.modInst.name + "_parentGrp")

            # parent under the new parent
            moverGrp = cmds.getAttr(networkNode + ".moduleName")
            moverGrp = moverGrp + "_mover_grp"

            if newParent == "root":
                mover = "root_mover"
                offsetMover = "root_mover"

            else:
                networkNodes = utils.returnRigModules()
                mover = utils.findMoverNodeFromJointName(
                    networkNodes, newParent, False, True)
                offsetMover = utils.findMoverNodeFromJointName(
                    networkNodes, newParent)

            # create the new bone representation
            childMover = utils.findOffsetMoverFromName(self.modInst.name)
            riggingUtils.createBoneConnection(offsetMover, childMover,
                                              self.modInst.name)

        # delete the old constraint and create the new one
        if cmds.objExists(self.modInst.name + "_mover_grp_parentConstraint*"):
            cmds.delete(self.modInst.name + "_mover_grp_parentConstraint*")

        networkNodes = utils.returnRigModules()
        mover = utils.findMoverNodeFromJointName(networkNodes, newParent,
                                                 False, True)
        if mover is not None:
            cmds.parentConstraint(mover,
                                  self.modInst.name + "_mover_grp",
                                  mo=True)

        if cmds.objExists(self.modInst.name + "_mover_grp_scaleConstraint*"):
            cmds.delete(self.modInst.name + "_mover_grp_scaleConstraint*")

        if mover is not None:
            cmds.scaleConstraint(mover,
                                 self.modInst.name + "_mover_grp",
                                 mo=True)

        # delete the UI
        mayaWindow = interfaceUtils.getMainWindow()
        mayaWindow = mayaWindow.objectName()
        cmds.deleteUI(mayaWindow + "|" + windowObject)

        cmds.select(clear=True)
Beispiel #6
0
    def applyModuleNameChange(self):
        """
        Checks to make sure a module doesn't exist with the new name, and if not, updates naming of the module in a
        multitude of places. Any UI elements, joint movers, attribute values (like .Created_Bones), etc.

        .. note::
            The following things get updated:
                  * QGroupBox label of the SkeletonSettingsUI
                  * Network Node .moduleName attribute
                  * Module Instance variable of self.name gets updated
                  * Created_Bones attribute values
                  * Joint Mover Nodes
                  * Rig Creator Outliner names for module
                  * Selection Script Job for outliner
                  * Any modules' attributes that have a value that matches the old name (like parent module bone)
                  * Any modules that are a mirror of this module, and their mirrorModule attribute value

        """

        # check to see if a module already has that name. If so, return out and do not continue
        modules = utils.returnRigModules()
        validName = False
        msg = "A module with that name already exists. Please enter a unique name for the module"

        for module in modules:
            name = cmds.getAttr(module + ".moduleName")
            if name == str(self.previewName.text()):
                cmds.confirmDialog(title="Name Exists",
                                   message=msg,
                                   icon="critical")
                return

        # update groupbox label
        originalName = self.modInst.groupBox.title()
        self.modInst.groupBox.setTitle(str(self.previewName.text()))

        # update network node moduleName attribute
        networkNode = self.modInst.returnNetworkNode
        cmds.setAttr(networkNode + ".moduleName", lock=False)
        cmds.setAttr(networkNode + ".moduleName",
                     str(self.previewName.text()),
                     type="string",
                     lock=True)

        # update self.name for rig module
        self.modInst.name = str(self.previewName.text())

        # update created bones attribute values
        prefix = str(self.prefix.text())
        suffix = str(self.suffix.text())

        if len(prefix) > 0:
            prefix += prefix + "_"
        if len(suffix) > 0:
            suffix = "_" + suffix

        createdBones = self.modInst.returnCreatedJoints

        attrString = ""

        for bone in createdBones:
            niceName = bone
            if len(bone) > 1:
                if self.prefixInc != "":
                    niceName = bone.partition(self.prefixInc)[2]
                if self.suffixInc != "":
                    niceName = niceName.partition(self.suffixInc)[0]

                attrString += prefix + niceName + suffix + "::"

        cmds.setAttr(networkNode + ".Created_Bones", lock=False)
        cmds.setAttr(networkNode + ".Created_Bones",
                     attrString,
                     type="string",
                     lock=True)

        # joint mover renaming
        cmds.select(originalName + "_mover_grp", hi=True)
        jointMoverNodes = cmds.ls(sl=True, type="transform")
        constraints = [
            "pointConstraint", "orientConstraint", "parentConstraint"
        ]

        for node in jointMoverNodes:
            try:
                if cmds.nodeType(node) not in constraints:
                    locked = cmds.lockNode(node, q=True)
                    if locked:
                        cmds.lockNode(node, lock=False)
                    nodeName = node.partition(originalName)[2]
                    newName = self.modInst.name + nodeName
                    cmds.rename(node, newName)

                    if locked:
                        cmds.lockNode(node, lock=True)
            except Exception, e:
                pass
Beispiel #7
0
    def buildResetModeUI(self, mainUI):

        if cmds.window("ART_ResetModeWin", exists=True):
            cmds.deleteUI("ART_ResetModeWin", wnd=True)

        #launch a UI to get the name information
        self.resetModeWin = QtWidgets.QMainWindow(mainUI)

        #load stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.resetModeWin.setStyleSheet(self.style)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        #create the main widget
        self.resetModeWin_mainWidget = QtWidgets.QWidget()
        self.resetModeWin.setCentralWidget(self.resetModeWin_mainWidget)

        #set qt object name
        self.resetModeWin.setObjectName("ART_ResetModeWin")
        self.resetModeWin.setWindowTitle("Reset Modules")

        #create the mainLayout for the rig creator UI
        self.resetModeWin_mainLayout = QtWidgets.QVBoxLayout(
            self.resetModeWin_mainWidget)
        self.resetModeWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.resetModeWin.resize(400, 250)
        self.resetModeWin.setSizePolicy(mainSizePolicy)
        self.resetModeWin.setMinimumSize(QtCore.QSize(400, 250))
        self.resetModeWin.setMaximumSize(QtCore.QSize(400, 250))

        #create the background image
        self.resetModeWin_frame = QtWidgets.QFrame()
        self.resetModeWin_mainLayout.addWidget(self.resetModeWin_frame)

        #create the layout for the widgets
        self.resetModeWin_widgetLayout = QtWidgets.QHBoxLayout(
            self.resetModeWin_frame)
        self.resetModeWin_widgetLayout.setContentsMargins(5, 5, 5, 5)

        #add the QListWidget Frame
        self.resetModeWin_moduleListFrame = QtWidgets.QFrame()
        self.resetModeWin_moduleListFrame.setMinimumSize(QtCore.QSize(
            275, 200))
        self.resetModeWin_moduleListFrame.setMaximumSize(QtCore.QSize(
            275, 200))
        self.resetModeWin_moduleListFrame.setContentsMargins(20, 0, 20, 0)

        #create the list widget
        self.resetModeWin_moduleList = QtWidgets.QListWidget(
            self.resetModeWin_moduleListFrame)
        self.resetModeWin_widgetLayout.addWidget(
            self.resetModeWin_moduleListFrame)
        self.resetModeWin_moduleList.setMinimumSize(QtCore.QSize(265, 200))
        self.resetModeWin_moduleList.setMaximumSize(QtCore.QSize(265, 200))
        self.resetModeWin_moduleList.setSelectionMode(
            QtWidgets.QAbstractItemView.MultiSelection)
        self.resetModeWin_moduleList.setSpacing(3)

        #add the layout for the buttons
        self.resetModeWin_buttonLayoutAll = QtWidgets.QVBoxLayout()
        self.resetModeWin_widgetLayout.addLayout(
            self.resetModeWin_buttonLayoutAll)
        self.resetModeWin_buttonLayoutAll.setContentsMargins(5, 20, 5, 20)

        #button background image
        image = utils.returnNicePath(self.iconsPath,
                                     "System/blue_field_background.png")

        #add the selection buttons
        self.resetModeWin_selectionButtonLayout = QtWidgets.QVBoxLayout()
        self.resetModeWin_buttonLayoutAll.addLayout(
            self.resetModeWin_selectionButtonLayout)
        self.resetModeWin_selectAllButton = QtWidgets.QPushButton("Select All")
        self.resetModeWin_selectAllButton.setMinimumSize(QtCore.QSize(115, 25))
        self.resetModeWin_selectAllButton.setMaximumSize(QtCore.QSize(115, 25))
        self.resetModeWin_selectionButtonLayout.addWidget(
            self.resetModeWin_selectAllButton)
        self.resetModeWin_selectAllButton.clicked.connect(
            self.resetModeWin_moduleList.selectAll)
        self.resetModeWin_selectAllButton.setObjectName("blueButton")

        self.resetModeWin_selectNoneButton = QtWidgets.QPushButton(
            "Clear Selection")
        self.resetModeWin_selectNoneButton.setMinimumSize(QtCore.QSize(
            115, 25))
        self.resetModeWin_selectNoneButton.setMaximumSize(QtCore.QSize(
            115, 25))
        self.resetModeWin_selectionButtonLayout.addWidget(
            self.resetModeWin_selectNoneButton)
        self.resetModeWin_selectNoneButton.clicked.connect(
            self.resetModeWin_moduleList.clearSelection)
        self.resetModeWin_selectNoneButton.setObjectName("blueButton")

        #spacer
        spacerItem = QtWidgets.QSpacerItem(20, 80,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.resetModeWin_selectionButtonLayout.addItem(spacerItem)

        #add the buttons for reset settings and reset transforms
        self.resetModeWin_resetSettings = QtWidgets.QPushButton(
            "Reset Settings")
        self.resetModeWin_resetSettings.setMinimumSize(QtCore.QSize(115, 25))
        self.resetModeWin_resetSettings.setMaximumSize(QtCore.QSize(115, 25))
        self.resetModeWin_selectionButtonLayout.addWidget(
            self.resetModeWin_resetSettings)
        self.resetModeWin_resetSettings.clicked.connect(
            partial(self.resetMode_resetSettings))
        self.resetModeWin_resetSettings.setObjectName("blueButton")

        self.resetModeWin_resetXforms = QtWidgets.QPushButton("Reset Xforms")
        self.resetModeWin_resetXforms.setMinimumSize(QtCore.QSize(115, 25))
        self.resetModeWin_resetXforms.setMaximumSize(QtCore.QSize(115, 25))
        self.resetModeWin_selectionButtonLayout.addWidget(
            self.resetModeWin_resetXforms)
        self.resetModeWin_resetXforms.clicked.connect(
            partial(self.resetMode_resetXformsUI))
        self.resetModeWin_resetXforms.setObjectName("blueButton")

        #populate the list widget
        modules = utils.returnRigModules()
        for module in modules:
            moduleName = cmds.getAttr(module + ".moduleName")
            self.resetModeWin_moduleList.addItem(moduleName)

        #show the window
        self.resetModeWin.show()
Beispiel #8
0
    def buildSymmetryModeUI(self, mainUI):

        if cmds.window("ART_SymmetryModeWin", exists=True):
            cmds.deleteUI("ART_SymmetryModeWin", wnd=True)

        #launch a UI to get the name information
        self.symmetryModeWin = QtWidgets.QMainWindow(mainUI)

        #load stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        style = f.read()
        f.close()

        self.symmetryModeWin.setStyleSheet(style)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        #create the main widget
        self.symModeWin_mainWidget = QtWidgets.QWidget()
        self.symmetryModeWin.setCentralWidget(self.symModeWin_mainWidget)

        #set qt object name
        self.symmetryModeWin.setObjectName("ART_SymmetryModeWin")
        self.symmetryModeWin.setWindowTitle("Mass Mirror Mode")

        #create the mainLayout for the rig creator UI
        self.symModeWin_mainLayout = QtWidgets.QVBoxLayout(
            self.symModeWin_mainWidget)
        self.symModeWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.symmetryModeWin.setSizePolicy(mainSizePolicy)
        self.symmetryModeWin.setMinimumSize(QtCore.QSize(600, 250))
        self.symmetryModeWin.setMaximumSize(QtCore.QSize(600, 250))

        #create the background
        self.symModeWin_frame = QtWidgets.QFrame()
        self.symModeWin_frame.setObjectName("mid")
        self.symModeWin_mainLayout.addWidget(self.symModeWin_frame)

        #create the layout for the widgets
        self.symModeWin_widgetLayout = QtWidgets.QHBoxLayout(
            self.symModeWin_frame)
        self.symModeWin_widgetLayout.setContentsMargins(5, 5, 5, 5)

        #add the QListWidget Frame
        self.symModeWin_moduleListFrame = QtWidgets.QFrame()
        self.symModeWin_moduleListFrame.setObjectName("mid")
        self.symModeWin_moduleListFrame.setMinimumSize(QtCore.QSize(450, 200))
        self.symModeWin_moduleListFrame.setMaximumSize(QtCore.QSize(450, 200))
        self.symModeWin_moduleListFrame.setContentsMargins(20, 0, 20, 0)

        #create the list widget
        self.symModeWin_moduleList = QtWidgets.QListWidget(
            self.symModeWin_moduleListFrame)
        self.symModeWin_widgetLayout.addWidget(self.symModeWin_moduleListFrame)
        self.symModeWin_moduleList.setMinimumSize(QtCore.QSize(450, 200))
        self.symModeWin_moduleList.setMaximumSize(QtCore.QSize(450, 200))
        self.symModeWin_moduleList.setSelectionMode(
            QtWidgets.QAbstractItemView.NoSelection)
        self.symModeWin_moduleList.setSpacing(3)

        #add the layout for the buttons
        self.symModeWin_buttonLayoutAll = QtWidgets.QVBoxLayout()
        self.symModeWin_widgetLayout.addLayout(self.symModeWin_buttonLayoutAll)
        self.symModeWin_buttonLayoutAll.setContentsMargins(5, 20, 5, 20)

        #add the selection buttons
        self.symModeWin_selectionButtonLayout = QtWidgets.QVBoxLayout()
        self.symModeWin_buttonLayoutAll.addLayout(
            self.symModeWin_selectionButtonLayout)
        self.symModeWin_selectAllButton = QtWidgets.QPushButton("Select All")
        self.symModeWin_selectAllButton.setMinimumSize(QtCore.QSize(115, 25))
        self.symModeWin_selectAllButton.setMaximumSize(QtCore.QSize(115, 25))
        self.symModeWin_selectionButtonLayout.addWidget(
            self.symModeWin_selectAllButton)
        self.symModeWin_selectAllButton.clicked.connect(
            partial(self.symmetryMode_selectDeselect, True))
        self.symModeWin_selectAllButton.setObjectName("blueButton")

        self.symModeWin_selectNoneButton = QtWidgets.QPushButton(
            "Clear Selection")
        self.symModeWin_selectNoneButton.setMinimumSize(QtCore.QSize(115, 25))
        self.symModeWin_selectNoneButton.setMaximumSize(QtCore.QSize(115, 25))
        self.symModeWin_selectionButtonLayout.addWidget(
            self.symModeWin_selectNoneButton)
        self.symModeWin_selectNoneButton.clicked.connect(
            partial(self.symmetryMode_selectDeselect, False))
        self.symModeWin_selectNoneButton.setObjectName("blueButton")

        #spacer
        spacerItem = QtWidgets.QSpacerItem(20, 40,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.symModeWin_buttonLayoutAll.addItem(spacerItem)

        #add the mirror buttons
        self.symModeWin_mirrorButtonLayout = QtWidgets.QVBoxLayout()
        self.symModeWin_buttonLayoutAll.addLayout(
            self.symModeWin_mirrorButtonLayout)
        self.symModeWin_mirrorL2RButton = QtWidgets.QPushButton(
            "Mirror Checked")
        self.symModeWin_mirrorL2RButton.setToolTip(
            "Mirror selected modules to unselected modules")

        self.symModeWin_mirrorL2RButton.setMinimumSize(QtCore.QSize(115, 25))
        self.symModeWin_mirrorL2RButton.setMaximumSize(QtCore.QSize(115, 25))
        self.symModeWin_mirrorButtonLayout.addWidget(
            self.symModeWin_mirrorL2RButton)
        self.symModeWin_mirrorL2RButton.setObjectName("blueButton")

        self.symModeWin_mirrorL2RButton.clicked.connect(
            partial(self.symmetryMode_mirror))

        #populate the list widget
        modules = utils.returnRigModules()
        entries = []
        listMods = []

        for mod in modules:
            modName = cmds.getAttr(mod + ".moduleName")
            mirrorModule = cmds.getAttr(mod + ".mirrorModule")
            invalidTypes = [None, "None"]
            if mirrorModule not in invalidTypes:
                if modName not in listMods:
                    entries.append([modName, mirrorModule])
                    listMods.append(modName)
                    listMods.append(mirrorModule)

        self.symModeWinModues = {}

        if len(entries) == 0:
            item = QtWidgets.QListWidgetItem(self.symModeWin_moduleList)
            label = QtWidgets.QLabel("No modules with mirroring setup")
            item.setSizeHint(label.sizeHint())
            self.symModeWin_moduleList.addItem(item)
            self.symModeWin_moduleList.setItemWidget(item, label)

        for each in entries:

            #create a custom widget to add to each entry in the listWidget
            mainWidget = QtWidgets.QWidget()
            buttonLayout = QtWidgets.QHBoxLayout(mainWidget)

            #create the checkbox
            checkbox = QtWidgets.QCheckBox()
            checkbox.setMinimumSize(QtCore.QSize(12, 12))
            checkbox.setMaximumSize(QtCore.QSize(12, 12))
            checkbox.setChecked(True)
            buttonLayout.addWidget(checkbox)

            label = QtWidgets.QLabel("Mirror ")
            buttonLayout.addWidget(label)

            mirrorFrom = QtWidgets.QComboBox()
            mirrorFrom.addItem(each[0])
            mirrorFrom.addItem(each[1])
            buttonLayout.addWidget(mirrorFrom)
            mirrorFrom.setMinimumWidth(150)

            label = QtWidgets.QLabel(" To ")
            buttonLayout.addWidget(label)
            label.setAlignment(QtCore.Qt.AlignCenter)

            mirrorTo = QtWidgets.QComboBox()
            mirrorTo.addItem(each[1])
            mirrorTo.addItem(each[0])
            buttonLayout.addWidget(mirrorTo)
            mirrorTo.setMinimumWidth(150)

            #signal/slots
            mirrorFrom.currentIndexChanged.connect(
                partial(self.toggleComboBoxFrom, mirrorFrom, mirrorTo))
            mirrorTo.currentIndexChanged.connect(
                partial(self.toggleComboBoxTo, mirrorFrom, mirrorTo))

            #add this item widget to the list
            item = QtWidgets.QListWidgetItem(self.symModeWin_moduleList)
            index = entries.index(each)
            if (index % 2) == 0:
                item.setBackground(QtGui.QColor(106, 106, 108))
            else:
                item.setBackground(QtGui.QColor(46, 46, 48))

            item.setSizeHint(mainWidget.sizeHint())
            self.symModeWin_moduleList.addItem(item)
            self.symModeWin_moduleList.setItemWidget(item, mainWidget)

        #show the window
        self.symmetryModeWin.show()
Beispiel #9
0
    def buildAimModeUI(self):
        """
        Builds the Aim Mode interface, finding all modules that have the ability to aim, and listing those modules
        as well as their current aim status.

        """

        if cmds.window("ART_AimModeWin", exists=True):
            cmds.deleteUI("ART_AimModeWin", wnd=True)

        # launch a UI to get the name information
        self.aimModeWin = QtWidgets.QMainWindow(self.mainUI)

        # load stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.aimModeWin.setStyleSheet(self.style)

        # size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        # create the main widget
        self.aimModeWin_mainWidget = QtWidgets.QWidget()
        self.aimModeWin.setCentralWidget(self.aimModeWin_mainWidget)

        # set qt object name
        self.aimModeWin.setObjectName("ART_AimModeWin")
        self.aimModeWin.setWindowTitle("Aim Mode")

        # create the mainLayout for the rig creator UI
        self.aimModeWin_mainLayout = QtWidgets.QVBoxLayout(
            self.aimModeWin_mainWidget)
        self.aimModeWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.aimModeWin.resize(400, 250)
        self.aimModeWin.setSizePolicy(mainSizePolicy)
        self.aimModeWin.setMinimumSize(QtCore.QSize(400, 250))
        self.aimModeWin.setMaximumSize(QtCore.QSize(400, 250))

        # create the background image
        self.aimModeWin_frame = QtWidgets.QFrame()
        self.aimModeWin_mainLayout.addWidget(self.aimModeWin_frame)

        # create the layout for the widgets
        self.aimModeWin_widgetLayout = QtWidgets.QHBoxLayout(
            self.aimModeWin_frame)
        self.aimModeWin_widgetLayout.setContentsMargins(5, 5, 5, 5)

        # add the QListWidget Frame
        self.aimModeWin_moduleListFrame = QtWidgets.QFrame()
        self.aimModeWin_moduleListFrame.setMinimumSize(QtCore.QSize(275, 200))
        self.aimModeWin_moduleListFrame.setMaximumSize(QtCore.QSize(275, 200))
        self.aimModeWin_moduleListFrame.setContentsMargins(20, 0, 20, 0)

        # create the list widget
        self.aimModeWin_moduleList = QtWidgets.QListWidget(
            self.aimModeWin_moduleListFrame)
        self.aimModeWin_widgetLayout.addWidget(self.aimModeWin_moduleListFrame)
        self.aimModeWin_moduleList.setMinimumSize(QtCore.QSize(265, 200))
        self.aimModeWin_moduleList.setMaximumSize(QtCore.QSize(265, 200))
        self.aimModeWin_moduleList.setSelectionMode(
            QtWidgets.QAbstractItemView.MultiSelection)
        self.aimModeWin_moduleList.setSpacing(3)

        # add the layout for the buttons
        self.aimModeWin_buttonLayoutAll = QtWidgets.QVBoxLayout()
        self.aimModeWin_widgetLayout.addLayout(self.aimModeWin_buttonLayoutAll)
        self.aimModeWin_buttonLayoutAll.setContentsMargins(5, 20, 5, 20)

        # add the selection buttons
        self.aimModeWin_selectionButtonLayout = QtWidgets.QVBoxLayout()
        self.aimModeWin_buttonLayoutAll.addLayout(
            self.aimModeWin_selectionButtonLayout)
        self.aimModeWin_selectAllButton = QtWidgets.QPushButton("Select All")
        self.aimModeWin_selectAllButton.setMinimumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectAllButton.setMaximumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectionButtonLayout.addWidget(
            self.aimModeWin_selectAllButton)
        self.aimModeWin_selectAllButton.clicked.connect(
            self.aimModeWin_moduleList.selectAll)
        self.aimModeWin_selectAllButton.setObjectName("blueButton")

        self.aimModeWin_selectNoneButton = QtWidgets.QPushButton(
            "Clear Selection")
        self.aimModeWin_selectNoneButton.setMinimumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectNoneButton.setMaximumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectionButtonLayout.addWidget(
            self.aimModeWin_selectNoneButton)
        self.aimModeWin_selectNoneButton.clicked.connect(
            self.aimModeWin_moduleList.clearSelection)
        self.aimModeWin_selectNoneButton.setObjectName("blueButton")

        # spacer
        spacerItem = QtWidgets.QSpacerItem(20, 80,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.aimModeWin_selectionButtonLayout.addItem(spacerItem)

        # add the buttons for reset settings and reset transforms
        self.aimModeWin_turnOnAim = QtWidgets.QPushButton("On")
        self.aimModeWin_turnOnAim.setMinimumSize(QtCore.QSize(115, 25))
        self.aimModeWin_turnOnAim.setMaximumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectionButtonLayout.addWidget(
            self.aimModeWin_turnOnAim)
        self.aimModeWin_turnOnAim.setToolTip(
            "Turn on Aim Mode for selected modules.")
        self.aimModeWin_turnOnAim.clicked.connect(
            partial(self.aimModeUI_Toggle, True))
        self.aimModeWin_turnOnAim.setObjectName("blueButton")

        self.aimModeWin_turnOffAim = QtWidgets.QPushButton("Off")
        self.aimModeWin_turnOffAim.setMinimumSize(QtCore.QSize(115, 25))
        self.aimModeWin_turnOffAim.setMaximumSize(QtCore.QSize(115, 25))
        self.aimModeWin_selectionButtonLayout.addWidget(
            self.aimModeWin_turnOffAim)
        self.aimModeWin_turnOffAim.setToolTip(
            "Turn off Aim Mode for selected modules.")
        self.aimModeWin_turnOffAim.clicked.connect(
            partial(self.aimModeUI_Toggle, False))
        self.aimModeWin_turnOffAim.setObjectName("blueButton")

        # populate the list widget
        modules = utils.returnRigModules()
        for module in modules:
            # get module name
            moduleName = cmds.getAttr(module + ".moduleName")

            # figure out if the module supports aimMode
            canAim = False
            if cmds.objExists(module + ".canAim"):
                canAim = cmds.getAttr(module + ".canAim")

                # see if it is currently in aimMode
                aimMode = cmds.getAttr(module + ".aimMode")

            # if it does, add it to the listwidget
            if canAim:

                # font
                headerFont = QtGui.QFont()
                headerFont.setPointSize(10)
                headerFont.setBold(True)

                # create the listWidgetItem
                pixmap = QtGui.QPixmap(10, 10)
                pixmap.fill(QtGui.QColor(0, 255, 0))
                icon = QtGui.QIcon(pixmap)

                pixmapOff = QtGui.QPixmap(10, 10)
                pixmapOff.fill(QtGui.QColor(255, 0, 0))
                iconOff = QtGui.QIcon(pixmapOff)

                item = QtWidgets.QListWidgetItem(iconOff, moduleName)
                item.setFont(headerFont)
                item.setTextAlignment(QtCore.Qt.AlignCenter)
                item.setData(QtCore.Qt.UserRole, [icon, iconOff])

                if aimMode:
                    item.setIcon(icon)

                self.aimModeWin_moduleList.addItem(item)

        # show the window
        self.aimModeWin.show()
Beispiel #10
0
    def buildBoneCounterUI(self):
        """
        Builds the interface for the bone counter tool, which is comprised off a QLineEdit that shows the current
        bone count, a QPushButton to launch another simple UI that allows the user to set a bone count target,
        and QProgressBar that shows a percentage to target bone count.

        .. seealso:: ART_BoneCounter.setBoneCountTarget

        """

        if cmds.window("ART_BoneCounterWin", exists=True):
            cmds.deleteUI("ART_BoneCounterWin", wnd=True)

        # launch a UI to get the name information
        self.boneCounterWin = QtWidgets.QMainWindow(self.mainUI)

        # size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        # create the main widget
        self.boneCounterWin_mainWidget = QtWidgets.QWidget()
        self.boneCounterWin.setCentralWidget(self.boneCounterWin_mainWidget)

        # set qt object name
        self.boneCounterWin.setObjectName("ART_BoneCounterWin")
        self.boneCounterWin.setWindowTitle("Bone Counter")

        # create the mainLayout for the rig creator UI
        self.boneCounterWin_mainLayout = QtWidgets.QVBoxLayout(self.boneCounterWin_mainWidget)
        self.boneCounterWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.boneCounterWin.resize(300, 100)
        self.boneCounterWin.setSizePolicy(mainSizePolicy)
        self.boneCounterWin.setMinimumSize(QtCore.QSize(300, 100))
        self.boneCounterWin.setMaximumSize(QtCore.QSize(300, 100))

        headerFont = QtGui.QFont()
        headerFont.setPointSize(8)
        headerFont.setBold(True)

        # load toolbar stylesheet
        styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        # create the bone counter stylesheet
        self.progBarStyle = """
        QProgressBar{
            border: 2px solid black;
            border-radius: 5px;
            text-align: center;
            font: 87 10pt "Arial";
            color: rgb(255,255,255);
        }

        QProgressBar::chunk {
            background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(25,175,255), stop:1 rgb(9,62,98));
            width: 10px;
            margin: 0.5px;
        }
        """

        self.progBarStyleMax = """
        QProgressBar{
            border: 2px solid black;
            border-radius: 5px;
            text-align: center;
            font: 87 10pt "Arial Black";
            color: rgb(255,255,255);
        }

        QProgressBar::chunk {
            background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(255,174,0), stop:1 rgb(30,30,30));
            width: 10px;
            margin: 0.5px;
        }
        """

        # create the background image
        self.boneCounterWin_frame = QtWidgets.QFrame()
        self.boneCounterWin_mainLayout.addWidget(self.boneCounterWin_frame)
        self.boneCounterWin_frame.setObjectName("mid")
        self.boneCounterWin.setStyleSheet(self.style)

        # create the layout for the widgets
        self.boneCounterWin_widgetLayoutMain = QtWidgets.QVBoxLayout(self.boneCounterWin_frame)
        self.boneCounterWin_widgetLayoutMain.setContentsMargins(5, 5, 5, 5)
        self.boneCounterWin_widgetLayout = QtWidgets.QHBoxLayout()
        self.boneCounterWin_widgetLayoutMain.addLayout(self.boneCounterWin_widgetLayout)

        # label creation
        self.boneCount = QtWidgets.QLabel("Bone Count:      ")
        self.boneCount.setFont(headerFont)
        self.boneCounterWin_widgetLayout.addWidget(self.boneCount)

        self.boneCounter = QtWidgets.QSpinBox()
        self.boneCounter.setReadOnly(True)
        self.boneCounter.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
        self.boneCounter.setRange(1, 9999)
        self.boneCounter.setMinimumWidth(60)
        self.boneCounter.setMaximumWidth(60)
        self.boneCounterWin_widgetLayout.addWidget(self.boneCounter)

        # create the button
        self.boneMaxButton = QtWidgets.QPushButton("Set Target")
        self.boneCounterWin_widgetLayout.addWidget(self.boneMaxButton)
        self.boneMaxButton.clicked.connect(partial(self.setBoneCountTarget))
        self.boneMaxButton.setMinimumHeight(30)
        self.boneMaxButton.setStyleSheet(self.style)
        self.boneMaxButton.setObjectName("blueButton")

        # add the progress bar
        self.boneCountBar = QtWidgets.QProgressBar()
        self.boneCounterWin_widgetLayoutMain.addWidget(self.boneCountBar)
        self.boneCountBar.setValue(1)
        self.boneCountBar.setStyleSheet(self.progBarStyle)
        self.boneCountBar.setRange(0, 100)
        self.boneCountBar.setFormat("target = %m")

        # add the max range of the progress bar to the main network node
        if cmds.objExists("ART_Root_Module.target"):
            value = cmds.getAttr("ART_Root_Module.target")
            currentValue = self.boneCountBar.value()
            self.boneCountBar.setMaximum(value)

            if value < currentValue:
                self.boneCountBar.setValue(value)

            if currentValue <= value:
                self.boneCountBar.setStyleSheet(self.progBarStyle)
            if currentValue > value:
                self.boneCountBar.setStyleSheet(self.progBarStyleMax)

        else:
            cmds.addAttr("ART_Root_Module", sn="target", keyable=False)
            cmds.setAttr("ART_Root_Module.target", 100, lock=True)

        # get the current bone count
        modules = utils.returnRigModules()
        allBones = []
        for module in modules:
            joints = cmds.getAttr(module + ".Created_Bones")
            splitJoints = joints.split("::")

            for bone in splitJoints:
                if bone != "":
                    allBones.append(bone)

        # update the spinBox and progress bar
        self.boneCounter.setValue(len(allBones))
        max = self.boneCountBar.maximum()

        if len(allBones) <= max:
            self.boneCountBar.setValue(len(allBones))
            self.boneCountBar.setStyleSheet(self.progBarStyle)
        if len(allBones) > max:
            self.boneCountBar.setValue(max)
            self.boneCountBar.setStyleSheet(self.progBarStyleMax)

        # show window
        self.boneCounterWin.show()
Beispiel #11
0
    def __init__(self, moduleInst, rigUiInst, parent = None):


        super(ART_SetMirrorModule_UI, 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")

        #create class variables
        self.modInst = moduleInst
        self.rigUiInst = rigUiInst


        #load stylesheet
        styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        style = f.read()
        f.close()

        self.setStyleSheet(style)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        #create the main widget
        self.mainWidget = QtWidgets.QWidget()
        self.setCentralWidget(self.mainWidget)

        #set qt object name
        self.setObjectName(windowObject)
        self.setWindowTitle(windowTitle)

        #create the mainLayout for the rig creator UI
        self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.setSizePolicy(mainSizePolicy)
        self.setMinimumSize(QtCore.QSize( 250, 200 ))
        self.setMaximumSize(QtCore.QSize( 250, 200 ))

        #create the background image
        self.frame = QtWidgets.QFrame()
        self.mainLayout.addWidget(self.frame)

        #create the layout for the widgets
        self.widgetLayout = QtWidgets.QVBoxLayout(self.frame)


        label = QtWidgets.QLabel("Choose Mirror Module:")
        self.widgetLayout.addWidget(label)
        font = QtGui.QFont()
        font.setBold(True)

        self.moduleList = QtWidgets.QListWidget()
        self.moduleList.addItem("None")
        self.widgetLayout.addWidget(self.moduleList)


        #add items to comboBox
        networkNode = self.modInst.returnNetworkNode
        modules = utils.returnRigModules()
        for mod in modules:
            modName = cmds.getAttr(mod + ".moduleName")
            modType = cmds.getAttr(mod + ".moduleType")

            if modType == cmds.getAttr(networkNode + ".moduleType"):
                if mod != networkNode:
                    self.moduleList.addItem(modName)

        self.moduleList.setCurrentRow(0)



        spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.widgetLayout.addItem(spacerItem1)


        #update button
        self.updateBtn = QtWidgets.QPushButton("UPDATE")
        self.widgetLayout.addWidget(self.updateBtn)
        self.updateBtn.setMinimumSize(QtCore.QSize(230, 40))
        self.updateBtn.setMaximumSize(QtCore.QSize(230, 40))
        self.updateBtn.setSizePolicy(mainSizePolicy)
        font = QtGui.QFont()
        font.setPointSize(12)
        self.updateBtn.setFont(font)
        self.updateBtn.setObjectName("blueButton")

        #hookup signal/slot on create button
        self.updateBtn.clicked.connect(self.setMirrorModule)
Beispiel #12
0
    def buildUI(self):

        if cmds.window("ART_PinModulesWin", exists = True):
            cmds.deleteUI("ART_PinModulesWin", wnd = True)

        #launch a UI to get the name information
        self.window = QtWidgets.QMainWindow(self.mainUI)

        #load stylesheet
        styleSheetFile = utils.returnNicePath(self.toolsPath, "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.window.setStyleSheet(self.style)

        #size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        #create the main widget
        self.mainWidget = QtWidgets.QWidget()
        self.window.setCentralWidget(self.mainWidget)

        #set qt object name
        self.window.setObjectName("ART_PinModulesWin")
        self.window.setWindowTitle("Pin Modules")

        #create the mainLayout for the rig creator UI
        self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)

        self.window.resize(400, 250)
        self.window.setSizePolicy(mainSizePolicy)
        self.window.setMinimumSize(QtCore.QSize( 400, 250 ))
        self.window.setMaximumSize(QtCore.QSize( 400, 250 ))

        #create the background image
        self.frame = QtWidgets.QFrame()
        self.mainLayout.addWidget(self.frame)

        #create the layout for the widgets
        self.widgetLayout = QtWidgets.QHBoxLayout(self.frame)
        self.widgetLayout.setContentsMargins(5, 5, 5, 5)


        #left side == list of modules in scene. for each item in list, will do something similar to aim mode, where we will toggle an icon for pin state
        self.moduleList = QtWidgets.QListWidget()
        self.widgetLayout.addWidget(self.moduleList)
        self.moduleList.setMinimumSize(QtCore.QSize( 265, 200 ))
        self.moduleList.setMaximumSize(QtCore.QSize( 265, 200 ))
        self.moduleList.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
        self.moduleList.setSpacing(3)

        #right side layout == select all, clear selection, Pin Selected buttons
        self.buttonLayout = QtWidgets.QVBoxLayout()
        self.widgetLayout.addLayout(self.buttonLayout)
        self.buttonLayout.setContentsMargins(5, 20, 5, 20)

        #add the selection buttons
        self.selectAllButton = QtWidgets.QPushButton("Select All")
        self.selectAllButton.setMinimumSize(QtCore.QSize( 115, 25 ))
        self.selectAllButton.setMaximumSize(QtCore.QSize( 115, 25 ))
        self.buttonLayout.addWidget(self.selectAllButton)
        self.selectAllButton.clicked.connect(self.moduleList.selectAll)
        self.selectAllButton.setObjectName("blueButton")

        self.selectNoneButton = QtWidgets.QPushButton("Clear Selection")
        self.selectNoneButton.setMinimumSize(QtCore.QSize( 115, 25 ))
        self.selectNoneButton.setMaximumSize(QtCore.QSize( 115, 25 ))
        self.buttonLayout.addWidget(self.selectNoneButton)
        self.selectNoneButton.clicked.connect(self.moduleList.clearSelection)
        self.selectNoneButton.setObjectName("blueButton")

        #spacer
        spacerItem = QtWidgets.QSpacerItem(20, 80, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.buttonLayout.addItem(spacerItem)

        #add the buttons for reset settings and reset transforms
        self.pinBtn = QtWidgets.QPushButton("Pin Selected")
        self.pinBtn.setMinimumSize(QtCore.QSize( 115, 25 ))
        self.pinBtn.setMaximumSize(QtCore.QSize( 115, 25 ))
        self.buttonLayout.addWidget(self.pinBtn)
        self.pinBtn.setToolTip("Pin the selected modules so that parent module movements do not effect the pinned module")
        self.pinBtn.clicked.connect(partial(self.toggleLock, True))
        self.pinBtn.setObjectName("blueButton")

        self.unpinBtn = QtWidgets.QPushButton("Unpin Selected")
        self.unpinBtn.setMinimumSize(QtCore.QSize( 115, 25 ))
        self.unpinBtn.setMaximumSize(QtCore.QSize( 115, 25 ))
        self.buttonLayout.addWidget(self.unpinBtn)
        self.unpinBtn.setToolTip("Unpin modules to resume normal module behavior")
        self.unpinBtn.clicked.connect(partial(self.toggleLock, False))
        self.unpinBtn.setObjectName("blueButton")



        #populate the list widget
        modules = utils.returnRigModules()
        for module in modules:
            #get module name
            moduleName = cmds.getAttr(module + ".moduleName")

            #font
            headerFont = QtGui.QFont()
            headerFont.setPointSize(10)
            headerFont.setBold(True)

            #create the listWidgetItem
            icon = QtGui.QIcon(os.path.join(self.iconsPath, "System/locked.png"))
            iconOff = QtGui.QIcon(os.path.join(self.iconsPath, "System/unlocked.png"))

            item = QtWidgets.QListWidgetItem(iconOff, "    " + moduleName)
            item.setFont(headerFont)
            item.setData(QtCore.Qt.UserRole, [icon, iconOff])

            pinState = cmds.getAttr(module + ".pinned")
            if pinState:
                item.setIcon(icon)


            self.moduleList.addItem(item)


        #show the window
        self.window.show()
Beispiel #13
0
    def buildBakeOffsetsUI(self):
        """
        Builds the interface, finding all modules and listing them for selection.

        """

        if cmds.window("ART_BakeOffsetsWin", exists=True):
            cmds.deleteUI("ART_BakeOffsetsWin", wnd=True)

        # launch a UI to get the name information
        self.bakeOffsetsWin = QtWidgets.QMainWindow(self.mainUI)

        # load stylesheet
        styleSheetFile = utils.returnNicePath(
            self.toolsPath,
            "Core/Scripts/Interfaces/StyleSheets/mainScheme.qss")
        f = open(styleSheetFile, "r")
        self.style = f.read()
        f.close()

        self.bakeOffsetsWin.setStyleSheet(self.style)

        # size policies
        mainSizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                               QtWidgets.QSizePolicy.Fixed)

        # create the main widget
        self.bakeOffsetsWin_mainWidget = QtWidgets.QWidget()
        self.bakeOffsetsWin.setCentralWidget(self.bakeOffsetsWin_mainWidget)

        # set qt object name
        self.bakeOffsetsWin.setObjectName("ART_BakeOffsetsWin")
        self.bakeOffsetsWin.setWindowTitle("Bake Offsets")

        # create the mainLayout for the rig creator UI
        self.bakeOffsetsWin_mainLayout = QtWidgets.QVBoxLayout(
            self.bakeOffsetsWin_mainWidget)
        self.bakeOffsetsWin_mainLayout.setContentsMargins(0, 0, 0, 0)

        self.bakeOffsetsWin.resize(400, 250)
        self.bakeOffsetsWin.setSizePolicy(mainSizePolicy)
        self.bakeOffsetsWin.setMinimumSize(QtCore.QSize(400, 250))
        self.bakeOffsetsWin.setMaximumSize(QtCore.QSize(400, 250))

        # create the background
        self.bakeOffsetsWin_frame = QtWidgets.QFrame()
        self.bakeOffsetsWin_mainLayout.addWidget(self.bakeOffsetsWin_frame)

        # create the layout for the widgets
        self.bakeOffsetsWin_widgetLayout = QtWidgets.QHBoxLayout(
            self.bakeOffsetsWin_frame)
        self.bakeOffsetsWin_widgetLayout.setContentsMargins(5, 5, 5, 5)

        # add the QListWidget Frame
        self.bakeOffsetsWin_moduleListFrame = QtWidgets.QFrame()
        self.bakeOffsetsWin_moduleListFrame.setMinimumSize(
            QtCore.QSize(265, 200))
        self.bakeOffsetsWin_moduleListFrame.setMaximumSize(
            QtCore.QSize(265, 200))
        self.bakeOffsetsWin_moduleListFrame.setContentsMargins(20, 0, 20, 0)

        # create the list widget
        self.bakeOffsetsWin_moduleList = QtWidgets.QListWidget(
            self.bakeOffsetsWin_moduleListFrame)
        self.bakeOffsetsWin_widgetLayout.addWidget(
            self.bakeOffsetsWin_moduleListFrame)
        self.bakeOffsetsWin_moduleList.setMinimumSize(QtCore.QSize(265, 200))
        self.bakeOffsetsWin_moduleList.setMaximumSize(QtCore.QSize(265, 200))
        self.bakeOffsetsWin_moduleList.setSelectionMode(
            QtWidgets.QAbstractItemView.MultiSelection)
        self.bakeOffsetsWin_moduleList.setSpacing(3)

        # add the layout for the buttons
        self.bakeOffsetsWin_buttonLayoutAll = QtWidgets.QVBoxLayout()
        self.bakeOffsetsWin_widgetLayout.addLayout(
            self.bakeOffsetsWin_buttonLayoutAll)
        self.bakeOffsetsWin_buttonLayoutAll.setContentsMargins(5, 20, 5, 20)

        # add the selection buttons
        self.bakeOffsetsWin_selectionButtonLayout = QtWidgets.QVBoxLayout()
        self.bakeOffsetsWin_buttonLayoutAll.addLayout(
            self.bakeOffsetsWin_selectionButtonLayout)
        self.bakeOffsetsWin_selectAllButton = QtWidgets.QPushButton(
            "Select All")
        self.bakeOffsetsWin_selectAllButton.setMinimumSize(
            QtCore.QSize(115, 25))
        self.bakeOffsetsWin_selectAllButton.setMaximumSize(
            QtCore.QSize(115, 25))
        self.bakeOffsetsWin_selectionButtonLayout.addWidget(
            self.bakeOffsetsWin_selectAllButton)
        self.bakeOffsetsWin_selectAllButton.clicked.connect(
            self.bakeOffsetsWin_moduleList.selectAll)
        self.bakeOffsetsWin_selectAllButton.setObjectName("blueButton")

        self.bakeOffsetsWin_selectNoneButton = QtWidgets.QPushButton(
            "Clear Selection")
        self.bakeOffsetsWin_selectNoneButton.setMinimumSize(
            QtCore.QSize(115, 25))
        self.bakeOffsetsWin_selectNoneButton.setMaximumSize(
            QtCore.QSize(115, 25))
        self.bakeOffsetsWin_selectionButtonLayout.addWidget(
            self.bakeOffsetsWin_selectNoneButton)
        self.bakeOffsetsWin_selectNoneButton.clicked.connect(
            self.bakeOffsetsWin_moduleList.clearSelection)
        self.bakeOffsetsWin_selectNoneButton.setObjectName("blueButton")

        # spacer
        spacerItem = QtWidgets.QSpacerItem(20, 80,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.bakeOffsetsWin_selectionButtonLayout.addItem(spacerItem)

        # add the buttons for reset settings and reset transforms
        self.bakeOffsetsWin_bakeOFfsetsBtn = QtWidgets.QPushButton(
            "Bake Offsets")
        self.bakeOffsetsWin_bakeOFfsetsBtn.setMinimumSize(QtCore.QSize(
            115, 25))
        self.bakeOffsetsWin_bakeOFfsetsBtn.setMaximumSize(QtCore.QSize(
            115, 25))
        self.bakeOffsetsWin_selectionButtonLayout.addWidget(
            self.bakeOffsetsWin_bakeOFfsetsBtn)
        self.bakeOffsetsWin_bakeOFfsetsBtn.setToolTip(
            "Turn on Aim Mode for selected modules.")
        self.bakeOffsetsWin_bakeOFfsetsBtn.clicked.connect(
            partial(self.bakeOffsets))
        self.bakeOffsetsWin_bakeOFfsetsBtn.setObjectName("blueButton")

        # populate the list widget
        modules = utils.returnRigModules()
        for module in modules:
            # get module name
            moduleName = cmds.getAttr(module + ".moduleName")
            if moduleName != "root":
                self.bakeOffsetsWin_moduleList.addItem(moduleName)

        # show the window
        self.bakeOffsetsWin.show()
Beispiel #14
0
    def createModule(self):
        """
        Instantiate our module class to create with the user specified name, creating the network node, building
        the Skeleton Settings UI for the module, adding the joint mover for that module (importing the joint mover
        file), and adding the joint mover to the outliner.

        """

        mod = __import__("RigModules." + self.className, {}, {},
                         [self.className])
        reload(mod)

        # get the class name from that module file (returns RigModules.ART_Root.ART_Root for example)
        moduleClass = getattr(mod, mod.className)
        jmPath = mod.jointMover

        # find the instance of that module and call on the skeletonSettings_UI function
        userSpecName = str(self.previewName.text())

        # check to see if a module already has that name
        modules = utils.returnRigModules()
        validName = False
        for module in modules:
            name = cmds.getAttr(module + ".moduleName")
            if name == userSpecName:
                cmds.confirmDialog(
                    title="Name Exists",
                    message=
                    "A module with that name already exists. Please enter a unique name.",
                    icon="critical")
                return

        # call functions to create network node, skeleton settings UI
        moduleInst = moduleClass(self.rigUiInst, userSpecName)
        self.rigUiInst.moduleInstances.append(
            moduleInst
        )  # add this instance to the ui's list of module instances
        networkNode = moduleInst.buildNetwork()

        # figure out side
        specialCaseModules = ["ART_Leg_Standard", "ART_Arm_Standard"]
        if self.className in specialCaseModules:
            side = "Left"
            if self.rightRadioBtn.isChecked():
                side = "Right"
                cmds.setAttr(networkNode + ".side", lock=False)
                cmds.setAttr(networkNode + ".side",
                             "Right",
                             type="string",
                             lock=True)

            # build new jmPath name
            jmPath = jmPath.partition(".ma")[0] + "_" + side + ".ma"

        moduleInst.skeletonSettings_UI(userSpecName)
        moduleInst.jointMover_Build(jmPath)
        moduleInst.addJointMoverToOutliner()

        # update the created joints attribute on the network node with the new names
        prefix = str(self.prefix.text())
        suffix = str(self.suffix.text())

        if len(prefix) > 0:
            prefix = prefix + "_"
        if len(suffix) > 0:
            suffix = "_" + suffix

        createdBones = cmds.getAttr(networkNode + ".Created_Bones")
        createdBones = createdBones.split("::")

        attrString = ""
        for bone in createdBones:
            if len(bone) > 1:
                attrString += prefix + bone + suffix + "::"

        cmds.setAttr(networkNode + ".Created_Bones", lock=False)
        cmds.setAttr(networkNode + ".Created_Bones",
                     attrString,
                     type="string",
                     lock=True)

        # update the self.currentParent label and the parentModuleBone attr on the network node
        parent = (self.hierarchyTree.currentItem().text())
        moduleInst.currentParent.setText(parent)

        cmds.setAttr(networkNode + ".parentModuleBone", lock=False)
        cmds.setAttr(networkNode + ".parentModuleBone",
                     parent,
                     type="string",
                     lock=True)

        # parent the joint mover to the offset mover of the parent
        mover = ""

        if parent == "root":
            mover = "root_mover"

        else:
            # find the parent mover name to parent to
            networkNodes = utils.returnRigModules()
            mover = utils.findMoverNodeFromJointName(networkNodes, parent,
                                                     False, True)

        if mover is not None:
            cmds.parentConstraint(mover, userSpecName + "_mover_grp", mo=True)
            cmds.scaleConstraint(mover, userSpecName + "_mover_grp")

        # create the connection geo between the two
        globalMover = utils.findGlobalMoverFromName(userSpecName)
        cmds.select(globalMover)
        cmds.setToolTo("moveSuperContext")

        utils.fitViewAndShade()

        # delete the UI
        cmds.deleteUI(windowObject)

        # obey the current UI visibility toggles
        self.rigUiInst.setMoverVisibility()
        moduleInst.updateBoneCount()
        self.rigUiInst.populateNetworkList()

        # turn on aim mode
        moduleInst.aimMode(True)