當前位置: 首頁>>代碼示例>>Python>>正文


Python NodeUtility.getPlug方法代碼示例

本文整理匯總了Python中marigold.utility.NodeUtility.getPlug方法的典型用法代碼示例。如果您正苦於以下問題:Python NodeUtility.getPlug方法的具體用法?Python NodeUtility.getPlug怎麽用?Python NodeUtility.getPlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在marigold.utility.NodeUtility的用法示例。


在下文中一共展示了NodeUtility.getPlug方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: storeControlTransforms

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
def storeControlTransforms( sourceObj, targetObj ):
    '''
    Store control transform data.
    
    @param sourceObj: String. Name of object to pull data from.
    @param targetObj: String. Name of object to store data on.
    '''    
    sourceMatrix = TransformUtility.getMatrix( sourceObj, 'matrix' )
    
    # Store the position
    targetPosPlug = NodeUtility.getPlug( targetObj, 'controlPosition' )
    sourceTranslation = TransformUtility.getMatrixTranslation( sourceMatrix, OpenMaya.MSpace.kTransform )
    pos = [ sourceTranslation.x, sourceTranslation.y, sourceTranslation.z ]
    NodeUtility.setPlugValue( targetPosPlug, pos )
    
    # Store the rotation
    targetRotPlug = NodeUtility.getPlug( targetObj, 'controlRotation' )
    sourceRotation = TransformUtility.getMatrixRotation( sourceMatrix, 'euler' )
    #rot = [ degrees(angle) for angle in (sourceRotation.x, sourceRotation.y, sourceRotation.z) ]
    rot = [ sourceRotation.x, sourceRotation.y, sourceRotation.z ]
    NodeUtility.setPlugValue( targetRotPlug, rot )
    
    # Store the scale.
    targetSclPlug = NodeUtility.getPlug( targetObj, 'controlScale' )
    sourceScale = TransformUtility.getMatrixScale( sourceMatrix, OpenMaya.MSpace.kTransform )
    scl = [ sourceScale.x, sourceScale.y, sourceScale.z ]
    NodeUtility.setPlugValue( targetSclPlug, scl )
開發者ID:EriLee,項目名稱:marigold,代碼行數:29,代碼來源:__init__.py

示例2: copyBitSettings

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
def copyBitSettings():
    '''
    Copies the bit shape settings (OpenGL stuff) from the second object to the
    first (in selection order).
    '''
    selList = cmds.ls( selection=True, long=True )
    depFn = OpenMaya.MFnDependencyNode()
    
    if len(selList) == 2:
        # First object is target.
        targetShape = cmds.listRelatives( selList[0], shapes=True, fullPath=True )[0]
        targetShapeMObj = NodeUtility.getDependNode( targetShape )
        depFn.setObject( targetShapeMObj )
        targetShapeType = depFn.typeName()
        
        # Second object is source.
        sourceShape = cmds.listRelatives( selList[1], shapes=True, fullPath=True )[0]
        sourceShapeMObj = NodeUtility.getDependNode( sourceShape )
        depFn.setObject( sourceShapeMObj )
        sourceShapeType = depFn.typeName()
        
        if targetShapeType == sourceShapeType:        
            # The types match. Do the copy of attribute settings.
            for attr in cmds.listAttr( sourceShape, multi=True, keyable=True ):
                # Get the plugs.
                sourcePlug = NodeUtility.getPlug( sourceShape, attr )
                targetPlug = NodeUtility.getPlug( targetShape, attr )
                
                # Get the source plug value.
                sourcePlugValue = NodeUtility.getPlugValue( sourcePlug )
                
                # Set the target's plug value.
                NodeUtility.setPlugValue( targetPlug, sourcePlugValue )
        else:
            raise ValueError( '{0} and {1} do not match.'.format( selList[0], selList[1] ) )
開發者ID:EriLee,項目名稱:marigold,代碼行數:37,代碼來源:FrameUtility.py

示例3: applyStoredTransforms

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
def applyStoredTransforms( sourceObj, targetObj ):
    '''
    Applies stored transform data for a control object.
    
    @param sourceObj: String. Name of object to pull data from.
    @param targetObj: String. Name of object to apply data to.
    '''
    #print 'applyStoredTransforms @@@@@@'
    #print 'sourceObj: {0}'.format( sourceObj )
    #print 'targetObj: {0}'.format( targetObj )
    
    MFnTrans = OpenMaya.MFnTransform()
    targetDagPath = NodeUtility.getDagPath( targetObj )
    MFnTrans.setObject( targetDagPath )
    
    sourcePosPlug = NodeUtility.getPlug( sourceObj, 'controlPosition' )
    sourcePosValue = NodeUtility.getPlugValue( sourcePosPlug )
    sourcePos = OpenMaya.MVector( sourcePosValue[0], sourcePosValue[1], sourcePosValue[2] )
    MFnTrans.setTranslation( sourcePos, OpenMaya.MSpace.kTransform )
    
    sourceRotPlug = NodeUtility.getPlug( sourceObj, 'controlRotation' )
    sourceRotValue = NodeUtility.getPlugValue( sourceRotPlug )
    sourceRot = OpenMaya.MEulerRotation( sourceRotValue[0], sourceRotValue[1], sourceRotValue[2] ) 
    MFnTrans.setRotation( sourceRot )
    
    sourceSclPlug = NodeUtility.getPlug( sourceObj, 'controlScale' )
    sourceSclValue = NodeUtility.getPlugValue( sourceSclPlug )
    scaleDoubleArray = OpenMaya.MScriptUtil()
    scaleDoubleArray.createFromList( [sourceSclValue[0], sourceSclValue[1], sourceSclValue[2]], 3 )
    scaleDoubleArrayPtr = scaleDoubleArray.asDoublePtr()
    MFnTrans.setScale( scaleDoubleArrayPtr )
開發者ID:EriLee,項目名稱:marigold,代碼行數:33,代碼來源:__init__.py

示例4: mirrorModule

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
def mirrorModule():
    # Mirrors a module.
    selList = cmds.ls( selection=True, long=True )
    if len( selList ) == 1:
        # Prompt for axis.
        mirrorAxis = int( cmds.layoutDialog( ui=mirrorObjectPrompt ) )
        
        inBitObj = selList[0]
    
        # Check if selected bit is the root.
        if NodeUtility.attributeCheck( inBitObj, 'frameRoot' ):
            # This is the root bit of the module. From here we know we can get the
            # meta node by accessing the frameRoot attribute.
            metaNode = NodeUtility.getNodeAttrDestination( inBitObj, 'frameRoot' )[0]
        else:
            # The selected bit is not the root. Run through each custom attribute
            # to find one connected to the meta node.
            attrList = cmds.listAttr( inBitObj, userDefined=True )
            for attr in attrList:
                connection = NodeUtility.getNodeAttrDestination( inBitObj, attr )
                if NodeUtility.attributeCheck( connection[0], 'metaType' ):
                    metaNode = connection[0]
                    break
                
        # Now that we have the meta node, we need the XML file name and it's location.
        metaClassPlug = NodeUtility.getPlug( metaNode, 'metaClass' )
        metaClassValue = NodeUtility.getPlugValue( metaClassPlug )
        
        metaBuildFolderPlug = NodeUtility.getPlug( metaNode, 'buildFolder' )
        metaBuildFolderValue = NodeUtility.getPlugValue( metaBuildFolderPlug )
        
        # Create the target module.
        '''
        NEED TO FIX THIS!
        targetRootBit = buildFrameModule( metaBuildFolderValue, metaClassValue )
        '''
    
        # Loop through each object in the source module.
        metaRootBit = NodeUtility.getNodeAttrSource( metaNode, 'rootBit' )[0]
        
        sourceChildBits = NodeUtility.getFrameRootAllChildren( metaRootBit )
        targetChildBits = NodeUtility.getFrameRootAllChildren( targetRootBit )
        
        sourceBits = []
        targetBits = []
        
        for i,bit in enumerate( sourceChildBits ):
            sourceBits.append( bit )
        sourceBits.insert( 0, metaRootBit )
        
        for i, bit in enumerate( targetChildBits ):
            targetBits.append( bit )
        targetBits.insert( 0, targetRootBit )
        
        for bit in xrange( len(sourceBits) ):
            # Mirror the source onto the target.
            mirrorObject( inSourceObj=sourceBits[bit], inTargetObj=targetBits[bit], inMirrorAxis=mirrorAxis )
開發者ID:EriLee,項目名稱:marigold,代碼行數:59,代碼來源:TransformUtility.py

示例5: setPriorities

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
 def setPriorities( self ):
     '''
     Applies the user adjusted priorities to all the modules of a character.
     '''
     for index in xrange( self.dropList.count() ):
         moduleName = self.dropList.item( index ).text()
         moduleComponent = self.modDict[moduleName][0]
         priorityPlug = NodeUtility.getPlug( moduleComponent, 'buildPriority' )
         NodeUtility.setPlugValue( priorityPlug, index )
         
     self.close()
開發者ID:EriLee,項目名稱:marigold,代碼行數:13,代碼來源:UICharacterPriorityPrompt.py

示例6: __init__

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
 def __init__( self, nodeName, parent=None ):
     super( componentWidget, self ).__init__( parent )
     self.parent = parent
     
     def on_context_menu( point, inNodeName ):
         popMenu = QtGui.QMenu()
         deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) )
         popMenu.addAction( deleteAction )
         
         popMenu.exec_( self.componentLabel.mapToGlobal( point ) )
         
     # Setup layout.
     verticalLayout = QtGui.QVBoxLayout()
     verticalLayout.setContentsMargins( 0,0,0,0 )
     verticalLayout.setSpacing( 0 )
     verticalLayout.setAlignment( QtCore.Qt.AlignTop )
     
     # Label for component
     componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 )
     componentLabel.setMinimumHeight( 18 )    
     componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
     componentLabel.customContextMenuRequested.connect( lambda point, nodeName=nodeName:on_context_menu( point, nodeName ) )
     
     # Properties
     propertyStack = QtGui.QVBoxLayout()
     
     propertyFrame = QTWidgets.basicFrame()
     propertyFrame.setMinimumHeight( 40 )
     propertyFrame.setMaximumHeight( 40 )
     
     # Add string edit property
     modulePlug = NodeUtility.getPlug( nodeName, 'moduleName' )
     moduleValue = NodeUtility.getPlugValue( modulePlug )
     moduleTextLayout = QTWidgets.stringProperty( 'Module Name', moduleValue )
     
     '''
     ADD EDIT FIELDS FOR PRIORITY AND CHARACTER ROOT!!!!!!!!!
     '''
     
     # Add everything to the vertical layout.
     propertyStack.addLayout( moduleTextLayout )        
     propertyFrame.setLayout( propertyStack )
     
     verticalLayout.addWidget( componentLabel )
     verticalLayout.addWidget( propertyFrame )
     
     # Connections
     moduleTextBox = propertyFrame.findChild( QtGui.QLineEdit, 'Module Name' )
     moduleTextBox.editingFinished.connect( lambda inPlugName='moduleName', inQTType='QLineEdit', inPlugValue=moduleTextBox, inNodeName=nodeName
                                            :ModuleRootComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) )
     
     #return mainWidget
     self.setLayout( verticalLayout )
開發者ID:EriLee,項目名稱:marigold,代碼行數:55,代碼來源:ModuleRoot.py

示例7: __init__

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
    def __init__( self, nodeName, parent=None ):
        super( componentWidget, self ).__init__( parent )
        self.parent = parent
                
        def on_context_menu( point, inNodeName ):
            popMenu = QtGui.QMenu()
            buildAction = QtGui.QAction( 'Build Joint', popMenu, triggered=lambda a=inNodeName:self.buildNode( a ) )
            popMenu.addAction( buildAction )
            
            deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) )
            popMenu.addAction( deleteAction )
            
            popMenu.exec_( componentLabel.mapToGlobal( point ) )
        
        # Setup layout.
        verticalLayout = QtGui.QVBoxLayout()
        verticalLayout.setContentsMargins( 0,0,0,0 )
        verticalLayout.setSpacing( 0 )
        verticalLayout.setAlignment( QtCore.Qt.AlignTop )
                
        # Label for component
        componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 )
        componentLabel.setMinimumHeight( 18 )    
        componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
        componentLabel.customContextMenuRequested.connect( lambda point, node=nodeName:on_context_menu( point, node ) )
        
        # Properties
        propertyStack = QtGui.QVBoxLayout()
        
        propertyFrame = QTWidgets.basicFrame()
        propertyFrame.setMinimumHeight( 40 )
        propertyFrame.setMaximumHeight( 40 )
        
        # Add string edit property
        propertyPlug = NodeUtility.getPlug( nodeName, 'jointName' )
        propertyValue = NodeUtility.getPlugValue( propertyPlug )
        jointTextLayout = QTWidgets.stringProperty( 'Joint Name', propertyValue )
        
        propertyStack.addLayout( jointTextLayout )        
        propertyFrame.setLayout( propertyStack )
        
        verticalLayout.addWidget( componentLabel )
        verticalLayout.addWidget( propertyFrame )

        # Connections
        textBox = propertyFrame.findChild( QtGui.QLineEdit )
        textBox.editingFinished.connect( lambda inPlugName='jointName', inQTType='QLineEdit', inPlugValue=textBox, inNodeName=nodeName
                                         :BasicJointComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) )
        
        self.setLayout( verticalLayout )
開發者ID:EriLee,項目名稱:marigold,代碼行數:52,代碼來源:BasicJoint.py

示例8: nodeRotation

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
 def nodeRotation( self ):
     '''
     dagFn= OpenMaya.MFnDagNode( self.fNodePath )
     path = OpenMaya.MDagPath()
     dagFn.getPath( path )
     path.pop()
     transformFn = OpenMaya.MFnTransform( path )
     q = OpenMaya.MQuaternion()
     transformFn.getRotation( q, OpenMaya.MSpace.kWorld )
     return q
     '''
     plug = NodeUtility.getPlug( 'ControlBox1', 'rotate' )
     rot = NodeUtility.getPlugValue( plug )
     e = OpenMaya.MEulerRotation( rot[0], rot[1], rot[2] )
     return e
開發者ID:EriLee,項目名稱:marigold,代碼行數:17,代碼來源:rigControllers.py

示例9: getFrameBitSettings

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
def getFrameBitSettings( inFrameBit ):
    '''
    Retrieves the settings for the frame bit.
    
    @param inFrameBit: String. Name of frame bit.
    @return: Dictionary. All the custom attributes on the frame bit.
    '''    
    attrList = cmds.listAttr( inFrameBit, userDefined=True )
    if attrList is not None:
        tempDict = {}
        for attr in attrList:
            plug = NodeUtility.getPlug( inFrameBit, attr )
            plugValue = NodeUtility.getPlugValue( plug )
            tempDict[ attr ] = plugValue
    else:
        tempDict = None
    return tempDict
開發者ID:EriLee,項目名稱:marigold,代碼行數:19,代碼來源:FrameUtility.py

示例10: saveModule

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
 def saveModule( self ):
     '''
     Save the module into an XML file for re-use.
     We assume that the root node of the module is the one with the module root meta node.
     This means it and all of it's children will be saved in the XML.
     '''
     # Get the selected module
     item = cmds.ls( long=True, selection=True )[0]
     
     # Try to get the module meta component.
     moduleComp = Components.searchModule( item, 'ModuleRootComponent' )
     
     if moduleComp:
         # Get the module info and save it as an XML.
         modulePlug = NodeUtility.getPlug( moduleComp[1], 'moduleName' )
         moduleName = NodeUtility.getPlugValue( modulePlug )
         XMLUtility.writeModuleXML( moduleComp[0], self.SELECTED_ITEM, moduleName )
開發者ID:EriLee,項目名稱:marigold,代碼行數:19,代碼來源:UILatticesTools.py

示例11: setBitChild

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
def setBitChild( inParent=None, inChild=None ):
    '''
    Connects the child object's matrix plug to the parent object's
    targetWorldMatrix array plug. This plug's data is used by the parent's
    draw() to render the hierarchy arrows.
    
    @param inParent: String. Name of the parent object.
    @param inChild: String. Name of the child object.
    '''
    if inParent is None or inChild is None:
        # Get selection and return the longnames of the objects.
        selList = cmds.ls( selection=True, long=True )
        if len(selList) is 2:
            # The child is the first object.
            # The parent is the second object.
            child = selList[0]
            parent = selList[1]
        else:
            return
    else:
        child = inChild
        parent = inParent
            
    # Get the parent shape's child matrix attribute.
    pShape = cmds.listRelatives( parent, type='shape', allDescendents=False )[0]
    shapeName = '{0}|{1}'.format( parent, pShape )
    parentChildPlug = NodeUtility.getPlug( shapeName, 'targetWorldMatrix' )
    
    # This will connect the first time attempted.
    attrName = 'targetWorldMatrix[{0}]'.format( parentChildPlug.numElements() )
    fullParent = '{0}.{1}'.format( shapeName, attrName )
    fullChild = '{0}.matrix'.format( child )
    cmds.connectAttr( fullChild, fullParent, force=True )
    
    # Do any parenting now.
    # Get the child's current parent.
    childParent = cmds.listRelatives( child, parent=True, fullPath=True )
    if childParent is None:
        # Child object has no parent. Do parenting.
        cmds.parent( child, parent )
    else:
        if childParent[0] != parent:
            # Has different parent currently. Do parenting
            cmds.parent( child, parent )
開發者ID:EriLee,項目名稱:marigold,代碼行數:46,代碼來源:FrameUtility.py

示例12: setAttribute

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
 def setAttribute( self, inPlugName, inPlugValue, inNodeName, inLock=False ):
     #print inPlugName, inPlugValue, inNodeName
     #print type( inPlugValue )
     '''
     if isinstance( inPlugValue, unicode ):
         # This is a unicode string. Likely a node name.
         print 'UNICODE'
         plugValue = inPlugValue
     elif isinstance( inPlugValue, str ):
         print 'STRING'
         plugValue = inPlugValue
     else:
         # This is likely coming from a QT object.
         print 'PASS'
         plugValue = inPlugValue.text()
     '''
     plug = NodeUtility.getPlug( inNodeName, inPlugName )
     NodeUtility.setPlugValue( plug, inPlugValue )
     cmds.setAttr( '{0}.{1}'.format( inNodeName, inPlugName ), lock=inLock )
開發者ID:EriLee,項目名稱:marigold,代碼行數:21,代碼來源:BaseComponent.py

示例13: componentGui

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
def componentGui( inNodeName ):        
    def on_context_menu( point ):
        popMenu = QtGui.QMenu()
        popMenu.addAction( 'actionEdit' )
        popMenu.addAction( 'actionDelete' )
        popMenu.addSeparator()
        popMenu.addAction( 'actionAdd' )
        popMenu.exec_( componentLabel.mapToGlobal( point ) )
    
    mainWidget = QtGui.QWidget()
        
    verticalLayout = QtGui.QVBoxLayout( mainWidget )
    verticalLayout.setContentsMargins( 0,0,0,0 )
    verticalLayout.setSpacing( 0 )
    verticalLayout.setAlignment( QtCore.Qt.AlignTop )
    
    # Label for component
    componentLabel = QTWidgets.basicLabel( inNodeName, 'bold', 10, 'black', 448094 )    
    componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
    componentLabel.customContextMenuRequested.connect( on_context_menu )
    
    propertyFrame = QTWidgets.basicFrame()
    propertyFrame.setMinimumHeight( 40 )
    propertyFrame.setMaximumHeight( 40 )
    
    # Add string edit property
    plug = NodeUtility.getPlug( inNodeName, 'jointName' )
    plugValue = NodeUtility.getPlugValue( plug )
    QTWidgets.stringProperty( propertyFrame, 'Joint Name', plugValue )
    
    # Add everything to the vertical layout.
    verticalLayout.addWidget( componentLabel )
    verticalLayout.addWidget( propertyFrame )
    
    #print 'test2: {0}'.format( prop.takeAt(0).widget() )
    #print propertyFrame.count()
    #print propertyFrame.findChild( QtGui.QLineEdit )
    #for item in xrange( propertyFrame.count() ):
    #    print propertyFrame.itemAt( item ).widget()
    
    return mainWidget
開發者ID:EriLee,項目名稱:marigold,代碼行數:43,代碼來源:qtui.py

示例14: readCurveValues

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
def readCurveValues(inObj):
    """
    Read stored curve CV values on an object. Object must have curve CV attributes
    created with addCurveValues().
    
    @param inObj: String. Name of object to add curve cv values too.
    @return: List of dicts.
    """
    curveAttrs = cmds.listAttr(inObj, string="curve*", category="nurbCurve")

    # [cur, cur, ...]
    # cur[i] = { #:[x,y,z] }
    curList = []
    for attr in curveAttrs:
        plug = NodeUtility.getPlug(inObj, attr)
        plugValue = NodeUtility.getPlugValue(plug)

        cvDict = {}
        for index, point in enumerate(plugValue):
            cvDict[index] = point
        curList.append(cvDict)

    curList
    return curList
開發者ID:EriLee,項目名稱:marigold,代碼行數:26,代碼來源:NurbsCurveUtility.py

示例15: __init__

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getPlug [as 別名]
 def __init__( self, nodeName, parent=None ):
     super( componentWidget, self ).__init__( parent )
     self.parent = parent
      
     def on_context_menu( point, inNodeName ):
         popMenu = QtGui.QMenu()
         deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) )
         popMenu.addAction( deleteAction )
         
         popMenu.exec_( self.componentLabel.mapToGlobal( point ) )
     
     # Colors.
     userColors = GeneralUtility.getUserDefinedColors( inType=1 )
     self.colorList = []
     for color in userColors:
         self.colorList.append( GeneralUtility.convertRGB( color, inType=1 ) )
     
     # Setup layout.
     verticalLayout = QtGui.QVBoxLayout()
     verticalLayout.setContentsMargins( 0,0,0,0 )
     verticalLayout.setSpacing( 0 )
     verticalLayout.setAlignment( QtCore.Qt.AlignTop )
     
     # Label for component
     #self.componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 )
     self.componentLabel = QtGui.QLabel()
     self.componentLabel.setText( nodeName )
     self.componentLabel.setIndent( 20 )
     controlColorPlug = NodeUtility.getPlug( nodeName, 'controlColor' )
     self.COLOR = NodeUtility.getPlugValue( controlColorPlug )
     self.componentLabel.setStyleSheet( 'font:bold; font-size:10px; color:black; background-color:rgb({0},{1},{2})'.format(self.colorList[self.COLOR-1][0],
                                                                                                                           self.colorList[self.COLOR-1][1],
                                                                                                                           self.colorList[self.COLOR-1][2] ) )
     self.componentLabel.setMinimumHeight( 18 )
     self.componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
     self.componentLabel.customContextMenuRequested.connect( lambda point, nodeName=nodeName:on_context_menu( point, nodeName ) )
     
     propertyFrame = QTWidgets.basicFrame()
     propertyFrame.setMinimumHeight( 100 )
     propertyFrame.setMaximumHeight( 100 )
     
     propertyStack = QtGui.QVBoxLayout()
     
     # Add string edit property
     propertyRow = QtGui.QHBoxLayout()
     propertyPlug = NodeUtility.getPlug( nodeName, 'controlName' )
     propertyValue = NodeUtility.getPlugValue( propertyPlug )
     self.textBox = QtGui.QLineEdit()
     self.textBox.setAlignment( QtCore.Qt.AlignLeft )
     self.textBox.setMinimumHeight( 20 )
     if propertyValue:
         self.textBox.setText( propertyValue )
     
     textBoxLabel = QtGui.QLabel()
     textBoxLabel.setText( 'Control Name' )
     textBoxLabel.setAlignment( QtCore.Qt.AlignCenter )
     textBoxLabel.setMinimumHeight( 12 )
     
     propertyRow.addWidget( self.textBox )
     propertyRow.addWidget( textBoxLabel )
     
     # Colors.
     colorRow = QtGui.QHBoxLayout()
     
     color1Btn = QtGui.QPushButton()
     color1Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[0][0], self.colorList[0][1], self.colorList[0][2] ) )
     color1Btn.clicked.connect( lambda a=nodeName, b=1:self.colorChange( a, b ) )
     
     color2Btn = QtGui.QPushButton()
     color2Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[1][0], self.colorList[1][1], self.colorList[1][2] ) )
     color2Btn.clicked.connect( lambda a=nodeName, b=2:self.colorChange( a, b ) )
     
     color3Btn = QtGui.QPushButton()
     color3Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[2][0], self.colorList[2][1], self.colorList[2][2] ) )
     color3Btn.clicked.connect( lambda a=nodeName, b=3:self.colorChange( a, b ) )
     
     color4Btn = QtGui.QPushButton()
     color4Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[3][0], self.colorList[3][1], self.colorList[3][2] ) )
     color4Btn.clicked.connect( lambda a=nodeName, b=4:self.colorChange( a, b ) )
     
     color5Btn = QtGui.QPushButton()
     color5Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[4][0], self.colorList[4][1], self.colorList[4][2] ) )
     color5Btn.clicked.connect( lambda a=nodeName, b=5:self.colorChange( a, b ) )
     
     color6Btn = QtGui.QPushButton()
     color6Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[5][0], self.colorList[5][1], self.colorList[5][2] ) )
     color6Btn.clicked.connect( lambda a=nodeName, b=6:self.colorChange( a, b ) )
     
     color7Btn = QtGui.QPushButton()
     color7Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[6][0], self.colorList[6][1], self.colorList[6][2] ) )
     color7Btn.clicked.connect( lambda a=nodeName, b=7:self.colorChange( a, b ) )
     
     color8Btn = QtGui.QPushButton()
     color8Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[7][0], self.colorList[7][1], self.colorList[7][2] ) )
     color8Btn.clicked.connect( lambda a=nodeName, b=8:self.colorChange( a, b ) )
     
     colorRow.addWidget( color1Btn )
     colorRow.addWidget( color2Btn )
     colorRow.addWidget( color3Btn )
     colorRow.addWidget( color4Btn )
#.........這裏部分代碼省略.........
開發者ID:EriLee,項目名稱:marigold,代碼行數:103,代碼來源:CurveControl.py


注:本文中的marigold.utility.NodeUtility.getPlug方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。