Example #1
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):
            editorNode = self.getReferencedNode('node_material')
            if not editorNode: return

            scriptItem = self.getScriptItem()

            rootPolicy = QT4FormWidgets.PythonGroupPolicy('material')

            rootPolicy.getWidgetHints()['open'] = True
            lookFileEnablePolicy = QT4FormWidgets.ValuePolicyProxy(
                FormMaster.CreateParameterPolicy(
                    rootPolicy,
                    SA.GetLookFileMaterialEnabledParameter(scriptItem)))
            lookFileEnablePolicy.setWidgetHints({'widget': 'checkBox'})

            rootPolicy.addChildPolicy(lookFileEnablePolicy)

            refPolicy = QT4FormWidgets.PythonGroupPolicy(
                'reference', rootPolicy)
            refPolicy.getWidgetHints().update({
                'open':
                True,
                'conditionalVisOp':
                'notEqualTo',
                'conditionalVisPath':
                '../%s' % lookFileEnablePolicy.getName(),
                'conditionalVisValue':
                '0',
            })

            rootPolicy.addChildPolicy(refPolicy)

            refParam = SA.GetLookFileMaterialReferenceParameter(scriptItem)

            remap = {
                'asset': 'lookfile',
            }
            for param in refParam.getChildren():
                policy = QT4FormWidgets.ValuePolicyProxy(
                    FormMaster.CreateParameterPolicy(refPolicy, param))
                hints = {}
                editorNode.addParameterHints(
                    'Material.lookfile.' +
                    remap.get(policy.getName(), policy.getName()), hints)
                if policy.getName() == 'materialPath':
                    hints = dict(hints)
                    hints['assetPolicy'] = '../asset'

                policy.setWidgetHints(hints)
                refPolicy.addChildPolicy(policy)

            rootPolicy.addChildPolicy(
                FormMaster.CreateParameterPolicy(
                    rootPolicy, editorNode.getParameter('addShaderType')))

            rootPolicy.addChildPolicy(
                FormMaster.CreateParameterPolicy(
                    rootPolicy, editorNode.getParameter('shaders')))

            return rootPolicy
Example #3
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.
        # 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
Example #4
0
    def getEditor(self, widgetParent):
        """
        Only displays the casting sheet scene graph location.
        The asset name isn't editable. You have to add a new casting sheet.
        You can change the casting sheet version though via the importomatic tree view.
        """

        # Only use this if we are in UI mode.
        #
        from Katana import UI4, QT4FormWidgets
        node = self.__node
        group = QT4FormWidgets.PythonGroupPolicy("Casting Sheet Information")
        group.getWidgetHints()['hideTitle'] = True

        paramPolicy = UI4.FormMaster.ParameterPolicy

        # The name policy
        #
        nameParam = node.getParameter("castingInfo.name")
        namePolicy = paramPolicy.CreateParameterPolicy(group, nameParam)
        group.addChildPolicy(namePolicy)

        factory = UI4.FormMaster.KatanaFactory.ParameterWidgetFactory
        w = factory.buildWidget(widgetParent, group)
        w.showPopdown(True)

        return w
    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 getLinkingTabPolicy(self):
            editorNode = self.getReferencedNode('node_aimConstraint')
            if not editorNode: return

            scriptItem = self.getScriptItem()

            rootPolicy = QT4FormWidgets.PythonGroupPolicy('object')
            rootPolicy.getWidgetHints()['hideTitle'] = True

            nodePolicy = FormMaster.CreateParameterPolicy(
                None, editorNode.getParameter("basePath"))
            rootPolicy.addChildPolicy(nodePolicy)

            return rootPolicy
        def getObjectTabPolicy(self):
            editorNode = self.getReferencedNode('node_primCreate')
            if not editorNode: return

            rootPolicy = QT4FormWidgets.PythonGroupPolicy('object')
            rootPolicy.getWidgetHints()['hideTitle'] = True

            scriptItem = self.getScriptItem()

            attrsParam = SA.GetAttributesParameterForPath(
                scriptItem.getGafferPro(),
                scriptItem.getMaterialPath(),
                create=False)
            if attrsParam:
                for name in ('resolution', ):

                    param = attrsParam.getChild("geometry." + name)
                    if not param:
                        continue

                    policy = QT4FormWidgets.ValuePolicyProxy(
                        FormMaster.CreateParameterPolicy(rootPolicy, param))
                    policy.getWidgetHints()['int'] = True
                    rootPolicy.addChildPolicy(policy)

            for name in (
                    'previewAlpha',
                    'transform',
                    'viewerPickable',
            ):
                rootPolicy.addChildPolicy(
                    FormMaster.CreateParameterPolicy(
                        rootPolicy, editorNode.getParameter(name)))

            ll = scriptItem.getNode().getParameter('latlongOrientation')
            if ll:
                llp = FormMaster.CreateParameterPolicy(rootPolicy, ll)
                llp.getWidgetHints()['widget'] = 'popup'
                llp.getWidgetHints()['options'] = 'Interior|Exterior'
                llp.getWidgetHints(
                )['help'] = Resources.HELP_LATLONGORIENTATION
                rootPolicy.addChildPolicy(llp)

            return rootPolicy
            def addLinkingPolicy(defaultPolicy, exceptionsPolicy, name):
                if not defaultPolicy: return

                group = QT4FormWidgets.PythonGroupPolicy(name, rootPolicy)
                group.getWidgetHints()['open'] = True
                rootPolicy.addChildPolicy(group)

                policy = QT4FormWidgets.ValuePolicyProxy(
                    FormMaster.CreateParameterPolicy(group, defaultPolicy))
                policy.setWidgetHints({
                    'widget': 'mapper',
                    'options': 'on:1|off:0'
                })
                group.addChildPolicy(policy)

                policy = FormMaster.NodeBypassPolicy(
                    group, exceptionsPolicy.getNode())
                hints = policy.getWidgetHints()
                hints['label'] = 'enable exceptions'
                hints['widget'] = 'checkBox'
                hints['headerChild'] = 'objects'
                group.addChildPolicy(policy)

                cel = QT4FormWidgets.ValuePolicyProxy(
                    FormMaster.CreateParameterPolicy(group, exceptionsPolicy))
                hints = {}
                hints['widget'] = 'cel'
                hints['conditionalVisOps'] = {
                    'conditionalVisOp': 'notEqualTo',
                    'conditionalVisPath': '../' + policy.getName(),
                    'conditionalVisValue': '0',
                }
                hints['widget'] = 'cel'
                hints['help'] = \
                        'Exceptions will not work unless scene' \
                        ' is connected into Gaffer'
                hints['helpAlert'] = 'warning'

                hints['open'] = True
                cel.setWidgetHints(hints)

                group.addChildPolicy(cel)
    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
Example #11
0
     def getObjectTabPolicy(self):
         editorNode = self.getReferencedNode('node_primCreate')
         if not editorNode: return
 
         scriptItem = self.getScriptItem()
         
         rootPolicy = QT4FormWidgets.PythonGroupPolicy('object')
         rootPolicy.getWidgetHints()['hideTitle'] = True
 
         nodePolicy = FormMaster.CreateParameterPolicy(None,
                 editorNode.getParameter("transform"))
         rootPolicy.addChildPolicy(nodePolicy)
 
         AddConstraintPolicy(scriptItem, rootPolicy,
                             scriptItem.getPointConstraintNode(), 'point',
                             ['targetPath.i0', 'allowMissingTargets',
                              'baseOrigin', 'targetOrigin'])
 
         AddConstraintPolicy(scriptItem, rootPolicy,
                             scriptItem.getOrientConstraintNode(), 'orient',
                             ['targetPath', 'targetOrientation', 'targetFaceIndex',
                              'allowMissingTargets', 'xAxis', 'yAxis', 'zAxis'])
 
         return rootPolicy
Example #12
0
    def __lightSelectionChangedCallback(self):
        """
        Is called when a light pass is selected. This will update the UI that
        displays information about the pass such as resolution, render
        location, etc.
        """
        # Don't respond to changes while we update
        if self.__updating:
            return


        # Remove previous settings from layout
        self.__removeItemsFromLayout(self.__lightSettingsWidget.layout())

        # Rebuild settings
        lightItems = self.__lightWidget.selectedItems()
        if len(lightItems) == 1:
            selectedLightItem = lightItems[0]

            lightPass = selectedLightItem.getItemData()

            # Get node references
            renderSettingsNode = lightPass.getRenderSettingsNode()
            renderOutputDefNode = lightPass.getRenderOutputDefineNode()
            renderPassNode = lightPass.getRenderPassItem().getGroupNode()
            lightParamGroup = renderPassNode.getParameter('lightPasses')
            passGroups = lightParamGroup.getChildren()
            lightPassParamName = passGroups[lightPass.getIndex()].getName()

            # Create group to hold parameters and hide its title
            group = QT4FormWidgets.PythonGroupPolicy("Light Pass Settings")
            group.getWidgetHints()['hideTitle'] = True

            # Define parameters to be added to the group
            params = []
            params.append(renderPassNode.getParameter(
                'lightPasses.' + lightPassParamName + '.renderLocation'))
            params.append(renderSettingsNode.getParameter(
                'args.renderSettings.resolution'))
            params.append(renderOutputDefNode.getParameter(
                'args.renderSettings.outputs.outputName.rendererSettings.shadowType'))
            params.append(renderOutputDefNode.getParameter(
                'args.renderSettings.outputs.outputName.rendererSettings.' +
                    'deepshadVolumeInterpretation'))

            # Create policies for each parameter and add it to the group.
            paramPolicy = UI4.FormMaster.ParameterPolicy
            for param in params:
                # Create a policy for this param
                policy = paramPolicy.CreateParameterPolicy(group, param)

                # Copy widget hints from the original policy to the parameter
                hints = policy.getWidgetHints()
                param.setHintString(repr(hints))

                # Add to the group
                group.addChildPolicy(policy)

            # Create a widget for the parameter group and add it to the layout
            factory = UI4.FormMaster.KatanaFactory.ParameterWidgetFactory
            widget = factory.buildWidget(None, group)
            self.__lightSettingsWidget.layout().addWidget(widget)
Example #13
0
        def GetLinkingTabPolicy(self):
            scriptItem = self.getScriptItem()
            gnode = scriptItem.getGafferPro()
            if not gnode:
                return

            rootPolicy = QT4FormWidgets.PythonGroupPolicy('linking')
            rootPolicy.getWidgetHints()['hideTitle'] = True

            def addLinkingPolicy(defaultPolicy, exceptionsPolicy, name):
                if not defaultPolicy: return

                group = QT4FormWidgets.PythonGroupPolicy(name, rootPolicy)
                group.getWidgetHints()['open'] = True
                rootPolicy.addChildPolicy(group)

                policy = QT4FormWidgets.ValuePolicyProxy(
                    FormMaster.CreateParameterPolicy(group, defaultPolicy))
                policy.setWidgetHints({
                    'widget': 'mapper',
                    'options': 'on:1|off:0'
                })
                group.addChildPolicy(policy)

                policy = FormMaster.NodeBypassPolicy(
                    group, exceptionsPolicy.getNode())
                hints = policy.getWidgetHints()
                hints['label'] = 'enable exceptions'
                hints['widget'] = 'checkBox'
                hints['headerChild'] = 'objects'
                group.addChildPolicy(policy)

                cel = QT4FormWidgets.ValuePolicyProxy(
                    FormMaster.CreateParameterPolicy(group, exceptionsPolicy))
                hints = {}
                hints['widget'] = 'cel'
                hints['conditionalVisOps'] = {
                    'conditionalVisOp': 'notEqualTo',
                    'conditionalVisPath': '../' + policy.getName(),
                    'conditionalVisValue': '0',
                }
                hints['widget'] = 'cel'
                hints['help'] = \
                        'Exceptions will not work unless scene' \
                        ' is connected into Gaffer'
                hints['helpAlert'] = 'warning'

                hints['open'] = True
                cel.setWidgetHints(hints)

                group.addChildPolicy(cel)

            addLinkingPolicy(scriptItem.getDefaultLinkingParameter(),
                             scriptItem.getLinkingExceptionsParameter(),
                             'light linking')

            addLinkingPolicy(scriptItem.getDefaultShadowLinkingParameter(),
                             scriptItem.getShadowLinkingExceptionsParameter(),
                             'shadow linking')

            if rootPolicy.getNumChildren():
                return rootPolicy
Example #14
0
        def getObjectTabPolicy(self):
            editorNode = self.getReferencedNode('node_lightCreate')
            if not editorNode: return

            scriptItem = self.getScriptItem()

            rootPolicy = QT4FormWidgets.PythonGroupPolicy('object')
            rootPolicy.getWidgetHints()['hideTitle'] = True

            geoPolicy = QT4FormWidgets.PythonGroupPolicy(
                'geometry', rootPolicy)
            geoPolicy.getWidgetHints()['open'] = True

            rootPolicy.addChildPolicy(geoPolicy)

            attrsParam = SA.GetAttributesParameterForPath(
                scriptItem.getGafferPro(),
                scriptItem.getFullName(),
                create=False)

            radiusParam = editorNode.getParameter('radius')

            if attrsParam and attrsParam.getChild('geometry'):
                geoParam = attrsParam.getChild('geometry')

                if not radiusParam:
                    radiusParam = geoParam.getChild('radius')

            if radiusParam:
                radiusPolicy = QT4FormWidgets.ValuePolicyProxy(
                    FormMaster.CreateParameterPolicy(geoPolicy, radiusParam))
                radiusPolicy.getWidgetHints()['min'] = '0'
                geoPolicy.addChildPolicy(radiusPolicy)

            for name in ('fov', 'centerOfInterest', 'near', 'far',
                         'screenWindow'):
                geoPolicy.addChildPolicy(
                    FormMaster.CreateParameterPolicy(
                        geoPolicy, editorNode.getParameter(name)))

            transformPolicy = FormMaster.CreateParameterPolicy(
                rootPolicy, editorNode.getParameter('transform'))

            rootPolicy.addChildPolicy(transformPolicy)

            constraintNode = self.getReferencedNode('node_aimConstraint')
            if not constraintNode: return rootPolicy

            AddConstraintPolicy(scriptItem, rootPolicy, constraintNode, 'aim',
                                [
                                    'targetPath.i0', 'targetOrigin',
                                    'baseAimAxis', 'baseUpAxis', 'targetUpAxis'
                                ])

            displayPolicy = QT4FormWidgets.PythonGroupPolicy(
                'display', rootPolicy)

            rootPolicy.addChildPolicy(displayPolicy)

            vosNode = self.getReferencedNode('node_viewerObjectSettings')
            if vosNode:
                #            textPolicy = FormMaster.NodeBypassPolicy(displayPolicy, vosNode)
                #            hints = textPolicy.getWidgetHints()
                #            hints['label'] = 'display annotation'
                #            hints['widget'] = 'checkBox'
                #            displayPolicy.addChildPolicy(textPolicy)
                displayPolicy.addChildPolicy(
                    FormMaster.CreateParameterPolicy(
                        displayPolicy,
                        vosNode.getParameter(
                            'args.viewer.default.annotation.text')))

            previewColorPolicy = QT4FormWidgets.ValuePolicyProxy(
                FormMaster.CreateParameterPolicy(
                    displayPolicy, editorNode.getParameter('previewColor')))
            displayPolicy.addChildPolicy(previewColorPolicy)

            return rootPolicy