def getObjectTabPolicy(self): """ Returns the widget that should be displayed under the 'Object' tab. """ # Get the create node in the package, which contains the transform # parameter. # return self._LightUIDelegate__getObjectTabPolicy() packageNode = self.getPackageNode() createNode = NU.GetRefNode(packageNode, "create") if createNode is None: return None # Create a root group policy and add some hints on it rootPolicy = QT4FormWidgets.PythonGroupPolicy('object') rootPolicy.getWidgetHints()['open'] = True rootPolicy.getWidgetHints()['hideTitle'] = True transformPolicy = QT4FormWidgets.PythonGroupPolicy('transform') transformPolicy.getWidgetHints()['open'] = True translatePolicy = FormMaster.CreateParameterPolicy( None, createNode.getParameter("transform.translate")) rotatePolicy = FormMaster.CreateParameterPolicy( None, createNode.getParameter("transform.rotate")) scalePolicy = FormMaster.CreateParameterPolicy( None, createNode.getParameter("transform.scale")) transformPolicy.addChildPolicy(translatePolicy) transformPolicy.addChildPolicy(rotatePolicy) transformPolicy.addChildPolicy(scalePolicy) rootPolicy.addChildPolicy(transformPolicy) viewerObjectSettingsNode = NU.GetRefNode(packageNode, "viewerObjectSettings") annotationPolicy = QT4FormWidgets.PythonGroupPolicy('annotation') annotationPolicy.getWidgetHints()['open'] = False textPolicy = FormMaster.CreateParameterPolicy( None, viewerObjectSettingsNode.getParameter( 'args.viewer.default.annotation.text')) colorPolicy = FormMaster.CreateParameterPolicy( None, viewerObjectSettingsNode.getParameter( 'args.viewer.default.annotation.color')) previewColor = FormMaster.CreateParameterPolicy( None, createNode.getParameter('previewColor')) pickablePolicy = FormMaster.CreateParameterPolicy( None, viewerObjectSettingsNode.getParameter( 'args.viewer.default.pickable')) annotationPolicy.addChildPolicy(textPolicy) annotationPolicy.addChildPolicy(colorPolicy) annotationPolicy.addChildPolicy(previewColor) annotationPolicy.addChildPolicy(pickablePolicy) rootPolicy.addChildPolicy(annotationPolicy) return rootPolicy
def editColour(collection, colour, parentNode): asStack = SuperToolUtils.GetRefNode(parentNode, Constants.ATTRSET_KEY) asNode = doesCollectionExistInStack(collection, asStack) for idx, component in enumerate(colour): asNode.getParameter("groupValue.colour.i{}".format(idx)).setValue( component, 0.0) mcStack = SuperToolUtils.GetRefNode(parentNode, Constants.MAT_KEY) mcNode = doesCollectionExistInStack(collection, mcStack) for idx, component in enumerate(colour): mcNode.getParameter( "shaders.hydraSurfaceParams.katanaColor.value.i{}".format( idx)).setValue(component, 0.0)
def __getObjectTabPolicy(self): """ Returns the widget that should be displayed under the 'Object' tab. """ # Get the create node in the package, which contains the transform # parameter. packageNode = self.getPackageNode() createNode = NU.GetRefNode(packageNode, "create") if createNode is None: return None # Create a root group policy and add some hints on it rootPolicy = QT4FormWidgets.PythonGroupPolicy('object') rootPolicy.getWidgetHints()['open'] = True rootPolicy.getWidgetHints()['hideTitle'] = True transformPolicy = QT4FormWidgets.PythonGroupPolicy('transform') transformPolicy.getWidgetHints()['open'] = True translatePolicy = FormMaster.CreateParameterPolicy( None, createNode.getParameter("transform.translate")) rotatePolicy = FormMaster.CreateParameterPolicy( None, createNode.getParameter("transform.rotate")) scalePolicy = FormMaster.CreateParameterPolicy( None, createNode.getParameter("transform.scale")) transformPolicy.addChildPolicy(translatePolicy) transformPolicy.addChildPolicy(rotatePolicy) transformPolicy.addChildPolicy(scalePolicy) rootPolicy.addChildPolicy(transformPolicy) return rootPolicy
def getMaterialTabPolicy(self): # Create a new material policy that just has the prmanLightParams for # each light type packageNode = self.getPackageNode() materialNode = NU.GetRefNode(packageNode, "material_edit") if materialNode is not None: materialPolicy = QT4FormWidgets.PythonGroupPolicy('material') materialPolicy.getWidgetHints()['hideTitle'] = True lightShaderPolicy = FormMaster.CreateParameterPolicy(materialPolicy, materialNode.getParameter('shaders.arnoldLightShader')) lightShaderPolicy = QT4FormWidgets.ValuePolicyProxy(lightShaderPolicy) lightShaderPolicy.setWidgetHints(lightShaderPolicy.getWidgetHints()) lightShaderPolicy.getWidgetHints()['readOnly'] = True materialPolicy.addChildPolicy(lightShaderPolicy) imageShaderPolicy = FormMaster.CreateParameterPolicy(materialPolicy, materialNode.getParameter('shaders.arnoldSurfaceShader')) imageShaderPolicy = QT4FormWidgets.ValuePolicyProxy(imageShaderPolicy) imageShaderPolicy.setWidgetHints(imageShaderPolicy.getWidgetHints()) imageShaderPolicy.getWidgetHints()['readOnly'] = True materialPolicy.addChildPolicy(imageShaderPolicy) params1Policy = FormMaster.CreateParameterPolicy(materialPolicy, materialNode.getParameter('shaders.arnoldLightParams')) params1Policy.getWidgetHints()['open'] = True params2Policy = FormMaster.CreateParameterPolicy(materialPolicy, materialNode.getParameter('shaders.arnoldSurfaceParams')) params2Policy.getWidgetHints()['open'] = True materialPolicy.addChildPolicy(params1Policy) materialPolicy.addChildPolicy(params2Policy) return materialPolicy return None
def __getObjectTabPolicy(self): """ Returns the widget that should be displayed under the 'Object' tab. """ # Works similarly to SkyDomeUIDelegate.__getObjectTabPolicy, but uses # the TransformEdit to modify the transform. packageNode = self.getPackageNode() transfromEditNode = NU.GetRefNode(packageNode, "transform_edit") if transfromEditNode is None: return None rootPolicy = QT4FormWidgets.PythonGroupPolicy('object') rootPolicy.getWidgetHints()['open'] = True rootPolicy.getWidgetHints()['hideTitle'] = True # Add these three top-level parameters in TransformEdit to the root # policy. for paramName in ('action', 'rotationOrder', 'args'): parameter = transfromEditNode.getParameter(paramName) policy = FormMaster.CreateParameterPolicy(rootPolicy, parameter) rootPolicy.addChildPolicy(policy) return rootPolicy
def createLights(self): ScriptActions.createMeshLights( SuperToolUtils.GetRefNode(self.node, Constants.GAFFER_NODE_KEY), self.celParamPolicy.getValue(), lightName=self.lightNameParamPolicy.getValue(), rigName=self.rigNameParamPolicy.getValue(), mode=self.modeNameParamPolicy.getValue(), lightType=self.typeParamPolicy.getValue(), )
def updateCollections(self, *args): # Cook at Dot node, aka at 'clean' point before any new attribute has been set by SuperTool collectionNames = ScriptActions.cookCollections(root=self.root, node=SuperToolUtils.GetRefNode(self.node, Constants.DOT_KEY ) ).keys() ScriptActions.setColourAttributes(collectionNames, SuperToolUtils.GetRefNode(self.node, Constants.ATTRSET_KEY ), root=self.root, ) # Re-cook since previous nodes added attributes self.collections = ScriptActions.cookCollections(root=self.root, node=SuperToolUtils.GetRefNode(self.node, Constants.ATTRSET_KEY ) ) ScriptActions.buildMaterials(self.collections, SuperToolUtils.GetRefNode(self.node, Constants.MAT_KEY ), ) ScriptActions.createAssignOpScripts(self.collections.keys(), SuperToolUtils.GetRefNode(self.node, Constants.OPSCRIPT_ASSIGN_KEY ), root=self.root) ScriptActions.createOverrideOpScripts(self.collections.keys(), SuperToolUtils.GetRefNode(self.node, Constants.OPSCRIPT_OVERRIDE_KEY ), root=self.root) self.collectionsList.clear() self.items = [] # Need to store items so Qt doesn't remove the objects from memory after the clear call idx = 0 for collection, attrs in self.collections.items(): self.items.append(Widgets.ColourCollectionItem(collection, attrs["colour"])) self.collectionsList.addItem(self.items[idx]) idx = idx + 1
def getMaterialTabPolicy(self): # Create a new material policy that just has the prmanLightParams for # each light type packageNode = self.getPackageNode() materialNode = NU.GetRefNode(packageNode, "material") if materialNode: materialNode.checkDynamicParameters() materialPolicy = QT4FormWidgets.PythonGroupPolicy('material') materialPolicy.getWidgetHints()['hideTitle'] = True shaderPolicy = FormMaster.CreateParameterPolicy(materialPolicy, materialNode.getParameter('shaders.arnoldLightShader')) shaderPolicy = QT4FormWidgets.ValuePolicyProxy(shaderPolicy) shaderPolicy.setWidgetHints(shaderPolicy.getWidgetHints()) shaderPolicy.getWidgetHints()['readOnly'] = False materialPolicy.addChildPolicy(shaderPolicy) paramsPolicy = FormMaster.CreateParameterPolicy(materialPolicy, materialNode.getParameter('shaders.arnoldLightParams')) paramsPolicy.getWidgetHints()['open'] = True materialPolicy.addChildPolicy(paramsPolicy) return materialPolicy return None