def showEvent(self, event): if event.spontaneous(): return screenWidth, screenHeight = self.screenCenter() defaultSize = QtCore.QSize(284, 643) defaultPos = QtCore.QPoint(screenWidth, screenHeight) self.settings.beginGroup("correctiveDockWidget") #QVariant no longer used in pyside self.resize(self.settings.value("size", defaultSize)) #self.resize(defaultSize) self.move(defaultPos) self.settings.endGroup()
def __init__(self, parent=MAYA_WINDOW): super(TabTemplateWindow, self).__init__(parent) self.layout = QtGui.QFormLayout() self.setLayout(self.layout) self.setObjectName('thetemplateWindow') self.setWindowTitle("Template Tools") self.setMinimumSize(500, 500) self.setMaximumSize(500, 500) self.tabWidget = QtGui.QTabWidget() self.layout.addWidget(self.tabWidget) twWindow = twistWidget.TwistWidget() pvWindow = poleVectorWidget.PoleVectorWidget() fWindow = faceWidget.FaceWidget() skWindow = otherDeformationWidget.OtherDeformationWidget() self.tabWidget.addTab(twWindow, "Twist System") self.tabWidget.addTab(pvWindow, "Pole Vector System") self.tabWidget.addTab(fWindow, "Face System") self.tabWidget.addTab(skWindow, "Other Deformation Systems") screenWidth, screenHeight = self.screenCenter() self.move(QtCore.QPoint(screenWidth, screenHeight))
class AttachWidget(form_class, base_class): closeSignal = QtCore.Signal() refreshSignal = QtCore.Signal() def __init__(self): super(AttachWidget, self).__init__() self.setupUi(self) self.setObjectName('AttachTool') self.setWindowTitle('Attach Tool') #self.setMinimumSize(250, 600) #self.setMaximumSize(250, 600) layout = QtGui.QVBoxLayout() #layout.addWidget(self.compWidget) layout.addWidget(self) self.setLayout(layout) #self.compWidget.widget_groupBox.toggled.connect(self.showAttach) self.attachPoint_groupBox.clicked.connect(self.assignObject) self.attachPointNode_groupBox.clicked.connect(self.assignObject) self.attachOrient_groupBox.clicked.connect(self.assignObject) self.attachOrientNode_groupBox.clicked.connect(self.assignObject) def assignObject(self): sender = self.sender() #checkboxes if sender is self.attachPoint_groupBox: if self.attachPoint_groupBox.isChecked(): self.attachPointNode_groupBox.setChecked(False) if sender is self.attachPointNode_groupBox: if self.attachPointNode_groupBox.isChecked(): self.attachPoint_groupBox.setChecked(False) if sender is self.attachOrient_groupBox: if self.attachOrient_groupBox.isChecked(): self.attachOrientNode_groupBox.setChecked(False) if sender is self.attachOrientNode_groupBox: if self.attachOrientNode_groupBox.isChecked(): self.attachOrient_groupBox.setChecked(False)
class BuilderMainWindow(QtGui.QMainWindow): closeSignal = QtCore.Signal() def __init__(self): super(BuilderMainWindow, self).__init__() #parent.__init__(self) self.settings = QtCore.QSettings() self.setObjectName('dockControl_correctives') self = BuilderWidget() self.setWindowTitle(self.windowTitle()) self.setMinimumSize(870, 330) self.setMaximumSize(870, 330) self.setCentralWidget(self.menuWidget) # connect close signal & dock close self.closeSignal.connect(self.close) self.menuWidget.actionClose.triggered.connect(self.close) self.show() def closeEvent(self, event): self.settings.beginGroup("correctiveDockWidget") self.settings.setValue("size", self.size()) self.settings.setValue("pos", self.pos()) self.settings.endGroup() self.closeSignal.emit() #cmds.scriptJob(kill=self.sceneImportedScriptJobID) #cmds.scriptJob(kill=self.sceneOpenedScriptJobID) self.deleteLater() def showEvent(self, event): if event.spontaneous(): return screenWidth, screenHeight = self.screenCenter() defaultSize = QtCore.QSize(284, 643) defaultPos = QtCore.QPoint(screenWidth, screenHeight) self.settings.beginGroup("correctiveDockWidget") #QVariant no longer used in pyside self.resize(self.settings.value("size", defaultSize)) #self.resize(defaultSize) self.move(defaultPos) self.settings.endGroup() def screenCenter(self): '''Center tool in the screen''' resolution = QtGui.QDesktopWidget().screenGeometry() width = (resolution.width() / 2) - (self.frameSize().width() / 2) height = (resolution.height() / 2) - (self.frameSize().height() / 2) return width, height
def __init__(self): super(BuilderMainWindow, self).__init__() #parent.__init__(self) self.settings = QtCore.QSettings() self.setObjectName('dockControl_correctives') self = BuilderWidget() self.setWindowTitle(self.windowTitle()) self.setMinimumSize(870, 330) self.setMaximumSize(870, 330) self.setCentralWidget(self.menuWidget) # connect close signal & dock close self.closeSignal.connect(self.close) self.menuWidget.actionClose.triggered.connect(self.close) self.show()
class TwistWidget(form_class, base_class): closeSignal = QtCore.Signal() refreshSignal = QtCore.Signal() def __init__(self): super(TwistWidget, self).__init__() self.setupUi(self) self.setObjectName('TwistTool') self.setWindowTitle('Twist Tool') self.reset() #check boxes self.all_checkBox.clicked.connect(self.assignObject) self.armShoulderLf_checkBox.clicked.connect(self.assignObject) self.armShoulderRt_checkBox.clicked.connect(self.assignObject) self.handWristLf_checkBox.clicked.connect(self.assignObject) self.handWristRt_checkBox.clicked.connect(self.assignObject) self.legHipLf_checkBox.clicked.connect(self.assignObject) self.legHipRt_checkBox.clicked.connect(self.assignObject) self.footAnkleLf_checkBox.clicked.connect(self.assignObject) self.footAnkleRt_checkBox.clicked.connect(self.assignObject) #load buttons self.startJoint_pushButton.clicked.connect(self.assignObject) self.endJoint_pushButton.clicked.connect(self.assignObject) #Text changed custom self.systemName_lineEdit.textChanged.connect(self.assignObject) self.startJoint_lineEdit.textChanged.connect(self.assignObject) self.endJoint_lineEdit.textChanged.connect(self.assignObject) #execute buttons self.create_pushButton.clicked.connect(self.assignObject) self.delete_pushButton.clicked.connect(self.assignObject) self.reset_pushButton.clicked.connect(self.assignObject) #muscle System self.createMuscles_pushButton.clicked.connect(self.assignObject) def assignObject(self): sender = self.sender() #checkboxes if sender is self.all_checkBox: self.uncheck_indivBoxes() elif sender is self.armShoulderLf_checkBox: self.all_checkBox.setChecked(False) elif sender is self.armShoulderRt_checkBox: self.all_checkBox.setChecked(False) elif sender is self.handWristLf_checkBox: self.all_checkBox.setChecked(False) elif sender is self.handWristRt_checkBox: self.all_checkBox.setChecked(False) elif sender is self.legHipLf_checkBox: self.all_checkBox.setChecked(False) elif sender is self.legHipRt_checkBox: self.all_checkBox.setChecked(False) elif sender is self.footAnkleLf_checkBox: self.all_checkBox.setChecked(False) elif sender is self.footAnkleRt_checkBox: self.all_checkBox.setChecked(False) #load buttons elif sender is self.startJoint_pushButton: self.all_checkBox.setChecked(False) self.loadSelection(self.startJoint_lineEdit) elif sender is self.endJoint_pushButton: self.all_checkBox.setChecked(False) self.loadSelection(self.endJoint_lineEdit) #text changed elif sender is self.systemName_lineEdit: self.all_checkBox.setChecked(False) elif sender is self.startJoint_lineEdit: self.all_checkBox.setChecked(False) elif sender is self.endJoint_lineEdit: self.all_checkBox.setChecked(False) #execute buttons elif sender is self.create_pushButton: self.create() elif sender is self.delete_pushButton: self.delete() elif sender is self.reset_pushButton: self.reset() #muscleSystem elif sender is self.createMuscles_pushButton: self.createMuscleSystem() def uncheck_indivBoxes(self): self.armShoulderLf_checkBox.setChecked(False) self.armShoulderRt_checkBox.setChecked(False) self.handWristLf_checkBox.setChecked(False) self.handWristRt_checkBox.setChecked(False) self.legHipLf_checkBox.setChecked(False) self.legHipRt_checkBox.setChecked(False) self.footAnkleLf_checkBox.setChecked(False) self.footAnkleRt_checkBox.setChecked(False) def loadSelection(self, lineEdit): try: sel = pm.ls(selection=True) lineEdit.setText(checks.pyNodeToString(sel[0])) except IndexError, TypeError: pm.error("Select one joint")
class AssignNewComponentWidget(editWidget.EditWidget): ''' Corrective assign edit widget, modify basic widget for new group functionality TODO: Fix bug that causes create new group dialog to appear in top left corner ''' refreshSignal = QtCore.Signal() def __init__(self, parent=None, componentDict=None, componentWidget=None, compType='FK', limb=None, puppet=None, compObj=None): super(AssignNewComponentWidget, self).__init__(parent, componentDict=componentDict, componentWidget=componentWidget, assignPath=ASSIGNPATH, compType=compType) #init variables #EDITER variables self.compType = compType self.limb = limb self.puppet = puppet self.compObj = compObj #init component list self._componentAttrList = list() #Connect Slots #COMPONENT SENDERS self.compWidget.startJoint_pushButton.clicked.connect( self.assignObject) self.compWidget.endListAdd_pushButton.clicked.connect( self.assignObject) self.compWidget.endListRemove_pushButton.clicked.connect( self.assignObject) #reset self.execWidget.reset_pushButton.clicked.connect(self.slotReset) self.execWidget.ok_pushButton.clicked.connect(self.setSlot) #clean window self.slotReset() 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) #init hier and attach attrs if hierDict: self.setHierarchyAttrs(hierDict) if attachDict: self.setAttachAttrs(attachDict) self.update() 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.side = 'left' self.compWidget.left_radioButton.setChecked(True) elif name.isSideRight(): self.side = 'right' self.compWidget.right_radioButton.setChecked(True) else: self.side = None self.compWidget.center_radioButton.setChecked(True) #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: for item in pm.ls(selection=True): self.compWidget.endList_listWidget.addItem(str(item)) 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)) #also excute overridden assign object super(AssignNewComponentWidget, self).assignObject(sender) #Get limb Name self.limb = self.compWidget.name_lineEdit.text() + naming.getSideName( self.side) #update self.update() def slotReset(self): ''' not sure why it didnt let me override this method''' self.compWidget.startJoint_lineEdit.clear() self.compWidget.center_radioButton.setChecked(True) self.compWidget.name_lineEdit.clear() self.compWidget.endList_listWidget.clear() super(AssignNewComponentWidget, self).slotReset() def update(self): '''update dict with latest edits''' #COMPONENT DICT #get endlist endList = list() for index in xrange(0, self.compWidget.endList_listWidget.count()): endList.append( self.compWidget.endList_listWidget.item(index).text()) #get side if self.compWidget.center_radioButton.isChecked(): self.side = None elif self.compWidget.left_radioButton.isChecked(): self.side = 'left' else: self.side = 'right' #Get limb Name self.limb = self.compWidget.name_lineEdit.text() + naming.getSideName( self.side) #set component attrs self._componentAttrList = [ str(self.compWidget.startJoint_lineEdit.text()), str(self.compWidget.name_lineEdit.text()), self.side, endList ] #set hier and attach attrs self.updateHierarchyAttrs() self.updateAttachAttrs() def showEvent(self, event): '''override showEvent, fill form with saved values super(AssignNewComponentWidget, self).showEvent(event) self.settings.beginGroup("AssignNewGroupWidget") #restore previous values''' self.setTitle() def returnGroupAttrObjects(self): '''return limb, group dict, and attach dict to the all builder''' #ONLY RETURN IF EDITED return self.limb, self._componentAttrList, self._hierarchyAttrList, self._attachAttrList def setSlot(self): oldLimb = self.limb self.update() self.setBuildString(oldLimb) super(AssignNewComponentWidget, self).setSlot(oldLimb) def setBuildString(self, oldLimb): #delete old attribute if the limb name has changed if oldLimb != self.limb: if self.puppet.hasAttr('%s_build' % oldLimb): pm.setAttr('%s.%s_build' % (self.puppet, oldLimb), lock=False) pm.deleteAttr('%s.%s_build' % (self.puppet, oldLimb)) if self.puppet and self.limb: if not self.puppet.hasAttr('%s_build' % self.limb): self.puppet.addTag('%s_build' % self.limb) buildObj = buildInfo.BuildInfo() buildObj.setBuildValues(compType=self.compType, startJoint=self._componentAttrList[0], endList=self._componentAttrList[3], name=self._componentAttrList[1], side=self._componentAttrList[2]) #unlock string pm.setAttr('%s.%s_build' % (self.puppet, self.limb), lock=False) pm.setAttr('%s.%s_build' % (self.puppet, self.limb), buildObj.toJson(), type='string') pm.setAttr('%s.%s_build' % (self.puppet, self.limb), lock=True) @property def component(self): name = naming.TipName(base=self.name, side=self.side, descriptor='component', suffix='1') return pm.PyNode(name.name) @property def rootGroup(self): name = naming.TipName(base=self.name, side=self.side, descriptor='rootGroup', suffix='1') return pm.PyNode(name.name) @property def attachGroup(self): name = naming.TipName(base=self.name, side=self.side, descriptor='attachGroup', suffix='1') return pm.PyNode(name.name)
class PoleVectorWidget(form_class, base_class): closeSignal = QtCore.Signal() refreshSignal = QtCore.Signal() def __init__(self): super(PoleVectorWidget, self).__init__() self.setupUi(self) self.setObjectName('poleVectorTool') self.setWindowTitle('Pole Vector Tool') self.reset() #check boxes self.all_checkBox.clicked.connect(self.assignObject) self.armLf_checkBox.clicked.connect(self.assignObject) self.armRt_checkBox.clicked.connect(self.assignObject) self.legLf_checkBox.clicked.connect(self.assignObject) self.legRt_checkBox.clicked.connect(self.assignObject) #load buttons self.startJoint_pushButton.clicked.connect(self.assignObject) self.endJoint_pushButton.clicked.connect(self.assignObject) #execute buttons self.create_pushButton.clicked.connect(self.assignObject) self.delete_pushButton.clicked.connect(self.assignObject) self.reset_pushButton.clicked.connect(self.assignObject) def assignObject(self): sender = self.sender() #checkboxes if sender is self.all_checkBox: self.uncheck_indivBoxes() elif sender is self.armLf_checkBox: self.all_checkBox.setChecked(False) elif sender is self.armRt_checkBox: self.all_checkBox.setChecked(False) elif sender is self.legLf_checkBox: self.all_checkBox.setChecked(False) elif sender is self.legRt_checkBox: self.all_checkBox.setChecked(False) #load buttons elif sender is self.startJoint_pushButton: self.loadSelection(self.startJoint_lineEdit) elif sender is self.endJoint_pushButton: self.loadSelection(self.endJoint_lineEdit) #execute buttons elif sender is self.create_pushButton: self.create() elif sender is self.delete_pushButton: self.delete() elif sender is self.reset_pushButton: self.reset() def reset(self): self.all_checkBox.setChecked(True) self.controlOffset_doubleSpinBox.setValue(10) self.sizeOfControl_doubleSpinBox.setValue(1) self.customSysName_lineEdit.clear() self.startJoint_lineEdit.clear() self.endJoint_lineEdit.clear() self.uncheck_indivBoxes() def uncheck_indivBoxes(self): self.armLf_checkBox.setChecked(False) self.armRt_checkBox.setChecked(False) self.legLf_checkBox.setChecked(False) self.legRt_checkBox.setChecked(False) def loadSelection(self, lineEdit): try: sel = pm.ls(selection=True) lineEdit.setText(checks.pyNodeToString(sel[0])) except IndexError, TypeError: pm.error("Select one joint")
class AssignNewComponentWidget(editWidget.EditWidget): ''' Corrective assign edit widget, modify basic widget for new group functionality TODO: Fix bug that causes create new group dialog to appear in top left corner ''' refreshSignal = QtCore.Signal() def __init__(self, parent=None, widgetDict=None, pupList=None, textEditor=None, builderList=None, allBuilderWidget=None, editorWidget=None, compType=None, limb=None): super(AssignNewComponentWidget, self).__init__(parent, assignPath=assignPath, compType=compType) #init variables #EDITER variables self.pupList = pupList self.widgetDict = widgetDict self.textEditor = textEditor self.builderList = builderList self.allBuilderWidget = allBuilderWidget self.editorWidget = editorWidget self.limb = limb #COMPONENT variables self.startJoint = None self.side = None self.name = None self.endJoint = None self.orient = None self.orientLabel = None self.aim = None self.aimLabel = None #Connect Slots #COMPONENT SENDERS self.widget.startJoint_pushButton.clicked.connect(self.assignObject) self.widget.name_lineEdit.textChanged.connect(self.assignObject) self.widget.endJoint_pushButton.clicked.connect(self.assignObject) self.widget.orient_pushButton.clicked.connect(self.assignObject) self.widget.orientLabel_lineEdit.textChanged.connect(self.assignObject) self.widget.aim_pushButton.clicked.connect(self.assignObject) self.widget.aimLabel_lineEdit.textChanged.connect(self.assignObject) #ATTACH SENDERS self.widget.addDrivers_pushButton.clicked.connect(self.assignObject) self.widget.removeDrivers_pushButton.clicked.connect(self.assignObject) self.widget.addLabels_pushButton.clicked.connect(self.assignObject) self.widget.removeLabels_pushButton.clicked.connect(self.assignObject) self.widget.configNode_lineEdit.textChanged.connect(self.assignObject) self.widget.attachPoint_True.toggled.connect(self.assignObject) self.widget.attachPoint_False.toggled.connect(self.assignObject) self.widget.attachOrient_True.toggled.connect(self.assignObject) self.widget.attachOrient_False.toggled.connect(self.assignObject) self.widget.attachScale_True.toggled.connect(self.assignObject) self.widget.attachScale_False.toggled.connect(self.assignObject) #Default Buttons self.widget.ok_pushButton.clicked.connect(self.slotCreateGroup) self.widget.reset_pushButton.clicked.connect(self.slotReset) self.widget.cancel_pushButton.clicked.connect(self.close) #clean window self.update() self.slotReset() def initWindow(self, grpDict=None, attachDict=None): #COMPONENT variables if grpDict: if grpDict["startJoint"]: self.widget.startJoint_lineEdit.setText(grpDict["startJoint"]) if grpDict["side"]: self.widget.side_lineEdit.setText(grpDict["side"]) self.side = grpDict["side"] if grpDict["name"]: self.widget.name_lineEdit.setText(grpDict["name"]) self.name = grpDict["name"] if grpDict["endJoint"]: self.widget.endJoint_lineEdit.setText(grpDict["endJoint"]) if grpDict["orient"]: self.widget.orient_lineEdit.setText(grpDict["orient"]) if grpDict["orientLabel"]: self.widget.orientLabel_lineEdit.setText(grpDict["orientLabel"]) if grpDict["aim"]: self.widget.aim_lineEdit.setText(grpDict["aim"]) if grpDict["aimLabel"]: self.widget.aimLabel_lineEdit.setText(grpDict["aimLabel"]) #ATTACH variables if attachDict: if isinstance(attachDict["drivers"], (list,tuple)): for item in attachDict["drivers"]: self.widget.driver_listWidget.addItem(item) else: if attachDict["drivers"]: self.widget.driver_listWidget.addItem(attachDict["drivers"]) if isinstance(attachDict["labels"], (list, tuple)): for item in attachDict["labels"]: self.widget.labels_listWidget.addItem(item) else: if attachDict["labels"]: self.widget.labels_listWidget.addItem(attachDict["labels"]) if attachDict["config"]: self.widget.configNode_lineEdit.setText(attachDict["config"]) self.widget.attachPoint_True.setChecked(True) self.widget.attachOrient_True.setChecked(False) self.widget.attachScale_True.setChecked(False) if self.limb: self.pupList.addItem(self.limb) #self.widgetDict[self.limb] = self self.update() self.setSceneGroupDict(self._groupDict) 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.widget.startJoint_pushButton: self.widget.startJoint_lineEdit.setText(self._selectedItem()[0].shortName()) if self.widget.startJoint_lineEdit.text().find("Lf") > -1: self.side = "left" self.widget.side_lineEdit.setText("left") elif self.widget.startJoint_lineEdit.text().find("Rt") > -1: self.side = "right" self.widget.side_lineEdit.setText("right") else: self.side = None self.widget.side_lineEdit.clear() if self.side: self.name = self._selectedItem()[0].split(naming.getSideName(self.side))[0][:-2] self.widget.name_lineEdit.setText(self.name) else: self.name = self._selectedItem()[0].split("_bnd")[0][:-2] self.widget.name_lineEdit.setText(self._selectedItem()[0].split("_bnd")[0][:-2]) elif sender is self.widget.endJoint_pushButton: self.widget.endJoint_lineEdit.setText(self._selectedItem()[0].shortName()) elif sender is self.widget.orient_pushButton: self.widget.orient_lineEdit.setText(self._selectedItem()[0].shortName()) elif sender is self.widget.aim_pushButton: self.widget.aim_lineEdit.setText(self._selectedItem()[0].shortName()) #ATTACH SENDERS #driversList elif sender is self.widget.addDrivers_pushButton: self._addItem(self.widget.driver_listWidget, self._selectedItem()) elif sender is self.widget.removeDrivers_pushButton: self._removeItem(self.widget.driver_listWidget) #labelsList elif sender is self.widget.addLabels_pushButton: self._addItem(self.widget.labels_listWidget, self._selectedItem()) elif sender is self.widget.removeLabels_pushButton: self._removeItem(self.widget.labels_listWidget) #Get limb Name self.limb = self.widget.name_lineEdit.text() + naming.getSideName(self.side) self.update() def setSceneGroupDict(self, groupDict): '''local dict to check if window has been edited. deal with later when creating comp chunks''' self.oldLimb = self.limb self._sceneGroupDict = groupDict def slotReset(self): ''' not sure why it didnt let me override this method''' self.widget.startJoint_lineEdit.clear() self.widget.side_lineEdit.clear() self.widget.name_lineEdit.clear() self.widget.endJoint_lineEdit.clear() self.widget.orient_lineEdit.clear() self.widget.orientLabel_lineEdit.clear() self.widget.aim_lineEdit.clear() self.widget.aimLabel_lineEdit.clear() self.widget.driver_listWidget.clear() self.widget.labels_listWidget.clear() self.widget.attachPoint_True.setChecked(True) self.widget.attachOrient_True.setChecked(False) self.widget.attachScale_True.setChecked(False) def _selectedItem(self): '''return selected''' sel = pm.ls(selection=True) return sel def update(self): '''update dict with latest edits''' #COMPONENT DICT self._groupDict['startJoint'] = str(self.widget.startJoint_lineEdit.text()) self._groupDict['side'] = str(self.widget.side_lineEdit.text()) self._groupDict['name'] = str(self.widget.name_lineEdit.text()) self._groupDict['endJoint'] = self.widget.endJoint_lineEdit.text() self._groupDict['orient'] = self.widget.orient_lineEdit.text() self._groupDict['orientLabel'] = self.widget.orientLabel_lineEdit.text() self._groupDict['aim'] = self.widget.aim_lineEdit.text() self._groupDict['aimLabel'] = self.widget.aimLabel_lineEdit.text() #ATTACH DICT items = list() for index in xrange(self.widget.driver_listWidget.count()): items.append(self.widget.driver_listWidget.item(index).text()) self._attachDict["drivers"] = items items = list() for index in xrange(self.widget.labels_listWidget.count()): items.append(self.widget.labels_listWidget.item(index).text()) self._attachDict["labels"] = items self._attachDict["config"] = self.widget.configNode_lineEdit.text() self._attachDict["attachPoint"] = self.widget.attachPoint_True.isChecked() self._attachDict["attachOrient"] = self.widget.attachOrient_True.isChecked() self._attachDict["attachScale"] = self.widget.attachScale_True.isChecked() def closeEvent(self, event): self.settings.beginGroup("AssignNewGroupWidget") # set dict values for s in self._groupDict.keys(): txt = self._groupDict[s] self.settings.setValue(s, txt) for s in self._attachDict.keys(): txt = self._attachDict[s] self.settings.setValue(s, txt) self.settings.setValue("size", self.size()) self.settings.setValue("pos", self.pos()) self.settings.endGroup() def showEvent(self, event): ''' override showEvent, fill form with saved values''' super(AssignNewComponentWidget, self).showEvent(event) self.settings.beginGroup("AssignNewGroupWidget") #restore previous values for s in self._groupDict.keys(): text = self.settings.value(s) if text: if s == 'startJoint': self.widget.startJoint_lineEdit.setText(text.toString()) elif s == 'side': self.widget.side_lineEdit.setText(text.toString()) elif s == 'name': self.widget.name_lineEdit.setText(text.toString()) elif s == 'endJoint': self.widget.endJoint_lineEdit.setText(text) elif s == 'orient': self.widget.orient_lineEdit.setText(text.toString()) elif s == 'orientLabel': self.widget.orientLabel_lineEdit.setText(text) elif s == 'aim': self.widget.aim_lineEdit.setText(text.toString()) elif s == 'aimLabel': self.widget.aimLabel_lineEdit.setText(text) elif s == 'drivers': for x in text: self.widget.driver_listWidget.addItem(x.toString()) elif s == 'labels': for x in text: self.widget.labels_listWidget.addItem(x.toString()) elif s == 'attachPoint': self.widget.attachPoint_True.setChecked(bool(text.toString())) elif s == 'attachOrient': self.widget.attachPoint_True.setChecked(bool(text.toString())) elif s == 'attachScale': self.widget.attachPoint_True.setChecked(bool(text.toString())) def slotCreateGroup(self): ''' CHECK IF ALREADY A GROUP WORK ON LATER WHEN BUILDING CHUNKS, make more robust?? :type self: object ''' try: cmds.undoInfo(openChunk=True) #update puppet component list items = [] for index in xrange(self.pupList.count()): items.append(self.pupList.item(index).text()) try: items.index(self.limb) except: if self.limb != self.oldLimb: if self.oldLimb: self.pupList.takeItem(items.index(self.oldLimb)) self.pupList.addItem(self.limb) #reset widget pointer self.widgetDict[self.limb] = self self.setSceneGroupDict(self._groupDict) self.hide() self.refreshSignal.emit() finally: cmds.undoInfo(closeChunk=True) def returnGroupDictObjects(self): '''return limb, group dict, and attachdict to the all builder''' #ONLY RETURN IF EDITED return self.limb, self._groupDict, self._attachDict
class OtherDeformationWidget(form_class, base_class): closeSignal = QtCore.Signal() refreshSignal = QtCore.Signal() def __init__(self): super(OtherDeformationWidget, self).__init__() self.setupUi(self) self.setObjectName('otherDeformationTool') self.setWindowTitle('Other Deformation Tool') #ikNeck self.neckJnt_pushButton.clicked.connect(self.assignObject) self.headJnt_pushButton.clicked.connect(self.assignObject) self.ikNeckSystem_pushButton.clicked.connect(self.assignObject) #foot and hand System self.handFoot_pushButton.clicked.connect(self.assignObject) self.createHandFoot_pushButton.clicked.connect(self.assignObject) #tail/Tentacle System self.createTailSystem_pushButton.clicked.connect(self.assignObject) def assignObject(self): sender = self.sender() #checkboxes if sender is self.neckJnt_pushButton: sel = pm.ls(selection=True) if sel: self.neckJnt_lineEdit.setText(str(sel[0])) elif sender is self.headJnt_pushButton: sel = pm.ls(selection=True) if sel: self.headJnt_lineEdit.setText(str(sel[0])) elif sender is self.ikNeckSystem_pushButton: self.create_neckIkSystem() elif sender is self.handFoot_pushButton: sel = pm.ls(selection=True) if sel: self.handFoot_lineEdit.setText(str(sel[0])) elif sender is self.createHandFoot_pushButton: self.create_digitSystem() elif sender is self.createTailSystem_pushButton: self.create_tentacleSystem() @undoable def create_tentacleSystem(self): jnt = pm.ls(selection=True) if not jnt: pm.error('Select a joint to create system') numFollicles = self.numFollicle_spinBox.value() name = self.name_lineEdit.text() if self.center_radioButton.isChecked(): side = None elif self.left_radioButton.isChecked(): side = 'left' else: side = 'right' if name: TipName = naming.TipName(base=name, side=side, suffix='bnd') else: TipName = naming.TipName(name=jnt[0]) tailTentacleSystem.TailTentacleSystem(startJnt=jnt[0], name=TipName, numFollicles=numFollicles, muscle=False, slide=False, wave=False, scale=False) #@undoable def create_digitSystem(self): controls = self.handFoot_checkBox.isChecked() rootJnt = pm.PyNode(self.handFoot_lineEdit.text()) digitSystem.DigitSystem(rootJnt, controls=controls) @undoable def create_neckIkSystem(self): try: neckJnt = pm.PyNode(self.neckJnt_lineEdit.text()) headJnt = pm.PyNode(self.headJnt_lineEdit.text()) neckEnd = pm.PyNode(naming.TipName(name=neckJnt, index='end')) headEnd = pm.PyNode(naming.TipName(name=headJnt, index='end')) except error.ArgumentError, err: raise error.ArgumentError, err except error.MayaNodeError, err: raise error.MayaNodeError, err
class BonesWidget(form_class, base_class): closeSignal = QtCore.Signal() refreshSignal = QtCore.Signal()
def __init__(self, parent=None, componentDict=None, componentWidget=None, compType='FKComponent', assignPath=None, limb=None, puppet=None): super(EditWidget, self).__init__() #Init Default variables for Builder self.limb = limb self.oldLimb = None self.puppet = puppet self.compType = compType self.componentDict = componentDict self.componentListWidget = componentWidget if assignPath: self.compWidget = uic.loadUi(assignPath) #Add Hierarchy Widget self.hierWidget = uic.loadUi(HIERWIDGET) #Create Attach Widget attachObj = attachWidget.AttachWidget() self.attachWidget = attachObj #Add Execute Widget self.execWidget = uic.loadUi(EXECWIDGET) layout = QtGui.QVBoxLayout() if assignPath: layout.addWidget(self.compWidget) layout.addWidget(self.hierWidget) layout.addWidget(self.attachWidget) layout.addWidget(self.execWidget) self.setLayout(layout) #other settings #hierWidget width/height if assignPath: compHeight = self.compWidget.height() else: compHeight = 0 height = compHeight + self.hierWidget.height( ) + self.attachWidget.height() + self.execWidget.height() self.setMinimumSize(500, height - 100) self.setMaximumSize(500, height - 100) self.settings = QtCore.QSettings() #Open in the Middle of the Screen screenWidth, screenHeight = self.screenCenter() self.move(QtCore.QPoint(screenWidth, screenHeight)) #create dicts self._sceneGroupDict = dict() self._hierarchyAttrList = dict() self._attachAttrList = dict() if assignPath: self.compWidget.widget_groupBox.toggled.connect(self.showAttach) self.hierWidget.widget_groupBox.toggled.connect(self.showAttach) self.attachWidget.widget_groupBox.toggled.connect(self.showAttach) #ATTACH #attach widget things self.attachWidget.attachPoint_groupBox.clicked.connect( self.assignObject) self.attachWidget.attachPointNode_groupBox.clicked.connect( self.assignObject) self.attachWidget.attachOrient_groupBox.clicked.connect( self.assignObject) self.attachWidget.attachOrientNode_groupBox.clicked.connect( self.assignObject) #ATTACH SENDERS self.attachWidget.driven_pushButton.clicked.connect(self.assignObject) self.attachWidget.addDrivers_pushButton.clicked.connect( self.assignObject) self.attachWidget.removeDrivers_pushButton.clicked.connect( self.assignObject) self.attachWidget.loadConfig_pushButton.clicked.connect( self.assignObject) self.attachWidget.loadAttachPoint_pushButton.clicked.connect( self.assignObject) self.attachWidget.loadAttachOrient_pushButton.clicked.connect( self.assignObject) self.execWidget.cancel_pushButton.clicked.connect(self.close) #clean window self.slotReset() self.update()
class FaceWidget(form_class, base_class): closeSignal = QtCore.Signal() refreshSignal = QtCore.Signal() def __init__(self): super(FaceWidget, self).__init__() self.setupUi(self) self.setObjectName('FaceTemplateTool') self.setWindowTitle('Face Template Tool') #EYE RIG self.lEyeSystem = None self.rEyeSystem = None self.placeLoc1 = None self.createEyeSystem_pushButton.clicked.connect(self.assignObject) self.deleteEyeSystem_pushButton.clicked.connect(self.assignObject) self.loadHeadJoint_pushButton.clicked.connect(self.assignObject) self.loadJawJoint_pushButton.clicked.connect(self.assignObject) self.createLocator_pushButton.clicked.connect(self.assignObject) self.createLipSystem_pushButton.clicked.connect(self.assignObject) self.deleteLipSystem_pushButton.clicked.connect(self.assignObject) ''' self.closeUpperAttr_pushButton.clicked.connect(self.assignObject) self.closeLowerAttr_pushButton.clicked.connect(self.assignObject) self.connectLidAttrs_pushButton.clicked.connect(self.assignObject) self.connectFaceRig_pushButton.clicked.connect(self.connectFaceRig) self.updateFaceRig_pushButton.clicked.connect(self.updateFaceRig) ''' def assignObject(self): sender = self.sender() #checkboxes #eye system if sender is self.createEyeSystem_pushButton: self.create_eyeSystem() elif sender is self.deleteEyeSystem_pushButton: self.delete_system() #lip system #load head joint elif sender is self.loadHeadJoint_pushButton: headJnt = pm.ls(selection=True) if len(headJnt) != 1: pm.error("Select one head joint") else: self.headJoint_lineEdit.setText("%s" % headJnt[0]) #load jaw joint elif sender is self.loadJawJoint_pushButton: jawJnt = pm.ls(selection=True) if len(jawJnt) != 1: pm.error("Select one jaw joint") else: self.jawJoint_lineEdit.setText("%s" % jawJnt[0]) elif sender is self.createLocator_pushButton: self.create_locator() elif sender is self.createLipSystem_pushButton: self.create_lipSystem() elif sender is self.deleteLipSystem_pushButton: self.delete_system() @undoable def create_locator(self): ##########create LIP RIG on any joint try: jawJnt = pm.PyNode(self.jawJoint_lineEdit.text()) headJnt = pm.PyNode(self.headJoint_lineEdit.text()) except error.ArgumentError, err: raise error.ArgumentError, err except error.MayaNodeError, err: raise error.MayaNodeError, err