Example #1
0
    def assignObject(self):
        ''' fill form based on sender, then update group dict'''
        sender = self.sender()

        #COMPONENT SENDERS
        #start joint, side, name
        if sender is self.compWidget.startJoint_pushButton:
            sel = pm.ls(selection=True)
            if sel:
                self.compWidget.startJoint_lineEdit.setText(sel[0].shortName())
                name = naming.TipName(
                    self.compWidget.startJoint_lineEdit.text())
                self.compWidget.name_lineEdit.setText(name.base)
                if name.isSideLeft():
                    self.compWidget.left_radioButton.setChecked(True)
                    self.side == 'left'
                elif name.isSideRight():
                    self.compWidget.right_radioButton.setChecked(True)
                    self.side = 'right'
                else:
                    self.compWidget.center_radioButton.setChecked(True)
                    self.side = None
                #Get limb Name
                self.limb = self.compWidget.name_lineEdit.text(
                ) + naming.getSideName(self.side)
                self.attachWidget.attrPrefix_lineEdit.setText(self.limb)
        #endList
        elif sender is self.compWidget.endListAdd_pushButton:
            sel = pm.ls(selection=True)

            if sel:
                for item in pm.ls(selection=True):
                    self.compWidget.endList_listWidget.addItem(str(item))
            else:
                self.compWidget.endList_listWidget.addItem()
        elif sender is self.compWidget.endListRemove_pushButton:
            for item in self.compWidget.endList_listWidget.selectedItems():
                self.compWidget.endList_listWidget.takeItem(
                    self.compWidget.endList_listWidget.row(item))
        #aim List
        elif sender is self.compWidget.controlAdd_pushButton:
            sel = pm.ls(selection=True)
            numRows = self.compWidget.controlIndex_tableWidget.rowCount()
            for i, s in enumerate(sel):
                self.compWidget.controlIndex_tableWidget.insertRow(numRows + i)
                self.compWidget.controlIndex_tableWidget.setItem(
                    numRows + i, 0, QtGui.QTableWidgetItem(str(s)))
                self.compWidget.controlIndex_tableWidget.setItem(
                    numRows + i, 1, QtGui.QTableWidgetItem(str(numRows + i)))
        elif sender is self.compWidget.controlRemove_pushButton:
            for item in self.compWidget.controlIndex_tableWidget.selectedItems(
            ):
                self.attachWidget.controlIndex_tableWidget.removeRow(
                    item.row())

        #also excute overridden assign object
        super(AssignNewComponentWidget, self).assignObject(sender)

        #update
        self.update()
Example #2
0
    def initWindow(self, buildDict=None, hierDict=None, attachDict=None):
        #COMPONENT variables

        if buildDict:
            #startJoint
            if 'startJoint' in buildDict:
                self.compWidget.startJoint_lineEdit.setText(
                    buildDict['startJoint'])
            if 'name' in buildDict:
                self.compWidget.name_lineEdit.setText(buildDict['name'])
            if 'side' in buildDict:
                if buildDict['side'] == 'left':
                    self.compWidget.left_radioButton.setCcontrolIndex_tableWidgethecked(
                        True)
                elif buildDict['side'] == 'right':
                    self.compWidget.right_radioButton.setChecked(True)
                else:
                    self.compWidget.center_radioButton.setChecked(True)
                self.side = buildDict['side']
            if 'endList' in buildDict and buildDict['endList']:
                for i, item in enumerate(buildDict['endList']):
                    self.compWidget.endList_listWidget.insertItem(i, item)
            if 'aimJoints' in buildDict and buildDict['aimJoints']:
                numRows = self.compWidget.aim_tabelWidget.rowCount()
                for x in range(0, numRows):
                    self.compWidget.aim_tabelWidget.removeRow(x)

                for i, item in enumerate(buildDict['aimJoints']):
                    self.compWidget.aim_tabelWidget.insertRow(i)
                    self.compWidget.aim_tabelWidget.setItem(
                        i, 0, QtGui.QTableWidgetItem(str(item)))
                    if 'aimSockets' in buildDict:
                        self.compWidget.aim_tabelWidget.setItem(
                            i, 1,
                            QtGui.QTableWidgetItem(
                                str(buildDict['aimSockets'][i])))
            if 'controlOffset' in buildDict:
                self.compWidget.controlOffset_doubleSpinBox.setValue(
                    buildDict['controlOffset'])
            if 'controlScale' in buildDict:
                self.compWidget.controlScale_doubleSpinBox.setValue(
                    buildDict['controlScale'])
            if 'style' in buildDict:
                if isinstance(buildDict['style'], str) or isinstance(
                        buildDict['style'], unicode):
                    index = controller.PUPPET_CONTROL_SHAPE_TYPES.index(
                        buildDict['style'])
                    self.compWidget.controlStyle_comboBox.setCurrentIndex(
                        index)
                else:
                    self.compWidget.controlStyle_comboBox.setCurrentIndex(
                        buildDict['style'])

        #init hier and attach attrs
        if hierDict:
            self.setHierarchyAttrs(hierDict)
        if attachDict:
            self.setAttachAttrs(attachDict)
        self.update()
    def initWindow(self, buildDict=None, hierDict=None, attachDict=None):

        #COMPONENT variables
        if buildDict:
            #startJoint
            if 'startJoint' in buildDict:
                self.compWidget.startJoint_lineEdit.setText(
                    buildDict['startJoint'])
            if 'name' in buildDict:
                self.compWidget.name_lineEdit.setText(buildDict['name'])
            if 'side' in buildDict:
                if buildDict['side'] == 'left':
                    self.compWidget.left_radioButton.setChecked(True)
                elif buildDict['side'] == 'right':
                    self.compWidget.right_radioButton.setChecked(True)
                else:
                    self.compWidget.center_radioButton.setChecked(True)
                self.side = buildDict['side']
            if 'endList' in buildDict and buildDict['endList']:
                for i, item in enumerate(buildDict['endList']):
                    self.compWidget.endList_listWidget.insertItem(i, item)
            if 'controlOffset' in buildDict:
                self.compWidget.pvOffset_doubleSpinBox.setValue(
                    buildDict['pvOffset'])
            if 'controlScale' in buildDict:
                self.compWidget.pvScale_doubleSpinBox.setValue(
                    buildDict['pvScale'])
            if 'inverseTop' in buildDict:
                self.compWidget.inverseTop_lineEdit.setText(
                    naming.noneToBlank(buildDict['inverseTop']))
            if 'inversePivot' in buildDict:
                self.compWidget.inversePivot_lineEdit.setText(
                    naming.noneToBlank(buildDict['inversePivot']))
            if 'inversePrefix' in buildDict:
                self.compWidget.inversePrefix_lineEdit.setText(
                    naming.noneToBlank(buildDict['inversePrefix']))

            if 'parentSwitchTarget' in buildDict and buildDict[
                    'parentSwitchTarget']:
                numRows = self.compWidget.parentSwitch_tableWidget.rowCount()
                for x in range(0, numRows):
                    self.compWidget.parentSwitch_tableWidget.removeRow(x)

                for i, item in enumerate(buildDict['parentSwitchTarget']):
                    self.compWidget.parentSwitch_tableWidget.insertRow(i)
                    self.compWidget.parentSwitch_tableWidget.setItem(
                        i, 0, QtGui.QTableWidgetItem(str(item)))
                    if 'parentSwitchLabel' in buildDict:
                        self.compWidget.parentSwitch_tableWidget.setItem(
                            i, 1,
                            QtGui.QTableWidgetItem(
                                str(buildDict['parentSwitchLabel'][i])))

        #init hier and attach attrs
        if hierDict:
            self.setHierarchyAttrs(hierDict)
        if attachDict:
            self.setAttachAttrs(attachDict)
        self.update()
Example #4
0
    def setAttachAttrs(self, attachDict):

        #ATTACH variables
        if 'driven' in attachDict:
            self.attachWidget.driven_lineEdit.setText(attachDict['driven'])
        if 'drivers' in attachDict:
            for i, item in enumerate(attachDict['drivers']):
                self.attachWidget.drivers_tableWidget.setItem(
                    i, 0, QtGui.QTableWidgetItem(str(item)))
        if 'labels' in attachDict:
            for i, item in enumerate(attachDict['labels']):
                self.attachWidget.drivers_tableWidget.setItem(
                    i, 1, QtGui.QTableWidgetItem(str(item)))
        if 'config' in attachDict:
            self.attachWidget.configNode_lineEdit.setText(attachDict['config'])
        if 'prefix' in attachDict:
            self.attachWidget.attrPrefix_lineEdit.setText(attachDict['prefix'])
        if 'point' in attachDict:
            self.attachWidget.point_checkBox.setChecked(attachDict['point'])
        if 'orient' in attachDict:
            self.attachWidget.orient_checkBox.setChecked(attachDict['orient'])
        if 'scale' in attachDict:
            self.attachWidget.scale_checkBox.setChecked(attachDict['scale'])
        if 'attachPoint' in attachDict:
            if isinstance(attachDict['attachPoint'], bool):
                self.attachWidget.attachPoint_groupBox.setChecked(True)
                self.attachWidget.attachPointNode_groupBox.setChecked(False)
                if attachDict['attachPoint']:
                    self.attachWidget.attachPoint_True.setChecked(True)
                else:
                    self.attachWidget.attachPoint_False.setChecked(True)
            else:
                self.attachWidget.attachPoint_groupBox.setChecked(False)
                self.attachWidget.attachPointNode_groupBox.setChecked(True)
                self.attachWidget.loadAttachPoint_lineEdit.setText(
                    attachDict['attachPoint'])
        if 'attachOrient' in attachDict:
            if isinstance(attachDict['attachOrient'], bool):
                self.attachWidget.attachOrient_groupBox.setChecked(True)
                self.attachWidget.attachOrientNode_groupBox.setChecked(False)
                if attachDict['attachOrient']:
                    self.attachWidget.attachOrient_True.setChecked(True)
                else:
                    self.attachWidget.attachOrient_False.setChecked(True)
            else:
                self.attachWidget.attachOrient_groupBox.setChecked(False)
                self.attachWidget.attachOrientNode_groupBox.setChecked(True)
                self.attachWidget.loadAttachOrient_lineEdit.setText(
                    attachDict['attachOrient'])
        if 'attachScale' in attachDict:
            if isinstance(attachDict['attachScale'], bool):
                self.attachWidget.attachScale_groupBox.setChecked(True)
                self.attachWidget.attachScaleNode_groupBox.setChecked(False)
                if attachDict['attachScale']:
                    self.attachWidget.attachScale_True.setChecked(True)
                else:
                    self.attachWidget.attachScale_False.setChecked(True)
            else:
                self.attachWidget.attachScale_groupBox.setChecked(False)
                self.attachWidget.attachScaleNode_groupBox.setChecked(True)
                self.attachWidget.loadAttachScale_lineEdit.setText(
                    attachDict['attachOrient'])
        if 'multiAttr':
            self.attachWidget.multiAttrSwitch_checkBox.setChecked(
                attachDict['multiAttr'])
        if 'switch':
            self.attachWidget.multiAttrSwitch_checkBox.setChecked(
                attachDict['switch'])

        self.updateAttachAttrs()
Example #5
0
    def assignObject(self, sender=None):
        if not sender:
            sender = self.sender()

        #driven
        if sender == self.attachWidget.driven_pushButton:
            sel = pm.ls(selection=True)
            if sel:
                self.attachWidget.driven_lineEdit.setText(sel[0])

        #add drivers
        if sender is self.attachWidget.addDrivers_pushButton:
            sel = pm.ls(selection=True)
            numRows = self.attachWidget.drivers_tableWidget.rowCount()
            for i, s in enumerate(sel):
                name = naming.TipName(name=s)
                self.attachWidget.drivers_tableWidget.insertRow(numRows + i)
                self.attachWidget.drivers_tableWidget.setItem(
                    numRows + i, 0, QtGui.QTableWidgetItem(str(s)))
                self.attachWidget.drivers_tableWidget.setItem(
                    numRows + i, 1, QtGui.QTableWidgetItem(str(name.base)))

        #remove drivers
        if sender is self.attachWidget.removeDrivers_pushButton:
            for item in self.attachWidget.drivers_tableWidget.selectedItems():
                self.attachWidget.drivers_tableWidget.setItem(item.row())

        #config
        if sender is self.attachWidget.loadConfig_pushButton:
            sel = pm.ls(selection=True)
            if sel:
                self.attachWidget.configNode_lineEdit.setText(str(sel[0]))

        #attach point
        if sender is self.attachWidget.loadAttachPoint_pushButton:
            sel = pm.ls(selection=True)
            if sel:
                self.attachWidget.loadAttachPoint_lineEdit.setText(str(sel[0]))

        #attach orient
        if sender is self.attachWidget.loadAttachOrient_pushButton:
            sel = pm.ls(selection=True)
            if sel:
                self.attachWidget.loadAttachOrient_lineEdit.setText(str(
                    sel[0]))

        #checkboxes
        if sender is self.attachWidget.attachPoint_groupBox:
            if self.attachWidget.attachPoint_groupBox.isChecked():
                self.attachWidget.attachPointNode_groupBox.setChecked(False)
        if sender is self.attachWidget.attachPointNode_groupBox:
            if self.attachWidget.attachPointNode_groupBox.isChecked():
                self.attachWidget.attachPoint_groupBox.setChecked(False)

        if sender is self.attachWidget.attachOrient_groupBox:
            if self.attachWidget.attachOrient_groupBox.isChecked():
                self.attachWidget.attachOrientNode_groupBox.setChecked(False)
        if sender is self.attachWidget.attachOrientNode_groupBox:
            if self.attachWidget.attachOrientNode_groupBox.isChecked():
                self.attachWidget.attachOrient_groupBox.setChecked(False)

        self.updateHierarchyAttrs()
        self.updateAttachAttrs()