Exemplo n.º 1
0
    def widgetParameters(self):
        """Create parameters widgets.
        """
        # Cluster Count
        self.autoK = QCheckBox(self.tr('Auto'))
        self.clusterCount = QSpinBox(self)
        self.clusterCount.setValue(2)
        self.clusterCount.setMinimum(1)
        self.modeK = QComboBox(self)

        hcluster = QHBoxLayout()
        hcluster.addWidget(QLabel(self.tr('Cluster count:')))
        hcluster.addWidget(self.modeK)
        hcluster.addWidget(self.clusterCount)

        # Slider
        hslider = QHBoxLayout()
        clusterLabel = QLabel(self.tr('Cluster count'))
        self.clusterSliderLabel = QLabel()
        compactnessLabel = QLabel(self.tr('Compactness'))
        self.compactnessSliderLabel = QLabel()
        self.clusterSlider = QSlider(QtCore.Qt.Horizontal)
        self.clusterSlider.valueChanged[int].connect(self.sliderMoved)
        self.clusterSlider.setMinimumWidth(100)
        self.clusterSlider.setValue(50)
        self.clusterSlider.setMaximum(100)
        hslider.addWidget(clusterLabel)
        hslider.addWidget(self.clusterSliderLabel)
        hslider.addWidget(self.clusterSlider)
        hslider.addWidget(compactnessLabel)
        hslider.addWidget(self.compactnessSliderLabel)
        self.clusterSliderWidget = QWidget()
        self.clusterSliderWidget.setLayout(hslider)

        # Set default mode
        self.modeK.currentIndexChanged.connect(self.toggleClusterCount)
        default = Clusterer.getDefaultKMode()
        defaultIndex = 0
        for i, (mode, name) in enumerate(Clusterer.getAllKModes()):
            if mode == default:
                defaultIndex = i
            self.modeK.addItem(name)
        self.modeK.setCurrentIndex(defaultIndex)

        # Algo
        combo = QComboBox(self)
        default = Clusterer.getDefaultMode()
        defaultIndex = 0
        for i, (mode, name) in enumerate(Clusterer.getAllModes()):
            if mode == default:
                defaultIndex = i
            combo.addItem(name)
        combo.setCurrentIndex(defaultIndex)
        halgo = QHBoxLayout()
        halgo.addWidget(QLabel(self.tr('Algorithm:')))
        halgo.addWidget(combo)
        self.modeCombo = combo

        # BG color
        color = QtGui.QColor(0, 0, 0)
        self.colorPicker = QPushButton('')
        self.colorPicker.setMaximumSize(QtCore.QSize(16, 16))
        self.colorPicker.clicked.connect(self.colorDialog)
        self.setPickerColor(color, self.colorPicker)
        self.transparentBg = QCheckBox(self.tr('Transparent'))
        self.transparentBg.setChecked(1)
        hbg = QHBoxLayout()
        hbg.addWidget(QLabel(self.tr('Background color:')))
        hbg.addWidget(self.colorPicker)
        hbg.addWidget(self.transparentBg)
        hbg.addStretch(1)

        # Features
        featureBox = QGroupBox(self.tr('Features'))
        features = self.widgetFeatureList()
        featureBox.setLayout(features)

        # Param Box
        paramBox = QGroupBox(self.tr('Parameters'))
        paramLayout = QVBoxLayout()
        paramLayout.addLayout(hcluster)
        paramLayout.addWidget(self.clusterSliderWidget)
        paramLayout.addLayout(halgo)
        paramLayout.addLayout(hbg)
        paramBox.setLayout(paramLayout)

        runButton = self.widgetRun()

        vbox = QVBoxLayout()
        vbox.addWidget(paramBox)
        vbox.addWidget(featureBox)
        vbox.addLayout(runButton)
        vbox.addStretch(1)

        return vbox
Exemplo n.º 2
0
    def widgetParameters(self):
        """Create parameters widgets.
        """
        # Cluster Count
        self.autoK = QCheckBox(self.tr('Auto'))
        self.clusterCount = QSpinBox(self)
        self.clusterCount.setValue(2)
        self.clusterCount.setMinimum(1)
        self.modeK = QComboBox(self)

        hcluster = QHBoxLayout()
        hcluster.addWidget(QLabel(self.tr('Cluster count:')))
        hcluster.addWidget(self.modeK)
        hcluster.addWidget(self.clusterCount)

        # Slider
        hslider = QHBoxLayout()
        clusterLabel = QLabel(self.tr('Cluster count'))
        self.clusterSliderLabel = QLabel()
        compactnessLabel = QLabel(self.tr('Compactness'))
        self.compactnessSliderLabel = QLabel()
        self.clusterSlider = QSlider(QtCore.Qt.Horizontal)
        self.clusterSlider.valueChanged[int].connect(self.sliderMoved)
        self.clusterSlider.setMinimumWidth(100)
        self.clusterSlider.setValue(50)
        self.clusterSlider.setMaximum(100)
        hslider.addWidget(clusterLabel)
        hslider.addWidget(self.clusterSliderLabel)
        hslider.addWidget(self.clusterSlider)
        hslider.addWidget(compactnessLabel)
        hslider.addWidget(self.compactnessSliderLabel)
        self.clusterSliderWidget = QWidget()
        self.clusterSliderWidget.setLayout(hslider)

        # Set default mode
        self.modeK.currentIndexChanged.connect(self.toggleClusterCount)
        default = Clusterer.getDefaultKMode()
        defaultIndex = 0
        for i, (mode, name) in enumerate(Clusterer.getAllKModes()):
            if mode == default:
                defaultIndex = i
            self.modeK.addItem(name)
        self.modeK.setCurrentIndex(defaultIndex)

        # Algo
        combo = QComboBox(self)
        default = Clusterer.getDefaultMode()
        defaultIndex = 0
        for i, (mode, name) in enumerate(Clusterer.getAllModes()):
            if mode == default:
                defaultIndex = i
            combo.addItem(name)
        combo.setCurrentIndex(defaultIndex)
        halgo = QHBoxLayout()
        halgo.addWidget(QLabel(self.tr('Algorithm:')))
        halgo.addWidget(combo)
        self.modeCombo = combo

        # BG color
        color = QtGui.QColor(0, 0, 0)
        self.colorPicker = QPushButton('')
        self.colorPicker.setMaximumSize(QtCore.QSize(16, 16))
        self.colorPicker.clicked.connect(self.colorDialog)
        self.setPickerColor(color, self.colorPicker)
        self.transparentBg = QCheckBox(self.tr('Transparent'))
        self.transparentBg.setChecked(1)
        hbg = QHBoxLayout()
        hbg.addWidget(QLabel(self.tr('Background color:')))
        hbg.addWidget(self.colorPicker)
        hbg.addWidget(self.transparentBg)
        hbg.addStretch(1)

        # Features
        featureBox = QGroupBox(self.tr('Features'))
        features = self.widgetFeatureList()
        featureBox.setLayout(features)

        # Param Box
        paramBox = QGroupBox(self.tr('Parameters'))
        paramLayout = QVBoxLayout()
        paramLayout.addLayout(hcluster)
        paramLayout.addWidget(self.clusterSliderWidget)
        paramLayout.addLayout(halgo)
        paramLayout.addLayout(hbg)
        paramBox.setLayout(paramLayout)

        runButton = self.widgetRun()

        vbox = QVBoxLayout()
        vbox.addWidget(paramBox)
        vbox.addWidget(featureBox)
        vbox.addLayout(runButton)
        vbox.addStretch(1)

        return vbox