Example #1
0
    def createMakePruneWeightsGroup(self,layout):
        self.controls.pruneWeightsGroup = group = self.createUIGroup(layout, 'Prune Small Weights')

        self.createFixedTitledRow(group, title="Prune elements")
        self.controls.pruneWeights = CheckBoxField(self.VAR_PRUNE_PREFIX+"pruneWeights",
                    "Influence weights", True);
        self.controls.pruneMask = CheckBoxField(self.VAR_PRUNE_PREFIX+"pruneMask",
                    "Mask", True);

        self.createFixedTitledRow(group, title="Prune influences below")
        self.controls.pruneWeightsThreshold = FloatField(self.VAR_PRUNE_PREFIX+'pruneWeightsThreshold', minValue=0, maxValue=1,step=0.001,defaultValue=0.01, 
                annotation='Influence weights lower than this value will be set to zero')
        
        
        self.createFixedTitledRow(group, title="Prune mask below")
        self.controls.pruneMaskThreshold = FloatField(self.VAR_PRUNE_PREFIX+'pruneMaskThreshold', minValue=0, maxValue=1,step=0.001,defaultValue=0.01, 
                annotation='Mask values lower than this value will be set to zero')

        cmds.setParent(group)

        cmds.rowLayout(nc=2,adjustableColumn=2,columnWidth2=[Constants.BUTTON_WIDTH_SMALL,50], columnAttach2=["both","both"],columnAlign2=["center","center"])
        BaseTab.createHelpButton(SkinToolsDocs.ASSIGNWEIGHTS_MAKERIGID_INTERFACE)
        cmds.button(height=Constants.BUTTON_HEIGHT,label='Prune',command=lambda *args:self.execPruneWeights())

        cmds.setParent(layout)  
Example #2
0
    def createTransferOptionsGroup(self):
        group = self.createUIGroup(self.cmdLayout.innerLayout,
                                   'Transfer Options')
        self.createTitledRow(parent=group, title="Vertex Transfer Mode")
        self.controls.transferMode = DropDownField(self.VAR_PREFIX +
                                                   'vertexTransferMode')

        for opt in CopyWeightsModel.vertexTransferModes.keys():
            self.controls.transferMode.addOption(opt)

        self.createTitledRow(parent=group, title="Influence namespaces")
        self.controls.ignoreNamespaces = CheckBoxField(
            self.VAR_PREFIX + 'IgnoreNamespaces',
            label="Ignore when matching by name",
            annotation='ignore when matching by name',
            defaultValue=1)
        self.controls.ignoreNamespaces.changeCommand.addHandler(
            self.previewInfluenceMapping, ownerUI=group)

        self.createTitledRow(parent=group, title=None)
        self.controls.keepExistingLayers = CheckBoxField(
            self.VAR_PREFIX + 'KeepExistingLayers',
            label="Keep existing layers",
            annotation=
            'when unselected, will delete existing layers in destination',
            defaultValue=1)
Example #3
0
    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()
Example #4
0
    def createBrushSettingsGroup(self, parent):
        group = self.createUIGroup(parent, 'Brush Settings')

        self.createTitledRow(group, 'Brush Shape')
        brushWidth = 35
        cmds.rowLayout(nc=4,
                       cw4=[brushWidth, brushWidth, brushWidth, brushWidth])
        self.createBrushShapeButtons()
        cmds.setParent("..")

        def innerLayout():
            return cmds.rowColumnLayout(numberOfColumns=2,
                                        columnWidth=[(1, 100), (2, 100)])

        self.createTitledRow(group,
                             'Mode',
                             innerContentConstructor=innerLayout)

        cmds.radioCollection()
        for index, i in enumerate(
            ['Replace', 'Add', 'Scale', 'Smooth', 'Sharpen']):
            ctrl = self.controls.__dict__['paintMode' + i] = RadioButtonField(
                self.VAR_PREFIX + 'paintMode' + i,
                defaultValue=1 if index == 0 else 0,
                label=i)
            ctrl.changeCommand.addHandler(self.paintValuesChanged)

        self.createTitledRow(group, title=None)
        self.controls.mirroredMode = CheckBoxField(
            self.VAR_PREFIX + 'mirroredMode',
            label="Interactive mirror",
            annotation=
            'Paint stroke is mirrored on the other side. Needs initialized mirror',
            defaultValue=0)
        self.controls.mirroredMode.changeCommand.addHandler(
            self.paintValuesChanged)

        self.controls.redistributeWeightSetting = CheckBoxField(
            self.VAR_PREFIX + 'redistributeWeight',
            label="Distribute removed weights",
            annotation=
            'When reducing weight on current influence, share that weight to other influences',
            defaultValue=1)
        self.controls.redistributeWeightSetting.changeCommand.addHandler(
            self.paintValuesChanged)

        self.controls.intensitySlider = FloatSliderField()
        self.controls.intensitySlider.flexibleRange = True
        self.createTitledRow(group, 'Intensity',
                             self.controls.intensitySlider.create)
        self.controls.intensitySlider.onChange.addHandler(
            self.paintValuesChanged)

        self.controls.brushRadiusSlider = FloatSliderField(range=[0, 30])
        self.controls.brushRadiusSlider.flexibleRange = True
        self.createTitledRow(group, 'Brush Radius',
                             self.controls.brushRadiusSlider.create)
        self.controls.brushRadiusSlider.onChange.addHandler(
            self.changeBrushRadius)
Example #5
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
Example #6
0
    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 createUI(self, parent):
        from mainwindow import MainWindow

        mainActions = MainWindow.getInstance().actions
        self.setTitle('Mirror')

        # base layout
        self.cmdLayout = self.createCommandLayout(
            [('Initialize', self.execInitMirror, ''),
             ('Mirror Weights', mainActions.mirrorWeights, '')],
            SkinToolsDocs.MIRRORWEIGHTS_INTERFACE)

        mainActions.mirrorWeights.addUpdateControl(self.cmdLayout.innerLayout)

        # mirror options group

        group = self.controls.mirrorOptionsGroup = self.createUIGroup(
            self.cmdLayout.innerLayout, 'Mirroring Options')

        self.createFixedTitledRow(group, 'Mirror direction')
        self.controls.mirrorDirection = DropDownField(self.VAR_PREFIX +
                                                      'mirrorDirection')
        self.rebuildMirrorDirectionDropDown()
        LayerEvents.mirrorCacheStatusChanged.addHandler(
            self.rebuildMirrorDirectionDropDown, parent)

        self.createFixedTitledRow(group, 'Mirror Seam Width')
        self.controls.mirrorWidth = FloatField(
            self.VAR_PREFIX + 'mirrorWidth',
            minValue=0,
            maxValue=None,
            step=1.0,
            defaultValue=0.1,
            annotation=
            'Defines width of the interpolation from left to right side on the model center line.'
        )
        cmds.setParent(group)
        self.createTitledRow(group, 'Elements')
        self.controls.mirrorWeights = CheckBoxField(
            self.VAR_PREFIX + 'MirrorWeights',
            label="Mirror weights",
            annotation=
            'Check this if mirror operation should be mirroring weights',
            defaultValue=1)
        self.controls.mirrorMask = CheckBoxField(
            self.VAR_PREFIX + 'MirrorMask',
            label="Mirror mask",
            annotation=
            'Check this if mirror operation should be mirroring layer mask',
            defaultValue=1)

        return self.cmdLayout.outerLayout.layout
    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
Example #9
0
    def createVolumeAssociationGroup(self, layout):
        group = self.createUIGroup(layout,
                                   "Surface and Volume Association Rules")

        self.controls.softSelection = SoftSelectionRow(self.VAR_RELAX_PREFIX +
                                                       'softSelection')
        self.controls.softSelection.create(group)

        cmds.setParent(group)
        self.controls.useVolumeAssociation = CheckBoxField(
            self.VAR_RELAX_PREFIX + 'associateByVolume',
            defaultValue=0,
            label="Associate by volume",
            annotation=
            'when turned on, smoothing will extend across vertices that are not connected by edges (across shell borders, seams, close-by meshes, etc)'
        )

        self.controls.useVolumeAssociation.changeCommand.addHandler(
            self.updateUIEnabled)

        self.controls.volumeSearchRow = self.createFixedTitledRow(
            group, "Volume search radius")
        self.controls.volumeAssociationRadius = FloatField(
            self.VAR_RELAX_PREFIX + 'associateByVolumeRadius',
            minValue=0,
            maxValue=10000,
            step=0.1,
            defaultValue=10,
            annotation=
            'search radius of volume association. set this to a fairly little value, just a little above distance of the gap you are trying to "close"'
        )
Example #10
0
    def createMakeUnifyGroup(self, layout):
        group = self.createUIGroup(layout, 'Unify Weights')

        self.controls.rigidIntensity = IntensitySlider(
            'amount of effect to apply', self.VAR_RIGID_PREFIX + 'Intensity')
        self.createTitledRow(
            group,
            "Intensity",
            innerContentConstructor=self.controls.rigidIntensity.create)

        row = self.createFixedTitledRow(group, "Clustering")
        self.controls.chkSingleClusterMode = CheckBoxField(
            self.VAR_RIGID_PREFIX + "singleClusterMode",
            "Ignore separate shells or selection gaps", False,
            "When selected, whole selection is treated as one vertex cluster, regardless if vertices "
            + " are in different shells or selection is not contiguous")

        self.controls.rigidSoftSelection = SoftSelectionRow(
            self.VAR_RIGID_PREFIX + 'softSelection')
        self.controls.rigidSoftSelection.create(group)

        cmds.setParent(group)

        cmds.rowLayout(nc=2,
                       adjustableColumn=2,
                       columnWidth2=[Constants.BUTTON_WIDTH_SMALL, 50],
                       columnAttach2=["both", "both"],
                       columnAlign2=["center", "center"])
        BaseTab.createHelpButton(
            SkinToolsDocs.ASSIGNWEIGHTS_MAKERIGID_INTERFACE)
        cmds.button(height=Constants.BUTTON_HEIGHT,
                    label='Assign',
                    command=lambda *args: self.execUnifyWeights())

        cmds.setParent(layout)
Example #11
0
    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
Example #12
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;
Example #13
0
    def createUI(self, parent):
        self.setTitle('Settings')
        self.outerLayout = FormLayout()
        scrollLayout = BaseTab.createScrollLayout(self.outerLayout)
        self.baseLayout = cmds.columnLayout(adjustableColumn=1)
        self.outerLayout.attachForm(scrollLayout, 0, 0, 0, 0)

        self.controls.selectedSkinSettingsGroup = group = self.createUIGroup(
            self.baseLayout, 'Selected Skin Settings')
        self.controls.useInfluenceLimit = CheckBoxField(
            None,
            defaultValue=0,
            label="Use maximum influences per vertex limit",
            annotation=
            'Turn this on to enforce a max influences per vertex limit')
        self.controls.useInfluenceLimit.changeCommand.addHandler(
            self.updateUIEnabled, ownerUI=parent)

        self.controls.influenceLimitRow = self.createFixedTitledRow(
            group, 'Influence limit')
        self.controls.numMaxInfluences = IntField(
            None,
            minValue=1,
            maxValue=None,
            annotation="Number of max influences per vertex")

        cmds.setParent(group)
        cmds.rowLayout(nc=2,
                       adjustableColumn=2,
                       columnWidth2=[Constants.BUTTON_WIDTH_SMALL, 50],
                       columnAttach2=["both", "both"],
                       columnAlign2=["center", "center"])
        BaseTab.createHelpButton(SkinToolsDocs.CURRENTSKINSETTINGS_INTERFACE)
        cmds.button(height=Constants.BUTTON_HEIGHT,
                    label='Apply',
                    command=lambda *args: self.applyCurrentSkinSettings())

        LayerEvents.layerAvailabilityChanged.addHandler(
            self.refreshSettingsFromSelection, parent)
        MayaEvents.nodeSelectionChanged.addHandler(
            self.refreshSettingsFromSelection, parent)
        MayaEvents.undoRedoExecuted.addHandler(
            self.refreshSettingsFromSelection, parent)

        self.refreshSettingsFromSelection()

        cmds.setParent(parent)

        return self.outerLayout
Example #14
0
    def createTransferOptionsGroup(self):
        group = self.createUIGroup(self.cmdLayout.innerLayout,
                                   'Transfer Options')
        self.createTitledRow(parent=group, title="Vertex Transfer Mode")
        self.controls.transferMode = DropDownField(self.VAR_PREFIX +
                                                   'vertexTransferMode')

        for opt in CopyWeightsModel.vertexTransferModes.keys():
            self.controls.transferMode.addOption(opt)

        self.createTitledRow(parent=group, title=None)
        self.controls.keepExistingLayers = CheckBoxField(
            self.VAR_PREFIX + 'KeepExistingLayers',
            label="Keep existing layers",
            annotation=
            'when unselected, will delete existing layers in destination',
            defaultValue=1)
Example #15
0
    def createTabletSettingsGroup(self, parent):
        group = self.createUIGroup(parent, 'Stylus Pressure')
        titledRow.create(group, title=None)
        self.controls.stylusPressureOnOff = CheckBoxField(
            self.VAR_PREFIX + 'stylusPressureOnOff',
            label="Use stylus pressure",
            annotation='Turn stylus pressure on/off',
            defaultValue=1)
        self.controls.stylusPressureOnOff.changeCommand.addHandler(
            self.configurePaintValues, ownerUI=parent)

        titledRow.createFixed(group, title="Pressure mapping")
        mode = DropDownField(self.VAR_PREFIX + 'stylesPressureMapping')
        mode.addOption("Opacity")
        mode.addOption("Radius")
        mode.addOption("Both")
        mode.changeCommand.addHandler(self.configurePaintValues,
                                      ownerUI=parent)
        self.controls.stylusPressureMode = mode
Example #16
0
    def createInfluenceMappingGroup(self):
        group = self.createUIGroup(self.cmdLayout.innerLayout,
                                   'Influence Mapping')

        self.createFixedTitledRow(group, 'Infl. Distance Error')
        self.controls.influenceDistanceError = FloatField(
            self.VAR_PREFIX + 'distanceError',
            minValue=0,
            maxValue=None,
            step=0.01,
            defaultValue=0.001,
            annotation=
            'Defines maximum inaccuracy between left and right influence positions'
        )
        self.controls.influenceDistanceError.changeCommand.addHandler(
            self.previewInfluenceMapping, group)

        self.createTitledRow(parent=group, title="Namespaces")
        self.controls.ignoreNamespaces = CheckBoxField(
            self.VAR_PREFIX + 'IgnoreNamespaces',
            label="Ignore",
            annotation='ignore influence namespaces when matching by name',
            defaultValue=1)
        self.controls.ignoreNamespaces.changeCommand.addHandler(
            self.previewInfluenceMapping, ownerUI=group)

        self.influenceMappingPreview.mirrorMode = False
        self.influenceMappingPreview.createUI(parent=group)
        self.influenceMappingPreview.onDelete.addHandler(
            self.influencesManualMapping.removeSelectedManualMappings, group)

        manualGroup = uiGroup.create(self.cmdLayout.innerLayout,
                                     'Manual influence mapping')
        self.influencesManualMapping.mirrorMode = False
        self.influencesManualMapping.createUI(parent=manualGroup)
        self.influencesManualMapping.getSelectedInfluences = lambda: self.influenceMappingPreview.currentInfluencesSelection
        self.influencesManualMapping.manualOverridesChanged.addHandler(
            self.previewInfluenceMapping, group)

        cmds.setParent(group)
Example #17
0
    def createUI(self, parent):
        group = self.mirrorOptionsGroup = uiGroup.create(
            parent, 'Mirroring Options')

        titledRow.createFixed(group, 'Mirror direction')
        self.mirrorDirection = DropDownField(self.VAR_PREFIX +
                                             'mirrorDirection')

        def getMirrorSideTexts():
            axis = selectionState.mirrorInfo.get()['axis']
            if axis is None:
                axis = 'x'
            return self.MIRROR_TEXTS[axis]

        def rebuildMirrorDirectionDropDown():
            self.mirrorDirection.beginRebuildItems()
            self.mirrorDirection.addOption(self.MIRROR_GUESS)
            for mirrorText in getMirrorSideTexts():
                self.mirrorDirection.addOption(mirrorText)
            self.mirrorDirection.addOption(self.MIRROR_FLIP)
            self.mirrorDirection.endRebuildItems()

        selectionState.mirrorInfo.changed.addHandler(
            rebuildMirrorDirectionDropDown, parent)

        def updateEnabled():
            data = LayerDataModel.getInstance()
            self.mirrorDq.setEnabled(data.layerDataAvailable
                                     and data.isDqMode())

        MayaEvents.nodeSelectionChanged.addHandler(updateEnabled, parent)

        titledRow.createFixed(group, 'Mirror Seam Width')
        self.mirrorWidth = FloatField(
            self.VAR_PREFIX + 'mirrorWidth',
            minValue=0,
            maxValue=None,
            step=1.0,
            defaultValue=0.1,
            annotation=
            'Defines width of the interpolation from left to right side on the model center line.'
        )
        cmds.setParent(group)
        titledRow.create(group, 'Elements')
        self.mirrorWeights = CheckBoxField(
            self.VAR_PREFIX + 'MirrorWeights',
            label="Mirror weights",
            annotation=
            'Check this if mirror operation should be mirroring weights',
            defaultValue=1)
        self.mirrorMask = CheckBoxField(
            self.VAR_PREFIX + 'MirrorMask',
            label="Mirror mask",
            annotation=
            'Check this if mirror operation should be mirroring layer mask',
            defaultValue=1)
        self.mirrorDq = CheckBoxField(
            self.VAR_PREFIX + 'MirrorDualQuaternion',
            label="Mirror dual quaternion weights",
            annotation=
            'Check this if mirror operation should be mirroring dual quaternion weights',
            defaultValue=1)

        LayerEvents.mirrorConfigurationChanged.addHandler(
            rebuildMirrorDirectionDropDown, parent)
        rebuildMirrorDirectionDropDown()
        updateEnabled()
Example #18
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()]
Example #19
0
    def createWindow(self):
        BaseToolWindow.createWindow(self)
        margin1 = 5
        margin2 = 10

        form = cmds.formLayout(parent=self.windowName)
        self.topLabel = cmds.text(label='', font='boldLabelFont')
        self.customUIContainer = cmds.columnLayout(adjustableColumn=1,
                                                   rowSpacing=margin2)
        cmds.separator()
        cmds.setParent('..')

        lowerRow = cmds.formLayout(height=Constants.BUTTON_HEIGHT)
        checkBox = CheckBoxField(
            Options.OPTION_CHECKFORUPDATES,
            label='Automatically check for updates',
            annotation=
            'Check for updates automatically when ngSkinTools window is opened (once per Maya application session)'
        )
        closeButton = cmds.button(label='Close',
                                  align='center',
                                  width=80,
                                  command=lambda *args: self.closeWindow())

        cmds.formLayout(lowerRow, e=True, attachForm=[(closeButton, 'top', 0)])
        cmds.formLayout(lowerRow, e=True, attachNone=[(closeButton, 'left')])
        cmds.formLayout(lowerRow,
                        e=True,
                        attachForm=[(closeButton, 'right', margin1)])
        cmds.formLayout(lowerRow,
                        e=True,
                        attachForm=[(closeButton, 'bottom', 0)])

        cmds.formLayout(lowerRow,
                        e=True,
                        attachForm=[(checkBox.field, 'top', 0)])
        cmds.formLayout(lowerRow,
                        e=True,
                        attachForm=[(checkBox.field, 'left', margin1)])
        cmds.formLayout(lowerRow,
                        e=True,
                        attachControl=[(checkBox.field, 'right', margin1,
                                        closeButton)])
        cmds.formLayout(lowerRow,
                        e=True,
                        attachForm=[(checkBox.field, 'bottom', 0)])

        cmds.formLayout(form,
                        e=True,
                        attachForm=[(self.topLabel, 'top', margin2)])
        cmds.formLayout(form,
                        e=True,
                        attachForm=[(self.topLabel, 'left', margin1)])
        cmds.formLayout(form, e=True, attachNone=[(self.topLabel, 'right')])
        cmds.formLayout(form, e=True, attachNone=[(self.topLabel, 'bottom')])

        cmds.formLayout(form, e=True, attachNone=[(lowerRow, 'top')])
        cmds.formLayout(form, e=True, attachForm=[(lowerRow, 'left', margin1)])
        cmds.formLayout(form,
                        e=True,
                        attachForm=[(lowerRow, 'right', margin1)])
        cmds.formLayout(form,
                        e=True,
                        attachForm=[(lowerRow, 'bottom', margin1)])

        cmds.formLayout(form,
                        e=True,
                        attachControl=[(self.customUIContainer, 'top', margin2,
                                        self.topLabel)])
        cmds.formLayout(form,
                        e=True,
                        attachForm=[(self.customUIContainer, 'left', margin1)])
        cmds.formLayout(form,
                        e=True,
                        attachForm=[(self.customUIContainer, 'right', margin1)
                                    ])
        cmds.formLayout(form,
                        e=True,
                        attachControl=[(self.customUIContainer, 'bottom',
                                        margin2, lowerRow)])
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()]