Skip to content

Commit

Permalink
feat: add setting for layer start randomization
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjonok committed Nov 26, 2024
1 parent b0891b2 commit 3373cdf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ slicing:
originz: 0.0
overlapping_infill_percentage: 100.0
overlapping_infill_lid_percentage: 60.0
random_layer_start: false
planes_contact_with_nozzle: ""
print_speed: 50
print_speed_layer1: 50
Expand Down
2 changes: 2 additions & 0 deletions src/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class Locale:
GCodeLoadingProgress = "GCode loading is in progress..."
SupportsSettings = "Supports settings"
MaterialShrinkage = "Material shrinkage, %:"
RandomLayerStart = "Random layer start"
FlowRate = "Flow rate, %:"
PressureAdvance = "Pressure advance"
PressureAdvanceValue = "Pressure advance value"
Expand Down Expand Up @@ -255,6 +256,7 @@ def __init__(self, **entries):
GCodeLoadingProgress="Загрузка GCode в прогрессе...",
SupportsSettings="Настройки поддержек",
MaterialShrinkage="Величина усадки материала, %:",
RandomLayerStart="Спрятать шов",
FlowRate="Коэффициент потока расплава, %:",
PressureAdvance="Управление давлением расплава",
PressureAdvanceValue="Коэффициент управления давлением",
Expand Down
39 changes: 30 additions & 9 deletions src/settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class SettingsWidget(QWidget):
"flow_rate", # Коэффициент потока расплава
"pressure_advance_on",
"pressure_advance_rate",
"random_layer_start",
# TODO: add separate dummy setting to mark the beginning of supports settings
"supports_on",
"support_density",
Expand Down Expand Up @@ -127,6 +128,7 @@ def __init__(self, parent=None, settings_provider: callable = None):
"retraction_speed": self.locale.RetractionSpeed,
"retraction_compensation": self.locale.RetractCompensationAmount,
"material_shrinkage": self.locale.MaterialShrinkage,
"random_layer_start": self.locale.RandomLayerStart,
# TODO: add separate dummy setting to mark the beginning of supports settings
"supports_on": self.locale.SupportsOn,
"support_density": self.locale.SupportDensity,
Expand Down Expand Up @@ -888,21 +890,21 @@ def on_change():
elif name == "retraction_on":
self.ensure_sett("slicing.retraction_on")

retraction_on_label = QLabel(self.locale.Retraction)
retraction_on_box = QCheckBox()
rls_on_label = QLabel(self.locale.Retraction)
rls_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)
rls_on_box.setCheckState(QtCore.Qt.Checked)
self.panel.addWidget(rls_on_label, self.next_row, 1)
self.panel.addWidget(rls_on_box, self.cur_row, 2, 1, self.col2_cells)

def on_change():
self.sett().slicing.retraction_on = retraction_on_box.isChecked()
self.sett().slicing.retraction_on = rls_on_box.isChecked()

retraction_on_box.stateChanged.connect(on_change)
rls_on_box.stateChanged.connect(on_change)

self.__elements[name] = {
"label": retraction_on_label,
"checkbox": retraction_on_box,
"label": rls_on_label,
"checkbox": rls_on_box,
}

elif name == "retraction_distance":
Expand Down Expand Up @@ -1005,6 +1007,25 @@ def on_change():
"edit": material_shrinkage_value,
}

elif name == "random_layer_start":
self.ensure_sett("slicing.random_layer_start")

rls_on_label = QLabel(self.locale.RandomLayerStart)
rls_on_box = QCheckBox()
if self.sett().slicing.random_layer_start:
rls_on_box.setCheckState(QtCore.Qt.Checked)
self.panel.addWidget(rls_on_label, self.next_row, 1)
self.panel.addWidget(rls_on_box, self.cur_row, 2, 1, self.col2_cells)

def on_change():
self.sett().slicing.random_layer_start = rls_on_box.isChecked()

rls_on_box.stateChanged.connect(on_change)

self.__elements[name] = {
"label": rls_on_label,
"checkbox": rls_on_box,
}
elif name == "flow_rate":
self.ensure_sett("slicing.flow_rate")

Expand Down

0 comments on commit 3373cdf

Please sign in to comment.