Exemple #1
0
    def selectInScene(self):
        """
        Call back function. Triggered when selction changed.
        """
        sel = cmds.ls(sl=1, l=1, type='transform')
        rows = self.treeWidget.topLevelItemCount()
        cols = self.treeWidget.columnCount()

        for i in range(0, rows):
            self.treeWidget.takeTopLevelItem(0)

        if not sel:
            return

        customAttrList = cmds.listAttr(sel[-1], ud=1)
        attrList = list()
        attrList = channels.CHANNELNAMES
        if customAttrList:
            attrList = channels.CHANNELNAMES + customAttrList
        self.mapperSlider = QtCore.QSignalMapper()
        i = 0
        for attr in attrList:
            if attr == 'attrTag':
                continue

            sliderIdA = str(i) + '|'
            item = QtWidgets.QTreeWidgetItem(self.treeWidget)
            ## Column 0
            item.setText(0, attr)
            for col in range(1, cols):
                sliderId = sliderIdA + str(col)
                ## Column 1, 2, 3
                slider = QtWidgets.QSlider(QtCore.Qt.Horizontal,
                                           self.treeWidget)
                self.treeWidget.setItemWidget(item, col, slider)
                slider.setMaximumWidth(self.sliderRange)
                slider.setMaximum(self.sliderRange)
                slider.setPageStep(self.sliderRange)
                slider.setStyleSheet(STYLESHEET)

                self.mapperSlider.setMapping(slider, sliderId)
                slider.sliderReleased.connect(self.mapperSlider.map)
            i += 1
        self.mapperSlider.mapped['QString'].connect(self.snapToEnd)

        self.readCurrentStatus(sel[-1])
Exemple #2
0
    def initialize(self):
        # add validators
        self.data['lineedit']['x'].setValidator(
            QtGui.QDoubleValidator(0, 180, 2))
        self.data['lineedit']['y'].setValidator(
            QtGui.QDoubleValidator(0, 180, 2))
        self.data['lineedit']['z'].setValidator(
            QtGui.QDoubleValidator(0, 180, 2))

        self.data['lineedit']['minScale'].setValidator(
            QtGui.QDoubleValidator(1.0, 100, 2))
        self.data['lineedit']['maxScale'].setValidator(
            QtGui.QDoubleValidator(1.0, 100, 2))

        # add buttons - add control curve
        dirs = os.listdir(ctrls.CONTROLS_DIRECTORY)
        col = 6
        row = 0
        count = 0
        self.mapperAddCurve = QtCore.QSignalMapper()
        for fileName in dirs:
            if fileName.endswith('.json'):
                if count == 6:
                    count = 0
                    row += 1
                btn = QtWidgets.QPushButton()
                btn.setToolTip(fileName)
                iconName = fileName.replace('.json', '.png')
                if iconName in dirs:
                    iconPath = os.path.join(ctrls.CONTROLS_DIRECTORY, iconName)
                    btn.setIcon(QtGui.QIcon(iconPath))
                    btn.setIconSize(QtCore.QSize(30, 30))
                self.data['layouts']['addCurve'].addWidget(btn, row, count)
                count += 1
                self.mapperAddCurve.setMapping(btn, fileName)
                btn.clicked.connect(self.mapperAddCurve.map)
        self.mapperAddCurve.mapped['QString'].connect(self.addCtrlShape)

        # add buttons - color
        self.mapperColor = QtCore.QSignalMapper()
        col = 8
        row = 0
        count = 4
        for i in xrange(1, 32):
            if count == col:
                count = 0
                row += 1
            rgb = cmds.colorIndex(i, q=True)
            r, g, b = rgb[0], rgb[1], rgb[2]
            btn = QtWidgets.QPushButton()
            btn.btnIndex = count
            btn.setAutoFillBackground(True)
            values = "{r}, {g}, {b}, {a}".format(r=r * 255,
                                                 g=g * 255,
                                                 b=b * 255,
                                                 a=255)
            btn.setStyleSheet("QPushButton { background-color: rgba(" +
                              values + "); }")
            self.data['layouts']['color'].addWidget(btn, row, count)
            count += 1
            self.mapperColor.setMapping(btn, i)
            btn.clicked.connect(self.mapperColor.map)
        self.mapperColor.mapped['int'].connect(self.colorShapes)