Beispiel #1
0
    def setup(self):
        """This is called one time when the module GUI is initialized
        """
        CIP_PointsLabellingWidget.setup(self)

        # Part of the GUI will be inherited. We just fill the radio buttons area
        # Radio buttons frame
        self.radioButtonsLayout = qt.QHBoxLayout(self.radioButtonsFrame)
        self.typesFrame = qt.QFrame()
        self.radioButtonsLayout.addWidget(self.typesFrame)
        self.typesLayout = qt.QVBoxLayout(self.typesFrame)

        labelsStyle = "font-weight: bold; margin: 0 0 10px 0px;"
        # Types Radio Buttons
        typesLabel = qt.QLabel("Select type")
        typesLabel.setStyleSheet(labelsStyle)
        self.typesLayout.addWidget(typesLabel)
        self.typesRadioButtonGroup = qt.QButtonGroup()
        for key in self.logic.params.mainTypes.iterkeys():
            rbitem = qt.QRadioButton(self.logic.params.getMainTypeLabel(key))
            self.typesRadioButtonGroup.addButton(rbitem, key)
            self.typesLayout.addWidget(rbitem)
        self.typesRadioButtonGroup.buttons()[0].setChecked(True)

        # Subtypes Radio buttons
        # The content will be loaded dynamically every time the main type is modified
        self.subtypesFrame = qt.QFrame()
        self.radioButtonsLayout.addWidget(self.subtypesFrame)
        self.subtypesLayout = qt.QVBoxLayout(self.subtypesFrame)
        subtypesLabel = qt.QLabel("Select subtype")
        subtypesLabel.setStyleSheet(labelsStyle)
        self.subtypesLayout.addWidget(subtypesLabel)
        self.subtypesLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.subtypesRadioButtonGroup = qt.QButtonGroup()
        # Add all the subtypes (we will filter later in "updateState" function)
        for key in self.logic.params.subtypes.iterkeys():
            # Build the description
            rbitem = qt.QRadioButton(self.logic.params.getSubtypeLabel(key))
            self.subtypesRadioButtonGroup.addButton(rbitem, key)
            self.subtypesLayout.addWidget(rbitem, SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.subtypesLayout.addStretch()

        # Region radio buttons
        self.regionsFrame = qt.QFrame()
        self.radioButtonsLayout.addWidget(self.regionsFrame)
        self.regionsLayout = qt.QVBoxLayout(self.regionsFrame)
        regionsLabel = qt.QLabel("Select region")
        regionsLabel.setStyleSheet(labelsStyle)
        self.regionsLayout.addWidget(regionsLabel)
        self.regionsLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.regionsLayout.setStretch(0, 0)
        self.regionsRadioButtonGroup = qt.QButtonGroup()
        self.regionsFrame = qt.QFrame()
        # Add all the regions
        for key in self.logic.params.regions.iterkeys():
            # Build the description
            rbitem = qt.QRadioButton(self.logic.params.getRegionLabel(key))
            self.regionsRadioButtonGroup.addButton(rbitem, key)
            self.regionsLayout.addWidget(rbitem, SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.regionsLayout.addStretch()
        self.regionsRadioButtonGroup.buttons()[0].setChecked(True)

        # Artifact radio buttons (Add them to the same layout as the type)
        self.separatorLabel = qt.QLabel("------------")
        labelsStyle = "margin: 5px 0 5px 0;"
        self.separatorLabel.setStyleSheet(labelsStyle)
        self.typesLayout.addWidget(self.separatorLabel)
        self.artifactsLabel = qt.QLabel("Select artifact")
        labelsStyle = "font-weight: bold; margin: 15px 0 10px 0;"
        self.artifactsLabel.setStyleSheet(labelsStyle)
        self.typesLayout.addWidget(self.artifactsLabel)
        self.artifactsRadioButtonGroup = qt.QButtonGroup()
        for artifactId in self.logic.params.artifacts.iterkeys():
            rbitem = qt.QRadioButton(self.logic.params.getArtifactLabel(artifactId))
            self.artifactsRadioButtonGroup.addButton(rbitem, artifactId)
            self.typesLayout.addWidget(rbitem)
        self.artifactsRadioButtonGroup.buttons()[0].setChecked(True)

        self.typesLayout.setAlignment(SlicerUtil.ALIGNMENT_VERTICAL_TOP)
        self.typesLayout.addStretch()

        # Connections
        self.typesRadioButtonGroup.connect("buttonClicked (QAbstractButton*)", self.__onTypesRadioButtonClicked__)
        self.subtypesRadioButtonGroup.connect("buttonClicked (QAbstractButton*)",
                                              self.__onSecondaryRadioButtonClicked__)
        self.regionsRadioButtonGroup.connect("buttonClicked (QAbstractButton*)", self.__onSecondaryRadioButtonClicked__)
        self.artifactsRadioButtonGroup.connect("buttonClicked (QAbstractButton*)",
                                               self.__onSecondaryRadioButtonClicked__)

        self.updateState()
Beispiel #2
0
 def __init__(self, parent):
     CIP_PointsLabellingWidget.__init__(self, parent)