Ejemplo n.º 1
0
    def updateRamp( self, attr ):
        name = self.nodeName
        translator = cmds.getAttr(self.nodeAttr('aiTranslator'))

        uiParent = pm.setParent( q = True )
        controls = pm.columnLayout( uiParent, q=True, ca=True )
        
        curveString = ""
        attr = self.nodeAttr('aiShutterCurve')
        size = cmds.getAttr(attr, size=True)
        if size > 0:
            x = cmds.getAttr(attr+'[0].aiShutterCurveX')
            y = cmds.getAttr(attr+'[0].aiShutterCurveY')
            curveString += str(y) +"," + str(x) +",1"
        else:
            curveString += "1,0,1"
        for i in range(1,size):
            x = cmds.getAttr(attr+'['+str(i)+'].aiShutterCurveX')
            y = cmds.getAttr(attr+'['+str(i)+'].aiShutterCurveY')
            curveString += ","+str(y) +"," + str(x) +",1"
            
        valuesSplit = curveString.split(",")
        
        if controls:
            for c in controls:
                control = c +"|ShutterCurveRowLayout|ShutterCurveGradientControl"
                valueField = c +"|ShutterCurveRowLayout|ShutterCurveColumLayout|ShutterCurveValueLayout|ShutterCurveValueField"
                positionField = c +"|ShutterCurveRowLayout|ShutterCurveColumLayout|ShutterCurvePositionLayout|ShutterCurvePositionField"
                cmds.gradientControlNoAttr( control, edit=True, asString=curveString)
                current = cmds.gradientControlNoAttr( control, query=True, currentKey=True) 
                
                pm.floatField(valueField, edit=True, value=float(valuesSplit[current*3]))
                pm.floatField(positionField, edit=True, value=float(valuesSplit[current*3+1]))
Ejemplo n.º 2
0
    def syncAttribute(self, attr, control, valueField, positionField):
        attr = self.nodeAttr('aiShutterCurve')
        values = cmds.gradientControlNoAttr( control, query=True, asString=True) 
        valuesSplit = values.split(',')

        points = []

        for i in range(0,len(valuesSplit)/3):
            points.append([valuesSplit[i*3+1],valuesSplit[i*3],0])
            
        current = cmds.gradientControlNoAttr( control, query=True, currentKey=True) 
        cmds.floatField(valueField, edit=True, value=float(points[current][1]))
        cmds.floatField(positionField, edit=True, value=float(points[current][0]))
        points[current][2] = 1
        points.sort()
        
        size = cmds.getAttr(attr, size=True)
        for i in range(0,size):
            cmds.removeMultiInstance(attr+'['+str(i)+']')
        
        curveString = ""
        for i in range(0,len(points)):
            cmds.setAttr(attr+'['+str(i)+'].aiShutterCurveX',float(points[i][0]))
            cmds.setAttr(attr+'['+str(i)+'].aiShutterCurveY',float(points[i][1]))
            if i is 0:
                curveString += points[i][1] +"," + points[i][0] +",1"
            else:
                curveString += ","+points[i][1] +"," + points[i][0] +",1"
            
        # We save the curve points sorted in the attribute, so we will also resort the points in
        #  the gradient control
        current = [x[2] for x in points].index(1)
        cmds.gradientControlNoAttr( control, edit=True, currentKey=current, asString=curveString) 
Ejemplo n.º 3
0
 def installFalloffGradient(self):
     """"""
     layout = cmds.frameLayout( "falloffLayout",
                                l='Falloff:',
                                cl=True,
                                cll=True,
                                mw=5,
                                mh=5,
                                ec=lambda *args: self.resizeMainWindow(),
                                cc=lambda *args: self.resizeMainWindow())
     
     # Install falloff mode scroll List
     cmds.rowLayout(nc=2, adj=1)
     falloffMode = self.installFalloffOption()
     resetBtn = cmds.button(l='Reset', c=lambda *args: self.resetFalloff(), w=40)
     cmds.setParent( '..' )
     
     # Install falloff gradient control
     self.gradient = cmds.gradientControlNoAttr( 'falloffCurve', h=90)
     self.copyFromMayaFalloffCurve()
     cmds.gradientControlNoAttr( 'falloffCurve',
                                 e=True,
                                 optionVar='falloffCurveOptionVar',
                                 changeCommand=lambda *args: self.changeSoftSelectValue(),
                                 currentKeyChanged=lambda *args: self.softSelectCurveKeyChanged() )
     
     # Install interpolation scroll List
     interpolation = self.installInterpolationOption()
     
     cmds.setParent( '..' )
     return layout
Ejemplo n.º 4
0
    def installFalloffGradient(self):
        """"""
        layout = cmds.frameLayout("falloffLayout",
                                  l='Falloff:',
                                  borderStyle='etchedIn',
                                  cl=True,
                                  cll=True,
                                  mw=5,
                                  mh=5,
                                  ec=lambda *args: self.resizeMainWindow(),
                                  cc=lambda *args: self.resizeMainWindow())

        # Install falloff mode scroll List
        cmds.rowLayout(nc=2, adj=1)
        falloffMode = self.installFalloffOption()
        resetBtn = cmds.button(l='Reset',
                               c=lambda *args: self.resetFalloff(),
                               w=40)
        cmds.setParent('..')

        # Install falloff gradient control
        self.gradient = cmds.gradientControlNoAttr('falloffCurve', h=90)
        self.copyFromMayaFalloffCurve()
        cmds.gradientControlNoAttr(
            'falloffCurve',
            e=True,
            optionVar='falloffCurveOptionVar',
            changeCommand=lambda *args: self.changeSoftSelectValue(),
            currentKeyChanged=lambda *args: self.softSelectCurveKeyChanged())

        # Install interpolation scroll List
        interpolation = self.installInterpolationOption()

        cmds.setParent('..')
        return layout
Ejemplo n.º 5
0
 def createRamp( self, attr ):
     #Create the control fields
     pm.columnLayout( )
     
     cmds.rowLayout(nc=2, cw2=(142,220))
     pm.text("Shutter Curve");
     pm.text(" ");
     pm.cmds.setParent('..')
     
     cmds.rowLayout("ShutterCurveRowLayout",nc=2, cw2=(142,220))
     
     pm.columnLayout("ShutterCurveColumLayout")
     cmds.rowLayout("ShutterCurveValueLayout", nc=2, cw2=(60,45))
     pm.text("Value");
     valueField = pm.floatField("ShutterCurveValueField");
     pm.cmds.setParent('..')
     
     pm.rowLayout("ShutterCurvePositionLayout", nc=2, cw2=(60,45))
     pm.text("Position");
     
     positionField = cmds.floatField("ShutterCurvePositionField");
     pm.cmds.setParent('..')
     
     '''pm.rowLayout(nc=2, cw2=(60,65))
     pm.text("Interpol.");
     pm.optionMenu(changeCommand=self.updateRamp )
     pm.menuItem( label='None' )
     pm.menuItem( label='Linear' )
     pm.menuItem( label='Smooth' )
     pm.menuItem( label='Spline' )
     pm.cmds.setParent('..')'''
     pm.cmds.setParent('..')
     
     gradient = pm.gradientControlNoAttr("ShutterCurveGradientControl", w=200, h=100 )
     pm.gradientControlNoAttr( gradient, edit=True, changeCommand=pm.Callback(self.syncAttribute,attr,gradient, valueField, positionField) )
     
     #Initialize the curve with the values in the attribute
     curveString = ""
     attr = self.nodeAttr('aiShutterCurve')
     size = cmds.getAttr(attr, size=True)
     startX = 0
     startY = 1
     if size > 0:
         x = cmds.getAttr(attr+'[0].aiShutterCurveX')
         y = cmds.getAttr(attr+'[0].aiShutterCurveY')
         startX = x
         startY = y
         curveString += str(y) +"," + str(x) +",1"
     else:
         curveString += "1,0,1"
     for i in range(1,size):
         x = cmds.getAttr(attr+'['+str(i)+'].aiShutterCurveX')
         y = cmds.getAttr(attr+'['+str(i)+'].aiShutterCurveY')
         curveString += ","+str(y) +"," + str(x) +",1"
         
     cmds.gradientControlNoAttr( gradient, edit=True, asString=curveString) 
     
     pm.floatField(valueField, edit=True, value=startY, changeCommand=pm.Callback(self.updateValue, attr, gradient, valueField, positionField))
     pm.floatField(positionField, edit=True, value=startX, changeCommand=pm.Callback(self.updatePosition, attr, gradient, valueField, positionField))
Ejemplo n.º 6
0
 def setDefaultFalloffCurve(self):
     """"""
     cmds.optionVar( clearArray='falloffCurveOptionVar' )
     cmds.optionVar(stringValueAppend=[ 'falloffCurveOptionVar', '0,1,2'])
     cmds.optionVar(stringValueAppend=[ 'falloffCurveOptionVar', '1,0,2'])
     cmds.gradientControlNoAttr( self.gradient, e=True, optionVar='falloffCurveOptionVar' )
     cmds.gradientControlNoAttr( self.gradient, e=True, asString='0,1,2,1,0,2' )
     cmds.softSelect(e=1, ssc='0,1,2,1,0,2')
Ejemplo n.º 7
0
 def setDefaultFalloffCurve(self):
     """"""
     cmds.optionVar( clearArray='falloffCurveOptionVar' )
     cmds.optionVar(stringValueAppend=[ 'falloffCurveOptionVar', '0,1,2'])
     cmds.optionVar(stringValueAppend=[ 'falloffCurveOptionVar', '1,0,2'])
     cmds.gradientControlNoAttr( self.gradient, e=True, optionVar='falloffCurveOptionVar' )
     cmds.gradientControlNoAttr( self.gradient, e=True, asString='0,1,2,1,0,2' )
     cmds.softSelect(e=1, ssc='0,1,2,1,0,2')
Ejemplo n.º 8
0
    def setValue(self, rampPoints, asString=True):
        if asString:
            strVals = rampPoints
            rampPoints = self.asRampPoints(strVals)
        else:
            strVals = ",".join([each.asString() for each in rampPoints])

        mc.gradientControlNoAttr(self.rampCtrlName, e=1, asString=strVals)
        self._rampPoints = rampPoints
Ejemplo n.º 9
0
 def updatePosition(self, attr, control, valueField, positionField):
     value = pm.floatField(positionField, query=True, value=True)
     
     values = cmds.gradientControlNoAttr( control, query=True, asString=True) 
     valuesSplit = values.split(',')
         
     current = cmds.gradientControlNoAttr( control, query=True, currentKey=True) 
     
     valuesSplit[current*3+1] = str(value)
     values = ",".join(valuesSplit)
     
     pm.gradientControlNoAttr( control, edit=True, asString=values)
     self.syncAttribute(attr, control, valueField, positionField)
Ejemplo n.º 10
0
    def copyFromMayaFalloffCurve(self):
        """"""
        # Read maya's native soft select falloff curve
        curveValue = cmds.softSelect(q=1, ssc=1).split(',')
        curveValue = zip(curveValue[0::3], curveValue[1::3], curveValue[2::3])
        curveValue = [','.join(v) for v in curveValue]
        
        if cmds.optionVar( exists='falloffCurveOptionVar' ):
            cmds.optionVar( clearArray='falloffCurveOptionVar' )

        [cmds.optionVar( stringValueAppend=['falloffCurveOptionVar', v] ) for v in curveValue]
        
        cmds.gradientControlNoAttr( self.gradient, e=True, optionVar='falloffCurveOptionVar' )
Ejemplo n.º 11
0
    def copyFromMayaFalloffCurve(self):
        """"""
        # Read maya's native soft select falloff curve
        curveValue = cmds.softSelect(q=1, ssc=1).split(',')
        curveValue = zip(curveValue[0::3], curveValue[1::3], curveValue[2::3])
        curveValue = [','.join(v) for v in curveValue]
        
        if cmds.optionVar( exists='falloffCurveOptionVar' ):
            cmds.optionVar( clearArray='falloffCurveOptionVar' )

        [cmds.optionVar( stringValueAppend=['falloffCurveOptionVar', v] ) for v in curveValue]
        
        cmds.gradientControlNoAttr( self.gradient, e=True, optionVar='falloffCurveOptionVar' )
    def updatePosition(self, attr, control, valueField, positionField):
        value = pm.floatField(positionField, query=True, value=True)

        values = cmds.gradientControlNoAttr(control, query=True, asString=True)
        valuesSplit = values.split(',')

        current = cmds.gradientControlNoAttr(control,
                                             query=True,
                                             currentKey=True)

        valuesSplit[current * 3 + 1] = str(value)
        values = ",".join(valuesSplit)

        pm.gradientControlNoAttr(control, edit=True, asString=values)
        self.syncAttribute(attr, control, valueField, positionField)
Ejemplo n.º 13
0
def colourAtPoint(rampName,point):

    rampData = cmds.gradientControlNoAttr(rampName,q=True,asString=True)
    rampList = rampData.split(',')

    def channelGrad(channel,point):
        
        channelDict = {'R':0,'G':1,'B':2}
        channelInt = channelDict[channel]
        
        cmds.optionVar(stringValue=['tempRChannelOptVar', '%s,%s,1'%(rampList[channelInt],rampList[3])])
    
        positions = rampList[3::5]
        for i,c in enumerate(positions[1:]):
            cmds.optionVar(stringValueAppend=['tempRChannelOptVar', '%s,%s,1'%(rampList[channelInt::5][i+1],c)])
        
        tempGrad = cmds.gradientControlNoAttr(h=90,m=False)
        cmds.gradientControlNoAttr(tempGrad, e=True, optionVar='tempRChannelOptVar' )
        
        channelValue = cmds.gradientControlNoAttr(tempGrad, q=True, valueAtPoint=point )
        cmds.deleteUI(tempGrad, control=True )
        return channelValue
    
    R = channelGrad('R',point)
    G = channelGrad('G',point)
    B = channelGrad('B',point)
    
    return([R,G,B])
Ejemplo n.º 14
0
 def _initMayaGradientCtrl(self):
     self.rampCtrlName = cmds.gradientControlNoAttr(
         h=90,
         changeCommand=self.rampWidgetEditedCallback,
         p=self.layout.objectName())
     ptr = omui.MQtUtil.findControl(self.rampCtrlName)
     self.rampWidget = wrapInstance(int(ptr), QtWidgets.QWidget)
Ejemplo n.º 15
0
 def channelGrad(channel,point):
     
     channelDict = {'R':0,'G':1,'B':2}
     channelInt = channelDict[channel]
     
     cmds.optionVar(stringValue=['tempRChannelOptVar', '%s,%s,1'%(rampList[channelInt],rampList[3])])
 
     positions = rampList[3::5]
     for i,c in enumerate(positions[1:]):
         cmds.optionVar(stringValueAppend=['tempRChannelOptVar', '%s,%s,1'%(rampList[channelInt::5][i+1],c)])
     
     tempGrad = cmds.gradientControlNoAttr(h=90,m=False)
     cmds.gradientControlNoAttr(tempGrad, e=True, optionVar='tempRChannelOptVar' )
     
     channelValue = cmds.gradientControlNoAttr(tempGrad, q=True, valueAtPoint=point )
     cmds.deleteUI(tempGrad, control=True )
     return channelValue
Ejemplo n.º 16
0
 def updateCurrentRampPoint(self, mode, value):
     key = cmds.gradientControlNoAttr(self.rampCtrlName, q=1, currentKey=1)
     if mode == "value":
         self._rampPoints[key][0] = value
     elif mode == "pos":
         self._rampPoints[key][1] = value
     elif mode == "intrep":
         self._rampPoints[key][2] = value
     self.setValue(self._rampPoints)
Ejemplo n.º 17
0
    def updateCurrentRampPoint(self, mode):
        key = mc.gradientControlNoAttr(self.rampCtrlName, q=1, currentKey=1)
        if mode == "value":
            self._rampPoints[key].value = self.valueField.getValue()
        elif mode == "pos":
            self._rampPoints[key].pos = self.posField.getValue()
        elif mode == "interp":
            self._rampPoints[key].interp = self.interpCB.getData()

        self.setValue(self._rampPoints, asString=False)
    def syncAttribute(self, attr, control, valueField, positionField):
        attr = self.nodeAttr('aiShutterCurve')
        values = cmds.gradientControlNoAttr(control, query=True, asString=True)
        valuesSplit = values.split(',')

        points = []

        for i in range(0, len(valuesSplit) / 3):
            points.append([valuesSplit[i * 3 + 1], valuesSplit[i * 3], 0])

        current = cmds.gradientControlNoAttr(control,
                                             query=True,
                                             currentKey=True)
        cmds.floatField(valueField, edit=True, value=float(points[current][1]))
        cmds.floatField(positionField,
                        edit=True,
                        value=float(points[current][0]))
        points[current][2] = 1
        points.sort()

        size = cmds.getAttr(attr, size=True)
        for i in range(0, size):
            cmds.removeMultiInstance(attr + '[' + str(i) + ']')

        curveString = ""
        for i in range(0, len(points)):
            cmds.setAttr(attr + '[' + str(i) + '].aiShutterCurveX',
                         float(points[i][0]))
            cmds.setAttr(attr + '[' + str(i) + '].aiShutterCurveY',
                         float(points[i][1]))
            if i is 0:
                curveString += points[i][1] + "," + points[i][0] + ",1"
            else:
                curveString += "," + points[i][1] + "," + points[i][0] + ",1"

        # We save the curve points sorted in the attribute, so we will also resort the points in
        #  the gradient control
        current = [x[2] for x in points].index(1)
        cmds.gradientControlNoAttr(control,
                                   edit=True,
                                   currentKey=current,
                                   asString=curveString)
    def updateRamp(self, attr):
        name = self.nodeName
        translator = cmds.getAttr(self.nodeAttr('aiTranslator'))

        uiParent = pm.setParent(q=True)
        controls = pm.columnLayout(uiParent, q=True, ca=True)

        curveString = ""
        attr = self.nodeAttr('aiShutterCurve')
        size = cmds.getAttr(attr, size=True)
        if size > 0:
            x = cmds.getAttr(attr + '[0].aiShutterCurveX')
            y = cmds.getAttr(attr + '[0].aiShutterCurveY')
            curveString += str(y) + "," + str(x) + ",1"
        else:
            curveString += "1,0,1"
        for i in range(1, size):
            x = cmds.getAttr(attr + '[' + str(i) + '].aiShutterCurveX')
            y = cmds.getAttr(attr + '[' + str(i) + '].aiShutterCurveY')
            curveString += "," + str(y) + "," + str(x) + ",1"

        valuesSplit = curveString.split(",")

        if controls:
            for c in controls:
                control = c + "|ShutterCurveRowLayout|ShutterCurveGradientControl"
                valueField = c + "|ShutterCurveRowLayout|ShutterCurveColumLayout|ShutterCurveValueLayout|ShutterCurveValueField"
                positionField = c + "|ShutterCurveRowLayout|ShutterCurveColumLayout|ShutterCurvePositionLayout|ShutterCurvePositionField"
                cmds.gradientControlNoAttr(control,
                                           edit=True,
                                           asString=curveString)
                current = cmds.gradientControlNoAttr(control,
                                                     query=True,
                                                     currentKey=True)

                pm.floatField(valueField,
                              edit=True,
                              value=float(valuesSplit[current * 3]))
                pm.floatField(positionField,
                              edit=True,
                              value=float(valuesSplit[current * 3 + 1]))
Ejemplo n.º 20
0
def createCTRL_ui():
    window = qtBase.BaseWindow(qtBase.GetMayaWindow(),'createCtrl.ui')
    window._windowTitle = 'Create CTRL Window'
    window._windowName = 'createCtrlWindow'
    window.pathModify = 'ramenRig/'
    window.BuildUI()
    #layout for color slider
    qtLayout = window.mainWidget.ctrlColorLayout
    paneLayoutName = cmds.columnLayout()
    # Create slider widget
    csg = cmds.colorSliderGrp('ctrlColour',hsvValue=randomColor(),cc='ramenRig.createCtrlUi.setRampCol()')
    rgbColour = cmds.colorSliderGrp('ctrlColour',q=True,rgbValue=True)
    cmds.optionVar(stringValue=['falloffCurveOptionVar', '1,1,1'])
    cmds.optionVar(stringValueAppend=['falloffCurveOptionVar', '1,0,1'])
    cmds.gradientControlNoAttr( 'falloffCurve', h=70,w=250,rac=True)
    cmds.gradientControlNoAttr( 'falloffCurve', e=True, optionVar='falloffCurveOptionVar',clv=rgbColour )
    cmds.gradientControlNoAttr( 'falloffCurve', e=True,currentKey=1,clv=rgbColour,cc='ramenRig.createCtrlUi.setColour()' )

    # Find a pointer to the paneLayout that we just created using Maya API
    ptr = mui.MQtUtil.findControl(paneLayoutName)
    # Wrap the pointer into a python QObject. Note that with PyQt QObject is needed. In Shiboken we use QWidget.
    paneLayoutQt = shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget)
    # Now that we have a QtWidget, we add it to our Qt layout
    qtLayout.addWidget(paneLayoutQt)

    window.show(dockable=False)

    #connect buttons
    window.mainWidget.btn_circle.clicked.connect(lambda: createBtn('circle'))
    window.mainWidget.btn_square.clicked.connect(lambda: createBtn('square'))
    window.mainWidget.btn_star.clicked.connect(lambda: createBtn('star'))
    window.mainWidget.btn_diamond.clicked.connect(lambda: createBtn('diamond'))
    window.mainWidget.btn_plus.clicked.connect(lambda: createBtn('plus'))
    window.mainWidget.btn_cross.clicked.connect(lambda: createBtn('cross'))
    window.mainWidget.btn_arch.clicked.connect(lambda: createBtn('arch'))
    window.mainWidget.btn_pin.clicked.connect(lambda: createBtn('pin'))
    window.mainWidget.btn_arrow.clicked.connect(lambda: createBtn('arrow'))
    window.mainWidget.btn_doubleArrow.clicked.connect(lambda: createBtn('doubleArrow'))
    window.mainWidget.horizontalSlider_2.sliderMoved.connect(sizeSlider)
    window.mainWidget.doubleSpinBox.valueChanged.connect(sizeSpinbox)

    return window
Ejemplo n.º 21
0
 def setValue(self, rampPoints):
     valueStr = ','.join(
         [','.join([str(b) for b in a]) for a in rampPoints])
     cmds.gradientControlNoAttr(self.rampCtrlName, e=1, asString=valueStr)
     self._rampPoints = rampPoints
Ejemplo n.º 22
0
 def changeInterpolationValue(self):
     interp = cmds.optionMenuGrp(self.interpOption, q=1, sl=1)
     cmds.gradientControlNoAttr(self.gradient, e=1, civ=interp-1)
Ejemplo n.º 23
0
 def changeSoftSelectValue(self):
     curveValue = cmds.gradientControlNoAttr(self.gradient, q=1, asString=1)
     cmds.softSelect(e=1, ssc=curveValue)
Ejemplo n.º 24
0
 def softSelectCurveKeyChanged(self):
     """"""
     interp = cmds.gradientControlNoAttr(self.gradient, q=1, civ=1)
     cmds.optionMenuGrp(self.interpOption, e=1, sl=interp+1)
Ejemplo n.º 25
0
 def changeInterpolationValue(self):
     interp = cmds.optionMenuGrp(self.interpOption, q=1, sl=1)
     cmds.gradientControlNoAttr(self.gradient, e=1, civ=interp - 1)
Ejemplo n.º 26
0
 def softSelectCurveKeyChanged(self):
     """"""
     interp = cmds.gradientControlNoAttr(self.gradient, q=1, civ=1)
     cmds.optionMenuGrp(self.interpOption, e=1, sl=interp + 1)
Ejemplo n.º 27
0
 def updateValueField(self):
     currValue = round(mc.gradientControlNoAttr(self.rampCtrlName, q=1, currentKeyCurveValue=1), 4)
     self.valueField.setValue(currValue)
Ejemplo n.º 28
0
 def updatePosField(self):
     currKey = mc.gradientControlNoAttr(self.rampCtrlName, q=1, currentKey=1)
     pos = self._rampPoints[currKey].pos
     self.posField.setValue(pos)
Ejemplo n.º 29
0
def setColour():
    col00 = cmds.gradientControlNoAttr( 'falloffCurve',q=True,currentKeyColorValue=True)
    cmds.colorSliderGrp('ctrlColour',e=True,rgbValue=col00)
Ejemplo n.º 30
0
 def updateValueField(self):
     currValue = round(
         cmds.gradientControlNoAttr(self.rampCtrlName,
                                    q=1,
                                    currentKeyCurveValue=1), 4)
     self.valueField.setValue(currValue)
Ejemplo n.º 31
0
 def updateInterpField(self):
     interp = mc.gradientControlNoAttr(self.rampCtrlName, q=1, currentKeyInterpValue=1)
     self.interpCB.setCurrentIndex(interp)
Ejemplo n.º 32
0
 def updatePosField(self):
     currKey = cmds.gradientControlNoAttr(self.rampCtrlName,
                                          q=1,
                                          currentKey=1)
     pos = self._rampPoints[currKey][1]
     self.posField.setValue(pos)
Ejemplo n.º 33
0
 def _initMayaGradientCtrl(self):
     mc.window()
     mc.columnLayout()
     rampCtrl = mc.gradientControlNoAttr(h=90, changeCommand=self.rampWidgetEditedCallback)
     self.rampWidget = convertMayaControl(rampCtrl)
     self.rampCtrlName = rampCtrl
Ejemplo n.º 34
0
 def changeSoftSelectValue(self):
     curveValue = cmds.gradientControlNoAttr(self.gradient, q=1, asString=1)
     cmds.softSelect(e=1, ssc=curveValue)
Ejemplo n.º 35
0
 def getValueAtPoint(self, point):
     return cmds.gradientControlNoAttr(self.rampCtrlName,
                                       q=1,
                                       valueAtPoint=point)
Ejemplo n.º 36
0
 def updateInterpField(self):
     interp = cmds.gradientControlNoAttr(self.rampCtrlName,
                                         q=1,
                                         currentKeyInterpValue=1)
     self.interpCB.setCurrentIndex(interp)
    def createRamp(self, attr):
        #Create the control fields
        pm.columnLayout()

        cmds.rowLayout(nc=2, cw2=(142, 220))
        pm.text("Shutter Curve")
        pm.text(" ")
        pm.cmds.setParent('..')

        cmds.rowLayout("ShutterCurveRowLayout", nc=2, cw2=(142, 220))

        pm.columnLayout("ShutterCurveColumLayout")
        cmds.rowLayout("ShutterCurveValueLayout", nc=2, cw2=(60, 45))
        pm.text("Value")
        valueField = pm.floatField("ShutterCurveValueField")
        pm.cmds.setParent('..')

        pm.rowLayout("ShutterCurvePositionLayout", nc=2, cw2=(60, 45))
        pm.text("Position")

        positionField = cmds.floatField("ShutterCurvePositionField")
        pm.cmds.setParent('..')
        '''pm.rowLayout(nc=2, cw2=(60,65))
        pm.text("Interpol.");
        pm.optionMenu(changeCommand=self.updateRamp )
        pm.menuItem( label='None' )
        pm.menuItem( label='Linear' )
        pm.menuItem( label='Smooth' )
        pm.menuItem( label='Spline' )
        pm.cmds.setParent('..')'''
        pm.cmds.setParent('..')

        gradient = pm.gradientControlNoAttr("ShutterCurveGradientControl",
                                            w=200,
                                            h=100)
        pm.gradientControlNoAttr(gradient,
                                 edit=True,
                                 changeCommand=pm.Callback(
                                     self.syncAttribute, attr, gradient,
                                     valueField, positionField))

        #Initialize the curve with the values in the attribute
        curveString = ""
        attr = self.nodeAttr('aiShutterCurve')
        size = cmds.getAttr(attr, size=True)
        startX = 0
        startY = 1
        if size > 0:
            x = cmds.getAttr(attr + '[0].aiShutterCurveX')
            y = cmds.getAttr(attr + '[0].aiShutterCurveY')
            startX = x
            startY = y
            curveString += str(y) + "," + str(x) + ",1"
        else:
            curveString += "1,0,1"
        for i in range(1, size):
            x = cmds.getAttr(attr + '[' + str(i) + '].aiShutterCurveX')
            y = cmds.getAttr(attr + '[' + str(i) + '].aiShutterCurveY')
            curveString += "," + str(y) + "," + str(x) + ",1"

        cmds.gradientControlNoAttr(gradient, edit=True, asString=curveString)

        pm.floatField(valueField,
                      edit=True,
                      value=startY,
                      changeCommand=pm.Callback(self.updateValue, attr,
                                                gradient, valueField,
                                                positionField))
        pm.floatField(positionField,
                      edit=True,
                      value=startX,
                      changeCommand=pm.Callback(self.updatePosition, attr,
                                                gradient, valueField,
                                                positionField))