コード例 #1
0
    def __setParameterValue(self, constant, value, createKeyframe):
        from Katana import FormMaster
        names = self.getProfile().getConstant(constant)
        param = self.__searchShaderParameters(names, edit=True)
        if param:
            frame = NodegraphAPI.GetCurrentTime()
            valueParam = param.getChild('value')
            oldValue = valueParam.getValue(NodegraphAPI.GetCurrentTime())
            if valueParam.isExpression():
                # Cannot keyframe an expression
                raise ScriptItems.AnimatingExpressionException(oldValue)

            elif param.isAnimated() and not NodegraphAPI.GetAutoKeyAll():
                if not valueParam.hasKey(frame) and createKeyframe:
                    valueParam.setKey(frame)
                elif valueParam.hasKey(
                        frame) is False and param.getAutoKey() is False:
                    raise ScriptItems.AnimationKeyNotFoundException(oldValue)

            FormMaster.CreateParameterPolicy(None, param).setValue(value)
コード例 #2
0
        def mousePressEvent(self, event, item, column):
            if not item: return
            if column == C.COLUMN_SHADER:
                return self.__class__.ShaderColumnClickEvent(
                    self, event, item, column)
            elif column == C.COLUMN_COLOR:

                button = event.button()

                if button == QtCore.Qt.LeftButton:
                    policy = self.getScriptItem().getColorPolicy()
                    if policy:

                        isAnimationCurve = False

                        needsKeyFrames = False
                        autoKeyEnabled = NodegraphAPI.GetAutoKeyAll()

                        for child in policy.getArrayChildren():

                            if child.isCurveEnabled():
                                isAnimationCurve = True

                            if not NodegraphAPI.GetAutoKeyAll(
                            ) and not child.getCurveAutoKey():
                                autoKeyEnabled = False

                            if not child.getCurveKey():
                                needsKeyFrames = True

                        if isAnimationCurve and needsKeyFrames and autoKeyEnabled is False:
                            QtGui.QMessageBox.question(
                                None, "Changing animated parameter",
                                "Warning, one or more of the color channels are animated without auto-key frame enabled. You may need to add key frames when changing this color or activate auto-keying",
                                "OK")

                        UI4.Util.Color.ShowColorPicker(policy)

                    #TODO, handle multiselection case

                elif button == QtCore.Qt.MidButton:

                    policy = self.getScriptItem().getColorPolicy()
                    if policy is None:
                        return GafferUIItem.mousePressEvent(
                            self, event, item, column)

                    dragDict = QT4Color.GetColorPolicyDragDict(policy)
                    dragDict['itemhash'] = hash(item)
                    dragData = QT4Color.BuildDragDataFromInfo(**dragDict)
                    mimeData = QtCore.QMimeData()
                    mimeData.setData(QT4Color.GetColorDragType(), dragData)

                    pixmap = QT4Widgets.InteractiveDrag.buildDragPixmap(
                        QT4Color.BuildDragPixmapFromColor(dragDict['color']),
                        1)
                    drag = QT4Widgets.InteractiveDrag(item.treeWidget(),
                                                      mimeData, pixmap)
                    event.accept()

                    drag.exec_()

            else:
                return GafferUIItem.mousePressEvent(self, event, item, column)