diff --git a/settings.yaml b/settings.yaml index 58e57a5..3bfa7b4 100644 --- a/settings.yaml +++ b/settings.yaml @@ -98,6 +98,9 @@ slicing: line_width: 0.4 magic_epsilon: 40 material_shrinkage: 1.5 + flow_rate: 100 + pressure_advance_on: false + pressure_advance: 0.45 mesh_file: lib/goosli_middle.msh minimum_path_area: 0.001 model_centering: false diff --git a/src/locales.py b/src/locales.py index 47c2ce2..23908f7 100644 --- a/src/locales.py +++ b/src/locales.py @@ -91,6 +91,10 @@ class Locale: GCodeLoadingProgress = "GCode loading is in progress..." SupportsSettings = "Supports settings" MaterialShrinkage = "Material shrinkage, %:" + FlowRate = "Flow rate, %:" + PressureAdvance = "Pressure advance" + PressureAdvanceValue = "Pressure advance value" + ValueInBetween = "Value should be in range from {} to {}" ProjectManager = "FASP project manager" NewProject = "New project" ProjectDirectory = "Project directory:" @@ -251,6 +255,10 @@ def __init__(self, **entries): GCodeLoadingProgress="Загрузка GCode в прогрессе...", SupportsSettings="Настройки поддержек", MaterialShrinkage="Величина усадки материала, %:", + FlowRate="Коэффициент потока расплава, %:", + PressureAdvance="Управление давлением расплава", + PressureAdvanceValue="Коэффициент управления давлением", + ValueInBetween="Значение должно быть в диапазоне от {} до {}", ProjectManager="FASP менеджер проектов", NewProject="Новый проект", ProjectDirectory="Директория проекта:", diff --git a/src/settings_widget.py b/src/settings_widget.py index e6eb9d6..b4010e6 100644 --- a/src/settings_widget.py +++ b/src/settings_widget.py @@ -59,6 +59,9 @@ class SettingsWidget(QWidget): "retraction_speed", "retraction_compensation", "material_shrinkage", + "flow_rate", # Коэффициент потока расплава + "pressure_advance_on", + "pressure_advance_rate", # TODO: add separate dummy setting to mark the beginning of supports settings "supports_on", "support_density", @@ -1002,6 +1005,93 @@ def on_change(): "edit": material_shrinkage_value, } + elif name == "flow_rate": + self.ensure_sett("slicing.flow_rate") + + flow_rate_label = QLabel(self.locale.FlowRate) + flow_rate_value = LineEdit(str(self.sett().slicing.flow_rate)) + self.panel.addWidget(flow_rate_label, self.next_row, 1) + self.panel.addWidget(flow_rate_value, self.cur_row, 2, 1, self.col2_cells) + + def on_change(): + value = self.__smart_float(flow_rate_value.text()) + # value should be between 45 and 150 percent + if 45 <= value <= 150: + flow_rate_value.setStyleSheet("") # Reset to default style + flow_rate_value.setToolTip("") + else: + flow_rate_value.setStyleSheet( + "background-color: lightcoral; color: black;" + ) + flow_rate_value.setToolTip( + self.locale.ValueInBetween.format(45, 150) + ) + self.sett().slicing.flow_rate = value + + flow_rate_value.textChanged.connect(on_change) + + self.__elements[name] = { + "label": flow_rate_label, + "edit": flow_rate_value, + } + + elif name == "pressure_advance_on": + self.ensure_sett("slicing.pressure_advance_on") + + pressure_advance_on_label = QLabel(self.locale.PressureAdvance) + pressure_advance_on_box = QCheckBox() + if self.sett().slicing.pressure_advance_on: + pressure_advance_on_box.setCheckState(QtCore.Qt.Checked) + self.panel.addWidget(pressure_advance_on_label, self.next_row, 1) + self.panel.addWidget( + pressure_advance_on_box, self.cur_row, 2, 1, self.col2_cells + ) + + def on_change(): + self.sett().slicing.pressure_advance_on = ( + pressure_advance_on_box.isChecked() + ) + + pressure_advance_on_box.stateChanged.connect(on_change) + + self.__elements[name] = { + "label": pressure_advance_on_label, + "checkbox": pressure_advance_on_box, + } + + elif name == "pressure_advance_rate": + self.ensure_sett("slicing.pressure_advance_rate") + + pressure_advance_label = QLabel(self.locale.PressureAdvanceValue) + pressure_advance_value = LineEdit(str(self.sett().slicing.pressure_advance)) + # between 0.01 and 0.9, default is 0.45 + self.panel.addWidget(pressure_advance_label, self.next_row, 1) + self.panel.addWidget( + pressure_advance_value, self.cur_row, 2, 1, self.col2_cells + ) + + def on_change(): + value = self.__smart_float(pressure_advance_value.text()) + # value should be between 0.01 and 0.9 + if 0.01 <= value <= 0.9: + pressure_advance_value.setStyleSheet("") + pressure_advance_value.setToolTip("") + else: + pressure_advance_value.setStyleSheet( + "background-color: lightcoral; color: black;" + ) + pressure_advance_value.setToolTip( + self.locale.ValueInBetween.format(0.01, 0.9) + ) + self.sett().slicing.pressure_advance = value + + pressure_advance_value.textChanged.connect(on_change) + + self.__elements[name] = { + "label": pressure_advance_label, + "edit": pressure_advance_value, + } + elif name == "supports_on": self.ensure_sett("supports.enabled") # supports_label = QLabel(self.locale.SupportsSettings)