Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
wawanbreton committed Nov 20, 2024
2 parents 94b8728 + 18cc068 commit 0286c6d
Show file tree
Hide file tree
Showing 130 changed files with 9,339 additions and 8,324 deletions.
12 changes: 8 additions & 4 deletions cura/BuildVolume.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,23 @@ def render(self, renderer):
if not self.getMeshData() or not self.isVisible():
return True

theme = self._application.getTheme()
if not self._shader:
self._shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "default.shader"))
self._grid_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "grid.shader"))
theme = self._application.getTheme()
self._grid_shader.setUniformValue("u_plateColor", Color(*theme.getColor("buildplate").getRgb()))
self._grid_shader.setUniformValue("u_gridColor0", Color(*theme.getColor("buildplate_grid").getRgb()))
self._grid_shader.setUniformValue("u_gridColor1", Color(*theme.getColor("buildplate_grid_minor").getRgb()))

plate_color = Color(*theme.getColor("buildplate").getRgb())
if self._global_container_stack.getMetaDataEntry("has_textured_buildplate", False):
plate_color.setA(0.5)
self._grid_shader.setUniformValue("u_plateColor", plate_color)

renderer.queueNode(self, mode = RenderBatch.RenderMode.Lines)
renderer.queueNode(self, mesh = self._origin_mesh, backface_cull = True)
renderer.queueNode(self, mesh = self._grid_mesh, shader = self._grid_shader, backface_cull = True)
renderer.queueNode(self, mesh = self._grid_mesh, shader = self._grid_shader, backface_cull = True, transparent = True, sort = -10)
if self._disallowed_area_mesh:
renderer.queueNode(self, mesh = self._disallowed_area_mesh, shader = self._shader, transparent = True, backface_cull = True, sort = -9)
renderer.queueNode(self, mesh = self._disallowed_area_mesh, shader = self._shader, transparent = True, backface_cull = True, sort = -5)

if self._error_mesh:
renderer.queueNode(self, mesh=self._error_mesh, shader=self._shader, transparent=True,
Expand Down
17 changes: 7 additions & 10 deletions cura/CuraApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -1895,23 +1895,20 @@ def _openUrl(self, url: QUrl) -> None:
def on_finish(response):
content_disposition_header_key = QByteArray("content-disposition".encode())

if not response.hasRawHeader(content_disposition_header_key):
Logger.log("w", "Could not find Content-Disposition header in response from {0}".format(
model_url.url()))
# Use the last part of the url as the filename, and assume it is an STL file
filename = model_url.path().split("/")[-1] + ".stl"
else:
filename = model_url.path().split("/")[-1] + ".stl"

if response.hasRawHeader(content_disposition_header_key):
# content_disposition is in the format
# ```
# content_disposition attachment; "filename=[FILENAME]"
# content_disposition attachment; filename="[FILENAME]"
# ```
# Use a regex to extract the filename
content_disposition = str(response.rawHeader(content_disposition_header_key).data(),
encoding='utf-8')
content_disposition_match = re.match(r'attachment; filename="(?P<filename>.*)"',
content_disposition_match = re.match(r'attachment; filename=(?P<filename>.*)',
content_disposition)
assert content_disposition_match is not None
filename = content_disposition_match.group("filename")
if content_disposition_match is not None:
filename = content_disposition_match.group("filename").strip("\"")

tmp = tempfile.NamedTemporaryFile(suffix=filename, delete=False)
with open(tmp.name, "wb") as f:
Expand Down
11 changes: 6 additions & 5 deletions cura/Settings/ExtruderStack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018 Ultimaker B.V.
# Copyright (c) 2024 UltiMaker
# Cura is released under the terms of the LGPLv3 or higher.

from typing import Any, Dict, TYPE_CHECKING, Optional
Expand All @@ -12,11 +12,8 @@
from UM.Settings.Interfaces import ContainerInterface, PropertyEvaluationContext
from UM.Util import parseBool

import cura.CuraApplication

from . import Exceptions
from .CuraContainerStack import CuraContainerStack, _ContainerIndexes
from .ExtruderManager import ExtruderManager

if TYPE_CHECKING:
from cura.Settings.GlobalStack import GlobalStack
Expand Down Expand Up @@ -141,7 +138,11 @@ def getProperty(self, key: str, property_name: str, context: Optional[PropertyEv
context.popContainer()
return result

limit_to_extruder = super().getProperty(key, "limit_to_extruder", context)
if not context:
context = PropertyEvaluationContext(self)
if "extruder_position" not in context.context:
context.context["extruder_position"] = super().getProperty(key, "limit_to_extruder", context)
limit_to_extruder = context.context["extruder_position"]
if limit_to_extruder is not None:
limit_to_extruder = str(limit_to_extruder)

Expand Down
2 changes: 1 addition & 1 deletion cura/Settings/MachineManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def _validateVariantsAndMaterials(self, global_stack) -> None:
self.setVariantByName(extruder.getMetaDataEntry("position"), machine_node.preferred_variant_name)
variant_node = machine_node.variants.get(machine_node.preferred_variant_name)

material_node = variant_node.materials.get(extruder.material.getMetaDataEntry("base_file"))
material_node = variant_node.materials.get(extruder.material.getMetaDataEntry("base_file")) if variant_node else None
if material_node is None:
Logger.log("w", "An extruder has an unknown material, switching it to the preferred material")
if not self.setMaterialById(extruder.getMetaDataEntry("position"), machine_node.preferred_material):
Expand Down
2 changes: 2 additions & 0 deletions cura/UI/CuraSplashScreen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) 2020 Ultimaker B.V.
# Uranium is released under the terms of the LGPLv3 or higher.
import math

from PyQt6.QtCore import Qt, QCoreApplication, QTimer
from PyQt6.QtGui import QPixmap, QColor, QFont, QPen, QPainter
Expand Down Expand Up @@ -51,6 +52,7 @@ def updateLoadingImage(self):
self._last_update_time = time.time()
# Since we don't know how much time actually passed, check how many intervals of 50 we had.
self._loading_image_rotation_angle -= 10 * (time_since_last_update * 1000 / 50)
self._loading_image_rotation_angle = math.fmod(self._loading_image_rotation_angle, 360)
self.repaint()

# Override the mousePressEvent so the splashscreen doesn't disappear when clicked
Expand Down
3 changes: 1 addition & 2 deletions cura/UI/WelcomePagesModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ def getPageIndexById(self, page_id: str) -> Optional[int]:
def _getBuiltinWelcomePagePath(page_filename: str) -> QUrl:
"""Convenience function to get QUrl path to pages that's located in "resources/qml/WelcomePages"."""
from cura.CuraApplication import CuraApplication
return QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
os.path.join("WelcomePages", page_filename)))
return QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "WelcomePages", page_filename))

# FIXME: HACKs for optimization that we don't update the model every time the active machine gets changed.
def _onActiveMachineChanged(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions plugins/SimulationView/layers3d.shader
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ geometry41core =
((v_prev_line_type[0] != 1) && (v_line_type[0] == 1)) ||
((v_prev_line_type[0] != 4) && (v_line_type[0] == 4))
)) {
float w = size_x;
float h = size_y;
float w = max(0.05, size_x);
float h = max(0.05, size_y);

myEmitVertex(v_vertex[0] + vec3( w, h, w), u_starts_color, normalize(vec3( 1.0, 1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, h, w, 0.0))); // Front-top-left
myEmitVertex(v_vertex[0] + vec3(-w, h, w), u_starts_color, normalize(vec3(-1.0, 1.0, 1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, h, w, 0.0))); // Front-top-right
Expand Down
44 changes: 40 additions & 4 deletions plugins/SliceInfoPlugin/SliceInfo.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright (c) 2023 UltiMaker
# Cura is released under the terms of the LGPLv3 or higher.
import datetime

import json
import os
import platform
import time
from typing import Optional, Set, TYPE_CHECKING
from typing import Any, Optional, Set, TYPE_CHECKING

from PyQt6.QtCore import pyqtSlot, QObject
from PyQt6.QtNetwork import QNetworkRequest
Expand Down Expand Up @@ -33,7 +34,18 @@ class SliceInfo(QObject, Extension):
no model files are being sent (Just a SHA256 hash of the model).
"""

info_url = "https://stats.ultimaker.com/api/cura"
info_url = "https://statistics.ultimaker.com/api/v2/cura/slice"

_adjust_flattened_names = {
"extruders_extruder": "extruders",
"extruders_settings": "extruders",
"models_model": "models",
"models_transformation_data": "models_transformation",
"print_settings_": "",
"print_times": "print_time",
"active_machine_": "",
"slice_uuid": "slice_id",
}

def __init__(self, parent = None):
QObject.__init__(self, parent)
Expand Down Expand Up @@ -112,6 +124,26 @@ def _getUserModifiedSettingKeys(self) -> list:

return list(sorted(user_modified_setting_keys))

def _flattenData(self, data: Any, result: dict, current_flat_key: Optional[str] = None, lift_list: bool = False) -> None:
if isinstance(data, dict):
for key, value in data.items():
total_flat_key = key if current_flat_key is None else f"{current_flat_key}_{key}"
self._flattenData(value, result, total_flat_key, lift_list)
elif isinstance(data, list):
for item in data:
self._flattenData(item, result, current_flat_key, True)
else:
actual_flat_key = current_flat_key.lower()
for key, value in self._adjust_flattened_names.items():
if actual_flat_key.startswith(key):
actual_flat_key = actual_flat_key.replace(key, value)
if lift_list:
if actual_flat_key not in result:
result[actual_flat_key] = []
result[actual_flat_key].append(data)
else:
result[actual_flat_key] = data

def _onWriteStarted(self, output_device):
try:
if not self._application.getPreferences().getValue("info/send_slice_info"):
Expand All @@ -125,8 +157,7 @@ def _onWriteStarted(self, output_device):
global_stack = machine_manager.activeMachine

data = dict() # The data that we're going to submit.
data["time_stamp"] = time.time()
data["schema_version"] = 0
data["schema_version"] = 1000
data["cura_version"] = self._application.getVersion()
data["cura_build_type"] = ApplicationMetadata.CuraBuildType
org_id = user_profile.get("organization_id", None) if user_profile else None
Expand Down Expand Up @@ -298,6 +329,11 @@ def _onWriteStarted(self, output_device):
"time_backend": int(round(time_backend)),
}

# Massage data into format used in the DB:
flat_data = dict()
self._flattenData(data, flat_data)
data = flat_data

# Convert data to bytes
binary_data = json.dumps(data).encode("utf-8")

Expand Down
2 changes: 1 addition & 1 deletion resources/conandata.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: "5.9.0-beta.2"
version: "5.9.0"
1 change: 1 addition & 0 deletions resources/definitions/ankermake_m5.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "ankermake_m5_platform.obj",
"has_machine_quality": true,
"has_textured_buildplate": true,
"machine_extruder_trains": { "0": "ankermake_m5_extruder_0" },
"platform_texture": "ankermake_m5.png",
"preferred_material": "generic_pla",
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/ankermake_m5c.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "ankermake_m5c_platform.obj",
"has_machine_quality": true,
"has_textured_buildplate": true,
"machine_extruder_trains": { "0": "ankermake_m5c_extruder_0" },
"platform_texture": "ankermake_m5c.png",
"preferred_material": "generic_pla",
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/dagoma_sigma_pro.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"platform": "dagoma_sigma_pro.obj",
"first_start_actions": [ "MachineSettingsAction" ],
"has_machine_quality": true,
"has_textured_buildplate": true,
"has_variants": true,
"machine_extruder_trains": { "0": "dagoma_sigma_pro_extruder" },
"platform_texture": "dagoma_sigma_pro.png",
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/dagoma_sigma_pro_dual.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"platform": "dagoma_sigma_pro.obj",
"first_start_actions": [ "MachineSettingsAction" ],
"has_machine_quality": true,
"has_textured_buildplate": true,
"has_variants": true,
"machine_extruder_trains":
{
Expand Down
11 changes: 7 additions & 4 deletions resources/definitions/fdmprinter.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"preferred_material": "generic_pla",
"preferred_quality_type": "normal",
"machine_extruder_trains": { "0": "fdmextruder" },
"has_textured_buildplate": false,
"supports_usb_connection": true,
"supports_network_connection": false,
"supports_abstract_color": false
"supports_abstract_color": false,
"variants_name_has_translation": false
},
"settings":
{
Expand Down Expand Up @@ -1434,7 +1436,7 @@
"z_seam_corner_weighted": "Smart Hiding"
},
"default_value": "z_seam_corner_inner",
"enabled": "z_seam_type != 'random'",
"enabled": "z_seam_type == 'sharpest_corner'",
"limit_to_extruder": "wall_0_extruder_nr",
"settable_per_mesh": true
},
Expand Down Expand Up @@ -8942,6 +8944,7 @@
"type": "float",
"default_value": 0,
"minimum_value": "0",
"maximum_value_warning": "50.0",
"unit": "mm",
"limit_to_extruder": "wall_0_extruder_nr",
"settable_per_extruder": true,
Expand Down Expand Up @@ -8991,7 +8994,7 @@
},
"wall_0_acceleration":
{
"label": "Outer Wall Acceleration",
"label": "Outer Wall Start Acceleration",
"description": "This is the acceleration with which to reach the top speed when printing an outer wall.",
"enabled": "wall_0_start_speed_ratio < 100.0",
"type": "float",
Expand All @@ -9018,7 +9021,7 @@
},
"wall_0_deceleration":
{
"label": "Outer Wall Deceleration",
"label": "Outer Wall End Deceleration",
"description": "This is the deceleration with which to end printing an outer wall.",
"enabled": "wall_0_end_speed_ratio < 100.0",
"type": "float",
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/flyingbear_ghost_4s.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"visible": true,
"author": "oducceu",
"platform": "flyingbear_platform.obj",
"has_textured_buildplate": true,
"platform_texture": "flyingbear_platform.png",
"quality_definition": "flyingbear_base"
},
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/flyingbear_ghost_5.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"visible": true,
"author": "oducceu",
"platform": "flyingbear_platform.obj",
"has_textured_buildplate": true,
"platform_texture": "flyingbear_platform.png",
"quality_definition": "flyingbear_base"
},
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/flyingbear_ghost_6.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"visible": true,
"author": "barrnet",
"platform": "flyingbear_platform.obj",
"has_textured_buildplate": true,
"platform_texture": "flyingbear_platform.png",
"quality_definition": "flyingbear_base"
},
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_adonis.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "hellbot_adonis.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains": { "0": "hellbot_adonis_extruder" },
"platform_offset": [
0,
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_hidra.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "hellbot_hidra.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains":
{
"0": "hellbot_hidra_extruder_0",
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_hidra_plus.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "hellbot_hidra_plus.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains":
{
"0": "hellbot_hidra_plus_extruder_0",
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_magna_2_230.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "Hellbot_Magna_2_230.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains": { "0": "hellbot_magna_2_230_extruder_0" },
"platform_texture": "Magna2_230.png"
},
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_magna_2_230_dual.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "Hellbot_Magna_2_230.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains":
{
"0": "hellbot_magna_2_230_dual_extruder_0",
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_magna_2_300.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "Hellbot_Magna_2_300.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains": { "0": "hellbot_magna_2_300_extruder_0" },
"platform_texture": "Magna2_300.png"
},
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_magna_2_300_dual.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "Hellbot_Magna_2_300.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains":
{
"0": "hellbot_magna_2_300_dual_extruder_0",
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_magna_2_400.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "Hellbot_Magna_2_400.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains": { "0": "hellbot_magna_2_400_extruder_0" },
"platform_texture": "Magna2_400.png"
},
Expand Down
1 change: 1 addition & 0 deletions resources/definitions/hellbot_magna_2_400_dual.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"file_formats": "text/x-gcode",
"platform": "Hellbot_Magna_2_400.obj",
"has_materials": true,
"has_textured_buildplate": true,
"machine_extruder_trains":
{
"0": "hellbot_magna_2_400_dual_extruder_0",
Expand Down
Loading

0 comments on commit 0286c6d

Please sign in to comment.