Exemplo n.º 1
0
 def buildNode( cls, nodeName ):
     '''
     Builds a curve control.
     
     @param nodeName: String. Name of the node.
     '''        
     # Create the curve.
     curveNode = CurveControlComponent( nodeName ).createCurveControl( cls( nodeName ).controlName, cls( nodeName ).curveType )
     controlName = OpenMaya.MDagPath.getAPathTo( curveNode ).fullPathName()
     
     # Set the control to the transform matrix.
     applyStoredTransforms( nodeName, controlName )
     
     # Get the saved properties and apply them to the curve.
     cvList = NurbsCurveUtility.readCurveValues( nodeName )
     cvPointArray = NurbsCurveUtility.buildCVPointArray( cvList )
     NurbsCurveUtility.setCurveCvs( controlName, cvPointArray )
     
     # Color.
     GeneralUtility.setUserColor( controlName, userColor=cls( nodeName ).controlColor )
     
     # Create the control spacer.
     transReference = NodeUtility.getNodeAttrSource( nodeName, 'parentName' )
     controlSpacer = GeneralUtility.createSpacer( None, inGroupName=cls( nodeName ).controlName, inTargetObject=transReference[0], inDoParent=False, inPrefix='sp' )
     cmds.parent( controlName, controlSpacer, relative=True )
     return curveNode
Exemplo n.º 2
0
 def colorChange( self, inNodeName, inPlugValue ):
     '''
     Sets the color of the control. Also changes the component label to the selected color.
     
     @param inNodeName: String. Name of the component node.
     @param inPlugValue: Int. 1-8. Which user defined color to use for the control.
     '''
     CurveControlComponent( inNodeName ).setComponentAttributeFromQT( 'controlColor', None, inPlugValue, inNodeName )
     self.componentLabel.setStyleSheet( 'background-color:rgb({0},{1},{2})'.format( self.colorList[inPlugValue-1][0], self.colorList[inPlugValue-1][1], self.colorList[inPlugValue-1][2] ) )
     self.COLOR = inPlugValue
     if self.editButton.isChecked():
         # Set the color of the control being edited.
         GeneralUtility.setUserColor( self.CONTROL, userColor=self.COLOR )
Exemplo n.º 3
0
    def editCurveProperties( self ):
        '''
        Activates the control so the user can edit it's properties.
        '''
        if self.editButton.isChecked():
            if self.textBox.text():
                # Lock the components UI.
                if self.parent.selectedLockActive is False:
                    self.parent.lockSelection()
                
                # Create the curve.
                curveType = CurveControlComponent( self.componentLabel.text() ).curveType
                node = CurveControlComponent( self.componentLabel.text() ).createCurveControl( self.textBox.text(), curveType )
                controlName = OpenMaya.MDagPath.getAPathTo( node ).fullPathName()
                
                # Parent the control to the bit.
                parentNode = CurveControlComponent( self.componentLabel.text() ).parentNode[0]
                cmds.parent( controlName, parentNode )
                self.CONTROL = OpenMaya.MDagPath.getAPathTo( node ).fullPathName()
                
                # Set the control to the transform matrix.
                applyStoredTransforms( self.componentLabel.text(), self.CONTROL )
                
                # Get the saved properties and apply them to the curve.
                cvList = NurbsCurveUtility.readCurveValues( self.componentLabel.text() )
                cvPointArray = NurbsCurveUtility.buildCVPointArray( cvList )
                NurbsCurveUtility.setCurveCvs( self.CONTROL, cvPointArray )
                
                # Color.
                GeneralUtility.setUserColor( self.CONTROL, userColor=self.COLOR )
            else:
                raise ValueError( '{0} does not have a Control Name set.'.format( self.componentLabel.text() ) )
        else:
            if self.CONTROL is not None:
                # Read the control properties and save them to the component node.
                cvList = NurbsCurveUtility.getCurveCvs( self.CONTROL )
                NurbsCurveUtility.writeCurveValues( self.componentLabel.text(), cvList )
                
                # Update the transform matrix.
                storeControlTransforms( self.CONTROL, self.componentLabel.text() )

                # Delete the control
                cmds.delete( self.CONTROL )
                self.CONTROL = None
                
            # Unlock the UI.
            if self.parent.selectedLockActive:
                self.parent.lockSelection()