diff --git a/src/controller.py b/src/controller.py index 39fc795..f31df18 100644 --- a/src/controller.py +++ b/src/controller.py @@ -709,7 +709,6 @@ def save_settings(self, slicing_type, filename=""): s.slicing.rotationz, ) = tf.GetOrientation() s.slicing.scalex, s.slicing.scaley, s.slicing.scalez = tf.GetScale() - s.slicing.angle = float(self.view.colorize_angle_value.text()) s.slicing.slicing_type = slicing_type m = vtkMatrix4x4() diff --git a/src/settings_widget.py b/src/settings_widget.py index d557568..6598e47 100644 --- a/src/settings_widget.py +++ b/src/settings_widget.py @@ -68,6 +68,7 @@ class SettingsWidget(QWidget): "support_priority_zoffset", "support_number_of_bottom_layers", "support_number_of_lid_layers", + "critical_angle", ] # extra parameters are only used for a small widget with parameters for each figure specifically @@ -337,952 +338,928 @@ def with_sett(self, name: str): return self # we match the given name with each setting and add it to the layout - match name: - case "printer_path": - # self.ensure_sett("hardware.printer_path") - - printer_basename = "" - try: - printer_basename = path.basename(self.sett().hardware.printer_dir) - if self.sett().hardware.printer_dir == "" or not path.isdir( - self.sett().hardware.printer_dir - ): - # empty directory - raise ValueError("Choose default printer") - - logging.info( - f"hardware printer path is {self.sett().hardware.printer_dir}" - ) - except ValueError: - # set default path to printer config - self.sett().hardware.printer_dir = path.join( - APP_PATH, "data", "printers", "default" - ) - logging.info( - f"hardware printer path is default: {self.sett().hardware.printer_dir}" - ) - printer_basename = path.basename(self.sett().hardware.printer_dir) - - printer_path_edit = ClickableLineEdit(printer_basename) - printer_path_edit.setReadOnly(True) - - printer_add_btn = QPushButton("+") - printer_add_btn.setToolTip(self.locale.AddNewPrinter) - - label = QLabel(self.locale.PrinterName) - self.panel.addWidget(label, self.next_row, 1) - self.panel.addWidget(printer_add_btn, self.cur_row, 2) - self.panel.addWidget(printer_path_edit, self.cur_row, 3, 1, 3) - - self.__elements[name] = { - "label": label, - "edit": printer_path_edit, - "add_btn": printer_add_btn, - } - case "uninterrupted_print": - self.ensure_sett("uninterrupted_print.enabled") - - uninterrupted_print = QLabel(self.locale.UninterruptedPrint) - uninterrupted_print_box = QCheckBox() - if sett().uninterrupted_print.enabled: - uninterrupted_print_box.setCheckState(QtCore.Qt.Checked) - self.panel.addWidget( - QLabel(self.locale.UninterruptedPrint), self.next_row, 1 + if name == "printer_path": + # self.ensure_sett("hardware.printer_path") + + printer_basename = "" + try: + printer_basename = path.basename(self.sett().hardware.printer_dir) + if self.sett().hardware.printer_dir == "" or not path.isdir( + self.sett().hardware.printer_dir + ): + # empty directory + raise ValueError("Choose default printer") + + logging.info( + f"hardware printer path is {self.sett().hardware.printer_dir}" ) - self.panel.addWidget( - uninterrupted_print_box, self.cur_row, 2, 1, self.col2_cells + except ValueError: + # set default path to printer config + self.sett().hardware.printer_dir = path.join( + APP_PATH, "data", "printers", "default" ) - - # on check on this box, we should restrict fill type to zigzag only - def on_uninterrupted_print_change(): - self.sett().uninterrupted_print.enabled = ( - uninterrupted_print_box.isChecked() - ) - - isUninterrupted = uninterrupted_print_box.isChecked() - - self.values("filling_type").setEnabled(not isUninterrupted) - self.checkbox("retraction_on").setEnabled(not isUninterrupted) - self.edit("retraction_distance").setEnabled(not isUninterrupted) - self.edit("retraction_speed").setEnabled(not isUninterrupted) - self.edit("retraction_compensation").setEnabled(not isUninterrupted) - - if isUninterrupted: - zigzag_idx = locales.getLocaleByLang( - "en" - ).FillingTypeValues.index("ZigZag") - self.values("filling_type").setCurrentIndex(zigzag_idx) - self.checkbox("retraction_on").setChecked(False) - - uninterrupted_print_box.stateChanged.connect( - on_uninterrupted_print_change + logging.info( + f"hardware printer path is default: {self.sett().hardware.printer_dir}" ) + printer_basename = path.basename(self.sett().hardware.printer_dir) + + printer_path_edit = ClickableLineEdit(printer_basename) + printer_path_edit.setReadOnly(True) + + printer_add_btn = QPushButton("+") + printer_add_btn.setToolTip(self.locale.AddNewPrinter) + + label = QLabel(self.locale.PrinterName) + self.panel.addWidget(label, self.next_row, 1) + self.panel.addWidget(printer_add_btn, self.cur_row, 2) + self.panel.addWidget(printer_path_edit, self.cur_row, 3, 1, 3) + + self.__elements[name] = { + "label": label, + "edit": printer_path_edit, + "add_btn": printer_add_btn, + } + elif name == "uninterrupted_print": + self.ensure_sett("uninterrupted_print.enabled") + + uninterrupted_print = QLabel(self.locale.UninterruptedPrint) + uninterrupted_print_box = QCheckBox() + if sett().uninterrupted_print.enabled: + uninterrupted_print_box.setCheckState(QtCore.Qt.Checked) + self.panel.addWidget( + QLabel(self.locale.UninterruptedPrint), self.next_row, 1 + ) + self.panel.addWidget( + uninterrupted_print_box, self.cur_row, 2, 1, self.col2_cells + ) - self.__elements[name] = { - "label": uninterrupted_print, - "checkbox": uninterrupted_print_box, - } - - case "m10_cut_distance": - self.ensure_sett("uninterrupted_print.cut_distance") - - m10_cut_distance = QLabel(self.locale.M10CutDistance) - m10_cut_distance_value = QLineEdit() - m10_cut_distance_value.setText( - str(sett().uninterrupted_print.cut_distance) + # on check on this box, we should restrict fill type to zigzag only + def on_uninterrupted_print_change(): + self.sett().uninterrupted_print.enabled = ( + uninterrupted_print_box.isChecked() ) - m10_cut_distance_value.setValidator(self.doubleValidator) - self.panel.addWidget(m10_cut_distance, self.next_row, 1) - self.panel.addWidget( - m10_cut_distance_value, self.cur_row, 2, 1, self.col2_cells - ) - - def on_change(): - sett().uninterrupted_print.cut_distance = self.__smart_float( - m10_cut_distance_value.text() - ) - m10_cut_distance_value.textChanged.connect(on_change) + isUninterrupted = uninterrupted_print_box.isChecked() - self.__elements[name] = { - "label": m10_cut_distance, - "edit": m10_cut_distance_value, - } + self.values("filling_type").setEnabled(not isUninterrupted) + self.checkbox("retraction_on").setEnabled(not isUninterrupted) + self.edit("retraction_distance").setEnabled(not isUninterrupted) + self.edit("retraction_speed").setEnabled(not isUninterrupted) + self.edit("retraction_compensation").setEnabled(not isUninterrupted) - case "line_width": - self.ensure_sett("slicing.line_width") + if isUninterrupted: + zigzag_idx = locales.getLocaleByLang("en").FillingTypeValues.index( + "ZigZag" + ) + self.values("filling_type").setCurrentIndex(zigzag_idx) + self.checkbox("retraction_on").setChecked(False) + + uninterrupted_print_box.stateChanged.connect(on_uninterrupted_print_change) + + self.__elements[name] = { + "label": uninterrupted_print, + "checkbox": uninterrupted_print_box, + } + + elif name == "m10_cut_distance": + self.ensure_sett("uninterrupted_print.cut_distance") + + m10_cut_distance = QLabel(self.locale.M10CutDistance) + m10_cut_distance_value = QLineEdit() + m10_cut_distance_value.setText(str(sett().uninterrupted_print.cut_distance)) + m10_cut_distance_value.setValidator(self.doubleValidator) + self.panel.addWidget(m10_cut_distance, self.next_row, 1) + self.panel.addWidget( + m10_cut_distance_value, self.cur_row, 2, 1, self.col2_cells + ) - line_width = QLabel(self.locale.LineWidth) - line_width_value = QLineEdit() - line_width_value.setText(str(self.sett().slicing.line_width)) - line_width_value.setValidator(self.doubleValidator) - line_width_value.textChanged.connect(self.__update_wall_thickness) - self.panel.addWidget(line_width, self.next_row, 1) - self.panel.addWidget( - line_width_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + sett().uninterrupted_print.cut_distance = self.__smart_float( + m10_cut_distance_value.text() ) - def on_change(): - self.sett().slicing.line_width = self.__smart_float( - line_width_value.text() - ) + m10_cut_distance_value.textChanged.connect(on_change) - line_width_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": m10_cut_distance, + "edit": m10_cut_distance_value, + } - self.__elements[name] = { - "label": line_width, - "edit": line_width_value, - } + elif name == "line_width": + self.ensure_sett("slicing.line_width") - case "layer_height": - self.ensure_sett("slicing.layer_height") + line_width = QLabel(self.locale.LineWidth) + line_width_value = QLineEdit() + line_width_value.setText(str(self.sett().slicing.line_width)) + line_width_value.setValidator(self.doubleValidator) + line_width_value.textChanged.connect(self.__update_wall_thickness) + self.panel.addWidget(line_width, self.next_row, 1) + self.panel.addWidget(line_width_value, self.cur_row, 2, 1, self.col2_cells) - layer_height = QLabel(self.locale.LayerHeight) - layer_height_value = QLineEdit() - layer_height_value.setText(str(self.sett().slicing.layer_height)) - layer_height_value.setValidator(self.doubleValidator) - layer_height_value.textChanged.connect(self.__change_layer_height) - self.panel.addWidget(layer_height, self.next_row, 1) - self.panel.addWidget( - layer_height_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.line_width = self.__smart_float( + line_width_value.text() ) - def on_change(): - self.sett().slicing.layer_height = self.__smart_float( - layer_height_value.text() - ) + line_width_value.textChanged.connect(on_change) - layer_height_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": line_width, + "edit": line_width_value, + } - self.__elements[name] = { - "label": layer_height, - "edit": layer_height_value, - } + elif name == "layer_height": + self.ensure_sett("slicing.layer_height") - case "number_wall_lines": - self.ensure_sett("slicing.wall_thickness") + layer_height = QLabel(self.locale.LayerHeight) + layer_height_value = QLineEdit() + layer_height_value.setText(str(self.sett().slicing.layer_height)) + layer_height_value.setValidator(self.doubleValidator) + layer_height_value.textChanged.connect(self.__change_layer_height) + self.panel.addWidget(layer_height, self.next_row, 1) + self.panel.addWidget( + layer_height_value, self.cur_row, 2, 1, self.col2_cells + ) - number_wall_lines_label = QLabel(self.locale.NumberWallLines) - if self.sett().slicing.line_width > 0: - number_wall_lines_value = int( - self.sett().slicing.wall_thickness - / self.sett().slicing.line_width - ) - else: - number_wall_lines_value = 0 + def on_change(): + self.sett().slicing.layer_height = self.__smart_float( + layer_height_value.text() + ) - number_wall_lines_value = LineEdit(str(number_wall_lines_value)) - number_wall_lines_value.setValidator(self.intValidator) + layer_height_value.textChanged.connect(on_change) - number_wall_lines_value.textChanged.connect( - self.__update_wall_thickness - ) + self.__elements[name] = { + "label": layer_height, + "edit": layer_height_value, + } - self.panel.addWidget(number_wall_lines_label, self.next_row, 1) - self.panel.addWidget(number_wall_lines_value, self.cur_row, 2) + elif name == "number_wall_lines": + self.ensure_sett("slicing.wall_thickness") - wall_thickness_label = QLabel(self.locale.WallThickness) - wall_thickness_value = LineEdit(str(self.sett().slicing.wall_thickness)) - wall_thickness_value.setReadOnly(True) - millimeter_label = QLabel(self.locale.Millimeter) - self.panel.addWidget(wall_thickness_label, self.cur_row, 3) - self.panel.addWidget(wall_thickness_value, self.cur_row, 4) - self.panel.addWidget(millimeter_label, self.cur_row, 5) + number_wall_lines_label = QLabel(self.locale.NumberWallLines) + if self.sett().slicing.line_width > 0: + number_wall_lines_value = int( + self.sett().slicing.wall_thickness / self.sett().slicing.line_width + ) + else: + number_wall_lines_value = 0 - def on_change(): - self.sett().slicing.wall_thickness = self.__smart_float( - wall_thickness_value.text() - ) + number_wall_lines_value = LineEdit(str(number_wall_lines_value)) + number_wall_lines_value.setValidator(self.intValidator) - number_wall_lines_value.textChanged.connect(on_change) + number_wall_lines_value.textChanged.connect(self.__update_wall_thickness) - self.__elements[name] = { - "label": number_wall_lines_label, - "edit": number_wall_lines_value, - "wall_thickness_label": wall_thickness_label, - "wall_thickness_value": wall_thickness_value, - } + self.panel.addWidget(number_wall_lines_label, self.next_row, 1) + self.panel.addWidget(number_wall_lines_value, self.cur_row, 2) - case "number_of_bottom_layers": - self.ensure_sett("slicing.bottoms_depth") + wall_thickness_label = QLabel(self.locale.WallThickness) + wall_thickness_value = LineEdit(str(self.sett().slicing.wall_thickness)) + wall_thickness_value.setReadOnly(True) + millimeter_label = QLabel(self.locale.Millimeter) + self.panel.addWidget(wall_thickness_label, self.cur_row, 3) + self.panel.addWidget(wall_thickness_value, self.cur_row, 4) + self.panel.addWidget(millimeter_label, self.cur_row, 5) - number_of_bottom_layers_label = QLabel(self.locale.NumberOfBottomLayers) - number_of_bottom_layers_value = LineEdit( - str(self.sett().slicing.bottoms_depth) - ) - number_of_bottom_layers_value.setValidator(self.intValidator) - number_of_bottom_layers_value.textChanged.connect( - self.__update_bottom_thickness + def on_change(): + self.sett().slicing.wall_thickness = self.__smart_float( + wall_thickness_value.text() ) - self.panel.addWidget(number_of_bottom_layers_label, self.next_row, 1) - self.panel.addWidget(number_of_bottom_layers_value, self.cur_row, 2) - - bottom_thickness_label = QLabel(self.locale.BottomThickness) - bottom_thickness_value = LineEdit( - str( - round( - self.sett().slicing.bottoms_depth - * self.sett().slicing.layer_height, - 2, - ), - ) - ) - bottom_thickness_value.setReadOnly(True) - millimeter_label = QLabel(self.locale.Millimeter) + number_wall_lines_value.textChanged.connect(on_change) - self.panel.addWidget(bottom_thickness_label, self.cur_row, 3) - self.panel.addWidget(bottom_thickness_value, self.cur_row, 4) - self.panel.addWidget(millimeter_label, self.cur_row, 5) + self.__elements[name] = { + "label": number_wall_lines_label, + "edit": number_wall_lines_value, + "wall_thickness_label": wall_thickness_label, + "wall_thickness_value": wall_thickness_value, + } - def on_change(): - self.sett().slicing.bottoms_depth = self.__smart_float( - bottom_thickness_value.text() - ) + elif name == "number_of_bottom_layers": + self.ensure_sett("slicing.bottoms_depth") - number_of_bottom_layers_value.textChanged.connect(on_change) + number_of_bottom_layers_label = QLabel(self.locale.NumberOfBottomLayers) + number_of_bottom_layers_value = LineEdit( + str(self.sett().slicing.bottoms_depth) + ) + number_of_bottom_layers_value.setValidator(self.intValidator) + number_of_bottom_layers_value.textChanged.connect( + self.__update_bottom_thickness + ) - self.__elements[name] = { - "label": number_of_bottom_layers_label, - "edit": number_of_bottom_layers_value, - "bottom_thickness_label": bottom_thickness_label, - "bottom_thickness_value": bottom_thickness_value, - } + self.panel.addWidget(number_of_bottom_layers_label, self.next_row, 1) + self.panel.addWidget(number_of_bottom_layers_value, self.cur_row, 2) + + bottom_thickness_label = QLabel(self.locale.BottomThickness) + bottom_thickness_value = LineEdit( + str( + round( + self.sett().slicing.bottoms_depth + * self.sett().slicing.layer_height, + 2, + ), + ) + ) + bottom_thickness_value.setReadOnly(True) + millimeter_label = QLabel(self.locale.Millimeter) - case "number_of_lids_layers": - self.ensure_sett("slicing.lids_depth") + self.panel.addWidget(bottom_thickness_label, self.cur_row, 3) + self.panel.addWidget(bottom_thickness_value, self.cur_row, 4) + self.panel.addWidget(millimeter_label, self.cur_row, 5) - number_of_lids_layers_label = QLabel(self.locale.NumberOfLidLayers) - number_of_lids_layers_value = LineEdit( - str(self.sett().slicing.lids_depth) - ) - number_of_lids_layers_value.setValidator(self.intValidator) - number_of_lids_layers_value.textChanged.connect( - self.__update_lid_thickness + def on_change(): + self.sett().slicing.bottoms_depth = self.__smart_float( + bottom_thickness_value.text() ) - self.panel.addWidget(number_of_lids_layers_label, self.next_row, 1) - self.panel.addWidget(number_of_lids_layers_value, self.cur_row, 2) - - lid_thickness_label = QLabel(self.locale.LidsThickness) - lid_thickness_value = LineEdit( - str( - round( - self.sett().slicing.lids_depth - * self.sett().slicing.layer_height, - 2, - ), - ) + number_of_bottom_layers_value.textChanged.connect(on_change) + + self.__elements[name] = { + "label": number_of_bottom_layers_label, + "edit": number_of_bottom_layers_value, + "bottom_thickness_label": bottom_thickness_label, + "bottom_thickness_value": bottom_thickness_value, + } + + elif name == "number_of_lids_layers": + self.ensure_sett("slicing.lids_depth") + + number_of_lids_layers_label = QLabel(self.locale.NumberOfLidLayers) + number_of_lids_layers_value = LineEdit(str(self.sett().slicing.lids_depth)) + number_of_lids_layers_value.setValidator(self.intValidator) + number_of_lids_layers_value.textChanged.connect(self.__update_lid_thickness) + + self.panel.addWidget(number_of_lids_layers_label, self.next_row, 1) + self.panel.addWidget(number_of_lids_layers_value, self.cur_row, 2) + + lid_thickness_label = QLabel(self.locale.LidsThickness) + lid_thickness_value = LineEdit( + str( + round( + self.sett().slicing.lids_depth + * self.sett().slicing.layer_height, + 2, + ), ) - lid_thickness_value.setReadOnly(True) - millimeter_label = QLabel(self.locale.Millimeter) + ) + lid_thickness_value.setReadOnly(True) + millimeter_label = QLabel(self.locale.Millimeter) - self.panel.addWidget(lid_thickness_label, self.cur_row, 3) - self.panel.addWidget(lid_thickness_value, self.cur_row, 4) - self.panel.addWidget(millimeter_label, self.cur_row, 5) + self.panel.addWidget(lid_thickness_label, self.cur_row, 3) + self.panel.addWidget(lid_thickness_value, self.cur_row, 4) + self.panel.addWidget(millimeter_label, self.cur_row, 5) - def on_change(): - self.sett().slicing.lids_depth = self.__smart_float( - lid_thickness_value.text() - ) + def on_change(): + self.sett().slicing.lids_depth = self.__smart_float( + lid_thickness_value.text() + ) - number_of_lids_layers_value.textChanged.connect(on_change) + number_of_lids_layers_value.textChanged.connect(on_change) - self.__elements[name] = { - "label": number_of_lids_layers_label, - "edit": number_of_lids_layers_value, - "lid_thickness_label": lid_thickness_label, - "lid_thickness_value": lid_thickness_value, - } + self.__elements[name] = { + "label": number_of_lids_layers_label, + "edit": number_of_lids_layers_value, + "lid_thickness_label": lid_thickness_label, + "lid_thickness_value": lid_thickness_value, + } - case "extruder_temp": - self.ensure_sett("slicing.extruder_temperature") + elif name == "extruder_temp": + self.ensure_sett("slicing.extruder_temperature") - extruder_temp_label = QLabel(self.locale.ExtruderTemp) - extruder_temp_value = LineEdit( - str(self.sett().slicing.extruder_temperature) - ) - extruder_temp_value.setValidator(self.intValidator) - self.panel.addWidget(extruder_temp_label, self.next_row, 1) - self.panel.addWidget( - extruder_temp_value, self.cur_row, 2, 1, self.col2_cells + extruder_temp_label = QLabel(self.locale.ExtruderTemp) + extruder_temp_value = LineEdit( + str(self.sett().slicing.extruder_temperature) + ) + extruder_temp_value.setValidator(self.intValidator) + self.panel.addWidget(extruder_temp_label, self.next_row, 1) + self.panel.addWidget( + extruder_temp_value, self.cur_row, 2, 1, self.col2_cells + ) + + def on_change(): + self.sett().slicing.extruder_temperature = self.__smart_float( + extruder_temp_value.text() ) - def on_change(): - self.sett().slicing.extruder_temperature = self.__smart_float( - extruder_temp_value.text() - ) + extruder_temp_value.textChanged.connect(on_change) - extruder_temp_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": extruder_temp_label, + "edit": extruder_temp_value, + } - self.__elements[name] = { - "label": extruder_temp_label, - "edit": extruder_temp_value, - } + elif name == "bed_temp": + self.ensure_sett("slicing.bed_temperature") - case "bed_temp": - self.ensure_sett("slicing.bed_temperature") + bed_temp_label = QLabel(self.locale.BedTemp) + bed_temp_value = LineEdit(str(self.sett().slicing.bed_temperature)) + bed_temp_value.setValidator(self.intValidator) + self.panel.addWidget(bed_temp_label, self.next_row, 1) + self.panel.addWidget(bed_temp_value, self.cur_row, 2, 1, self.col2_cells) - bed_temp_label = QLabel(self.locale.BedTemp) - bed_temp_value = LineEdit(str(self.sett().slicing.bed_temperature)) - bed_temp_value.setValidator(self.intValidator) - self.panel.addWidget(bed_temp_label, self.next_row, 1) - self.panel.addWidget( - bed_temp_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.bed_temperature = self.__smart_float( + bed_temp_value.text() ) - def on_change(): - self.sett().slicing.bed_temperature = self.__smart_float( - bed_temp_value.text() - ) + bed_temp_value.textChanged.connect(on_change) - bed_temp_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": bed_temp_label, + "edit": bed_temp_value, + } - self.__elements[name] = { - "label": bed_temp_label, - "edit": bed_temp_value, - } + elif name == "skirt_line_count": + self.ensure_sett("slicing.skirt_line_count") - case "skirt_line_count": - self.ensure_sett("slicing.skirt_line_count") + skirt_line_count_label = QLabel(self.locale.SkirtLineCount) + skirt_line_count_value = LineEdit(str(self.sett().slicing.skirt_line_count)) + skirt_line_count_value.setValidator(self.intValidator) + self.panel.addWidget(skirt_line_count_label, self.next_row, 1) + self.panel.addWidget( + skirt_line_count_value, self.cur_row, 2, 1, self.col2_cells + ) - skirt_line_count_label = QLabel(self.locale.SkirtLineCount) - skirt_line_count_value = LineEdit( - str(self.sett().slicing.skirt_line_count) - ) - skirt_line_count_value.setValidator(self.intValidator) - self.panel.addWidget(skirt_line_count_label, self.next_row, 1) - self.panel.addWidget( - skirt_line_count_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.skirt_line_count = self.__smart_float( + skirt_line_count_value.text() ) - def on_change(): - self.sett().slicing.skirt_line_count = self.__smart_float( - skirt_line_count_value.text() - ) + skirt_line_count_value.textChanged.connect(on_change) - skirt_line_count_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": skirt_line_count_label, + "edit": skirt_line_count_value, + } - self.__elements[name] = { - "label": skirt_line_count_label, - "edit": skirt_line_count_value, - } + elif name == "fan_speed": + self.ensure_sett("slicing.fan_speed") - case "fan_speed": - self.ensure_sett("slicing.fan_speed") + fan_speed_label = QLabel(self.locale.FanSpeed) + fan_speed_value = LineEdit(str(self.sett().slicing.fan_speed)) + fan_speed_value.setValidator(self.intValidator) + self.panel.addWidget(fan_speed_label, self.next_row, 1) + self.panel.addWidget(fan_speed_value, self.cur_row, 2, 1, self.col2_cells) - fan_speed_label = QLabel(self.locale.FanSpeed) - fan_speed_value = LineEdit(str(self.sett().slicing.fan_speed)) - fan_speed_value.setValidator(self.intValidator) - self.panel.addWidget(fan_speed_label, self.next_row, 1) - self.panel.addWidget( - fan_speed_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.fan_speed = self.__smart_float( + fan_speed_value.text() ) - def on_change(): - self.sett().slicing.fan_speed = self.__smart_float( - fan_speed_value.text() - ) + fan_speed_value.textChanged.connect(on_change) - fan_speed_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": fan_speed_label, + "edit": fan_speed_value, + } - self.__elements[name] = { - "label": fan_speed_label, - "edit": fan_speed_value, - } + elif name == "fan_off_layer1": + self.ensure_sett("slicing.fan_off_layer1") - case "fan_off_layer1": - self.ensure_sett("slicing.fan_off_layer1") + fan_off_layer1_label = QLabel(self.locale.FanOffLayer1) + fan_off_layer1_box = QCheckBox() + if self.sett().slicing.fan_off_layer1: + fan_off_layer1_box.setCheckState(QtCore.Qt.Checked) + self.panel.addWidget(fan_off_layer1_label, self.next_row, 1) + self.panel.addWidget( + fan_off_layer1_box, self.cur_row, 2, 1, self.col2_cells + ) - fan_off_layer1_label = QLabel(self.locale.FanOffLayer1) - fan_off_layer1_box = QCheckBox() - if self.sett().slicing.fan_off_layer1: - fan_off_layer1_box.setCheckState(QtCore.Qt.Checked) - self.panel.addWidget(fan_off_layer1_label, self.next_row, 1) - self.panel.addWidget( - fan_off_layer1_box, self.cur_row, 2, 1, self.col2_cells - ) + def on_change(): + self.sett().slicing.fan_off_layer1 = fan_off_layer1_box.isChecked() - def on_change(): - self.sett().slicing.fan_off_layer1 = fan_off_layer1_box.isChecked() + fan_off_layer1_box.stateChanged.connect(on_change) - fan_off_layer1_box.stateChanged.connect(on_change) + self.__elements[name] = { + "label": fan_off_layer1_label, + "checkbox": fan_off_layer1_box, + } - self.__elements[name] = { - "label": fan_off_layer1_label, - "checkbox": fan_off_layer1_box, - } + elif name == "print_speed": + self.ensure_sett("slicing.print_speed") - case "print_speed": - self.ensure_sett("slicing.print_speed") + print_speed_label = QLabel(self.locale.PrintSpeed) + print_speed_value = LineEdit(str(self.sett().slicing.print_speed)) + print_speed_value.setValidator(self.intValidator) + self.panel.addWidget(print_speed_label, self.next_row, 1) + self.panel.addWidget(print_speed_value, self.cur_row, 2, 1, self.col2_cells) - print_speed_label = QLabel(self.locale.PrintSpeed) - print_speed_value = LineEdit(str(self.sett().slicing.print_speed)) - print_speed_value.setValidator(self.intValidator) - self.panel.addWidget(print_speed_label, self.next_row, 1) - self.panel.addWidget( - print_speed_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.print_speed = self.__smart_float( + print_speed_value.text() ) - def on_change(): - self.sett().slicing.print_speed = self.__smart_float( - print_speed_value.text() - ) + print_speed_value.textChanged.connect(on_change) - print_speed_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": print_speed_label, + "edit": print_speed_value, + } - self.__elements[name] = { - "label": print_speed_label, - "edit": print_speed_value, - } + elif name == "print_speed_layer1": + self.ensure_sett("slicing.print_speed_layer1") - case "print_speed_layer1": - self.ensure_sett("slicing.print_speed_layer1") + print_speed_layer1_label = QLabel(self.locale.PrintSpeedLayer1) + print_speed_layer1_value = LineEdit( + str(self.sett().slicing.print_speed_layer1) + ) + print_speed_layer1_value.setValidator(self.intValidator) + self.panel.addWidget(print_speed_layer1_label, self.next_row, 1) + self.panel.addWidget( + print_speed_layer1_value, self.cur_row, 2, 1, self.col2_cells + ) - print_speed_layer1_label = QLabel(self.locale.PrintSpeedLayer1) - print_speed_layer1_value = LineEdit( - str(self.sett().slicing.print_speed_layer1) - ) - print_speed_layer1_value.setValidator(self.intValidator) - self.panel.addWidget(print_speed_layer1_label, self.next_row, 1) - self.panel.addWidget( - print_speed_layer1_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.print_speed_layer1 = self.__smart_float( + print_speed_layer1_value.text() ) - def on_change(): - self.sett().slicing.print_speed_layer1 = self.__smart_float( - print_speed_layer1_value.text() - ) + print_speed_layer1_value.textChanged.connect(on_change) - print_speed_layer1_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": print_speed_layer1_label, + "edit": print_speed_layer1_value, + } - self.__elements[name] = { - "label": print_speed_layer1_label, - "edit": print_speed_layer1_value, - } + elif name == "print_speed_wall": + self.ensure_sett("slicing.print_speed_wall") - case "print_speed_wall": - self.ensure_sett("slicing.print_speed_wall") + print_speed_wall_label = QLabel(self.locale.PrintSpeedWall) + print_speed_wall_value = LineEdit(str(self.sett().slicing.print_speed_wall)) + print_speed_wall_value.setValidator(self.intValidator) + self.panel.addWidget(print_speed_wall_label, self.next_row, 1) + self.panel.addWidget( + print_speed_wall_value, self.cur_row, 2, 1, self.col2_cells + ) - print_speed_wall_label = QLabel(self.locale.PrintSpeedWall) - print_speed_wall_value = LineEdit( - str(self.sett().slicing.print_speed_wall) + def on_change(): + self.sett().slicing.print_speed_wall = self.__smart_float( + print_speed_wall_value.text() ) - print_speed_wall_value.setValidator(self.intValidator) - self.panel.addWidget(print_speed_wall_label, self.next_row, 1) - self.panel.addWidget( - print_speed_wall_value, self.cur_row, 2, 1, self.col2_cells - ) - - def on_change(): - self.sett().slicing.print_speed_wall = self.__smart_float( - print_speed_wall_value.text() - ) - print_speed_wall_value.textChanged.connect(on_change) + print_speed_wall_value.textChanged.connect(on_change) - self.__elements[name] = { - "label": print_speed_wall_label, - "edit": print_speed_wall_value, - } + self.__elements[name] = { + "label": print_speed_wall_label, + "edit": print_speed_wall_value, + } - case "filling_type": - self.ensure_sett("slicing.filling_type") + elif name == "filling_type": + self.ensure_sett("slicing.filling_type") - filling_type_label = QLabel(self.locale.FillingType) - filling_type_values = QComboBox() - filling_type_values.addItems(self.locale.FillingTypeValues) - filling_type_values.setCurrentIndex( - locales.getLocaleByLang("en").FillingTypeValues.index( - self.sett().slicing.filling_type - ) - ) - self.panel.addWidget(filling_type_label, self.next_row, 1) - self.panel.addWidget( - filling_type_values, self.cur_row, 2, 1, self.col2_cells + filling_type_label = QLabel(self.locale.FillingType) + filling_type_values = QComboBox() + filling_type_values.addItems(self.locale.FillingTypeValues) + filling_type_values.setCurrentIndex( + locales.getLocaleByLang("en").FillingTypeValues.index( + self.sett().slicing.filling_type ) + ) + self.panel.addWidget(filling_type_label, self.next_row, 1) + self.panel.addWidget( + filling_type_values, self.cur_row, 2, 1, self.col2_cells + ) + + def on_change(): + self.sett().slicing.filling_type = locales.getLocaleByLang( + "en" + ).FillingTypeValues[filling_type_values.currentIndex()] - def on_change(): - self.sett().slicing.filling_type = locales.getLocaleByLang( - "en" - ).FillingTypeValues[filling_type_values.currentIndex()] + filling_type_values.currentIndexChanged.connect(on_change) - filling_type_values.currentIndexChanged.connect(on_change) + self.__elements[name] = { + "label": filling_type_label, + "values": filling_type_values, + "setting": "slicing.filling_type", + } - self.__elements[name] = { - "label": filling_type_label, - "values": filling_type_values, - "setting": "slicing.filling_type", - } + elif name == "fill_density": + self.ensure_sett("slicing.fill_density") - case "fill_density": - self.ensure_sett("slicing.fill_density") + fill_density_label = QLabel(self.locale.FillDensity) + fill_density_value = LineEdit(str(self.sett().slicing.fill_density)) + fill_density_value.setValidator(self.intValidator) + self.panel.addWidget(fill_density_label, self.next_row, 1) + self.panel.addWidget( + fill_density_value, self.cur_row, 2, 1, self.col2_cells + ) - fill_density_label = QLabel(self.locale.FillDensity) - fill_density_value = LineEdit(str(self.sett().slicing.fill_density)) - fill_density_value.setValidator(self.intValidator) - self.panel.addWidget(fill_density_label, self.next_row, 1) - self.panel.addWidget( - fill_density_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.fill_density = self.__smart_float( + fill_density_value.text() ) - def on_change(): - self.sett().slicing.fill_density = self.__smart_float( - fill_density_value.text() - ) + fill_density_value.textChanged.connect(on_change) - fill_density_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": fill_density_label, + "edit": fill_density_value, + "setting": "slicing.fill_density", + } - self.__elements[name] = { - "label": fill_density_label, - "edit": fill_density_value, - "setting": "slicing.fill_density", - } + elif name == "overlap_infill": + self.ensure_sett("slicing.overlapping_infill_percentage") - case "overlap_infill": - self.ensure_sett("slicing.overlapping_infill_percentage") + overlap_infill_label = QLabel(self.locale.OverlappingInfillPercentage) + overlap_infill_value = LineEdit( + str(self.sett().slicing.overlapping_infill_percentage) + ) + overlap_infill_value.setValidator(self.intValidator) + self.panel.addWidget(overlap_infill_label, self.next_row, 1) + self.panel.addWidget( + overlap_infill_value, self.cur_row, 2, 1, self.col2_cells + ) - overlap_infill_label = QLabel(self.locale.OverlappingInfillPercentage) - overlap_infill_value = LineEdit( - str(self.sett().slicing.overlapping_infill_percentage) - ) - overlap_infill_value.setValidator(self.intValidator) - self.panel.addWidget(overlap_infill_label, self.next_row, 1) - self.panel.addWidget( - overlap_infill_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.overlapping_infill_percentage = self.__smart_float( + overlap_infill_value.text() ) - def on_change(): - self.sett().slicing.overlapping_infill_percentage = ( - self.__smart_float(overlap_infill_value.text()) - ) + overlap_infill_value.textChanged.connect(on_change) - overlap_infill_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": overlap_infill_label, + "edit": overlap_infill_value, + } - self.__elements[name] = { - "label": overlap_infill_label, - "edit": overlap_infill_value, - } + elif name == "retraction_on": + self.ensure_sett("slicing.retraction_on") - case "retraction_on": - self.ensure_sett("slicing.retraction_on") + retraction_on_label = QLabel(self.locale.Retraction) + retraction_on_box = QCheckBox() + if self.sett().slicing.retraction_on: + retraction_on_box.setCheckState(QtCore.Qt.Checked) + self.panel.addWidget(retraction_on_label, self.next_row, 1) + self.panel.addWidget(retraction_on_box, self.cur_row, 2, 1, self.col2_cells) - retraction_on_label = QLabel(self.locale.Retraction) - retraction_on_box = QCheckBox() - if self.sett().slicing.retraction_on: - retraction_on_box.setCheckState(QtCore.Qt.Checked) - self.panel.addWidget(retraction_on_label, self.next_row, 1) - self.panel.addWidget( - retraction_on_box, self.cur_row, 2, 1, self.col2_cells - ) + def on_change(): + self.sett().slicing.retraction_on = retraction_on_box.isChecked() - def on_change(): - self.sett().slicing.retraction_on = retraction_on_box.isChecked() + retraction_on_box.stateChanged.connect(on_change) - retraction_on_box.stateChanged.connect(on_change) + self.__elements[name] = { + "label": retraction_on_label, + "checkbox": retraction_on_box, + } - self.__elements[name] = { - "label": retraction_on_label, - "checkbox": retraction_on_box, - } + elif name == "retraction_distance": + self.ensure_sett("slicing.retraction_distance") - case "retraction_distance": - self.ensure_sett("slicing.retraction_distance") + retraction_distance_label = QLabel(self.locale.RetractionDistance) + retraction_distance_value = LineEdit( + str(self.sett().slicing.retraction_distance) + ) + retraction_distance_value.setValidator(self.doubleValidator) + self.panel.addWidget(retraction_distance_label, self.next_row, 1) + self.panel.addWidget( + retraction_distance_value, self.cur_row, 2, 1, self.col2_cells + ) - retraction_distance_label = QLabel(self.locale.RetractionDistance) - retraction_distance_value = LineEdit( - str(self.sett().slicing.retraction_distance) - ) - retraction_distance_value.setValidator(self.doubleValidator) - self.panel.addWidget(retraction_distance_label, self.next_row, 1) - self.panel.addWidget( - retraction_distance_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.retraction_distance = self.__smart_float( + retraction_distance_value.text() ) - def on_change(): - self.sett().slicing.retraction_distance = self.__smart_float( - retraction_distance_value.text() - ) + retraction_distance_value.textChanged.connect(on_change) - retraction_distance_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": retraction_distance_label, + "edit": retraction_distance_value, + } - self.__elements[name] = { - "label": retraction_distance_label, - "edit": retraction_distance_value, - } + elif name == "retraction_speed": + self.ensure_sett("slicing.retraction_speed") - case "retraction_speed": - self.ensure_sett("slicing.retraction_speed") + retraction_speed_label = QLabel(self.locale.RetractionSpeed) + retraction_speed_value = LineEdit(str(self.sett().slicing.retraction_speed)) + retraction_speed_value.setValidator(self.intValidator) + self.panel.addWidget(retraction_speed_label, self.next_row, 1) + self.panel.addWidget( + retraction_speed_value, self.cur_row, 2, 1, self.col2_cells + ) - retraction_speed_label = QLabel(self.locale.RetractionSpeed) - retraction_speed_value = LineEdit( - str(self.sett().slicing.retraction_speed) - ) - retraction_speed_value.setValidator(self.intValidator) - self.panel.addWidget(retraction_speed_label, self.next_row, 1) - self.panel.addWidget( - retraction_speed_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.retraction_speed = self.__smart_float( + retraction_speed_value.text() ) - def on_change(): - self.sett().slicing.retraction_speed = self.__smart_float( - retraction_speed_value.text() - ) + retraction_speed_value.textChanged.connect(on_change) - retraction_speed_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": retraction_speed_label, + "edit": retraction_speed_value, + } - self.__elements[name] = { - "label": retraction_speed_label, - "edit": retraction_speed_value, - } + elif name == "retraction_compensation": + self.ensure_sett("slicing.retract_compensation_amount") - case "retraction_compensation": - self.ensure_sett("slicing.retract_compensation_amount") + retraction_compensation_label = QLabel( + self.locale.RetractCompensationAmount + ) + retraction_compensation_value = LineEdit( + str(self.sett().slicing.retract_compensation_amount) + ) + retraction_compensation_value.setValidator(self.doubleValidator) + self.panel.addWidget(retraction_compensation_label, self.next_row, 1) + self.panel.addWidget( + retraction_compensation_value, self.cur_row, 2, 1, self.col2_cells + ) - retraction_compensation_label = QLabel( - self.locale.RetractCompensationAmount - ) - retraction_compensation_value = LineEdit( - str(self.sett().slicing.retract_compensation_amount) - ) - retraction_compensation_value.setValidator(self.doubleValidator) - self.panel.addWidget(retraction_compensation_label, self.next_row, 1) - self.panel.addWidget( - retraction_compensation_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.retract_compensation_amount = self.__smart_float( + retraction_compensation_value.text() ) - def on_change(): - self.sett().slicing.retract_compensation_amount = ( - self.__smart_float(retraction_compensation_value.text()) - ) + retraction_compensation_value.textChanged.connect(on_change) - retraction_compensation_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": retraction_compensation_label, + "edit": retraction_compensation_value, + } - self.__elements[name] = { - "label": retraction_compensation_label, - "edit": retraction_compensation_value, - } + elif name == "material_shrinkage": + self.ensure_sett("slicing.material_shrinkage") - case "material_shrinkage": - self.ensure_sett("slicing.material_shrinkage") + material_shrinkage_label = QLabel(self.locale.MaterialShrinkage) + material_shrinkage_value = LineEdit( + str(self.sett().slicing.material_shrinkage) + ) + material_shrinkage_value.setValidator(self.doublePercentValidator) + self.panel.addWidget(material_shrinkage_label, self.next_row, 1) + self.panel.addWidget( + material_shrinkage_value, self.cur_row, 2, 1, self.col2_cells + ) - material_shrinkage_label = QLabel(self.locale.MaterialShrinkage) - material_shrinkage_value = LineEdit( - str(self.sett().slicing.material_shrinkage) - ) - material_shrinkage_value.setValidator(self.doublePercentValidator) - self.panel.addWidget(material_shrinkage_label, self.next_row, 1) - self.panel.addWidget( - material_shrinkage_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().slicing.material_shrinkage = self.__smart_float( + material_shrinkage_value.text() ) - def on_change(): - self.sett().slicing.material_shrinkage = self.__smart_float( - material_shrinkage_value.text() - ) + material_shrinkage_value.textChanged.connect(on_change) - material_shrinkage_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": material_shrinkage_label, + "edit": material_shrinkage_value, + } - self.__elements[name] = { - "label": material_shrinkage_label, - "edit": material_shrinkage_value, - } + elif name == "supports_on": + self.ensure_sett("supports.enabled") + # supports_label = QLabel(self.locale.SupportsSettings) - case "supports_on": - self.ensure_sett("supports.enabled") - # supports_label = QLabel(self.locale.SupportsSettings) + # supports on + supports_on_label = QLabel(self.locale.SupportsOn) + supports_on_box = QCheckBox() + if self.sett().supports.enabled: + supports_on_box.setCheckState(QtCore.Qt.Checked) - # supports on - supports_on_label = QLabel(self.locale.SupportsOn) - supports_on_box = QCheckBox() - if self.sett().supports.enabled: - supports_on_box.setCheckState(QtCore.Qt.Checked) + # self.panel.addWidget(supports_label, self.next_row, 1) - # self.panel.addWidget(supports_label, self.next_row, 1) + self.panel.addWidget(supports_on_label, self.next_row, 1) + self.panel.addWidget(supports_on_box, self.cur_row, 2, 1, self.col2_cells) - self.panel.addWidget(supports_on_label, self.next_row, 1) - self.panel.addWidget( - supports_on_box, self.cur_row, 2, 1, self.col2_cells - ) + def on_change(): + self.sett().supports.enabled = supports_on_box.isChecked() - def on_change(): - self.sett().supports.enabled = supports_on_box.isChecked() + supports_on_box.stateChanged.connect(on_change) - supports_on_box.stateChanged.connect(on_change) + self.__elements[name] = { + # "group_label": supports_label, + "label": supports_on_label, + "checkbox": supports_on_box, + } - self.__elements[name] = { - # "group_label": supports_label, - "label": supports_on_label, - "checkbox": supports_on_box, - } + elif name == "support_density": + self.ensure_sett("supports.fill_density") - case "support_density": - self.ensure_sett("supports.fill_density") + support_density_label = QLabel(self.locale.SupportDensity) + support_density_value = LineEdit(str(self.sett().supports.fill_density)) + support_density_value.setValidator(self.intValidator) + self.panel.addWidget(support_density_label, self.next_row, 1) + self.panel.addWidget( + support_density_value, self.cur_row, 2, 1, self.col2_cells + ) - support_density_label = QLabel(self.locale.SupportDensity) - support_density_value = LineEdit(str(self.sett().supports.fill_density)) - support_density_value.setValidator(self.intValidator) - self.panel.addWidget(support_density_label, self.next_row, 1) - self.panel.addWidget( - support_density_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().supports.fill_density = self.__smart_float( + support_density_value.text() ) - def on_change(): - self.sett().supports.fill_density = self.__smart_float( - support_density_value.text() - ) - - support_density_value.textChanged.connect(on_change) + support_density_value.textChanged.connect(on_change) - self.__elements[name] = { - "label": support_density_label, - "edit": support_density_value, - } + self.__elements[name] = { + "label": support_density_label, + "edit": support_density_value, + } - case "support_fill_type": - self.ensure_sett("supports.fill_type") + elif name == "support_fill_type": + self.ensure_sett("supports.fill_type") - support_fill_type_label = QLabel(self.locale.FillingType) - support_fill_type_values = QComboBox() - support_fill_type_values.addItems(self.locale.FillingTypeValues) - support_fill_type_values.setCurrentIndex( - locales.getLocaleByLang("en").FillingTypeValues.index( - self.sett().supports.fill_type - ) - ) - self.panel.addWidget(support_fill_type_label, self.next_row, 1) - self.panel.addWidget( - support_fill_type_values, self.cur_row, 2, 1, self.col2_cells + support_fill_type_label = QLabel(self.locale.FillingType) + support_fill_type_values = QComboBox() + support_fill_type_values.addItems(self.locale.FillingTypeValues) + support_fill_type_values.setCurrentIndex( + locales.getLocaleByLang("en").FillingTypeValues.index( + self.sett().supports.fill_type ) + ) + self.panel.addWidget(support_fill_type_label, self.next_row, 1) + self.panel.addWidget( + support_fill_type_values, self.cur_row, 2, 1, self.col2_cells + ) + + def on_change(): + self.sett().supports.fill_type = locales.getLocaleByLang( + "en" + ).FillingTypeValues[support_fill_type_values.currentIndex()] - def on_change(): - self.sett().supports.fill_type = locales.getLocaleByLang( - "en" - ).FillingTypeValues[support_fill_type_values.currentIndex()] + support_fill_type_values.currentIndexChanged.connect(on_change) - support_fill_type_values.currentIndexChanged.connect(on_change) + self.__elements[name] = { + "label": support_fill_type_label, + "values": support_fill_type_values, + } - self.__elements[name] = { - "label": support_fill_type_label, - "values": support_fill_type_values, - } + elif name == "support_xy_offset": + self.ensure_sett("supports.xy_offset") - case "support_xy_offset": - self.ensure_sett("supports.xy_offset") + support_xy_offset_label = QLabel(self.locale.SupportXYOffset) + support_xy_offset_value = LineEdit(str(self.sett().supports.xy_offset)) + support_xy_offset_value.setValidator(self.intValidator) + self.panel.addWidget(support_xy_offset_label, self.next_row, 1) + self.panel.addWidget( + support_xy_offset_value, self.cur_row, 2, 1, self.col2_cells + ) - support_xy_offset_label = QLabel(self.locale.SupportXYOffset) - support_xy_offset_value = LineEdit(str(self.sett().supports.xy_offset)) - support_xy_offset_value.setValidator(self.intValidator) - self.panel.addWidget(support_xy_offset_label, self.next_row, 1) - self.panel.addWidget( - support_xy_offset_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().supports.xy_offset = self.__smart_float( + support_xy_offset_value.text() ) - def on_change(): - self.sett().supports.xy_offset = self.__smart_float( - support_xy_offset_value.text() - ) + support_xy_offset_value.textChanged.connect(on_change) - support_xy_offset_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": support_xy_offset_label, + "edit": support_xy_offset_value, + } - self.__elements[name] = { - "label": support_xy_offset_label, - "edit": support_xy_offset_value, - } + elif name == "support_z_offset": + self.ensure_sett("supports.z_offset_layers") - case "support_z_offset": - self.ensure_sett("supports.z_offset_layers") + support_z_offset_label = QLabel(self.locale.SupportZOffsetLayers) + support_z_offset_value = LineEdit(str(self.sett().supports.z_offset_layers)) + support_z_offset_value.setValidator(self.intValidator) + self.panel.addWidget(support_z_offset_label, self.next_row, 1) + self.panel.addWidget( + support_z_offset_value, self.cur_row, 2, 1, self.col2_cells + ) - support_z_offset_label = QLabel(self.locale.SupportZOffsetLayers) - support_z_offset_value = LineEdit( - str(self.sett().supports.z_offset_layers) - ) - support_z_offset_value.setValidator(self.intValidator) - self.panel.addWidget(support_z_offset_label, self.next_row, 1) - self.panel.addWidget( - support_z_offset_value, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().supports.z_offset_layers = self.__smart_float( + support_z_offset_value.text() ) - def on_change(): - self.sett().supports.z_offset_layers = self.__smart_float( - support_z_offset_value.text() - ) + support_z_offset_value.textChanged.connect(on_change) - support_z_offset_value.textChanged.connect(on_change) + self.__elements[name] = { + "label": support_z_offset_label, + "edit": support_z_offset_value, + } - self.__elements[name] = { - "label": support_z_offset_label, - "edit": support_z_offset_value, - } + elif name == "support_priority_zoffset": + self.ensure_sett("supports.priority_z_offset") - case "support_priority_zoffset": - self.ensure_sett("supports.priority_z_offset") + support_priority_zoffset_label = QLabel(self.locale.SupportPriorityZOffset) + support_priorityz_offset_box = QCheckBox() + if self.sett().supports.priority_z_offset: + support_priorityz_offset_box.setCheckState(QtCore.Qt.Checked) - support_priority_zoffset_label = QLabel( - self.locale.SupportPriorityZOffset - ) - support_priorityz_offset_box = QCheckBox() - if self.sett().supports.priority_z_offset: - support_priorityz_offset_box.setCheckState(QtCore.Qt.Checked) + self.panel.addWidget(support_priority_zoffset_label, self.next_row, 1) + self.panel.addWidget( + support_priorityz_offset_box, self.cur_row, 2, 1, self.col2_cells + ) - self.panel.addWidget(support_priority_zoffset_label, self.next_row, 1) - self.panel.addWidget( - support_priorityz_offset_box, self.cur_row, 2, 1, self.col2_cells + def on_change(): + self.sett().supports.priority_z_offset = ( + support_priorityz_offset_box.isChecked() ) - def on_change(): - self.sett().supports.priority_z_offset = ( - support_priorityz_offset_box.isChecked() - ) - - support_priorityz_offset_box.stateChanged.connect(on_change) + support_priorityz_offset_box.stateChanged.connect(on_change) - self.__elements[name] = { - "label": support_priority_zoffset_label, - "checkbox": support_priorityz_offset_box, - } + self.__elements[name] = { + "label": support_priority_zoffset_label, + "checkbox": support_priorityz_offset_box, + } - case "support_number_of_bottom_layers": - self.ensure_sett("supports.bottoms_depth") + elif name == "support_number_of_bottom_layers": + self.ensure_sett("supports.bottoms_depth") - support_number_of_bottom_layers_label = QLabel( - self.locale.NumberOfBottomLayers - ) - support_number_of_bottom_layers_value = LineEdit( - str(self.sett().supports.bottoms_depth) - ) - support_number_of_bottom_layers_value.setValidator(self.intValidator) - support_number_of_bottom_layers_value.textChanged.connect( - self.__update_supports_bottom_thickness - ) - self.panel.addWidget( - support_number_of_bottom_layers_label, self.next_row, 1 - ) - self.panel.addWidget( - support_number_of_bottom_layers_value, self.cur_row, 2 + support_number_of_bottom_layers_label = QLabel( + self.locale.NumberOfBottomLayers + ) + support_number_of_bottom_layers_value = LineEdit( + str(self.sett().supports.bottoms_depth) + ) + support_number_of_bottom_layers_value.setValidator(self.intValidator) + support_number_of_bottom_layers_value.textChanged.connect( + self.__update_supports_bottom_thickness + ) + self.panel.addWidget( + support_number_of_bottom_layers_label, self.next_row, 1 + ) + self.panel.addWidget(support_number_of_bottom_layers_value, self.cur_row, 2) + + bottom_thickness_label = QLabel(self.locale.BottomThickness) + bottom_thickness_value = LineEdit( + str( + round( + self.sett().supports.bottoms_depth + * self.sett().slicing.layer_height, + 2, + ), ) + ) + bottom_thickness_value.setReadOnly(True) + millimeter_label = QLabel(self.locale.Millimeter) - bottom_thickness_label = QLabel(self.locale.BottomThickness) - bottom_thickness_value = LineEdit( - str( - round( - self.sett().supports.bottoms_depth - * self.sett().slicing.layer_height, - 2, - ), - ) + self.panel.addWidget(bottom_thickness_label, self.cur_row, 3) + self.panel.addWidget(bottom_thickness_value, self.cur_row, 4) + self.panel.addWidget(millimeter_label, self.cur_row, 5) + + def on_change(): + self.sett().supports.bottoms_depth = self.__smart_float( + bottom_thickness_value.text() ) - bottom_thickness_value.setReadOnly(True) - millimeter_label = QLabel(self.locale.Millimeter) - self.panel.addWidget(bottom_thickness_label, self.cur_row, 3) - self.panel.addWidget(bottom_thickness_value, self.cur_row, 4) - self.panel.addWidget(millimeter_label, self.cur_row, 5) + support_number_of_bottom_layers_value.textChanged.connect(on_change) - def on_change(): - self.sett().supports.bottoms_depth = self.__smart_float( - bottom_thickness_value.text() - ) + self.__elements[name] = { + "label": support_number_of_bottom_layers_label, + "edit": support_number_of_bottom_layers_value, + "bottom_thickness_label": bottom_thickness_label, + "bottom_thickness_value": bottom_thickness_value, + } - support_number_of_bottom_layers_value.textChanged.connect(on_change) + elif name == "support_number_of_lid_layers": + self.ensure_sett("supports.lids_depth") - self.__elements[name] = { - "label": support_number_of_bottom_layers_label, - "edit": support_number_of_bottom_layers_value, - "bottom_thickness_label": bottom_thickness_label, - "bottom_thickness_value": bottom_thickness_value, - } + support_number_of_lid_layers_label = QLabel(self.locale.NumberOfLidLayers) + support_number_of_lid_layers_value = LineEdit( + str(self.sett().supports.lids_depth) + ) + support_number_of_lid_layers_value.setValidator(self.intValidator) + support_number_of_lid_layers_value.textChanged.connect( + self.__update_supports_lid_thickness + ) + self.panel.addWidget(support_number_of_lid_layers_label, self.next_row, 1) + self.panel.addWidget(support_number_of_lid_layers_value, self.cur_row, 2) + + lid_thickness_label = QLabel(self.locale.LidsThickness) + lid_thickness_value = LineEdit( + str( + round( + self.sett().supports.lids_depth + * self.sett().slicing.layer_height, + 2, + ), + ) + ) + lid_thickness_value.setReadOnly(True) + millimeter_label = QLabel(self.locale.Millimeter) - case "support_number_of_lid_layers": - self.ensure_sett("supports.lids_depth") + self.panel.addWidget(lid_thickness_label, self.cur_row, 3) + self.panel.addWidget(lid_thickness_value, self.cur_row, 4) + self.panel.addWidget(millimeter_label, self.cur_row, 5) - support_number_of_lid_layers_label = QLabel( - self.locale.NumberOfLidLayers - ) - support_number_of_lid_layers_value = LineEdit( - str(self.sett().supports.lids_depth) - ) - support_number_of_lid_layers_value.setValidator(self.intValidator) - support_number_of_lid_layers_value.textChanged.connect( - self.__update_supports_lid_thickness - ) - self.panel.addWidget( - support_number_of_lid_layers_label, self.next_row, 1 - ) - self.panel.addWidget( - support_number_of_lid_layers_value, self.cur_row, 2 + def on_change(): + self.sett().supports.lids_depth = self.__smart_float( + lid_thickness_value.text() ) - lid_thickness_label = QLabel(self.locale.LidsThickness) - lid_thickness_value = LineEdit( - str( - round( - self.sett().supports.lids_depth - * self.sett().slicing.layer_height, - 2, - ), - ) - ) - lid_thickness_value.setReadOnly(True) - millimeter_label = QLabel(self.locale.Millimeter) + support_number_of_lid_layers_value.textChanged.connect(on_change) - self.panel.addWidget(lid_thickness_label, self.cur_row, 3) - self.panel.addWidget(lid_thickness_value, self.cur_row, 4) - self.panel.addWidget(millimeter_label, self.cur_row, 5) + self.__elements[name] = { + "label": support_number_of_lid_layers_label, + "edit": support_number_of_lid_layers_value, + "lid_thickness_label": lid_thickness_label, + "lid_thickness_value": lid_thickness_value, + } + elif name == "critical_angle": + self.ensure_sett("slicing.angle") - def on_change(): - self.sett().supports.lids_depth = self.__smart_float( - lid_thickness_value.text() - ) + angle_label = QLabel(self.locale.CriticalWallOverhangAngle) + angle_value = LineEdit(str(self.sett().slicing.angle)) + angle_value.setValidator(self.doubleValidator) + self.panel.addWidget(angle_label, self.next_row, 1) + self.panel.addWidget(angle_value, self.cur_row, 2, 1, self.col2_cells) + + def on_change(): + self.sett().slicing.angle = self.__smart_float(angle_value.text()) - support_number_of_lid_layers_value.textChanged.connect(on_change) + angle_value.textChanged.connect(on_change) - self.__elements[name] = { - "label": support_number_of_lid_layers_label, - "edit": support_number_of_lid_layers_value, - "lid_thickness_label": lid_thickness_label, - "lid_thickness_value": lid_thickness_value, - } + self.__elements[name] = { + "label": angle_label, + "edit": angle_value, + } # add row index for element self.__elements[name]["row_idx"] = self.cur_row diff --git a/src/window.py b/src/window.py index ec5f5e2..23e0029 100644 --- a/src/window.py +++ b/src/window.py @@ -420,17 +420,7 @@ def get_cur_row(): self.save_gcode_button = QPushButton(self.locale.SaveGCode) buttons_layout.addWidget(self.save_gcode_button, get_cur_row(), 3) - - self.critical_wall_overhang_angle_label = QLabel( - self.locale.CriticalWallOverhangAngle - ) - buttons_layout.addWidget( - self.critical_wall_overhang_angle_label, get_next_row(), 1, 1, 2 - ) buttons_layout.setColumnMinimumWidth(1, 230) - self.colorize_angle_value = LineEdit(str(sett().slicing.angle)) - self.colorize_angle_value.setValidator(doubleValidator) - buttons_layout.addWidget(self.colorize_angle_value, get_cur_row(), 2, 1, 1) self.color_model_button = QPushButton(self.locale.ColorModel) buttons_layout.addWidget(self.color_model_button, get_cur_row(), 3)