mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Merge branch '2.5' of github.com:Ultimaker/Cura
This commit is contained in:
commit
dbfa5873ce
3 changed files with 32 additions and 6 deletions
|
@ -255,6 +255,11 @@ class ExtruderManager(QObject):
|
||||||
|
|
||||||
preferred_materials = container_registry.findInstanceContainers(**search_criteria)
|
preferred_materials = container_registry.findInstanceContainers(**search_criteria)
|
||||||
if len(preferred_materials) >= 1:
|
if len(preferred_materials) >= 1:
|
||||||
|
# In some cases we get multiple materials. In that case, prefer materials that are marked as read only.
|
||||||
|
read_only_preferred_materials = [preferred_material for preferred_material in preferred_materials if preferred_material.isReadOnly()]
|
||||||
|
if len(read_only_preferred_materials) >= 1:
|
||||||
|
material = read_only_preferred_materials[0]
|
||||||
|
else:
|
||||||
material = preferred_materials[0]
|
material = preferred_materials[0]
|
||||||
else:
|
else:
|
||||||
Logger.log("w", "The preferred material \"%s\" of machine %s doesn't exist or is not a material profile.", preferred_material_id, machine_id)
|
Logger.log("w", "The preferred material \"%s\" of machine %s doesn't exist or is not a material profile.", preferred_material_id, machine_id)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
from UM.Backend import Backend
|
||||||
from UM.Job import Job
|
from UM.Job import Job
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
from UM.Math.AxisAlignedBox import AxisAlignedBox
|
||||||
|
@ -340,6 +341,8 @@ class GCodeReader(MeshReader):
|
||||||
gcode_list_decorator.setGCodeList(gcode_list)
|
gcode_list_decorator.setGCodeList(gcode_list)
|
||||||
scene_node.addDecorator(gcode_list_decorator)
|
scene_node.addDecorator(gcode_list_decorator)
|
||||||
|
|
||||||
|
Application.getInstance().getController().getScene().gcode_list = gcode_list
|
||||||
|
|
||||||
Logger.log("d", "Finished parsing %s" % file_name)
|
Logger.log("d", "Finished parsing %s" % file_name)
|
||||||
self._message.hide()
|
self._message.hide()
|
||||||
|
|
||||||
|
@ -361,4 +364,8 @@ class GCodeReader(MeshReader):
|
||||||
"Make sure the g-code is suitable for your printer and printer configuration before sending the file to it. The g-code representation may not be accurate."), lifetime=0)
|
"Make sure the g-code is suitable for your printer and printer configuration before sending the file to it. The g-code representation may not be accurate."), lifetime=0)
|
||||||
caution_message.show()
|
caution_message.show()
|
||||||
|
|
||||||
|
# The "save/print" button's state is bound to the backend state.
|
||||||
|
backend = Application.getInstance().getBackend()
|
||||||
|
backend.backendStateChange.emit(Backend.BackendState.Disabled)
|
||||||
|
|
||||||
return scene_node
|
return scene_node
|
||||||
|
|
|
@ -625,7 +625,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
if print_information.materialLengths:
|
if print_information.materialLengths:
|
||||||
# Check if print cores / materials are loaded at all. Any failure in these results in an Error.
|
# Check if print cores / materials are loaded at all. Any failure in these results in an Error.
|
||||||
for index in range(0, self._num_extruders):
|
for index in range(0, self._num_extruders):
|
||||||
if print_information.materialLengths[index] != 0:
|
if index < len(print_information.materialLengths) and print_information.materialLengths[index] != 0:
|
||||||
if self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"] == "":
|
if self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"] == "":
|
||||||
Logger.log("e", "No cartridge loaded in slot %s, unable to start print", index + 1)
|
Logger.log("e", "No cartridge loaded in slot %s, unable to start print", index + 1)
|
||||||
self._error_message = Message(
|
self._error_message = Message(
|
||||||
|
@ -643,13 +643,13 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
for index in range(0, self._num_extruders):
|
for index in range(0, self._num_extruders):
|
||||||
# Check if there is enough material. Any failure in these results in a warning.
|
# Check if there is enough material. Any failure in these results in a warning.
|
||||||
material_length = self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["length_remaining"]
|
material_length = self._json_printer_state["heads"][0]["extruders"][index]["active_material"]["length_remaining"]
|
||||||
if material_length != -1 and print_information.materialLengths[index] > material_length:
|
if material_length != -1 and index < len(print_information.materialLengths) and print_information.materialLengths[index] > material_length:
|
||||||
Logger.log("w", "Printer reports that there is not enough material left for extruder %s. We need %s and the printer has %s", index + 1, print_information.materialLengths[index], material_length)
|
Logger.log("w", "Printer reports that there is not enough material left for extruder %s. We need %s and the printer has %s", index + 1, print_information.materialLengths[index], material_length)
|
||||||
warnings.append(i18n_catalog.i18nc("@label", "Not enough material for spool {0}.").format(index+1))
|
warnings.append(i18n_catalog.i18nc("@label", "Not enough material for spool {0}.").format(index+1))
|
||||||
|
|
||||||
# Check if the right cartridges are loaded. Any failure in these results in a warning.
|
# Check if the right cartridges are loaded. Any failure in these results in a warning.
|
||||||
extruder_manager = cura.Settings.ExtruderManager.ExtruderManager.getInstance()
|
extruder_manager = cura.Settings.ExtruderManager.ExtruderManager.getInstance()
|
||||||
if print_information.materialLengths[index] != 0:
|
if index < len(print_information.materialLengths) and print_information.materialLengths[index] != 0:
|
||||||
variant = extruder_manager.getExtruderStack(index).findContainer({"type": "variant"})
|
variant = extruder_manager.getExtruderStack(index).findContainer({"type": "variant"})
|
||||||
core_name = self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"]
|
core_name = self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"]
|
||||||
if variant:
|
if variant:
|
||||||
|
@ -796,13 +796,25 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
Logger.log("d", "Started sending g-code to remote printer.")
|
Logger.log("d", "Started sending g-code to remote printer.")
|
||||||
self._compressing_print = True
|
self._compressing_print = True
|
||||||
## Mash the data into single string
|
## Mash the data into single string
|
||||||
|
|
||||||
|
max_chars_per_line = 1024 * 1024 / 4 # 1 / 4 MB
|
||||||
|
|
||||||
byte_array_file_data = b""
|
byte_array_file_data = b""
|
||||||
|
batched_line = ""
|
||||||
for line in self._gcode:
|
for line in self._gcode:
|
||||||
if not self._compressing_print:
|
if not self._compressing_print:
|
||||||
self._progress_message.hide()
|
self._progress_message.hide()
|
||||||
return # Stop trying to zip, abort was called.
|
return # Stop trying to zip, abort was called.
|
||||||
|
|
||||||
|
# if the gcode was read from a gcode file, self._gcode will be a list of all lines in that file.
|
||||||
|
# Compressing line by line in this case is extremely slow, so we need to batch them.
|
||||||
|
if len(batched_line) < max_chars_per_line:
|
||||||
|
batched_line += line
|
||||||
|
continue
|
||||||
|
|
||||||
if self._use_gzip:
|
if self._use_gzip:
|
||||||
byte_array_file_data += gzip.compress(line.encode("utf-8"))
|
byte_array_file_data += gzip.compress(batched_line.encode("utf-8"))
|
||||||
|
batched_line = ""
|
||||||
QCoreApplication.processEvents() # Ensure that the GUI does not freeze.
|
QCoreApplication.processEvents() # Ensure that the GUI does not freeze.
|
||||||
# Pretend that this is a response, as zipping might take a bit of time.
|
# Pretend that this is a response, as zipping might take a bit of time.
|
||||||
self._last_response_time = time()
|
self._last_response_time = time()
|
||||||
|
@ -858,7 +870,10 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
url = QUrl("http://" + self._address + self._api_prefix + "auth/request")
|
url = QUrl("http://" + self._address + self._api_prefix + "auth/request")
|
||||||
request = QNetworkRequest(url)
|
request = QNetworkRequest(url)
|
||||||
request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json")
|
request.setHeader(QNetworkRequest.ContentTypeHeader, "application/json")
|
||||||
|
self._authentication_key = None
|
||||||
|
self._authentication_id = None
|
||||||
self._manager.post(request, json.dumps({"application": "Cura-" + Application.getInstance().getVersion(), "user": self._getUserName()}).encode())
|
self._manager.post(request, json.dumps({"application": "Cura-" + Application.getInstance().getVersion(), "user": self._getUserName()}).encode())
|
||||||
|
self.setAuthenticationState(AuthState.AuthenticationRequested)
|
||||||
|
|
||||||
## Send all material profiles to the printer.
|
## Send all material profiles to the printer.
|
||||||
def sendMaterialProfiles(self):
|
def sendMaterialProfiles(self):
|
||||||
|
@ -1054,7 +1069,6 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
Logger.log("w", "Received an invalid authentication request reply from printer: Not valid JSON.")
|
Logger.log("w", "Received an invalid authentication request reply from printer: Not valid JSON.")
|
||||||
return
|
return
|
||||||
self.setAuthenticationState(AuthState.AuthenticationRequested)
|
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack: # Remove any old data.
|
if global_container_stack: # Remove any old data.
|
||||||
Logger.log("d", "Removing old network authentication data as a new one was requested.")
|
Logger.log("d", "Removing old network authentication data as a new one was requested.")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue