Ejemplo n.º 1
0
    def createWidgets(self):
        dist_type_sheet = PropertySheetWidget(self)
        dist_type_sheet.newSection("Distance modes and radii")
        radius_edit_max_width = QFontMetrics(
            QApplication.font()).width("8888888888")
        for dt in self.DIST_MODES:
            edit = QLineEdit()
            edit.setAlignment(Qt.AlignRight)
            edit.setFixedWidth(radius_edit_max_width)
            unit = QLabel(dt[2])
            checkbox = WidgetEnableCheckBox(dt[0], [edit, unit])
            self.regProp(dt[3] + "_enabled", WizProp(checkbox, False))
            self.regProp(dt[3], WizPropFloat(edit, dt[1], 0))
            dist_type_sheet.add(checkbox, edit, unit)

        func_sheet = PropertySheetWidget(self)
        func_sheet.newSection("Weight function")
        func_sheet.addComboProp("f(x)",
                                [("1-x^C", "pow"),
                                 ("1-(4x^C)/2 <0.5< ((2-2x)^C)/2", "curve"),
                                 ("(x+1)^-C", "divide")], "pow", "weight_func")
        func_sheet.addNumberProp("C", 1, 2, None, "weight_func_constant")

        enable_checkbox = WidgetEnableCheckBox("Enable distance weight mode",
                                               [dist_type_sheet, func_sheet])
        self.regProp("weight_enabled", WizProp(enable_checkbox, False))
        #prop_sheet = PropertySheetWidget(self)
        #prop_sheet.newSection("Weight mode")
        #radio = QRadioButton("No weight")
        #radio.setChecked(True)
        #prop_sheet.add(radio)
        #weight_mode_radio = WidgetEnableRadioButton("Weigh by distance", [dist_type_sheet, func_sheet])
        #self.regProp("weight_enabled", WizProp(weight_mode_radio, False))
        #prop_sheet.add(weight_mode_radio)

        glayout = QGridLayout()
        #glayout.addWidget(prop_sheet, 0, 0)
        glayout.addWidget(enable_checkbox, 0, 0)
        glayout.setRowMinimumHeight(1, 10)
        glayout.addWidget(dist_type_sheet, 2, 0, 2, 1)
        glayout.addWidget(func_sheet, 2, 1)
        glayout.setRowStretch(4, 1)

        self.setLayout(glayout)