Пример #1
0
class SceneTab(QWidget):  # FIXME I'm Ugly.
    """This widget is for changing the Scene propagation policies
       of the module.
    """

    def __init__(self, parent, agent):
        """Construct the SceneTab with the given parent (TabDialog) and
           ModuleAgent.
        """
        super(SceneTab, self).__init__(parent)

        self.agent = agent

        self.layout = QVBoxLayout()
        self.layout.setAlignment(Qt.AlignCenter)

        self.layout.addWidget(self.buildHighlightGroupBox())
        self.layout.addItem(QSpacerItem(5, 5))
        self.layout.addWidget(self.buildModuleGroupBox())
        self.layout.addItem(QSpacerItem(5, 5))
        self.layout.addWidget(self.buildAttributeGroupBox())

        self.setLayout(self.layout)

    def buildHighlightGroupBox(self):
        """Layout/construct the highlight UI for this tab."""
        groupBox = QGroupBox("Highlight Policy")
        layout = QVBoxLayout()

        # agent.propagate_highlights
        self.highlights_propagate = QCheckBox("Propagate highlights to " + "other modules.")
        self.highlights_propagate.setChecked(self.agent.propagate_highlights)
        self.highlights_propagate.stateChanged.connect(self.highlightsPropagateChanged)
        # We only allow this change if the parent does not propagate
        if self.agent.parent().propagate_highlights:
            self.highlights_propagate.setDisabled(True)

        # agent.apply_highlights
        self.applyHighlights = QCheckBox("Apply highlights from " + "other modules.")
        self.applyHighlights.setChecked(self.agent.apply_highlights)
        self.applyHighlights.stateChanged.connect(self.applyHighlightsChanged)

        layout.addWidget(self.applyHighlights)
        layout.addItem(QSpacerItem(5, 5))
        layout.addWidget(self.highlights_propagate)
        groupBox.setLayout(layout)
        return groupBox

    def highlightsPropagateChanged(self):
        """Called when highlight propagtion is changed to update the
           Agent.
        """
        self.agent.propagate_highlights = self.highlights_propagate.isChecked()

    def applyHighlightsChanged(self):
        """Called when highlight application is changed to update the
           Agent.
        """
        self.agent.apply_highlights = self.applyHighlights.isChecked()

    def buildModuleGroupBox(self):
        """Layout/construct the ModuleScene UI for this tab."""
        groupBox = QGroupBox("Module Policy")
        layout = QVBoxLayout()

        # agent.propagate_module_scenes
        self.module_propagate = QCheckBox("Propagate module scene information " + "to other modules.")
        self.module_propagate.setChecked(self.agent.propagate_module_scenes)
        self.module_propagate.stateChanged.connect(self.modulePropagateChanged)
        # We only allow this change if the parent does not propagate
        if self.agent.parent().propagate_module_scenes:
            self.module_propagate.setDisabled(True)

        # agent.apply_module_scenes
        self.module_applyScene = QCheckBox("Apply module scene information " + "from other modules.")
        self.module_applyScene.setChecked(self.agent.apply_module_scenes)
        self.module_applyScene.stateChanged.connect(self.moduleApplyChanged)

        layout.addWidget(self.module_applyScene)
        layout.addItem(QSpacerItem(5, 5))
        layout.addWidget(self.module_propagate)
        groupBox.setLayout(layout)
        return groupBox

    def modulePropagateChanged(self):
        """Called when ModuleScene propagtion is changed to update the
           Agent.
        """
        self.agent.propagate_module_scenes = self.module_propagate.isChecked()

    def moduleApplyChanged(self):
        """Called when ModuleScene application is changed to update the
           Agent.
        """
        self.agent.apply_module_scenes = self.module_applyScene.isChecked()

    def buildAttributeGroupBox(self):
        """Layout/construct the AttributeScene UI for this tab."""
        groupBox = QGroupBox("Attribute Policy (Colors)")
        layout = QVBoxLayout()

        # agent.propagate_attribute_scenes
        self.attr_propagate = QCheckBox(
            "Propagate attribute scene " + "information (e.g. color maps) to other modules."
        )
        self.attr_propagate.setChecked(self.agent.propagate_attribute_scenes)
        self.attr_propagate.stateChanged.connect(self.attrPropagateChanged)
        # We only allow this change if the parent does not propagate
        if self.agent.parent().propagate_attribute_scenes:
            self.attr_propagate.setDisabled(True)

        # agent.apply_attribute_scenes
        self.attr_applyScene = QCheckBox("Apply attribute scene information " + "from other modules.")
        self.attr_applyScene.setChecked(self.agent.apply_attribute_scenes)
        self.attr_applyScene.stateChanged.connect(self.attrApplyChanged)

        layout.addWidget(self.attr_applyScene)
        layout.addItem(QSpacerItem(5, 5))
        layout.addWidget(self.attr_propagate)
        groupBox.setLayout(layout)
        return groupBox

    def attrPropagateChanged(self):
        """Called when AttributeScene propagtion is changed to update the
           Agent.
        """
        self.agent.propagate_attribute_scenes = self.attr_propagate.isChecked()

    def attrApplyChanged(self):
        """Called when AttributeScene application is changed to update the
           Agent.
        """
        self.agent.apply_attribute_scenes = self.attr_applyScene.isChecked()
Пример #2
0
class SceneTab(QWidget):  #FIXME I'm Ugly.
    """This widget is for changing the Scene propagation policies
       of the module.
    """
    def __init__(self, parent, agent):
        """Construct the SceneTab with the given parent (TabDialog) and
           ModuleAgent.
        """
        super(SceneTab, self).__init__(parent)

        self.agent = agent

        self.layout = QVBoxLayout()
        self.layout.setAlignment(Qt.AlignCenter)

        self.layout.addWidget(self.buildHighlightGroupBox())
        self.layout.addItem(QSpacerItem(5, 5))
        self.layout.addWidget(self.buildModuleGroupBox())
        self.layout.addItem(QSpacerItem(5, 5))
        self.layout.addWidget(self.buildAttributeGroupBox())

        self.setLayout(self.layout)

    def buildHighlightGroupBox(self):
        """Layout/construct the highlight UI for this tab."""
        groupBox = QGroupBox("Highlight Policy")
        layout = QVBoxLayout()

        # agent.propagate_highlights
        self.highlights_propagate = QCheckBox("Propagate highlights to " +
                                              "other modules.")
        self.highlights_propagate.setChecked(self.agent.propagate_highlights)
        self.highlights_propagate.stateChanged.connect(
            self.highlightsPropagateChanged)
        # We only allow this change if the parent does not propagate
        if self.agent.parent().propagate_highlights:
            self.highlights_propagate.setDisabled(True)

        # agent.apply_highlights
        self.applyHighlights = QCheckBox("Apply highlights from " +
                                         "other modules.")
        self.applyHighlights.setChecked(self.agent.apply_highlights)
        self.applyHighlights.stateChanged.connect(self.applyHighlightsChanged)

        layout.addWidget(self.applyHighlights)
        layout.addItem(QSpacerItem(5, 5))
        layout.addWidget(self.highlights_propagate)
        groupBox.setLayout(layout)
        return groupBox

    def highlightsPropagateChanged(self):
        """Called when highlight propagtion is changed to update the
           Agent.
        """
        self.agent.propagate_highlights = self.highlights_propagate.isChecked()

    def applyHighlightsChanged(self):
        """Called when highlight application is changed to update the
           Agent.
        """
        self.agent.apply_highlights = self.applyHighlights.isChecked()

    def buildModuleGroupBox(self):
        """Layout/construct the ModuleScene UI for this tab."""
        groupBox = QGroupBox("Module Policy")
        layout = QVBoxLayout()

        # agent.propagate_module_scenes
        self.module_propagate = QCheckBox(
            "Propagate module scene information " + "to other modules.")
        self.module_propagate.setChecked(self.agent.propagate_module_scenes)
        self.module_propagate.stateChanged.connect(self.modulePropagateChanged)
        # We only allow this change if the parent does not propagate
        if self.agent.parent().propagate_module_scenes:
            self.module_propagate.setDisabled(True)

        # agent.apply_module_scenes
        self.module_applyScene = QCheckBox("Apply module scene information " +
                                           "from other modules.")
        self.module_applyScene.setChecked(self.agent.apply_module_scenes)
        self.module_applyScene.stateChanged.connect(self.moduleApplyChanged)

        layout.addWidget(self.module_applyScene)
        layout.addItem(QSpacerItem(5, 5))
        layout.addWidget(self.module_propagate)
        groupBox.setLayout(layout)
        return groupBox

    def modulePropagateChanged(self):
        """Called when ModuleScene propagtion is changed to update the
           Agent.
        """
        self.agent.propagate_module_scenes = self.module_propagate.isChecked()

    def moduleApplyChanged(self):
        """Called when ModuleScene application is changed to update the
           Agent.
        """
        self.agent.apply_module_scenes = self.module_applyScene.isChecked()

    def buildAttributeGroupBox(self):
        """Layout/construct the AttributeScene UI for this tab."""
        groupBox = QGroupBox("Attribute Policy (Colors)")
        layout = QVBoxLayout()

        # agent.propagate_attribute_scenes
        self.attr_propagate = QCheckBox(
            "Propagate attribute scene " +
            "information (e.g. color maps) to other modules.")
        self.attr_propagate.setChecked(self.agent.propagate_attribute_scenes)
        self.attr_propagate.stateChanged.connect(self.attrPropagateChanged)
        # We only allow this change if the parent does not propagate
        if self.agent.parent().propagate_attribute_scenes:
            self.attr_propagate.setDisabled(True)

        # agent.apply_attribute_scenes
        self.attr_applyScene = QCheckBox("Apply attribute scene information " +
                                         "from other modules.")
        self.attr_applyScene.setChecked(self.agent.apply_attribute_scenes)
        self.attr_applyScene.stateChanged.connect(self.attrApplyChanged)

        layout.addWidget(self.attr_applyScene)
        layout.addItem(QSpacerItem(5, 5))
        layout.addWidget(self.attr_propagate)
        groupBox.setLayout(layout)
        return groupBox

    def attrPropagateChanged(self):
        """Called when AttributeScene propagtion is changed to update the
           Agent.
        """
        self.agent.propagate_attribute_scenes = self.attr_propagate.isChecked()

    def attrApplyChanged(self):
        """Called when AttributeScene application is changed to update the
           Agent.
        """
        self.agent.apply_attribute_scenes = self.attr_applyScene.isChecked()