Ejemplo n.º 1
0
class SoftSelectionRow:
    def __init__(self, uiName):
        self.name = uiName

    def checkUiEnabled(self):
        '''
        update UI enabled/disabled values
        '''
        self.nativeSoftSelect.editUI(enable=self.useSoftSelect.getValue())
        self.softSelectRadius.editUI(enable=self.useSoftSelect.getValue()
                                     and not self.nativeSoftSelect.getValue())

    def uiChanged(self):
        '''
        called when controls change value
        '''
        self.checkUiEnabled()

    def create(self, parent):
        cmds.rowLayout(parent=parent,
                       nc=2,
                       adjustableColumn=2,
                       columnWidth2=[Constants.MARGIN_COLUMN2, 50])
        self.useSoftSelect = CheckBoxField(
            self.name + 'On',
            label='Use soft selection',
            defaultValue=0,
            annotation=
            'extend effect outside selection with a fade out by defined distance'
        )
        self.useSoftSelect.changeCommand.addHandler(self.uiChanged)

        self.nativeSoftSelect = CheckBoxField(
            self.name + 'Native',
            label='Native soft selection',
            defaultValue=0,
            annotation=
            'use maya\'s soft selection instead of soft selection radius')
        self.nativeSoftSelect.changeCommand.addHandler(self.uiChanged)

        BaseTab.createFixedTitledRow(parent, "Selection radius")
        self.softSelectRadius = FloatField(
            self.name + 'Radius',
            minValue=0,
            defaultValue=1,
            step=0.1,
            annotation='soft selection radius is defined in world units')

        self.checkUiEnabled()

    def addToArgs(self, args):
        if self.useSoftSelect.getValue():
            args['softSelectionRadius'] = self.softSelectRadius.getValue()

        if self.nativeSoftSelect.getValue():
            args['nativeSoftSelection'] = 1
Ejemplo n.º 2
0
class SoftSelectionRow:

    
    def __init__(self,uiName):
        self.name = uiName
        
    def checkUiEnabled(self):
        '''
        update UI enabled/disabled values
        '''
        self.nativeSoftSelect.editUI(enable=self.useSoftSelect.getValue())
        self.softSelectRadius.editUI(enable=self.useSoftSelect.getValue() and not self.nativeSoftSelect.getValue())

    def uiChanged(self):
        '''
        called when controls change value
        '''
        self.checkUiEnabled()
        
    def create(self,parent):
        cmds.rowLayout(parent=parent,nc=2,adjustableColumn=2,columnWidth2=[Constants.MARGIN_COLUMN2,50])
        self.useSoftSelect = CheckBoxField(self.name+'On',label='Use soft selection',defaultValue=0,annotation='extend effect outside selection with a fade out by defined distance') 
        self.useSoftSelect.changeCommand.addHandler(self.uiChanged)

        self.nativeSoftSelect = CheckBoxField(self.name+'Native',label='Native soft selection',defaultValue=0,annotation='use maya\'s soft selection instead of soft selection radius') 
        self.nativeSoftSelect.changeCommand.addHandler(self.uiChanged)
        
        BaseTab.createFixedTitledRow(parent, "Selection radius")
        self.softSelectRadius = FloatField(self.name+'Radius', minValue=0,defaultValue=1,step=0.1,annotation='soft selection radius is defined in world units') 
        
        self.checkUiEnabled()
        
    
    def addToArgs(self,args):
        if self.useSoftSelect.getValue():
            args['softSelectionRadius'] = self.softSelectRadius.getValue()
            
        if self.nativeSoftSelect.getValue():
            args['nativeSoftSelection'] = 1;
Ejemplo n.º 3
0
class AddPairDialog(BaseDialog):
    CTRL_PREFIX = 'ngSkinToolsAddPairDialog_'

    def __init__(self):
        BaseDialog.__init__(self)
        self.title = "Add Influences Association"
        self.sourceValue = ValueModel()
        self.destinationValue = ValueModel()
        self.buttons = [self.BUTTON_OK, self.BUTTON_CANCEL]

    def updateEnabled(self):
        cmds.layout(self.destinationRow,
                    e=True,
                    enable=not self.chkSelfReference.getValue())
        self.chkBidirectional.setEnabled(not self.chkSelfReference.getValue())

    def getAvailableInfluences(self):
        result = []
        layerInfluences = cmds.ngSkinLayer(q=True, listLayerInfluences=True)
        for index, i in enumerate(layerInfluences):
            if index % 2 != 0:
                result.append(i)
        return result

    def createInnerUi(self, parent):

        #container = BaseTab.createScrollLayout(parent)
        rows = cmds.columnLayout(parent=parent,
                                 adjustableColumn=1,
                                 rowSpacing=Constants.MARGIN_SPACING_VERTICAL,
                                 width=400)

        BaseTab.createFixedTitledRow(rows, "Influence names")
        self.chkLongNames = CheckBoxField(
            AddPairDialog.CTRL_PREFIX + 'longNames',
            label="Longer, where ambiguous",
            annotation="Show long names in drop down boxes")
        self.chkLongNames.changeCommand.addHandler(self.updateInfluenceLabels)

        BaseTab.createFixedTitledRow(rows, "Source influence")

        self.sourceDropdown = DropDownField(self.sourceValue)

        BaseTab.createFixedTitledRow(rows, None)

        self.chkSelfReference = CheckBoxField(
            AddPairDialog.CTRL_PREFIX + 'selfReference',
            label="Self reference",
            annotation=
            "Don't map to another influence, mirror on the same influence")
        self.chkSelfReference.changeCommand.addHandler(self.updateEnabled)
        self.chkBidirectional = CheckBoxField(
            AddPairDialog.CTRL_PREFIX + 'bidirectional',
            label="Bidirectional association")

        self.destinationRow = BaseTab.createTitledRow(rows,
                                                      "Destination influence")
        self.destinationDropdown = DropDownField(self.destinationValue)

        self.updateEnabled()
        self.updateInfluenceLabels()
        self.sourceDropdown.updateModel()
        self.destinationDropdown.updateModel()
        return rows

    def updateInfluenceLabels(self):
        self.influences = self.getAvailableInfluences()
        self.sourceDropdown.clear()
        self.destinationDropdown.clear()

        if self.chkLongNames.getValue():
            nameProcessor = lambda name: cmds.ls(name)[0]
        else:
            nameProcessor = InfluencesListEntry.shortName

        for i in self.influences:
            self.sourceDropdown.addOption(nameProcessor(i))
        for i in self.influences:
            self.destinationDropdown.addOption(nameProcessor(i))

    def getSourceInfluence(self):
        return self.influences[self.sourceDropdown.model.get()]

    def getDestinationInfluence(self):
        return self.influences[self.destinationDropdown.model.get()]
Ejemplo n.º 4
0
class AddPairDialog(BaseDialog):
    CTRL_PREFIX = 'ngSkinToolsAddPairDialog_'
    
    def __init__(self):
        BaseDialog.__init__(self)
        self.title = "Add Influences Association"
        self.sourceValue = ValueModel()
        self.destinationValue = ValueModel()
        self.buttons = [self.BUTTON_OK,self.BUTTON_CANCEL]
        
    def updateEnabled(self):
        cmds.layout(self.destinationRow,e=True,enable=not self.chkSelfReference.getValue())
        self.chkBidirectional.setEnabled(not self.chkSelfReference.getValue())
        
    def getAvailableInfluences(self):
        result = []
        layerInfluences = cmds.ngSkinLayer(q=True,listLayerInfluences=True) 
        for index,i in enumerate(layerInfluences):
            if index%2!=0:
                result.append(i)
        return result
        
    def createInnerUi(self,parent):
        
        #container = BaseTab.createScrollLayout(parent)
        rows=cmds.columnLayout(parent=parent,
            adjustableColumn=1,rowSpacing=Constants.MARGIN_SPACING_VERTICAL,
            width=400)
        
        BaseTab.createFixedTitledRow(rows, "Influence names")
        self.chkLongNames = CheckBoxField(AddPairDialog.CTRL_PREFIX+'longNames',label="Longer, where ambiguous",annotation="Show long names in drop down boxes")
        self.chkLongNames.changeCommand.addHandler(self.updateInfluenceLabels)
        
        BaseTab.createFixedTitledRow(rows, "Source influence")
        
        
        self.sourceDropdown = DropDownField(self.sourceValue)

        BaseTab.createFixedTitledRow(rows, None)

        self.chkSelfReference = CheckBoxField(AddPairDialog.CTRL_PREFIX+'selfReference',label="Self reference",annotation="Don't map to another influence, mirror on the same influence")
        self.chkSelfReference.changeCommand.addHandler(self.updateEnabled)
        self.chkBidirectional = CheckBoxField(AddPairDialog.CTRL_PREFIX+'bidirectional',label="Bidirectional association")
            
 
        self.destinationRow = BaseTab.createTitledRow(rows, "Destination influence")
        self.destinationDropdown = DropDownField(self.destinationValue)
        
        self.updateEnabled()
        self.updateInfluenceLabels()
        self.sourceDropdown.updateModel()
        self.destinationDropdown.updateModel()
        return rows
    
    def updateInfluenceLabels(self):
        self.influences = self.getAvailableInfluences()
        self.sourceDropdown.clear()
        self.destinationDropdown.clear()
        
        if self.chkLongNames.getValue():
            nameProcessor = lambda name: cmds.ls(name)[0]
        else:
            nameProcessor = InfluencesListEntry.shortName
        
        for i in self.influences:
            self.sourceDropdown.addOption(nameProcessor(i))
        for i in self.influences:
            self.destinationDropdown.addOption(nameProcessor(i))
            
    def getSourceInfluence(self):
        return self.influences[self.sourceDropdown.model.get()]
    
    def getDestinationInfluence(self):
        return self.influences[self.destinationDropdown.model.get()]