def customCreateFlt(self, attr): # print "creating %s" % attr pname = attr.split('.')[-1] ptype = self.params[pname].ptype plabel = self.params[pname].label pann = self.params[pname].annotation presets = self.params[pname].presets precision = self.params[pname].precision controlName = pname + 'Ctrl' l = plabel if presets is not None: l += ' <span>≡</span>' # fix unicode problem in Windows using html pm.attrFieldSliderGrp(controlName, attribute=attr, label=l, annotation=pann, precision=precision) if presets is not None: # pm.attrFieldSliderGrp(controlName, edit=True) # pm.popupMenu() # for k in sorted(presets, key=presets.get): # pm.menuItem(label=k, command=pm.Callback(setPresetFlt, controlName, presets[k])) attrChildren = pm.layout(controlName, query=True, childArray=True) pm.popupMenu(button=1, parent=attrChildren[0]) for k in sorted(presets, key=presets.get): pm.menuItem(label=k, command=pm.Callback(setPresetFlt, controlName, presets[k]))
def create(self): self.main_layout = pm.columnLayout(adjustableColumn= True, width= 400) main_frame = pm.frameLayout( label='%s' % (self.light), collapsable= True) pm.frameLayout( label='Light Attributes', collapsable= True) pm.attrColorSliderGrp( at='%s.color' % (self.light), columnWidth4= [100, 75, 175, 50]) pm.attrFieldSliderGrp(at='%s.intensity' % (self.light), columnWidth4= [100, 75, 175, 50]) pm.setParent(main_frame) pm.frameLayout(label= 'Shadows', collapsable= True) pm.attrColorSliderGrp( at='%s.shadowColor' % (self.light), columnWidth4= [100, 75, 175, 50]) self.check_box = pm.checkBox(label= 'Use Ray Trace Shadows', changeCommand= pm.Callback(self.shadows)) self.light_angle = pm.attrFieldSliderGrp( at='%s.lightAngle' %(self.light), enable= False, columnWidth4= [100, 75, 175, 50]) self.shadow_rays = pm.attrFieldSliderGrp( at='%s.shadowRays' % (self.light), enable= False, columnWidth4= [100, 75, 175, 50]) self.ray_depth = pm.attrFieldSliderGrp( at='%s.rayDepthLimit' % (self.light), enable= False, columnWidth4= [100, 75, 175, 50]) pm.setParent(main_frame) pm.rowColumnLayout(numberOfColumns= 2, columnWidth= [200, 200]) pm.button(label= 'Select Light', width= 200, command= pm.Callback(self.select)) pm.button(label= 'Save Preset', width= 200, command= pm.Callback(self.preset)) pm.button(label= 'Hide', command= pm.Callback(self.hide)) pm.button(label= 'Show', command= pm.Callback(self.show)) return self.main_layout
def _updateControls(self, light, enable=True): if self.Renderer.isArnoldLoaded and self.Renderer.isArnold: kelvinState = pmc.getAttr('{}.aiUseColorTemperature'.format( light.getShape().name())) self.useKelvinCheckbox.setChecked(kelvinState) elif self.Renderer.isPrmanLoaded and self.Renderer.isPrman: kelvinState = pmc.getAttr('{}.enableTemperature'.format( light.getShape().name())) self.useKelvinCheckbox.setChecked(kelvinState) else: kelvinState = False self.useKelvinCheckbox.setHidden(True) lightState = light.visibility.get() self.lightEnableCheckbox.setChecked(lightState) self.useKelvinCheckbox.setEnabled(lightState) for key, value in self.controller.iteritems(): slider, name = value if key == 'scale': self._updateSlider(slider, light, key, enable) else: self._updateSlider(slider, light.getShape(), key, enable) if light.visibility.get(): pmc.attrFieldSliderGrp('lcTemperatureSlider', e=True, en=kelvinState)
def layersReplace(self, attribute): if attribute is not "none": self.thisNode = pm.PyNode(attribute).node() log.debug("layersReplace {0}".format(attribute)) pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) materialEntries = self.thisNode.materialEntryMtl.numElements() #print "layersReplace: node has ", self.thisNode.materialEntryMtl.numElements(), "layers" if self.layersUi is not None and pm.columnLayout(self.layersUi, q=True, exists=True): pm.deleteUI(self.layersUi) with pm.columnLayout(adj=True, parent=self.uiParent) as self.layersUi: for layerNumber in range(materialEntries): layerIndex = self.thisNode.materialEntryMtl.elementByPhysicalIndex(layerNumber).index() with pm.frameLayout(label="Layer {0}".format(layerNumber), collapsable=True, collapse=False, bv=True) as fl: log.debug("create layers UI {0}".format(self.thisNode.materialEntryMtl[layerIndex])) with pm.columnLayout(adj=True): attribute = self.thisNode.materialEntryMtl[layerIndex] if attribute.isConnected(): pm.frameLayout(fl, edit=True, label=attribute.inputs(p=1)[0]) pm.attrColorSliderGrp(label="Material", at=attribute) attribute = self.thisNode.materialEntryMsk[layerIndex] pm.attrFieldSliderGrp(label="Mask", at=attribute) attribute = self.thisNode.materialEntryMode[layerIndex] pm.attrEnumOptionMenuGrp(label="Mode", at=attribute) with pm.columnLayout(adj=True): pm.button(label="Remove Layer", c=pm.Callback(self.removeLayer, layerIndex), height=18) pm.button(label="Layer Up", c=pm.Callback(self.moveLayerUp, layerIndex), height=18) pm.button(label="Layer Down", c=pm.Callback(self.moveLayerDown, layerIndex), height=18) pm.setUITemplate("attributeEditorTemplate", popTemplate=True)
def updateList(self, name, lgt, totalLgt, *args): #create new buttons self.text = pm.text(name, label="Name: %s" %name) visibilityLgt = pm.getAttr(lgt+'.visibility') if visibilityLgt == True: self.button = pm.button(name, label="ON" ,command = lambda *args: self.turnOn(totalLgt, name)) else: self.button = pm.button(name, label="OFF" ,command = lambda *args: self.turnOn(totalLgt, name)) self.button = pm.button('btnNameS'+str(totalLgt), label="SOLO", command = lambda *args: self.turnSolo(totalLgt, name)) pm.attrColorSliderGrp(at='%s.color' % name ) pm.attrFieldSliderGrp( min=0.0, max=10.0, at='%s.intensity' % name )
def createCommonAttr(self, node, deformerType): with pm.rowLayout(numberOfColumns=3): pm.button(l="Add selection to ctrl points", c=pm.Callback(self.addSelectedProbe, node, deformerType)) pm.button(l="Delete deformer", c=pm.Callback(self.deleteNode, node)) pm.attrControlGrp(label="Poisson", attribute=node.poisson) with pm.rowLayout(numberOfColumns=4): pm.attrControlGrp(label="MLS mode", attribute=node.mlsm) pm.attrControlGrp(label="area weight", attribute=node.aw) pm.attrControlGrp(label="neighbour weighting", attribute=node.nghbrw) pm.attrFieldSliderGrp(label="iteration", min=1, max=20, attribute=node.it) with pm.rowLayout(numberOfColumns=4): pm.attrControlGrp(label="Weight mode", attribute=node.wtm) pm.attrFieldSliderGrp(label="effect radius", min=0.001, max=20.0, attribute=node.er) pm.attrControlGrp(label="normalise weight", attribute=node.nw) pm.attrControlGrp(label="normExponent", attribute=node.ne) with pm.rowLayout(numberOfColumns=4): pm.attrControlGrp(label="tet mode", attribute=node.tm) pm.attrControlGrp(label="constraint mode", attribute=node.ctm) pm.attrFieldSliderGrp(label="constraint weight", min=0.001, max=1000, attribute=node.cw) pm.attrFieldSliderGrp(label="constraint radius", min=0.001, max=10.0, attribute=node.cr)
def createUISet(self): self._childLayout = pm.columnLayout( adj=True ) with self._childLayout: pm.text(l="Click cage mesh first, then shift+click target mesh, and click the menu item.") for type in deformerTypes: deformers = pm.ls(type=type) for node in deformers: frameLayout = pm.frameLayout( label=node.name(), collapsable = True) with frameLayout: with pm.rowLayout(numberOfColumns=2) : pm.button( l="Del", c=pm.Callback( self.deleteNode, node)) pm.attrFieldSliderGrp( label="iteration", min=1, max=100, attribute=node.it) with pm.rowLayout(numberOfColumns=2) : pm.attrControlGrp( label="rotation consistency", attribute= node.rc) pm.attrFieldSliderGrp( label="global rotation", min=-720, max=720, attribute=node.ir) with pm.rowLayout(numberOfColumns=3) : pm.attrControlGrp( label="blend mode", attribute= node.bm) pm.attrControlGrp( label="tet mode", attribute= node.tm) pm.attrControlGrp( label="area weight", attribute= node.aw) with pm.rowLayout(numberOfColumns=2) : pm.attrControlGrp( label="visualise energy", attribute= node.ve) pm.attrFieldSliderGrp( label="visualisation multiplier", min=0.001, max=1000, attribute=node.vmp) for j in range(node.blendMesh.numElements()): with pm.rowLayout(numberOfColumns=1) : pm.attrFieldSliderGrp(label=node.blendWeight[j].getAlias(), min=-1.0, max=2.0, attribute= node.blendWeight[j])
def createCommonAttr(self,node,deformerType): with pm.rowLayout(numberOfColumns=len(self.probes[node])+2) : pm.button( l="Delete deformer", c=pm.Callback( self.deleteNode, node)) pm.button( l="Add selection to probes", c=pm.Callback( self.addSelectedProbe, node, deformerType) ) for j in range(len(self.probes[node])): pm.button( l=self.probes[node][j].name(), c=pm.Callback( self.deleteProbe, node, j) ) with pm.rowLayout(numberOfColumns=2) : pm.attrControlGrp( label="blend mode", attribute= node.bm) # pm.attrControlGrp( label="world mode", attribute= node.worldMode) pm.attrControlGrp( label="rotation consistency", attribute= node.rc) with pm.rowLayout(numberOfColumns=4) : pm.attrControlGrp( label="Weight mode", attribute= node.wtm) pm.attrFieldSliderGrp(label="effect radius", min=0.001, max=20.0, attribute=node.er) pm.attrControlGrp( label="normalise weight", attribute= node.nw) pm.attrControlGrp( label="normExponent", attribute=node.ne)
def createUISet(self): self._childLayout = pm.columnLayout( adj=True ) with self._childLayout: pm.text(l="Click target mesh, then shift+click end mesh") self.deformers = pm.ls(type=deformerTypes[0]) for node in self.deformers: frameLayout = pm.frameLayout( label=node.name(), collapsable = True) with frameLayout: pm.button( l="Del", c=pm.Callback( self.deleteNode, node)) pm.attrControlGrp( label="active", attribute= node.active) pm.attrFieldSliderGrp(label="delta", min=0.001, max=5.0, attribute=node.delta) pm.attrFieldSliderGrp(label="shapeMatching", min=0.1, max=10.0, attribute=node.smw) # self.deformers = pm.ls(type=deformerTypes[1]) for node in self.deformers: frameLayout = pm.frameLayout( label=node.name(), collapsable = True) with frameLayout: pm.button( l="Del", c=pm.Callback( self.deleteNode, node)) pm.attrControlGrp( label="active", attribute= node.active) pm.attrFieldSliderGrp(label="delta", min=0.001, max=5.0, attribute=node.delta) pm.attrFieldSliderGrp(label="stiffness", min=0.001, max=10.0, attribute=node.stf) pm.attrFieldSliderGrp(label="attenuation", min=0.001, max=1.0, attribute=node.att)
def createCommonAttr(self, node): with pm.rowLayout(numberOfColumns=4): pm.button(l="Delete deformer", c=pm.Callback(self.deleteNode, node)) pm.button(l="Set selected as cage", c=pm.Callback(self.setCage, node)) pm.attrControlGrp(label="cage mode", attribute=node.cgm) pm.attrControlGrp(label="blend mode", attribute=node.bm) with pm.rowLayout(numberOfColumns=3): pm.attrControlGrp(label="normalise cage tet", attribute=node.nr) pm.attrControlGrp(label="symmetrise face", attribute=node.sf) pm.attrControlGrp(label="area weight", attribute=node.aw) with pm.rowLayout(numberOfColumns=2): pm.attrControlGrp(label="rotation consistency", attribute=node.rc) pm.attrControlGrp(label="Frechet sum", attribute=node.fs) with pm.rowLayout(numberOfColumns=4): pm.attrControlGrp(label="Weight mode", attribute=node.wtm) pm.attrControlGrp(label="normExponent", attribute=node.ne) pm.attrFieldSliderGrp(label="effect radius", min=0.001, max=20.0, attribute=node.er) pm.attrControlGrp(label="normalise weight", attribute=node.nw)
def _deleteExisting(self): for key, value in self.controller.iteritems(): slider, name = value if slider == 'lcColorSlider' and pmc.attrColorSliderGrp(slider, ex=True): pmc.deleteUI(slider) elif slider == 'lcScaleSlider' and pmc.attrFieldGrp(slider, ex=True): pmc.deleteUI(slider) else: if pmc.attrFieldSliderGrp(slider, ex=True): pmc.deleteUI(slider)
def customCreateFlt(self, attr): print "creating %s" % attr pname = attr.split('.')[-1] ptype = self.params[pname].ptype plabel = self.params[pname].label pann = self.params[pname].annotation presets = self.params[pname].presets precision = self.params[pname].precision l = plabel if presets is not None: l = unicode(plabel) + u' \u1392' self.controls[pname] = pm.attrFieldSliderGrp(pname + 'Ctrl', attribute=attr, label=l, annotation=pann, precision=precision) if presets is not None: pm.attrFieldSliderGrp(self.controls[pname], edit=True) pm.popupMenu() for k in sorted(presets, key=presets.get): pm.menuItem(label=k, command=pm.Callback(setPresetFlt, self.controls[pname], presets[k]))
def createUISet(self): self._childLayout = pm.columnLayout(adj=True) with self._childLayout: self.deformers = [ pm.ls(type=deformerTypes[i]) for i in range(len(deformerTypes)) ] for i in range(len(deformerTypes)): for node in self.deformers[i]: self.probes[node] = pm.listConnections(node.cp) # specific for node in self.deformers[0]: frameLayout = pm.frameLayout(label=node.name(), collapsable=True) with frameLayout: self.createCommonAttr(node, deformerTypes[0]) indices = cmds.getAttr(node + ".cp", multiIndices=True) if indices: for j in indices: with pm.rowLayout(numberOfColumns=1): pm.attrFieldSliderGrp( label=node.ctlw[j].getAlias(), min=0, max=10.0, attribute=node.ctlw[j])
def createUISet(self): self._childLayout = pm.columnLayout(adj=True) with self._childLayout: pm.text( l="Click cage mesh first, then shift+click target mesh, and click the menu item." ) # cageDeformer specific deformers = pm.ls(type=deformerTypes[0]) for node in deformers: frameLayout = pm.frameLayout(label=node.name(), collapsable=True) with frameLayout: self.createCommonAttr(node) # cageDeformerARAP specific deformers = pm.ls(type=deformerTypes[1]) for node in deformers: frameLayout = pm.frameLayout(label=node.name(), collapsable=True) with frameLayout: self.createCommonAttr(node) with pm.rowLayout(numberOfColumns=3): pm.attrControlGrp(label="constraint mode", attribute=node.ctm) pm.attrFieldSliderGrp(label="constraint weight", min=0.001, max=1000, attribute=node.cw) pm.attrFieldSliderGrp(label="constraint radius", min=0.001, max=10.0, attribute=node.cr) with pm.rowLayout(numberOfColumns=3): pm.attrFieldSliderGrp(label="iteration", min=1, max=20, attribute=node.it) pm.attrControlGrp(label="tet mode", attribute=node.tm) pm.attrFieldSliderGrp(label="translation weight", min=0.0, max=1.0, attribute=node.tw)
def kelvinEnableEvent(self, obj, state, *args, **kwargs): super(LightControl, self).kelvinEnableEvent(args, kwargs) if self.Renderer.isArnold: pmc.setAttr( '{}.aiUseColorTemperature'.format( self.activeLight.getShape().name()), state) pmc.attrFieldSliderGrp('lcTemperatureSlider', e=True, en=state) elif self.Renderer.isPrman: pmc.setAttr( '{}.enableTemperature'.format( self.activeLight.getShape().name()), state) pmc.attrFieldSliderGrp('lcTemperatureSlider', e=True, en=state) if not self.activeLight.visibility.get(): pmc.attrFieldSliderGrp('lcTemperatureSlider', e=True, en=False)
def create(self): createGlobalsNode() parentForm = pm.setParent(query=True) pm.setUITemplate("renderGlobalsTemplate", pushTemplate=True) pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) with pm.scrollLayout("customMayaRendererScrollLayout", horizontalScrollBarThickness=0): with pm.columnLayout("customMayaRendererColumnLayout", adjustableColumn=True, width=400): with pm.frameLayout("generalFrameLayout", label="General", collapsable=True, collapse=False): with pm.columnLayout("generalColumnLayout", adjustableColumn=True, width=380, rowSpacing=2): pm.separator(height=2) pm.attrFieldSliderGrp( label="Minimal distance", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=0, attribute="customMayaRendererGlobalsNode.minDist") pm.attrFieldSliderGrp( label="Maximal distance", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=0, attribute="customMayaRendererGlobalsNode.maxDist") pm.attrFieldSliderGrp( label="Number of samples:", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=1, maxValue=100, fieldMinValue=1, fieldMaxValue=100, attribute="customMayaRendererGlobalsNode.samples") pm.attrFieldSliderGrp( label="Number of bounces:", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=1, maxValue=100, fieldMinValue=1, fieldMaxValue=50, attribute="customMayaRendererGlobalsNode.maxBounces" ) pm.setUITemplate("renderGlobalsTemplate", popTemplate=True) pm.setUITemplate("attributeEditorTemplate", popTemplate=True) pm.formLayout(parentForm, edit=True, attachForm=[ ("customMayaRendererScrollLayout", "top", 0), ("customMayaRendererScrollLayout", "bottom", 0), ("customMayaRendererScrollLayout", "left", 0), ("customMayaRendererScrollLayout", "right", 0) ])
def customUpdateFlt(self, attr): # print "updating attr %s" % attr pname = attr.split('.')[-1] ptype = self.params[pname].ptype controlName = pname + 'Ctrl' pm.attrFieldSliderGrp(controlName, edit=True, attribute=attr)
def setPresetFlt(ctrl, value): attr = pm.attrFieldSliderGrp(ctrl, query=True, attribute=True) pm.setAttr(attr, value)
def createUISet(self): self._childLayout = pm.columnLayout( adj=True ) with self._childLayout: self.deformers = [pm.ls(type=deformerTypes[i]) for i in range(len(deformerTypes))] for i in range(len(deformerTypes)): for node in self.deformers[i]: self.probes[node] = pm.listConnections(node.pm) # "probeDeformer" specific for node in self.deformers[0]: frameLayout = pm.frameLayout( label=node.name(), collapsable = True) with frameLayout: self.createRamp(node) self.createCommonAttr(node, deformerTypes[0]) indices = cmds.getAttr(node+".pm", multiIndices=True) if indices: for j in indices: with pm.rowLayout(numberOfColumns=1) : pm.attrFieldSliderGrp(label=node.prw[j].getAlias(), min=0, max=10.0, attribute=node.prw[j]) with pm.rowLayout(numberOfColumns=3) : pm.attrControlGrp( label="Frechet sum", attribute= node.fs) pm.attrControlGrp( label="visualisation", attribute= node.vm) pm.attrFieldSliderGrp( label="visualisation multiplier", min=0.001, max=1000, attribute=node.vmp) # "probeDeformerARAP" specific for node in self.deformers[1]: frameLayout = pm.frameLayout( label=node.name(), collapsable = True) with frameLayout: self.createRamp(node) self.createCommonAttr(node, deformerTypes[1]) indices = cmds.getAttr(node+".pm", multiIndices=True) if indices: for j in indices: with pm.rowLayout(numberOfColumns=2) : pm.attrFieldSliderGrp(label=node.prw[j].getAlias(), min=0, max=1.0, attribute=node.prw[j]) pm.attrFieldSliderGrp(label=node.prcr[j].getAlias(), min=0, max=1.0, attribute=node.prcr[j]) with pm.rowLayout(numberOfColumns=3) : pm.button( l="Set supervisor", c=pm.Callback( self.setSupervisor, node)) pm.attrControlGrp( label="tet mode", attribute= node.tm) pm.attrFieldSliderGrp( label="translation weight", min=0.0, max=1.0, attribute=node.tw) with pm.rowLayout(numberOfColumns=3) : pm.attrControlGrp( label="constraint mode", attribute= node.ctm) pm.attrFieldSliderGrp( label="constraint weight", min=0.001, max=1000, attribute=node.cw) pm.attrFieldSliderGrp(label="constraint radius", min=0.001, max=10.0, attribute=node.cr) with pm.rowLayout(numberOfColumns=3) : pm.attrFieldSliderGrp( label="iteration", min=1, max=20, attribute=node.it) pm.attrControlGrp( label="visualisation", attribute= node.vm) pm.attrFieldSliderGrp( label="visualisation multiplier", min=0.001, max=1000, attribute=node.vmp) with pm.rowLayout(numberOfColumns=3) : pm.attrControlGrp( label="stiffness mode", attribute=node.stiffnessMode)
def customUpdateFlt(self, attr): print "updating %s" % attr pname = attr.split('.')[-1] ptype = self.params[pname].ptype pm.attrFieldSliderGrp(self.controls[pname], edit=True, attribute=attr)
def _addControls(self): self._deleteExisting() # Converting and Adding maya slider self.controlBoxLayout.addWidget(LightControl._addSeparator()) self.controlBoxLayout.addWidget( getQObject( pmc.attrColorSliderGrp('lcColorSlider', label='{:>10}'.format('Color:'), cw4=[55, 60, 60, 40], visible=False))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcTemperatureSlider', label='{:>10}'.format('Kelvin:'), pre=0, visible=False, min=-99999, max=99999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcIntensitySlider', label='{:>10}'.format('Intensity:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcExposureSlider', label='{:>10}'.format('Exposure:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcSpreadSlider', label='{:>10}'.format('Spread:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcRoundnessSlider', label='{:>10}'.format('Roundness:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcSoftEdgeSlider', label='{:>10}'.format('Soft Edge:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcConeAngleSlider', label='{:>10}'.format('Cone:'), pre=2, visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcPenumbraAngleSlider', label='{:>10}'.format('Penumbra:'), pre=2, visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcDropoffSlider', label='{:>10}'.format('Dropoff:'), pre=2, visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcSampleSlider', label='{:>10}'.format('Samples:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget(LightControl._addSeparator()) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcDiffuseSlider', label='{:>10}'.format('Diffuse:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lsSpecularSlider', label='{:>10}'.format('Specular:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcSssSlider', label='{:>10}'.format('SSS:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcIndirectSlider', label='{:>10}'.format('Indirect:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldSliderGrp('lcVolumeSlider', label='{:>10}'.format('Volume:'), visible=False, min=-9999, max=9999))) self.controlBoxLayout.addWidget(LightControl._addSeparator()) self.controlBoxLayout.addWidget( getQObject( pmc.attrFieldGrp('lcScaleSlider', label='{:>10}'.format('Scale:'), pre=3, visible=False))) self.controlBoxLayout.addWidget(LightControl._addSeparator()) self.controlBoxLayout.addItem( QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding))
def _updateSlider(self, sliderName, lightShape, attribute, state): # Checking for hidden attributes and skipping try: if pmc.Attribute('%s.%s' % (lightShape, attribute)).isHidden(): pmc.attrFieldSliderGrp(sliderName, edit=True, visible=False) return except pmc.MayaAttributeError: pass if sliderName == 'lcColorSlider': pmc.attrColorSliderGrp(sliderName, edit=True, visible=True, at='%s.%s' % (lightShape, attribute)) pmc.attrColorSliderGrp(sliderName, edit=True, cw4=[60, 70, 10, 10]) pmc.attrColorSliderGrp(sliderName, edit=True, en=state) return if sliderName == 'lcScaleSlider': pmc.attrFieldGrp(sliderName, edit=True, cw4=[60, 65, 65, 65], visible=True, at='%s.%s' % (lightShape, attribute)) pmc.attrFieldGrp(sliderName, edit=True, en=state) return pmc.attrFieldSliderGrp(sliderName, edit=True, cw=[1, 60]) pmc.attrFieldSliderGrp(sliderName, edit=True, cw=[2, 70]) try: pmc.attrFieldSliderGrp(sliderName, edit=True, visible=True, at='%s.%s' % (lightShape, attribute)) except RuntimeError: pmc.attrFieldSliderGrp(sliderName, edit=True, visible=False) pmc.attrFieldSliderGrp(sliderName, edit=True, en=state)
def create(self): createGlobalsNode() parentForm = pm.setParent(query=True) pm.setUITemplate("renderGlobalsTemplate", pushTemplate=True) pm.setUITemplate("attributeEditorTemplate", pushTemplate=True) with pm.scrollLayout("AtlasRendererScrollLayout", horizontalScrollBarThickness=0): with pm.columnLayout("AtlasRendererColumnLayout", adjustableColumn=True, width=400): with pm.frameLayout("samplingFrameLayout", label="Sampling", collapsable=True, collapse=False): with pm.columnLayout("samplingColumnLayout", adjustableColumn=True, width=380, rowSpacing=2): pm.separator(height=2) pm.attrFieldSliderGrp( label="Samples", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=1, attribute="AtlasRendererGlobalsNode.samplesPerPixel" ) pm.attrFieldSliderGrp( label="Min light bounces", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=0, attribute="AtlasRendererGlobalsNode.minLightBounce" ) pm.attrFieldSliderGrp( label="Max light bounces", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=1, attribute="AtlasRendererGlobalsNode.maxLightBounce" ) with pm.frameLayout("rayFrameLayout", label="Ray", collapsable=True, collapse=False): with pm.columnLayout("rayColumnLayout", adjustableColumn=True, width=380, rowSpacing=2): pm.separator(height=2) pm.attrFieldSliderGrp( label="Light treshold", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=0, maxValue=1, attribute="AtlasRendererGlobalsNode.lightTreshold") pm.separator(height=2) pm.attrFieldSliderGrp( label="Minimum hit distance", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=0, maxValue=1, attribute="AtlasRendererGlobalsNode.tmin") #pm.attrFieldSliderGrp( # label = "Maximum hit distance", # columnWidth = (3, 160), # columnAttach= (1, "left", 4), # minValue = 0, # maxValue = 1, # attribute = "AtlasRendererGlobalsNode.tmax" # ) with pm.frameLayout("batchFrameLayout", label="Batch management", collapsable=True, collapse=False): with pm.columnLayout("batchColumnLayout", adjustableColumn=True, width=380, rowSpacing=2): pm.separator(height=2) pm.attrFieldSliderGrp( label="Batch size:", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=1, attribute="AtlasRendererGlobalsNode.batchSize") pm.attrFieldSliderGrp( label="Small batch treshold:", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=0, attribute= "AtlasRendererGlobalsNode.smallBatchTreshold") pm.attrFieldSliderGrp( label="Local bin size:", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=1, attribute="AtlasRendererGlobalsNode.localBinSize") with pm.frameLayout("techFrameLayout", label="Technical details", collapsable=True, collapse=False): with pm.columnLayout("techColumnLayout", adjustableColumn=True, width=380, rowSpacing=2): pm.separator(height=2) pm.attrFieldSliderGrp( label="Target thread count:", columnWidth=(3, 160), columnAttach=(1, "left", 4), minValue=1, attribute= "AtlasRendererGlobalsNode.targetThreadCount") pm.setUITemplate("renderGlobalsTemplate", popTemplate=True) pm.setUITemplate("attributeEditorTemplate", popTemplate=True) pm.formLayout(parentForm, edit=True, attachForm=[("AtlasRendererScrollLayout", "top", 0), ("AtlasRendererScrollLayout", "bottom", 0), ("AtlasRendererScrollLayout", "left", 0), ("AtlasRendererScrollLayout", "right", 0)])
def _build_program_tab(self, controller, tab_name, parent_layout, parent=None): """ """ # TO-DO: Break this into smaller utility functions # Strip "_CTRL" from transform name for tab name ctrl = controller.ctrl ctrl_name = str(ctrl) if not parent: program_tab_columnLayout = pm.columnLayout(tab_name, adj=True) else: program_tab_columnLayout = pm.columnLayout(tab_name, adj=True, parent=parent) ## CONNECT FRAME ## # Define dynamic names based on ctrl input motor_api_optionMenu_name = '{}{}'.format(ctrl_name, MOTOR_API_OPTIONMENU_EXT) device_name_optionMenu_name = '{}{}'.format( ctrl_name, DEVICE_NAME_OPTION_MENU_EXT) connect_frameLayout = pm.frameLayout(label='Connect') pm.columnLayout(adj=True) pm.separator(height=5, style='none') TEXT_COL_WIDTH = 63 # API Selector Row pm.rowLayout( numberOfColumns=2, # columnAttach=[1, 'left', 3], columnWidth=[1, TEXT_COL_WIDTH], adjustableColumn2=2) pm.text('Motor API:') motor_api_optionMenu = pm.optionMenu(motor_api_optionMenu_name) # Get supported Motor APIs from the config and assign them to the option menu supported_apis = mFIZ_config.SUPPORTED_MOTOR_APIS for api in supported_apis: pm.menuItem(api) pm.setParent('..') # Device Name Selector Row devices = serial_utils.get_device_names() pm.rowLayout(numberOfColumns=5, columnAttach=[2, 'right', 3], columnWidth=[1, TEXT_COL_WIDTH], adjustableColumn=2) pm.text('Serial Port:') device_name_optionMenu = pm.optionMenu(device_name_optionMenu_name) for device in devices: pm.menuItem(device, label=device) pm.symbolButton(image='refresh_icon.png', width=20, height=20, command=self._refresh_port_optionMenus) connection_icon = pm.symbolButton(image=CONNECTION_ICON_NAMES[0], width=20, height=20, command=pm.Callback( self.connect, tab_name)) connection_indicator_field = pm.textField( 'connection_indicator_field', editable=False, height=20, width=10, backgroundColor=CONNECTION_INDICATOR_COLORS[0]) pm.setParent('..') pm.separator(height=5, style='none') pm.setParent(program_tab_columnLayout) pm.separator(height=5, style='none') ## CONTROL FRAME ## # Define dynamic names based on ctrl input control_frameLayout = pm.frameLayout(label='Control') pm.columnLayout(adj=True) pm.separator(height=5, style='none') BUTTON_COL_WIDTH = 21 FIZ_CONTROL_COL_HEIGHT = 70 # Creat a row layout that will hold two columns # First column will have the main FIZ controls and the second column # Will hold the "Keyfram All" command fiz_controls_rowLayout = pm.rowLayout(numberOfColumns=2, columnAttach=[2, 'left', -5], rowAttach=[2, 'top', 0], adjustableColumn=1) fiz_controls_columnLayout_1 = pm.columnLayout(adj=True) attrs = ['focus', 'iris', 'zoom'] for attr in attrs: # Create row layout for attribute slider group and "set keyfram" button attr_abbrev = attr[0].capitalize() pm.rowLayout( numberOfColumns=2, #columnAttach=[2, 'right', 3], columnWidth=[2, BUTTON_COL_WIDTH], adjustableColumn=1) pm.attrFieldSliderGrp(tab_name + '_attrFieldSliderGrp_' + attr_abbrev, l=attr_abbrev, min=0, max=1, columnAlign=[1, 'center'], columnWidth3=[15, 50, 0], adjustableColumn=3, attribute='{}.{}'.format(ctrl, attr)) pm.symbolButton(image='set_keyframe_icon.png', command=pm.Callback(self._set_keyframe, [attr])) pm.setParent('..') pm.setParent(fiz_controls_rowLayout) # Key All button fiz_controls_columnLayout_2 = pm.columnLayout(adj=True, width=BUTTON_COL_WIDTH, columnAlign='left') pm.symbolButton(image='keyframe_all_icon.png', width=BUTTON_COL_WIDTH, height=FIZ_CONTROL_COL_HEIGHT, command=self._set_keyframe) pm.setParent(parent_layout) # Add an OpenMaya.MMessage attributeChanged callback to handle UI stat # if a device becomes connected/disconnected node_name = str(controller.node) self._add_attribute_changed_callback(node_name) ## Save the tab data to the self.controls_tab_data dict tab_data = CONTROLS_TAB_DATA(controller, connection_indicator_field, connection_icon, motor_api_optionMenu, device_name_optionMenu) self.controls_tab_data[tab_name] = { 'tab_data': tab_data, 'connected': False } return program_tab_columnLayout