示例#1
0
    def _makeArgRow(self,
                    methodIndex,
                    type,
                    argName,
                    direction,
                    annotation=''):
        COL1_WIDTH = 260
        COL2_WIDTH = 120
        pm.rowLayout(nc=4,
                     cw4=[COL1_WIDTH, COL2_WIDTH, 70, 150],
                     **self.layout)

        label = str(type)

        pm.text(l=label, ann=annotation)
        pm.text(l=argName, ann=annotation)

        if direction == 'return':
            pm.text(l='(result)')
        else:
            direction_om = pm.optionMenu(l='',
                                         w=60,
                                         ann=annotation,
                                         cc=pm.CallbackWithArgs(
                                             MethodRow.setDirection, self,
                                             methodIndex, argName))
            for unit in ['in', 'out']:
                pm.menuItem(l=unit)
            direction_om.setValue(direction)

        if self._isPotentialUnitType(type):
            om = pm.optionMenu(l='',
                               ann=annotation,
                               cc=pm.CallbackWithArgs(MethodRow.setUnitType,
                                                      self, methodIndex,
                                                      argName))
            for unit in ['unitless', 'linear', 'angular', 'time']:
                pm.menuItem(l=unit)
            if argName == 'return':
                try:
                    value = factories.apiClassOverrides[
                        self.apiClassName]['methods'][self.apiMethodName][
                            methodIndex]['returnInfo']['unitType']
                except KeyError:
                    pass
            else:
                try:
                    value = factories.apiClassOverrides[
                        self.apiClassName]['methods'][self.apiMethodName][
                            methodIndex]['argInfo'][argName]['unitType']
                except KeyError:
                    pass
            try:
                om.setValue(value)
            except:
                pass

        else:
            pm.text(l='', ann=annotation)
        pm.setParent('..')
示例#2
0
    def buildMenuItems(self):
        self.collection = getActiveCollection()
        self.isReadOnly = self.collection.isReadOnly()

        # build menu items for each set
        for i, s in enumerate(self.collection.sets):
            itemKwargs = {
                'l':s.getTitle(),
            }
            if SHOW_COUNTS:
                itemKwargs['l'] += ' ({0})'.format(len(s))
            if s.position:
                itemKwargs['rp'] = s.position
            pm.menuItem(c=pm.Callback(pm.select, s.nodes, add=True), **itemKwargs)
            if not self.isReadOnly:
                pm.menuItem(ob=True, c=pm.Callback(self.editSet, s, i))

        # put in slots for vacancies
        if not self.isReadOnly:
            vacantPositions = self.collection.getRadialVacancies()
            for rp in vacantPositions:
                pm.menuItem(l='...', rp=rp, c=pm.Callback(self.addSetFromSelection, position=rp))
            # always include slot at end of extras list
            pm.menuItem(l='...', c=pm.Callback(self.addSetFromSelection))

        # collection title
        pm.menuItem(d=True)
        pm.menuItem(l=self.collection.name, c=pm.Callback(self.selectAll))
        pm.menuItem(ob=True, c=pm.CallbackWithArgs(QuickSelectCollectionsMenu.editCollection, self.collection))
示例#3
0
    def buildMenuItems(self):
        # header
        pm.menuItem(l='Quick Select Collections', en=False)
        pm.menuItem(d=True)

        # list all collections
        collections = getAllCollections()
        collections.sort(lambda a, b: cmp(a.name, b.name))
        for coll in collections:
            itemKwargs = {
                'l': coll.name,
                'cb': coll.isActive(),
            }
            pm.menuItem(c=pm.Callback(coll.makeActive), **itemKwargs)
            pm.menuItem(ob=True, c=pm.CallbackWithArgs(QuickSelectCollectionsMenu.editCollection, coll))

        # new collection item
        pm.menuItem(l='New...', itl=True, c=pm.Callback(QuickSelectCollectionsMenu.newCollectionPrompt))

        # additional options
        pm.menuItem(d=True)
        pm.menuItem(l='Show Node Counts', cb=SHOW_COUNTS, c=pm.CallbackWithArgs(setShowCounts),
            ann="Display node counts on menu items in the quick select menu"
        )
示例#4
0
    def buildResetterItems(self):
        if not resetter:
            return
        pm.menuItem(
            rp='N',
            l='Smart',
            ecr=True,
            c=pm.Callback(resetter.reset),
            ann=
            'Reset the selected objects\' attributes to the defaults, or identity if defaults are not set'
        )
        pm.menuItem(
            rp='NE',
            l='Defaults',
            ecr=True,
            c=pm.CallbackWithArgs(resetter.reset, useBasicDefaults=False),
            ann=
            'Reset the selected objects\' attributes to their defaults, does nothing if no defaults are set'
        )
        pm.menuItem(
            rp='SE',
            l='All Defaults',
            ecr=True,
            c=pm.Callback(resetter.resetAll),
            ann=
            'Reset all objects\' attributes with defaults set to their default values'
        )

        pm.menuItem(l='Resetter',
                    ecr=False,
                    c=pm.Callback(resetter.GUI),
                    ann='Open the Resetter GUI')
        pm.menuItem(d=True)
        pm.menuItem(
            l='Select Objects',
            ecr=True,
            c=pm.Callback(self.selectObjectsWithDefaults),
            ann='Select all objects in the scene that have attribute defaults')
示例#5
0
    def buildMenuItems(self):
        pm.menuItem(rp='NW',
                    l='Reset',
                    ecr=False,
                    ann='Reset all selection masks',
                    c=pm.Callback(self.resetSelectionMasking))
        pm.menuItem(rp='NE',
                    l='All Off',
                    ecr=False,
                    c=pm.Callback(self.setObjectSelectType,
                                  enabled=False,
                                  keys=self.allkeys))
        pm.menuItem(rp='SE',
                    l='Clear Selection',
                    ecr=True,
                    c=pm.Callback(pm.select, cl=True))
        pm.menuItem(rp='S',
                    l='Use Selected',
                    c=pm.Callback(self.setMaskingToSelection))

        selType = lambda x: pm.selectType(q=True, **{x: True})

        # common masking
        pm.menuItem(rp='N',
                    l='Polys',
                    ecr=False,
                    cb=selType('p'),
                    c=pm.CallbackWithArgs(self.setObjectSelectType,
                                          keys=['polymesh']))
        pm.menuItem(rp='E',
                    l='Curves',
                    ecr=False,
                    cb=selType('nurbsCurve'),
                    c=pm.CallbackWithArgs(self.setObjectSelectType,
                                          keys=['nurbsCurve', 'cos',
                                                'stroke']))
        pm.menuItem(rp='SW',
                    l='Joints',
                    ecr=False,
                    cb=selType('joint'),
                    c=pm.CallbackWithArgs(self.setObjectSelectType,
                                          keys=['joint']))
        pm.menuItem(rp='W',
                    l='Surfaces',
                    ecr=False,
                    cb=selType('nurbsSurface'),
                    c=pm.CallbackWithArgs(
                        self.setObjectSelectType,
                        keys=['nurbsSurface', 'subdiv', 'plane']))

        # extended menu
        pm.menuItem(l='Selection Masking', en=False)
        pm.menuItem(d=True)
        pm.menuItem(l='Render',
                    ecr=False,
                    cb=selType('light'),
                    c=pm.CallbackWithArgs(self.setObjectSelectType,
                                          keys=['light', 'camera', 'texture']))
        pm.menuItem(l='Deformers',
                    ecr=False,
                    cb=selType('lattice'),
                    c=pm.CallbackWithArgs(
                        self.setObjectSelectType,
                        keys=['lattice', 'cluster', 'sculpt', 'nonlinear']))
        pm.menuItem(l='Dynamics',
                    ecr=False,
                    cb=selType('particleShape'),
                    c=pm.CallbackWithArgs(self.setObjectSelectType,
                                          keys=[
                                              'particleShape', 'emitter',
                                              'field', 'spring', 'rigidBody',
                                              'fluid', 'hairSystem',
                                              'follicle', 'rigidConstraint'
                                          ]))
        pm.menuItem(l='Misc',
                    ecr=False,
                    cb=selType('ikEndEffector'),
                    c=pm.CallbackWithArgs(
                        self.setObjectSelectType,
                        keys=['ikEndEffector', 'locator', 'dimension']))
示例#6
0
    def buildMenuItems(self):
        pm.menuItem(rp='NW',
                    l='Show All',
                    ecr=False,
                    c=pm.Callback(self.setDisplay,
                                  enabled=True,
                                  keys=['allObjects']))
        pm.menuItem(rp='NE',
                    l='Hide All',
                    ecr=False,
                    c=pm.Callback(self.setDisplay,
                                  enabled=False,
                                  keys=['allObjects']))
        pm.menuItem(rp='S',
                    l='Hide Selected',
                    ecr=True,
                    c=pm.Callback(self.hideSelected))

        query = lambda x: pm.modelEditor(self.panel, q=True, **{x: True})

        # common masking
        pm.menuItem(rp='N',
                    l='Polys',
                    ecr=False,
                    cb=query('polymeshes'),
                    c=pm.CallbackWithArgs(self.setDisplay,
                                          keys=['polymeshes']))
        pm.menuItem(rp='E',
                    l='Curves',
                    ecr=False,
                    cb=query('nurbsCurves'),
                    c=pm.CallbackWithArgs(self.setDisplay,
                                          keys=['nurbsCurves']))
        pm.menuItem(rp='W',
                    l='Surfaces',
                    ecr=False,
                    cb=query('nurbsSurfaces'),
                    c=pm.CallbackWithArgs(
                        self.setDisplay,
                        keys=['nurbsSurfaces', 'subdivSurfaces']))
        pm.menuItem(rp='SW',
                    l='Joints',
                    ecr=False,
                    cb=query('joints'),
                    c=pm.CallbackWithArgs(self.setDisplay, keys=['joints']))
        pm.menuItem(rp='SE',
                    l='Lights',
                    ecr=False,
                    cb=query('lights'),
                    c=pm.CallbackWithArgs(self.setDisplay, keys=['lights']))

        # extended menu
        pm.menuItem(l='Display Masking', en=False)
        pm.menuItem(d=True)
        pm.menuItem(l='Cameras',
                    ecr=False,
                    cb=query('cameras'),
                    c=pm.CallbackWithArgs(self.setDisplay, keys=['cameras']))
        pm.menuItem(l='Locators',
                    ecr=False,
                    cb=query('locators'),
                    c=pm.CallbackWithArgs(self.setDisplay, keys=['locators']))
        pm.menuItem(l='Deformers',
                    ecr=False,
                    cb=query('deformers'),
                    c=pm.CallbackWithArgs(self.setDisplay, keys=['deformers']))
        pm.menuItem(l='Dynamics',
                    ecr=False,
                    cb=query('dynamics'),
                    c=pm.CallbackWithArgs(self.setDisplay, keys=['dynamics']))
        pm.menuItem(l='Misc',
                    ecr=False,
                    cb=query('planes'),
                    c=pm.CallbackWithArgs(self.setDisplay,
                                          keys=[
                                              'planes', 'ikHandles', 'fluids',
                                              'hairSystems', 'follicles',
                                              'dynamicConstraints', 'pivots',
                                              'handles', 'textures', 'strokes'
                                          ]))
示例#7
0
    def buildUI(self, filter=None):

        if filter:
            match = False
            for i, info in enumerate(self.methodInfoList):
                argUtil = factories.ApiArgUtil(self.apiClassName,
                                               self.apiMethodName, i)
                if filter.intersection(argUtil.getInputTypes() +
                                       argUtil.getOutputTypes()):
                    match = True
                    break
            if match == False:
                return False

        self.layout = {
            'columnAlign': [1, 'right'],
            'columnAttach': [1, 'right', 8]
        }

        #print className, self.methodName, melMethods
        isOverloaded = len(self.methodInfoList) > 1
        self.frame = pm.frameLayout(w=FRAME_WIDTH,
                                    labelVisible=False,
                                    collapsable=False)
        logger.debug("building row for %s - %s" %
                     (self.methodName, self.frame))
        col = pm.columnLayout()

        enabledArray = []
        self.rows = []
        self.overloadPrecedenceColl = None
        self.enabledChBx = pm.checkBox(label=self.methodName,
                                       changeCommand=pm.CallbackWithArgs(
                                           MethodRow.enableCB, self))

        if isOverloaded:

            self.overloadPrecedenceColl = pm.radioCollection()
            for i in range(len(self.methodInfoList)):

                self.createMethodInstance(i)

        else:
            #row = rowLayout( self.methodName + '_rowMain', nc=2, cw2=[200, 400] )
            #self.enabledChBx = checkBox(label=self.methodName, changeCommand=CallbackWithArgs( MethodRow.enableCB, self ) )
            #text(label='')
            self.createMethodInstance(0)
            #setParent('..')

        pm.setParent(col)
        pm.separator(w=800, h=6)

        #self.row = rowLayout( self.methodName + '_rowSettings', nc=4, cw4=[200, 160, 180, 160] )
        #self.rows.append(row)

        self.row = pm.rowLayout(self.methodName + '_rowSettings',
                                nc=2,
                                cw2=[200, 220],
                                **self.layout)
        self.rows.append(self.row)

        # create ui elements
        pm.text(label='Mel Equivalent')

        self.melNameTextField = pm.textField(w=170, editable=False)
        self.melNameOptMenu = pm.popupMenu(parent=self.melNameTextField,
                                           button=1,
                                           postMenuCommand=pm.Callback(
                                               MethodRow.populateMelNameMenu,
                                               self))
        pm.setParent('..')

        self.row2 = pm.rowLayout(self.methodName + '_rowSettings2',
                                 nc=3,
                                 cw3=[200, 180, 240],
                                 **self.layout)
        self.rows.append(self.row2)

        pm.text(label='Use Name')
        self.nameMode = pm.radioButtonGrp(label='',
                                          nrb=3,
                                          cw4=[1, 50, 50, 50],
                                          labelArray3=['api', 'mel', 'other'])
        self.altNameText = pm.textField(w=170, enable=False)
        self.altNameText.changeCommand(
            pm.CallbackWithArgs(MethodRow.alternateNameCB, self))
        self.nameMode.onCommand(pm.Callback(MethodRow.nameTypeCB, self))

        isEnabled = self.data.get('enabled', True)

        # UI SETUP

        melName = self.data.get('melName', '')

        try:
            #self.melNameOptMenu.setValue( melName )
            self.melNameTextField.setText(melName)
            if melName != '':
                self.parent.parent.assignMelMethod(melName)

        except RuntimeError:
            # it is possible for a method name to be listed here that was set from a different view,
            # where this class was a super class and more mel commands were available.  expand the option list,
            # and make this frame read-only
            pm.menuItem(label=melName, parent=self.melNameOptMenu)
            self.melNameOptMenu.setValue(melName)
            logger.debug("making %s frame read-only" % self.methodName)
            self.frame.setEnable(False)

        self.enabledChBx.setValue(isEnabled)
        self.row.setEnable(isEnabled)
        self.row2.setEnable(isEnabled)

        name = self.data['useName']
        if name == 'API':
            self.nameMode.setSelect(1)
            self.altNameText.setEnable(False)
        elif name == 'MEL':
            self.nameMode.setSelect(2)
            self.altNameText.setEnable(False)
        else:
            self.nameMode.setSelect(3)
            self.altNameText.setText(name)
            self.altNameText.setEnable(True)

        if self.overloadPrecedenceColl:
            items = self.overloadPrecedenceColl.getCollectionItemArray()
            try:
                val = self.data.get('overloadIndex', 0)

                if val is None:
                    logger.info("no wrappable options for method %s" %
                                self.methodName)
                    self.frame.setEnable(False)
                else:
                    self.overloadPrecedenceColl.setSelect(items[val])
            except:
                pass

#            # ensure we don't use a value that is not valid
#            for val in range(val, len(enabledArray)+1):
#                try:
#                    if enabledArray[val]:
#                        break
#                except IndexError:
#                    val = None
#            if val is not None:
#                self.overloadPrecedenceColl.setSelect( items[ val ] )

        pm.setParent('..')

        pm.setParent('..')  # frame
        pm.setParent('..')  # column

        return True