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 Oct 1, 2024
2 parents 8f31bb6 + dcc4d5b commit a311af1
Show file tree
Hide file tree
Showing 16 changed files with 963 additions and 828 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,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==5.13.0
python3 -m pip install -r linux-req.txt
- name: Lint with flake8
run: |
Expand All @@ -47,6 +47,7 @@ jobs:
run: |
mv settings.yaml dist/settings.yaml
mv icon.png dist/icon.png
mv icons/ dist/icons/
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
run: |
mv settings.yaml dist/settings.yaml
mv icon.png dist/icon.png
mv icons/ dist/icons/
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
Expand Down
Binary file added icons/redo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/undo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 25 additions & 18 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,8 @@ def excepthook(exc_type, exc_value, exc_tb):
style_sheet = getStyleSheet()
app.setStyleSheet(style_sheet)

def open_project(project_path: str):
load_settings(str(pathlib.Path(project_path, "settings.yaml")))

# update project_path in settings, because it originally might be in another place
sett().project_path = project_path
create_temporary_project_files()

window = MainWindow()
window.close_signal.connect(entry_window.show)

model = MainModel()
cntrl = MainController(window, model)

# try to open stl file
stlpath = pathlib.Path(project_path, sett().slicing.stl_file)
if os.path.isfile(stlpath):
cntrl.load_stl(stlpath)

def splanes_update(project_path, cntrl):
# update splanes in settings because we might have different versions
if hasattr(sett().slicing, "splanes_file"):
# we have kinda old settings which point to separate file with planes
# load planes as it is, but remove this parameter and save settings
Expand All @@ -98,6 +82,26 @@ def open_project(project_path: str):
[read_plane(figure.description) for figure in sett().figures]
)

def open_project(project_path: str):
load_settings(str(pathlib.Path(project_path, "settings.yaml")))

# update project_path in settings, because it originally might be in another place
sett().project_path = project_path
create_temporary_project_files()

window = MainWindow()
window.close_signal.connect(entry_window.show)

model = MainModel()
cntrl = MainController(window, model)

# try to open stl file
stlpath = pathlib.Path(project_path, sett().slicing.stl_file)
if os.path.isfile(stlpath):
cntrl.load_stl(stlpath)

splanes_update(project_path, cntrl)

window.showMaximized()
window.show()
cntrl.reset_settings()
Expand All @@ -114,6 +118,9 @@ def create_project(project_path: str):

model = MainModel()
cntrl = MainController(window, model)

splanes_update(project_path, cntrl)

window.showMaximized()
window.show()
entry_window.close()
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', 'numpy-stl'],
hiddenimports=['vtkmodules', 'vtkmodules.all', 'vtkmodules.qt.QVTKRenderWindowInteractor', 'vtkmodules.util', 'vtkmodules.util.numpy_support', 'yaml', 'numpy', 'pkg_resources.extern'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
Expand Down
6 changes: 5 additions & 1 deletion settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ slicing:
originz: 0.0
overlapping_infill_percentage: 100.0
overlapping_infill_lid_percentage: 60.0
planes_contact_with_nozzle: ''
planes_contact_with_nozzle: ""
print_speed: 50
print_speed_layer1: 50
print_speed_wall: 50
Expand Down Expand Up @@ -158,3 +158,7 @@ supports:
uninterrupted_print:
enabled: false
cut_distance: 0.0
figures:
- description: plane X0.00 Y0.00 Z0.00 T0.00 R0.00
index: 0
settings: {}
1 change: 1 addition & 0 deletions src/InteractorAroundActivePlane.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def leftBtnPress(self, obj, event, view=None):
normal = actor.GetTriangleNormal(triangle_id)
actor.RotateByVector(-normal)
view.model_centering()
view.save_current_movement()

def middleBtnPress(self, obj, event):
if event == "MouseWheelForwardEvent":
Expand Down
2 changes: 1 addition & 1 deletion src/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def get_file_chunks(filename):

def prepare_bug(filename, error_description):
with open("auth.yaml", "r") as file:
auth_data = yaml.safe_load(file)
auth_data = yaml.full_load(file)

req = srv_bug_pb2.AddBugRequest(
info=srv_bug_pb2.BugInfo(
Expand Down
23 changes: 10 additions & 13 deletions src/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def _connect_signals(self):
self.view.picture_slider.valueChanged.connect(self.change_layer_view)
self.view.move_button.clicked.connect(self.move_model)
self.view.place_button.clicked.connect(self.place_model)
self.view.cancel_action.clicked.connect(partial(self.view.shift_state, True))
self.view.return_action.clicked.connect(partial(self.view.shift_state, False))
self.view.load_model_button.clicked.connect(self.open_file)
self.view.slice3a_button.clicked.connect(partial(self.slice_stl, "3axes"))
self.view.slice_vip_button.clicked.connect(partial(self.slice_stl, "vip"))
Expand Down Expand Up @@ -204,7 +206,7 @@ def create_printer(self):
save_settings()

# update label with printer path
self.view.printer_path_edit.setText(os.path.basename(printer_path))
self.view.setts.edit("printer_path").setText(os.path.basename(printer_path))

# update path in calibration model
try:
Expand Down Expand Up @@ -243,7 +245,7 @@ def choose_printer_path(self):
save_settings()

# update label with printer path
self.view.printer_path_edit.setText(os.path.basename(printer_path))
self.view.setts.edit("printer_path").setText(os.path.basename(printer_path))

# update path in calibration model
try:
Expand Down Expand Up @@ -709,7 +711,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()
Expand Down Expand Up @@ -762,12 +763,14 @@ def save_settings_file(self):
def save_project_files(self, save_path=""):
if save_path == "":
self.save_settings("vip", PathBuilder.settings_file())
shutil.copy2(PathBuilder.stl_model_temp(), PathBuilder.stl_model())
if os.path.isfile(PathBuilder.stl_model_temp()):
shutil.copy2(PathBuilder.stl_model_temp(), PathBuilder.stl_model())
else:
self.save_settings("vip", path.join(save_path, "settings.yaml"))
shutil.copy2(
PathBuilder.stl_model_temp(), path.join(save_path, "model.stl")
)
if os.path.isfile(PathBuilder.stl_model_temp()):
shutil.copy2(
PathBuilder.stl_model_temp(), path.join(save_path, "model.stl")
)

def save_project(self):
try:
Expand Down Expand Up @@ -887,15 +890,9 @@ def display_settings(self):
self.view.supports_number_of_bottom_layers_value.setText(
str(s.supports.bottoms_depth)
)
self.view.supports_bottom_thickness_value.setText(
str(round(s.slicing.layer_height * s.supports.bottoms_depth, 2))
)
self.view.supports_number_of_lid_layers_value.setText(
str(int(s.supports.lids_depth))
)
self.view.supports_lid_thickness_value.setText(
str(round(s.slicing.layer_height * s.supports.lids_depth, 2))
)
self.view.colorize_angle_value.setText(str(s.slicing.angle))

def colorize_model(self):
Expand Down
3 changes: 2 additions & 1 deletion src/figure_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def params(self):


class StlMovePanel(QWidget):
def __init__(self, methods, captions):
def __init__(self, viev, methods, captions):
super().__init__()

self.setEnabled(False)
Expand All @@ -302,6 +302,7 @@ def __init__(self, methods, captions):
gridLayout.addWidget(btn_neg, row, 1)

edit = QLineEdit()
edit.installEventFilter(viev)
edit.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
edit.setMinimumWidth(20)
gridLayout.addWidget(edit, row, 2)
Expand Down
1 change: 1 addition & 0 deletions src/gui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ def setTransform(self):
self.view.stlActor.SetUserTransform(self.tf)
self.view.updateTransform()
self.view.reload_scene()
self.view.save_current_movement()

def set(self, text, axis):
try:
Expand Down
2 changes: 2 additions & 0 deletions src/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Locale:
WarningPathNotClosed = "When cutting the model, not closed areas were found! Check that the shapes are positioned correctly"

RemoveFirstPlaneError = "First figure cannot be removed"
CannotDropHere = "Figure cannot be dropped here"

def __init__(self, **entries):
self.__dict__.update(entries)
Expand Down Expand Up @@ -295,6 +296,7 @@ def __init__(self, **entries):
M10CutDistance="Дистанция отреза филамента, мм:",
RemoveFirstPlaneError="Первая фигура не может быть убрана",
WarningPathNotClosed="При разрезании модели были обнаружены незамкнутые участки! Проверьте корректность расположения фигур",
CannotDropHere="Фигура не может быть перенесена сюда",
),
}

Expand Down
56 changes: 41 additions & 15 deletions src/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ def compare_figures(settings):
if current_figures[i]["description"] != figures_from_settings[i].description:
return False

if current_figures[i]["settings"] != figures_from_settings[i].settings:
return False

return True


Expand All @@ -99,6 +102,10 @@ def compare_project_file(filename):


def compare_files(file1_path, file2_path):
# if either of the files does not exist, return False
if not os.path.exists(file1_path) or not os.path.exists(file2_path):
return True

try:
with open(file1_path, "rb") as file1:
data1 = file1.read()
Expand Down Expand Up @@ -265,7 +272,7 @@ def save_splanes_to_file(splanes, filename):
def get_version(settings_filename):
try:
with open(settings_filename, "r") as settings_file:
settings = yaml.safe_load(settings_file)
settings = yaml.full_load(settings_file)

version = settings["common"]["version"]
return version
Expand All @@ -277,7 +284,7 @@ def get_version(settings_filename):
def set_version(settings_filename, version):
try:
with open(settings_filename, "r") as settings_file:
settings = yaml.safe_load(settings_file)
settings = yaml.full_load(settings_file)

settings["common"]["version"] = version

Expand All @@ -290,10 +297,10 @@ def set_version(settings_filename, version):

def paths_transfer_in_settings(initial_settings_filename, final_settings_filename):
with open(initial_settings_filename, "r") as settings_file:
initial_settings = yaml.safe_load(settings_file)
initial_settings = yaml.load(settings_file)

with open(final_settings_filename, "r") as settings_file:
final_settings = yaml.safe_load(settings_file)
final_settings = yaml.load(settings_file)

compare_settings(initial_settings, final_settings)

Expand All @@ -319,23 +326,38 @@ def __init__(self, d):
else:
setattr(self, a, Settings(b) if isinstance(b, dict) else b)

def __repr__(self):
return str(self.__dict__)

def __eq__(self, other):
if not isinstance(other, Settings):
return False
ignore_attributes = [
"splanes_file",
"figures",
"print_time",
"consumption_material",
"planes_contact_with_nozzle",
]

# try to compare attributes from left to right
for attr in self.__dict__:
if attr in ignore_attributes:
continue
if not hasattr(other, attr):
return False
if getattr(self, attr) != getattr(other, attr):
return False

# try to compare attributes from right to left
for attr in other.__dict__:
if attr in ignore_attributes:
continue
if not hasattr(self, attr):
return False
if getattr(self, attr) != getattr(other, attr):
return False

return True


Expand Down Expand Up @@ -370,9 +392,22 @@ def settings_file_default():
def settings_file_old():
return path.join(PathBuilder.project_path(), "settings_old.yaml")

@staticmethod
def get_cmd_with_path(cmd):
temp_settings = prepare_temp_settings(sett())
encoded_temp_settings = base64.b64encode(temp_settings.encode("utf-8")).decode(
"utf-8"
)
return (
cmd
+ f'"{PathBuilder.settings_file_temp()}"'
+ " --data="
+ f"{encoded_temp_settings}"
)

@staticmethod
def colorizer_cmd():
return sett().colorizer.cmd + f'"{PathBuilder.settings_file()}"'
return PathBuilder.get_cmd_with_path(sett().colorizer.cmd)

@staticmethod
def colorizer_stl():
Expand All @@ -384,16 +419,7 @@ def colorizer_result():

@staticmethod
def slicing_cmd():
temp_settings = prepare_temp_settings(sett())
encoded_temp_settings = base64.b64encode(temp_settings.encode("utf-8")).decode(
"utf-8"
)
return (
sett().slicing.cmd
+ f'"{PathBuilder.settings_file_temp()}"'
+ " --data="
+ f"{encoded_temp_settings}"
)
return PathBuilder.get_cmd_with_path(sett().slicing.cmd)

@staticmethod
def gcodevis_file():
Expand Down
Loading

0 comments on commit a311af1

Please sign in to comment.