Пример #1
0
 def defaultTranslatorChanged(self, defaultNode, menu, outputType):
     '''
     rebuilds the menu, updating the value for the default driver/filter and
     restoring the selected item to the proper value
     '''
     # clear menu
     value = pm.optionMenu(menu, query=True, value=True)
     for item in pm.optionMenu(menu, query=True, itemListLong=True) or []:
         pm.deleteUI(item)
     default = '<%s>' % pm.getAttr(defaultNode + '.aiTranslator')
     pm.cmds.menuItem(parent=menu, label=default)
     for tran in templates.getTranslators(outputType):
         pm.cmds.menuItem(parent=menu, label=tran)
     callbacks.DelayedIdleCallbackQueue(self.fixOptionMenus)
     if value.startswith('<'):
         value = default
     pm.cmds.optionMenu(menu, e=True, value=value)
Пример #2
0
 def defaultTranslatorChanged(self, defaultNode, menu, outputType):
     '''
     rebuilds the menu, updating the value for the default driver/filter and
     restoring the selected item to the proper value
     '''
     # clear menu
     value = pm.optionMenu(menu, query=True, value=True)
     for item in pm.optionMenu(menu, query=True, itemListLong=True) or []:
         pm.deleteUI(item)
     default = '<%s>' % pm.getAttr(defaultNode + '.aiTranslator')
     pm.cmds.menuItem(parent=menu, label=default)
     for tran in templates.getTranslators(outputType):
         pm.cmds.menuItem(parent=menu, label=tran)
     callbacks.DelayedIdleCallbackQueue(self.fixOptionMenus)
     if value.startswith('<'):
         value = default
     pm.cmds.optionMenu(menu, e=True, value=value)
Пример #3
0
    def buildOutputRow(self):
        '''
        Add a new Driver and Filter row within the AOVItem row
        '''
        pm.setParent(self.parent)
        

        # DRIVER UI ----------
        self.row = pm.cmds.rowLayout(nc=2,
                     columnWidth2=OUTPUT_ROW_WIDTHS,
                     columnAttach2=['both', 'both'])

        self.driverMenu = pm.cmds.optionMenu(label='', w=50,
                                             changeCommand=lambda newDriver, at=self.outputAttr.driver: \
                                             self.driverMenuChanged(at, newDriver))

        defaultDriver = '<%s>' % pm.getAttr('defaultArnoldDriver.aiTranslator')
        pm.cmds.menuItem(label=defaultDriver)
        for tran in templates.getTranslators('aiAOVDriver'):
            pm.cmds.menuItem(label=tran)
        if self.driverNode.name() == 'defaultArnoldDriver':
            driver = defaultDriver
            isDefaultDriver=True
        else:
            driver = self.driverNode.attr('aiTranslator').get()
            isDefaultDriver=False
        try:
            pm.cmds.optionMenu(self.driverMenu, e=True, value=driver)
            #driverMenu.setValue(driver)
        except RuntimeError:
            pm.warning("[mtoa] %s: Unknown driver %r" % (self.driverNode, driver))
        else:
            if not isDefaultDriver:
                drivTransAttr = self.driverNode.attr('aiTranslator')
                self.driverJobId = pm.scriptJob(attributeChange=[drivTransAttr,
                                              lambda: self.translatorChanged(drivTransAttr, self.driverMenu)],
                             parent=self.driverMenu)
            # rebuild the menu when the default driver changes
            pm.scriptJob(attributeChange=['defaultArnoldDriver.aiTranslator',
                                          lambda: self.defaultTranslatorChanged('defaultArnoldDriver', self.driverMenu, 'aiAOVDriver')],
                                          parent=self.parent)
            
        # FILTER UI ----------
        self.filterMenu = pm.cmds.optionMenu(label='', w=60,
                                             changeCommand=lambda newFilter, at=self.outputAttr.filter: \
                                             self.filterMenuChanged(at, newFilter))
        
        defaultFilter = '<%s>' % pm.getAttr('defaultArnoldFilter.aiTranslator')
        pm.cmds.menuItem(label=defaultFilter)
        for tran in templates.getTranslators('aiAOVFilter'):
            pm.cmds.menuItem(label=tran)
        if self.filterNode.name() == 'defaultArnoldFilter':
            filter = defaultFilter
            isDefaultFilter=True
        else:
            filter = self.filterNode.attr('aiTranslator').get()
            isDefaultFilter=False
        try:
            pm.cmds.optionMenu(self.filterMenu, e=True, value=filter)
            #filterMenu.setValue(filter)
        except RuntimeError:
            pm.warning("[mtoa] %s: Unknown filter %r" % (self.filterNode, filter))
        else:
            if not isDefaultFilter:
                filtTransAttr = self.filterNode.attr('aiTranslator')
                self.filterJobId = pm.scriptJob(attributeChange=[filtTransAttr,
                                              lambda: self.translatorChanged(filtTransAttr, self.filterMenu, isDefaultFilter, 'aiAOVFilter')],
                             parent=self.filterMenu)
            # rebuild the menu when the default filter changes
            pm.scriptJob(attributeChange=['defaultArnoldFilter.aiTranslator',
                                          lambda: self.defaultTranslatorChanged('defaultArnoldFilter', self.filterMenu, 'aiAOVFilter')],
                                          parent=self.parent)

        callbacks.DelayedIdleCallbackQueue(self.fixOptionMenus)
Пример #4
0
    def buildOutputRow(self):
        '''
        Add a new Driver and Filter row within the AOVItem row
        '''
        pm.setParent(self.parent)

        # DRIVER UI ----------
        self.row = pm.cmds.rowLayout(nc=2,
                                     columnWidth2=OUTPUT_ROW_WIDTHS,
                                     columnAttach2=['both', 'both'])

        self.driverMenu = pm.cmds.optionMenu(label='', w=50,
                                             changeCommand=lambda newDriver, at=self.outputAttr.driver: \
                                             self.driverMenuChanged(at, newDriver))

        defaultDriver = '<%s>' % pm.getAttr('defaultArnoldDriver.aiTranslator')
        pm.cmds.menuItem(label=defaultDriver)
        for tran in templates.getTranslators('aiAOVDriver'):
            pm.cmds.menuItem(label=tran)
        if self.driverNode.name() == 'defaultArnoldDriver':
            driver = defaultDriver
            isDefaultDriver = True
        else:
            driver = self.driverNode.attr('aiTranslator').get()
            isDefaultDriver = False
        try:
            pm.cmds.optionMenu(self.driverMenu, e=True, value=driver)
            #driverMenu.setValue(driver)
        except RuntimeError:
            pm.warning("[mtoa] %s: Unknown driver %r" %
                       (self.driverNode, driver))
        else:
            if not isDefaultDriver:
                drivTransAttr = self.driverNode.attr('aiTranslator')
                self.driverJobId = pm.scriptJob(attributeChange=[
                    drivTransAttr, lambda: self.translatorChanged(
                        drivTransAttr, self.driverMenu)
                ],
                                                parent=self.driverMenu)
            # rebuild the menu when the default driver changes
            pm.scriptJob(attributeChange=[
                'defaultArnoldDriver.aiTranslator',
                lambda: self.defaultTranslatorChanged(
                    'defaultArnoldDriver', self.driverMenu, 'aiAOVDriver')
            ],
                         parent=self.parent)

        # FILTER UI ----------
        self.filterMenu = pm.cmds.optionMenu(label='', w=60,
                                             changeCommand=lambda newFilter, at=self.outputAttr.filter: \
                                             self.filterMenuChanged(at, newFilter))

        defaultFilter = '<%s>' % pm.getAttr('defaultArnoldFilter.aiTranslator')
        pm.cmds.menuItem(label=defaultFilter)
        for tran in templates.getTranslators('aiAOVFilter'):
            pm.cmds.menuItem(label=tran)
        if self.filterNode.name() == 'defaultArnoldFilter':
            filter = defaultFilter
            isDefaultFilter = True
        else:
            filter = self.filterNode.attr('aiTranslator').get()
            isDefaultFilter = False
        try:
            pm.cmds.optionMenu(self.filterMenu, e=True, value=filter)
            #filterMenu.setValue(filter)
        except RuntimeError:
            pm.warning("[mtoa] %s: Unknown filter %r" %
                       (self.filterNode, filter))
        else:
            if not isDefaultFilter:
                filtTransAttr = self.filterNode.attr('aiTranslator')
                self.filterJobId = pm.scriptJob(attributeChange=[
                    filtTransAttr, lambda: self.translatorChanged(
                        filtTransAttr, self.filterMenu, isDefaultFilter,
                        'aiAOVFilter')
                ],
                                                parent=self.filterMenu)
            # rebuild the menu when the default filter changes
            pm.scriptJob(attributeChange=[
                'defaultArnoldFilter.aiTranslator',
                lambda: self.defaultTranslatorChanged(
                    'defaultArnoldFilter', self.filterMenu, 'aiAOVFilter')
            ],
                         parent=self.parent)

        callbacks.DelayedIdleCallbackQueue(self.fixOptionMenus)