def addControl(self, attr, label=None, changeCommand=None, annotation=None, preventOverride=False, dynamic=False, enumeratedItem=None): if not label: label = prettify(attr) if label.startswith('Ai '): label = label[3:] args = [attr] kwargs = {} # kwargs['preventOverride'] = preventOverride if dynamic: kwargs['addDynamicControl'] = True else: kwargs['addControl'] = True if changeCommand: if hasattr(changeCommand, '__call__'): changeCommand = aeCallback(changeCommand) args.append(changeCommand) if label: kwargs['label'] = label if annotation: kwargs['annotation'] = annotation pm.cmds.editorTemplate(*args, **kwargs)
def _processClass(nodeType): ''' convert the passed node type's classification string to a tuple containing a formatted path string compatible with the node lister and the runtime classification. e.g. from 'aiStandard' to ('rendernode/arnold/shader/surface', 'asShader', 'Arnold/Shader/Surface') ''' for klass in pm.getClassification(nodeType): if klass.startswith('rendernode/arnold'): parts = klass.split('/') if len(parts) < 3: return (klass, 'asUtility', 'Arnold') else: # remove the rendernode first token parts.pop(0) label = '/'.join([utils.prettify(x) for x in parts]) cat = 'asUtility' # find a runtime classification. try matching from most specific to most generic # first token is always 'arnold': parts.pop(0) while parts: try: cat = CATEGORY_TO_RUNTIME_CLASS[tuple(parts)] except KeyError: parts.pop(-1) else: break return (klass, cat, label) return (None, None, None)
def _processClass(nodeType): ''' convert the passed node type's classification string to a tuple containing a formatted path string compatible with the node lister and the runtime classification. e.g. from 'aiStandard' to ('rendernode/arnold/shader/surface', 'asShader', 'Arnold/Shader/Surface') ''' for klass in pm.getClassification(nodeType): if klass.startswith('rendernode/arnold'): parts = klass.split('/') if len(parts) < 3: return (klass, 'asUtility', 'Arnold') else : # remove the rendernode first token parts.pop(0) label = '/'.join([utils.prettify(x) for x in parts]) cat = 'asUtility' # find a runtime classification. try matching from most specific to most generic # first token is always 'arnold': parts.pop(0) while parts: try: cat = CATEGORY_TO_RUNTIME_CLASS[tuple(parts)] except KeyError: parts.pop(-1) else: break return (klass, cat, label) return (None, None, None)
def addControl(self, attr, label=None, changeCommand=None, annotation=None, preventOverride=False, dynamic=False, enumeratedItem=None): # TODO: lookup label and descr from metadata if not label: label = prettify(attr) if label.startswith('Ai '): label = label[3:] kwargs = {} kwargs['label'] = label kwargs['attribute'] = self.nodeAttr(attr) if annotation: kwargs['annotation'] = annotation if changeCommand: kwargs['changeCommand'] = changeCommand if enumeratedItem: kwargs['enumeratedItem'] = enumeratedItem parent = self._layoutStack[-1] pm.setParent(parent) control = AttrControlGrp(**kwargs) self._controls.append((attr, control.setAttribute, parent))
def setup(self): """ default setup automatically builds a UI based on metadata """ if self.__class__._attribData is None: self.__class__._attribData = core.getAttributeData(self._arnoldNodeType) for paramName, attrName, label, annotation in self._attribData: self.addControl(attrName, label if label else prettify(paramName), annotation)
def setup(self): """ default setup automatically builds a UI based on metadata """ if self.__class__._attribData is None: self.__class__._attribData = core.getAttributeData( self._arnoldNodeType) for paramName, attrName, label, annotation in self._attribData: self.addControl(attrName, label if label else prettify(paramName), annotation)
def __init__(self, aovNode=None): self.waitingToRefresh = False self.aovControls = [] self.optionMenus = [] self.aovRows = {} self.renderOptions = aovs.AOVInterface() if aovNode is None else aovNode self.mainCol = pm.cmds.columnLayout('arnoldAOVMainColumn') # global drivers pm.cmds.frameLayout('arnoldDisplayDriverFrame', label='Default Drivers', width=WIDTH, collapsable=True, collapse=True) pm.cmds.columnLayout(adj=True) for attr in self.renderOptions.node.drivers: driver = attr.inputs() if driver: pm.cmds.rowLayout(nc=2, columnAttach2=['both', 'right'], adjustableColumn=1, rowAttach=[2, 'top', 5]) pm.cmds.columnLayout(adj=True) templates.createTranslatorMenu(driver[0], label=utils.prettify(driver[0].name()), nodeType='aiAOVDriver') pm.cmds.setParent('..') pm.cmds.symbolButton(image="navButtonConnected.png", command=Callback(pm.select, driver)) pm.cmds.setParent('..') pm.setParent(self.mainCol) pm.cmds.frameLayout('arnoldAOVBrowserFrame', label='AOV Browser', width=WIDTH, collapsable=True, collapse=False, height=200) self.browser = AOVBrowser(self.renderOptions) pm.setParent(self.mainCol) pm.cmds.frameLayout('arnoldAOVPrimaryFrame', label='AOVs', width=WIDTH, collapsable=True, collapse=False) self.aovCol = pm.cmds.columnLayout('arnoldAOVListColumn', adj=True) pm.cmds.rowLayout('arnoldAOVButtonRow', nc=3, columnWidth3=[140, 100, 100], columnAttach3=['right', 'both', 'both']) pm.cmds.text(label='') pm.cmds.button(label='Add Custom', c=lambda *args: shaderTemplate.newAOVPrompt()) pm.cmds.button(label='Delete All', c=lambda *args: (self.renderOptions.removeAOVs(self.aovRows.keys()), \ hooks.setupDefaultAOVs(self.renderOptions))) pm.setParent('..') # rowLayout pm.cmds.separator(style='in') pm.rowLayout(nc=4, columnWidth4=[130, 66, 80, 40], columnAttach4=['both', 'both', 'both', 'both']) pm.cmds.text(label='name') pm.cmds.text(label='data') pm.cmds.text(label='driver') pm.cmds.text(label='filter') pm.cmds.setParent('..') # rowLayout pm.cmds.separator(style='in') # pm.text(_uiName('prefixLbl'), align='center', label='Prefix', parent=form) # pm.textField(_uiName('prefixFld'), enable=False, text='', parent=form, changeCommand=Callback(setAOVPrefix, aovnode)) self.browser.populate() # add all control rows self.addRows() aovs.addAOVChangedCallback(self.refresh, 'aoveditor') # update AOV imageFormat of all rows when the default imageFormat changes. a scriptJob will suffice here pm.scriptJob(parent=self.aovCol, attributeChange=[self.renderOptions.node.imageFormat.name(), lambda *args: pm.evalDeferred(self.refresh)])
def __init__(self, aovNode=None): self.waitingToRefresh = False self.aovControls = [] self.optionMenus = [] self.aovRows = {} self.renderOptions = aovs.AOVInterface( ) if aovNode is None else aovNode self.mainCol = pm.cmds.columnLayout('arnoldAOVMainColumn') # global drivers pm.cmds.frameLayout('arnoldDisplayDriverFrame', label='Default Drivers', width=WIDTH, collapsable=True, collapse=True) pm.cmds.columnLayout(adj=True) for attr in self.renderOptions.node.drivers: driver = attr.inputs() if driver: pm.cmds.rowLayout(nc=2, columnAttach2=['both', 'right'], adjustableColumn=1, rowAttach=[2, 'top', 5]) pm.cmds.columnLayout(adj=True) templates.createTranslatorMenu(driver[0], label=utils.prettify( driver[0].name()), nodeType='aiAOVDriver') pm.cmds.setParent('..') pm.cmds.symbolButton(image="navButtonConnected.png", command=Callback(pm.select, driver)) pm.cmds.setParent('..') pm.setParent(self.mainCol) pm.cmds.frameLayout('arnoldAOVBrowserFrame', label='AOV Browser', width=WIDTH, collapsable=True, collapse=False, height=200) self.browser = AOVBrowser(self.renderOptions) pm.setParent(self.mainCol) pm.cmds.frameLayout('arnoldAOVPrimaryFrame', label='AOVs', width=WIDTH, collapsable=True, collapse=False) self.aovCol = pm.cmds.columnLayout('arnoldAOVListColumn', adj=True) pm.cmds.rowLayout('arnoldAOVButtonRow', nc=3, columnWidth3=[140, 100, 100], columnAttach3=['right', 'both', 'both']) pm.cmds.text(label='') pm.cmds.button(label='Add Custom', c=lambda *args: shaderTemplate.newAOVPrompt()) pm.cmds.button(label='Delete All', c=lambda *args: (self.renderOptions.removeAOVs(self.aovRows.keys()), \ hooks.setupDefaultAOVs(self.renderOptions))) pm.setParent('..') # rowLayout pm.cmds.separator(style='in') pm.rowLayout(nc=4, columnWidth4=[130, 66, 80, 40], columnAttach4=['both', 'both', 'both', 'both']) pm.cmds.text(label='name') pm.cmds.text(label='data') pm.cmds.text(label='driver') pm.cmds.text(label='filter') pm.cmds.setParent('..') # rowLayout pm.cmds.separator(style='in') # pm.text(_uiName('prefixLbl'), align='center', label='Prefix', parent=form) # pm.textField(_uiName('prefixFld'), enable=False, text='', parent=form, changeCommand=Callback(setAOVPrefix, aovnode)) self.browser.populate() # add all control rows self.addRows() aovs.addAOVChangedCallback(self.refresh, 'aoveditor') # update AOV imageFormat of all rows when the default imageFormat changes. a scriptJob will suffice here pm.scriptJob(parent=self.aovCol, attributeChange=[ self.renderOptions.node.imageFormat.name(), lambda *args: pm.evalDeferred(self.refresh) ])
def filters(self): result = [] for filter in self.template.validFilters(): result.append((prettify(filter).strip('Ai '), filter)) return result