Skip to content

Commit

Permalink
feat: add flow rate and pressure advance settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjonok committed Nov 16, 2024
1 parent 16e692e commit 574a12a
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
3 changes: 3 additions & 0 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down Expand Up @@ -251,6 +255,10 @@ def __init__(self, **entries):
GCodeLoadingProgress="Загрузка GCode в прогрессе...",
SupportsSettings="Настройки поддержек",
MaterialShrinkage="Величина усадки материала, %:",
FlowRate="Коэффициент потока расплава, %:",
PressureAdvance="Управление давлением расплава",
PressureAdvanceValue="Коэффициент управления давлением",
ValueInBetween="Значение должно быть в диапазоне от {} до {}",
ProjectManager="FASP менеджер проектов",
NewProject="Новый проект",
ProjectDirectory="Директория проекта:",
Expand Down
90 changes: 90 additions & 0 deletions src/settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 574a12a

Please sign in to comment.