Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjonok committed Dec 25, 2024
2 parents 3b4777f + 2969972 commit 6911d35
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cache: "pip"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel flake8 pyinstaller
python3 -m pip install --upgrade pip setuptools wheel flake8 pyinstaller==6.10.0
python3 -m pip install -r win-req.txt
- name: Lint with flake8
run: |
Expand Down
2 changes: 1 addition & 1 deletion main.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ block_cipher = None
a = Analysis(['main.py'],
binaries=[],
datas=[('src', 'src/'), ('settings.yaml', 'lib/')],
hiddenimports=['vtkmodules', 'vtkmodules.all', 'vtkmodules.qt.QVTKRenderWindowInteractor', 'vtkmodules.util', 'vtkmodules.util.numpy_support', 'yaml', 'numpy', 'pkg_resources.extern'],
hiddenimports=['vtkmodules', 'vtkmodules.all', 'vtkmodules.qt.QVTKRenderWindowInteractor', 'vtkmodules.util', 'vtkmodules.util.numpy_support', 'vtkmodules.util.data_model', 'yaml', 'numpy', 'pkg_resources.extern'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PyYAML>=6.0
vtk>=9.0.0
vtk==9.3.1
numpy
qdarkstyle>=3.1
numpy-stl
Expand Down
17 changes: 11 additions & 6 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,27 @@ slicing:
bottoms_depth: 3
line_width: 0.4
magic_epsilon: 40
material_shrinkage: 1.5
material_shrinkage: 0.0
flow_rate: 100
pressure_advance_on: true
pressure_advance: 0.45
mesh_file: lib/goosli_middle.msh
minimum_path_area: 0.001
model_centering: false
originx: 0.0
originy: 0.0
originz: 0.0
overlapping_infill_percentage: 100.0
overlapping_infill_lid_percentage: 60.0
overlapping_infill_percentage: 30.0
overlapping_infill_lid_percentage: 30.0
random_layer_start: false
is_wall_outside_in: true
planes_contact_with_nozzle: ""
print_speed: 50
print_speed_layer1: 50
print_speed_wall: 50
print_time: 0
retract_compensation_amount: 0.0
retraction_distance: 0.3
retract_compensation_amount: 3.0
retraction_distance: 3.0
retraction_on: true
retraction_speed: 50
rotationx: 0.0
Expand Down Expand Up @@ -148,7 +153,7 @@ slicing:
wall_thickness: 0.8
supports:
enabled: true
xy_offset: 1.0
xy_offset: 0.3
z_offset_layers: 1
priority_z_offset: true
fill_type: Lines
Expand Down
4 changes: 2 additions & 2 deletions src/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,8 @@ def display_settings(self):
self.view.colorize_angle_value.setText(str(s.slicing.angle))

def colorize_model(self):
shutil.copyfile(PathBuilder.stl_model(), PathBuilder.colorizer_stl())
self.save_settings("vip")
shutil.copyfile(PathBuilder.stl_model_temp(), PathBuilder.colorizer_stl())
self.save_settings("vip", PathBuilder.settings_file_temp())

p = Process(PathBuilder.colorizer_cmd()).wait()
if p.returncode:
Expand Down
26 changes: 22 additions & 4 deletions src/gcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,34 @@ def parseGCode(lines):
line = line + ";" if len(line) == 0 or ";" not in line else line
args, comment = line.split(";")[:2]
args = args.split(" ")
if comment.lower() == "rotation": # we have either rotation or incline
if line.endswith("rotation-hack"): # we pass U in the comment section
args, comment = line.split(";")[1:3] # we remove first colon
args = args.split(" ")
printer.finishLayer()
# if any(a.lower().startswith('u') for a in args): # rotation
printer.rotations.append(
Rotation(printer.rotations[-1].x_rot, parseRotation(args[1:]))
)
printer.currPos.U = printer.rotations[-1].z_rot
elif comment.lower() == "incline":
elif line.endswith("rotation"): # we have either rotation or incline
printer.finishLayer()
printer.rotations.append(
Rotation(printer.rotations[-1].x_rot, parseRotation(args[1:]))
)
printer.currPos.U = printer.rotations[-1].z_rot
elif line.endswith("incline-hack"):
args, comment = line.split(";")[1:3] # we remove first colon
args = args.split(" ")
printer.finishLayer()
printer.rotations.append(
Rotation(parseRotation(args[1:]), printer.rotations[-1].z_rot)
)

printer.cone_axis = rotation_matrix(
[1, 0, 0], np.radians(printer.rotations[-1].x_rot)
).dot([0, 0, 1])
printer.currPos.V = printer.rotations[-1].x_rot
elif line.endswith("incline"):
printer.finishLayer()
# if any(a.lower().startswith('v') for a in args): # incline
printer.rotations.append(
Rotation(parseRotation(args[1:]), printer.rotations[-1].z_rot)
)
Expand Down
12 changes: 12 additions & 0 deletions src/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ class Locale:
GCodeLoadingProgress = "GCode loading is in progress..."
SupportsSettings = "Supports settings"
MaterialShrinkage = "Material shrinkage, %:"
RandomLayerStart = "Random layer start"
IsWallsOutsideIn = "Printing walls from outside in"
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 +257,12 @@ def __init__(self, **entries):
GCodeLoadingProgress="Загрузка GCode в прогрессе...",
SupportsSettings="Настройки поддержек",
MaterialShrinkage="Величина усадки материала, %:",
RandomLayerStart="Спрятать шов",
IsWallsOutsideIn="Печать стенок снаружи внутрь",
FlowRate="Коэффициент потока расплава, %:",
PressureAdvance="Управление давлением расплава",
PressureAdvanceValue="Коэффициент управления давлением",
ValueInBetween="Значение должно быть в диапазоне от {} до {}",
ProjectManager="FASP менеджер проектов",
NewProject="Новый проект",
ProjectDirectory="Директория проекта:",
Expand Down
157 changes: 148 additions & 9 deletions src/settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class SettingsWidget(QWidget):
"retraction_speed",
"retraction_compensation",
"material_shrinkage",
"flow_rate", # Коэффициент потока расплава
"pressure_advance_on",
"pressure_advance_rate",
"random_layer_start",
"is_wall_outside_in",
# TODO: add separate dummy setting to mark the beginning of supports settings
"supports_on",
"support_density",
Expand All @@ -73,9 +78,11 @@ class SettingsWidget(QWidget):
]

# extra parameters are only used for a small widget with parameters for each figure specifically
# also in corresponding branch "setting" key should point to the correct setting
extra_sett_parameters = [
"filling_type",
"fill_density",
"fan_speed",
]

def __init__(self, parent=None, settings_provider: callable = None):
Expand Down Expand Up @@ -124,6 +131,8 @@ 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,
"is_wall_outside_in": self.locale.IsWallsOutsideIn,
# 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 @@ -329,6 +338,8 @@ def has_setting(name: str):
self.with_sett("filling_type")
if has_setting("slicing.fill_density"):
self.with_sett("fill_density")
if has_setting("slicing.fan_speed"):
self.with_sett("fan_speed")
# TODO: this list should be increased with the growth of extra parameters

return self
Expand Down Expand Up @@ -711,6 +722,7 @@ def on_change():
self.__elements[name] = {
"label": fan_speed_label,
"edit": fan_speed_value,
"setting": "slicing.fan_speed",
}

elif name == "fan_off_layer1":
Expand Down Expand Up @@ -885,21 +897,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 @@ -1002,6 +1014,133 @@ 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 == "is_wall_outside_in":
self.ensure_sett("slicing.is_wall_outside_in")

wall_outside_in_label = QLabel(self.locale.IsWallsOutsideIn)
wall_outside_in_box = QCheckBox()
if self.sett().slicing.is_wall_outside_in:
wall_outside_in_box.setCheckState(QtCore.Qt.Checked)
self.panel.addWidget(wall_outside_in_label, self.next_row, 1)
self.panel.addWidget(
wall_outside_in_box, self.cur_row, 2, 1, self.col2_cells
)

def on_change():
self.sett().slicing.is_wall_outside_in = wall_outside_in_box.isChecked()

wall_outside_in_box.stateChanged.connect(on_change)

self.__elements[name] = {
"label": wall_outside_in_label,
"checkbox": wall_outside_in_box,
}
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 6911d35

Please sign in to comment.