Ejemplo n.º 1
0
    def refresh(self, data=None):
        self.clear()

        def setName(value):
            # Store original node name
            origName = self.nodeItem.getName()
            self.component.setName(value)
            if origName != self.component.getDecoratedName():
                self.nodeItem.setName(self.component.getDecoratedName())

        def getName():
            return self.component.getName()

        nameController = GetterSetterController('name', 'String', getter=getName, setter=setName)
        nameWidget = EditorFactory.constructEditor(nameController, parent=self)
        self.addEditor("name", nameWidget)

        def setLocation(value):
            # Store original node name
            origName = self.nodeItem.getName()
            self.component.setLocation(value)
            if origName != self.component.getDecoratedName():
                self.nodeItem.setName(self.component.getDecoratedName())

                # this is a hack to force the UI to update to reflect changes in the rig.
                # Ideally, we should be using an MVC pattern where the UI listens to changes
                # in the model, but we don't have an event system in KRaken. Instead we have to
                # push changes to the UI widgets. (an awkward and not-scalable solution.)
                self.nameWidget.setWidgetValue(self.component.getName())

        def getLocation():
            return self.component.getLocation()

        locationController = GetterSetterController('location', 'String', getter=getLocation, setter=setLocation)
        locationWidget = EditorFactory.constructEditor(locationController, parent=self)
        self.addEditor("location", locationWidget)

        def displayAttribute(attribute):

            def setValue(value):
                attribute.setValue(value)

            def getValue():
                return attribute.getValue()

            attributeController = GetterSetterController(attribute.getName(), attribute.getDataType(), getter=getValue, setter=setValue)
            if attribute.getDataType() in ('Integer', 'Scalar'):
                attributeController.setOption('range', {'min': attribute.getMin(), 'max': attribute.getMax()})

            attributeWidget = EditorFactory.constructEditor(attributeController, parent=self)
            self.addEditor(attribute.getName(), attributeWidget)

        for i in range(self.component.getNumAttributeGroups()):
            grp = self.component.getAttributeGroupByIndex(i)
            self.addSeparator(grp.getName())
            for j in range(grp.getNumAttributes()):
                displayAttribute(grp.getAttributeByIndex(j))

        # Add a stretch so that the widgets pack at the top.
        self.addStretch(2)
Ejemplo n.º 2
0
        def displayAttribute(attribute):

            def setValue(value):
                attribute.setValue(value)

            def getValue():
                return attribute.getValue()

            attributeController = GetterSetterController(attribute.getName(), attribute.getDataType(), getter=getValue, setter=setValue)
            if attribute.getDataType() in ('Integer', 'Scalar'):
                attributeController.setOption('range', {'min': attribute.getMin(), 'max': attribute.getMax()})

            attributeWidget = EditorFactory.constructEditor(attributeController, parent=self)
            self.addEditor(attribute.getName(), attributeWidget)
Ejemplo n.º 3
0
        def displayAttribute(attribute):
            def setValue(value):
                attribute.setValue(value)

            def getValue():
                return attribute.getValue()

            attributeController = GetterSetterController(
                attribute.getName(),
                attribute.getDataType(),
                getter=getValue,
                setter=setValue)
            if attribute.getDataType() in ('Integer', 'Scalar'):
                attributeController.setOption('range', {
                    'min': attribute.getMin(),
                    'max': attribute.getMax()
                })

            attributeWidget = EditorFactory.constructEditor(
                attributeController, parent=self)
            self.addEditor(attribute.getName(), attributeWidget)
Ejemplo n.º 4
0
    def refresh(self, data=None):
        self.clear()

        def setName(value):
            # Store original node name
            origName = self.nodeItem.getName()
            self.component.setName(value)
            if origName != self.component.getDecoratedName():
                self.nodeItem.setName(self.component.getDecoratedName())

        def getName():
            return self.component.getName()

        nameController = GetterSetterController('name',
                                                'String',
                                                getter=getName,
                                                setter=setName)
        self.nameWidget = EditorFactory.constructEditor(nameController,
                                                        parent=self)
        self.addEditor("name", self.nameWidget)

        def setLocation(value):
            # Store original node name
            origName = self.nodeItem.getName()
            self.component.setLocation(value)
            if origName != self.component.getDecoratedName():
                self.nodeItem.setName(self.component.getDecoratedName())

                # this is a hack to force the UI to update to reflect changes in the rig.
                # Ideally, we should be using an MVC pattern where the UI listens to changes
                # in the model, but we don't have an event system in KRaken. Instead we have to
                # push changes to the UI widgets. (an awkward and not-scalable solution.)
                # self.nameWidget.setWidgetValue(self.component.getName())

        def getLocation():
            return self.component.getLocation()

        locationController = GetterSetterController('location',
                                                    'String',
                                                    getter=getLocation,
                                                    setter=setLocation)
        locationWidget = EditorFactory.constructEditor(locationController,
                                                       parent=self)
        self.addEditor("location", locationWidget)

        def displayAttribute(attribute):
            def setValue(value):
                attribute.setValue(value)

            def getValue():
                return attribute.getValue()

            attributeController = GetterSetterController(
                attribute.getName(),
                attribute.getDataType(),
                getter=getValue,
                setter=setValue)
            if attribute.getDataType() in ('Integer', 'Scalar'):
                attributeController.setOption('range', {
                    'min': attribute.getMin(),
                    'max': attribute.getMax()
                })

            attributeWidget = EditorFactory.constructEditor(
                attributeController, parent=self)
            self.addEditor(attribute.getName(), attributeWidget)

        for i in xrange(self.component.getNumAttributeGroups()):
            attrGrp = self.component.getAttributeGroupByIndex(i)
            if attrGrp.getName() == "implicitAttrGrp":
                continue

            grp = self.component.getAttributeGroupByIndex(i)
            self.addSeparator(grp.getName())
            for j in xrange(grp.getNumAttributes()):
                displayAttribute(grp.getAttributeByIndex(j))

        # Add a stretch so that the widgets pack at the top.
        self.addStretch(2)