mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-07 22:13:58 -06:00
Merge remote-tracking branch 'origin/master' into shader_optimization
This commit is contained in:
commit
dab0a43214
304 changed files with 53275 additions and 18828 deletions
|
@ -1,7 +1,7 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import Optional
|
||||
from typing import List, Optional, Union, TYPE_CHECKING
|
||||
import os.path
|
||||
import zipfile
|
||||
|
||||
|
@ -9,15 +9,16 @@ import numpy
|
|||
|
||||
import Savitar
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Logger import Logger
|
||||
from UM.Math.Matrix import Matrix
|
||||
from UM.Math.Vector import Vector
|
||||
from UM.Mesh.MeshBuilder import MeshBuilder
|
||||
from UM.Mesh.MeshReader import MeshReader
|
||||
from UM.Scene.GroupDecorator import GroupDecorator
|
||||
from UM.Scene.SceneNode import SceneNode #For typing.
|
||||
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.Settings.ExtruderManager import ExtruderManager
|
||||
from cura.Scene.CuraSceneNode import CuraSceneNode
|
||||
from cura.Scene.BuildPlateDecorator import BuildPlateDecorator
|
||||
|
@ -25,11 +26,9 @@ from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator
|
|||
from cura.Scene.ZOffsetDecorator import ZOffsetDecorator
|
||||
from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch
|
||||
|
||||
MYPY = False
|
||||
|
||||
|
||||
try:
|
||||
if not MYPY:
|
||||
if not TYPE_CHECKING:
|
||||
import xml.etree.cElementTree as ET
|
||||
except ImportError:
|
||||
Logger.log("w", "Unable to load cElementTree, switching to slower version")
|
||||
|
@ -55,7 +54,7 @@ class ThreeMFReader(MeshReader):
|
|||
self._unit = None
|
||||
self._object_count = 0 # Used to name objects as there is no node name yet.
|
||||
|
||||
def _createMatrixFromTransformationString(self, transformation):
|
||||
def _createMatrixFromTransformationString(self, transformation: str) -> Matrix:
|
||||
if transformation == "":
|
||||
return Matrix()
|
||||
|
||||
|
@ -85,13 +84,13 @@ class ThreeMFReader(MeshReader):
|
|||
|
||||
return temp_mat
|
||||
|
||||
## Convenience function that converts a SceneNode object (as obtained from libSavitar) to a Uranium scene node.
|
||||
# \returns Uranium scene node.
|
||||
def _convertSavitarNodeToUMNode(self, savitar_node):
|
||||
## Convenience function that converts a SceneNode object (as obtained from libSavitar) to a scene node.
|
||||
# \returns Scene node.
|
||||
def _convertSavitarNodeToUMNode(self, savitar_node: Savitar.SceneNode) -> Optional[SceneNode]:
|
||||
self._object_count += 1
|
||||
node_name = "Object %s" % self._object_count
|
||||
|
||||
active_build_plate = Application.getInstance().getMultiBuildPlateModel().activeBuildPlate
|
||||
active_build_plate = CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate
|
||||
|
||||
um_node = CuraSceneNode() # This adds a SettingOverrideDecorator
|
||||
um_node.addDecorator(BuildPlateDecorator(active_build_plate))
|
||||
|
@ -122,7 +121,7 @@ class ThreeMFReader(MeshReader):
|
|||
|
||||
# Add the setting override decorator, so we can add settings to this node.
|
||||
if settings:
|
||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
||||
|
||||
# Ensure the correct next container for the SettingOverride decorator is set.
|
||||
if global_container_stack:
|
||||
|
@ -161,7 +160,7 @@ class ThreeMFReader(MeshReader):
|
|||
um_node.addDecorator(sliceable_decorator)
|
||||
return um_node
|
||||
|
||||
def _read(self, file_name):
|
||||
def _read(self, file_name: str) -> Union[SceneNode, List[SceneNode]]:
|
||||
result = []
|
||||
self._object_count = 0 # Used to name objects as there is no node name yet.
|
||||
# The base object of 3mf is a zipped archive.
|
||||
|
@ -181,12 +180,13 @@ class ThreeMFReader(MeshReader):
|
|||
mesh_data = um_node.getMeshData()
|
||||
if mesh_data is not None:
|
||||
extents = mesh_data.getExtents()
|
||||
center_vector = Vector(extents.center.x, extents.center.y, extents.center.z)
|
||||
transform_matrix.setByTranslation(center_vector)
|
||||
if extents is not None:
|
||||
center_vector = Vector(extents.center.x, extents.center.y, extents.center.z)
|
||||
transform_matrix.setByTranslation(center_vector)
|
||||
transform_matrix.multiply(um_node.getLocalTransformation())
|
||||
um_node.setTransformation(transform_matrix)
|
||||
|
||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
||||
|
||||
# Create a transformation Matrix to convert from 3mf worldspace into ours.
|
||||
# First step: flip the y and z axis.
|
||||
|
@ -215,17 +215,20 @@ class ThreeMFReader(MeshReader):
|
|||
um_node.setTransformation(um_node.getLocalTransformation().preMultiply(transformation_matrix))
|
||||
|
||||
# Check if the model is positioned below the build plate and honor that when loading project files.
|
||||
if um_node.getMeshData() is not None:
|
||||
minimum_z_value = um_node.getMeshData().getExtents(um_node.getWorldTransformation()).minimum.y # y is z in transformation coordinates
|
||||
if minimum_z_value < 0:
|
||||
um_node.addDecorator(ZOffsetDecorator())
|
||||
um_node.callDecoration("setZOffset", minimum_z_value)
|
||||
node_meshdata = um_node.getMeshData()
|
||||
if node_meshdata is not None:
|
||||
aabb = node_meshdata.getExtents(um_node.getWorldTransformation())
|
||||
if aabb is not None:
|
||||
minimum_z_value = aabb.minimum.y # y is z in transformation coordinates
|
||||
if minimum_z_value < 0:
|
||||
um_node.addDecorator(ZOffsetDecorator())
|
||||
um_node.callDecoration("setZOffset", minimum_z_value)
|
||||
|
||||
result.append(um_node)
|
||||
|
||||
except Exception:
|
||||
Logger.logException("e", "An exception occurred in 3mf reader.")
|
||||
return None
|
||||
return []
|
||||
|
||||
return result
|
||||
|
||||
|
|
173
plugins/AMFReader/AMFReader.py
Normal file
173
plugins/AMFReader/AMFReader.py
Normal file
|
@ -0,0 +1,173 @@
|
|||
# Copyright (c) 2019 fieldOfView
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
# This AMF parser is based on the AMF parser in legacy cura:
|
||||
# https://github.com/daid/LegacyCura/blob/ad7641e059048c7dcb25da1f47c0a7e95e7f4f7c/Cura/util/meshLoaders/amf.py
|
||||
from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from UM.Logger import Logger
|
||||
|
||||
from UM.Mesh.MeshData import MeshData, calculateNormalsFromIndexedVertices
|
||||
from UM.Mesh.MeshReader import MeshReader
|
||||
|
||||
from cura.Scene.CuraSceneNode import CuraSceneNode
|
||||
from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator
|
||||
from cura.Scene.BuildPlateDecorator import BuildPlateDecorator
|
||||
from cura.Scene.ConvexHullDecorator import ConvexHullDecorator
|
||||
from UM.Scene.GroupDecorator import GroupDecorator
|
||||
|
||||
import numpy
|
||||
import trimesh
|
||||
import os.path
|
||||
import zipfile
|
||||
|
||||
MYPY = False
|
||||
try:
|
||||
if not MYPY:
|
||||
import xml.etree.cElementTree as ET
|
||||
except ImportError:
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from typing import Dict
|
||||
|
||||
|
||||
class AMFReader(MeshReader):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self._supported_extensions = [".amf"]
|
||||
self._namespaces = {} # type: Dict[str, str]
|
||||
|
||||
MimeTypeDatabase.addMimeType(
|
||||
MimeType(
|
||||
name="application/x-amf",
|
||||
comment="AMF",
|
||||
suffixes=["amf"]
|
||||
)
|
||||
)
|
||||
|
||||
# Main entry point
|
||||
# Reads the file, returns a SceneNode (possibly with nested ones), or None
|
||||
def _read(self, file_name):
|
||||
base_name = os.path.basename(file_name)
|
||||
try:
|
||||
zipped_file = zipfile.ZipFile(file_name)
|
||||
xml_document = zipped_file.read(zipped_file.namelist()[0])
|
||||
zipped_file.close()
|
||||
except zipfile.BadZipfile:
|
||||
raw_file = open(file_name, "r")
|
||||
xml_document = raw_file.read()
|
||||
raw_file.close()
|
||||
|
||||
try:
|
||||
amf_document = ET.fromstring(xml_document)
|
||||
except ET.ParseError:
|
||||
Logger.log("e", "Could not parse XML in file %s" % base_name)
|
||||
return None
|
||||
|
||||
if "unit" in amf_document.attrib:
|
||||
unit = amf_document.attrib["unit"].lower()
|
||||
else:
|
||||
unit = "millimeter"
|
||||
if unit == "millimeter":
|
||||
scale = 1.0
|
||||
elif unit == "meter":
|
||||
scale = 1000.0
|
||||
elif unit == "inch":
|
||||
scale = 25.4
|
||||
elif unit == "feet":
|
||||
scale = 304.8
|
||||
elif unit == "micron":
|
||||
scale = 0.001
|
||||
else:
|
||||
Logger.log("w", "Unknown unit in amf: %s. Using mm instead." % unit)
|
||||
scale = 1.0
|
||||
|
||||
nodes = []
|
||||
for amf_object in amf_document.iter("object"):
|
||||
for amf_mesh in amf_object.iter("mesh"):
|
||||
amf_mesh_vertices = []
|
||||
for vertices in amf_mesh.iter("vertices"):
|
||||
for vertex in vertices.iter("vertex"):
|
||||
for coordinates in vertex.iter("coordinates"):
|
||||
v = [0.0, 0.0, 0.0]
|
||||
for t in coordinates:
|
||||
if t.tag == "x":
|
||||
v[0] = float(t.text) * scale
|
||||
elif t.tag == "y":
|
||||
v[2] = float(t.text) * scale
|
||||
elif t.tag == "z":
|
||||
v[1] = float(t.text) * scale
|
||||
amf_mesh_vertices.append(v)
|
||||
if not amf_mesh_vertices:
|
||||
continue
|
||||
|
||||
indices = []
|
||||
for volume in amf_mesh.iter("volume"):
|
||||
for triangle in volume.iter("triangle"):
|
||||
f = [0, 0, 0]
|
||||
for t in triangle:
|
||||
if t.tag == "v1":
|
||||
f[0] = int(t.text)
|
||||
elif t.tag == "v2":
|
||||
f[1] = int(t.text)
|
||||
elif t.tag == "v3":
|
||||
f[2] = int(t.text)
|
||||
indices.append(f)
|
||||
|
||||
mesh = trimesh.base.Trimesh(vertices=numpy.array(amf_mesh_vertices, dtype=numpy.float32), faces=numpy.array(indices, dtype=numpy.int32))
|
||||
mesh.merge_vertices()
|
||||
mesh.remove_unreferenced_vertices()
|
||||
mesh.fix_normals()
|
||||
mesh_data = self._toMeshData(mesh)
|
||||
|
||||
new_node = CuraSceneNode()
|
||||
new_node.setSelectable(True)
|
||||
new_node.setMeshData(mesh_data)
|
||||
new_node.setName(base_name if len(nodes)==0 else "%s %d" % (base_name, len(nodes)))
|
||||
new_node.addDecorator(BuildPlateDecorator(CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate))
|
||||
new_node.addDecorator(SliceableObjectDecorator())
|
||||
|
||||
nodes.append(new_node)
|
||||
|
||||
if not nodes:
|
||||
Logger.log("e", "No meshes in file %s" % base_name)
|
||||
return None
|
||||
|
||||
if len(nodes) == 1:
|
||||
return nodes[0]
|
||||
|
||||
# Add all scenenodes to a group so they stay together
|
||||
group_node = CuraSceneNode()
|
||||
group_node.addDecorator(GroupDecorator())
|
||||
group_node.addDecorator(ConvexHullDecorator())
|
||||
group_node.addDecorator(BuildPlateDecorator(CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate))
|
||||
|
||||
for node in nodes:
|
||||
node.setParent(group_node)
|
||||
|
||||
return group_node
|
||||
|
||||
def _toMeshData(self, tri_node: trimesh.base.Trimesh) -> MeshData:
|
||||
tri_faces = tri_node.faces
|
||||
tri_vertices = tri_node.vertices
|
||||
|
||||
indices = []
|
||||
vertices = []
|
||||
|
||||
index_count = 0
|
||||
face_count = 0
|
||||
for tri_face in tri_faces:
|
||||
face = []
|
||||
for tri_index in tri_face:
|
||||
vertices.append(tri_vertices[tri_index])
|
||||
face.append(index_count)
|
||||
index_count += 1
|
||||
indices.append(face)
|
||||
face_count += 1
|
||||
|
||||
vertices = numpy.asarray(vertices, dtype=numpy.float32)
|
||||
indices = numpy.asarray(indices, dtype=numpy.int32)
|
||||
normals = calculateNormalsFromIndexedVertices(vertices, indices, face_count)
|
||||
|
||||
mesh_data = MeshData(vertices=vertices, indices=indices, normals=normals)
|
||||
return mesh_data
|
21
plugins/AMFReader/__init__.py
Normal file
21
plugins/AMFReader/__init__.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Copyright (c) 2019 fieldOfView
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from . import AMFReader
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
i18n_catalog = i18nCatalog("uranium")
|
||||
|
||||
|
||||
def getMetaData():
|
||||
return {
|
||||
"mesh_reader": [
|
||||
{
|
||||
"extension": "amf",
|
||||
"description": i18n_catalog.i18nc("@item:inlistbox", "AMF File")
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def register(app):
|
||||
return {"mesh_reader": AMFReader.AMFReader()}
|
7
plugins/AMFReader/plugin.json
Normal file
7
plugins/AMFReader/plugin.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "AMF Reader",
|
||||
"author": "fieldOfView",
|
||||
"version": "1.0.0",
|
||||
"description": "Provides support for reading AMF files.",
|
||||
"api": "6.0.0"
|
||||
}
|
|
@ -45,7 +45,7 @@ class DriveApiService:
|
|||
"Authorization": "Bearer {}".format(access_token)
|
||||
})
|
||||
except requests.exceptions.ConnectionError:
|
||||
Logger.log("w", "Unable to connect with the server.")
|
||||
Logger.logException("w", "Unable to connect with the server.")
|
||||
return []
|
||||
|
||||
# HTTP status 300s mean redirection. 400s and 500s are errors.
|
||||
|
@ -98,7 +98,12 @@ class DriveApiService:
|
|||
# If there is no download URL, we can't restore the backup.
|
||||
return self._emitRestoreError()
|
||||
|
||||
download_package = requests.get(download_url, stream = True)
|
||||
try:
|
||||
download_package = requests.get(download_url, stream = True)
|
||||
except requests.exceptions.ConnectionError:
|
||||
Logger.logException("e", "Unable to connect with the server")
|
||||
return self._emitRestoreError()
|
||||
|
||||
if download_package.status_code >= 300:
|
||||
# Something went wrong when attempting to download the backup.
|
||||
Logger.log("w", "Could not download backup from url %s: %s", download_url, download_package.text)
|
||||
|
@ -142,9 +147,14 @@ class DriveApiService:
|
|||
Logger.log("w", "Could not get access token.")
|
||||
return False
|
||||
|
||||
delete_backup = requests.delete("{}/{}".format(self.BACKUP_URL, backup_id), headers = {
|
||||
"Authorization": "Bearer {}".format(access_token)
|
||||
})
|
||||
try:
|
||||
delete_backup = requests.delete("{}/{}".format(self.BACKUP_URL, backup_id), headers = {
|
||||
"Authorization": "Bearer {}".format(access_token)
|
||||
})
|
||||
except requests.exceptions.ConnectionError:
|
||||
Logger.logException("e", "Unable to connect with the server")
|
||||
return False
|
||||
|
||||
if delete_backup.status_code >= 300:
|
||||
Logger.log("w", "Could not delete backup: %s", delete_backup.text)
|
||||
return False
|
||||
|
@ -159,15 +169,19 @@ class DriveApiService:
|
|||
if not access_token:
|
||||
Logger.log("w", "Could not get access token.")
|
||||
return None
|
||||
|
||||
backup_upload_request = requests.put(self.BACKUP_URL, json = {
|
||||
"data": {
|
||||
"backup_size": backup_size,
|
||||
"metadata": backup_metadata
|
||||
}
|
||||
}, headers = {
|
||||
"Authorization": "Bearer {}".format(access_token)
|
||||
})
|
||||
try:
|
||||
backup_upload_request = requests.put(
|
||||
self.BACKUP_URL,
|
||||
json = {"data": {"backup_size": backup_size,
|
||||
"metadata": backup_metadata
|
||||
}
|
||||
},
|
||||
headers = {
|
||||
"Authorization": "Bearer {}".format(access_token)
|
||||
})
|
||||
except requests.exceptions.ConnectionError:
|
||||
Logger.logException("e", "Unable to connect with the server")
|
||||
return None
|
||||
|
||||
# Any status code of 300 or above indicates an error.
|
||||
if backup_upload_request.status_code >= 300:
|
||||
|
|
|
@ -517,9 +517,6 @@ class CuraEngineBackend(QObject, Backend):
|
|||
self._build_plates_to_be_sliced.append(build_plate_number)
|
||||
self.printDurationMessage.emit(source_build_plate_number, {}, [])
|
||||
self.processingProgress.emit(0.0)
|
||||
self.setState(BackendState.NotStarted)
|
||||
# if not self._use_timer:
|
||||
# With manually having to slice, we want to clear the old invalid layer data.
|
||||
self._clearLayerData(build_plate_changed)
|
||||
|
||||
self._invokeSlice()
|
||||
|
@ -563,10 +560,10 @@ class CuraEngineBackend(QObject, Backend):
|
|||
|
||||
## Convenient function: mark everything to slice, emit state and clear layer data
|
||||
def needsSlicing(self) -> None:
|
||||
self.determineAutoSlicing()
|
||||
self.stopSlicing()
|
||||
self.markSliceAll()
|
||||
self.processingProgress.emit(0.0)
|
||||
self.setState(BackendState.NotStarted)
|
||||
if not self._use_timer:
|
||||
# With manually having to slice, we want to clear the old invalid layer data.
|
||||
self._clearLayerData()
|
||||
|
@ -735,6 +732,7 @@ class CuraEngineBackend(QObject, Backend):
|
|||
"support_interface": message.time_support_interface,
|
||||
"support": message.time_support,
|
||||
"skirt": message.time_skirt,
|
||||
"prime_tower": message.time_prime_tower,
|
||||
"travel": message.time_travel,
|
||||
"retract": message.time_retract,
|
||||
"none": message.time_none
|
||||
|
|
|
@ -256,10 +256,7 @@ class StartSliceJob(Job):
|
|||
self._buildGlobalInheritsStackMessage(stack)
|
||||
|
||||
# Build messages for extruder stacks
|
||||
# Send the extruder settings in the order of extruder positions. Somehow, if you send e.g. extruder 3 first,
|
||||
# then CuraEngine can slice with the wrong settings. This I think should be fixed in CuraEngine as well.
|
||||
extruder_stack_list = sorted(list(global_stack.extruders.items()), key = lambda item: int(item[0]))
|
||||
for _, extruder_stack in extruder_stack_list:
|
||||
for extruder_stack in global_stack.extruderList:
|
||||
self._buildExtruderMessage(extruder_stack)
|
||||
|
||||
for group in filtered_object_groups:
|
||||
|
@ -334,25 +331,29 @@ class StartSliceJob(Job):
|
|||
|
||||
return result
|
||||
|
||||
def _cacheAllExtruderSettings(self):
|
||||
global_stack = cast(ContainerStack, CuraApplication.getInstance().getGlobalContainerStack())
|
||||
|
||||
# NB: keys must be strings for the string formatter
|
||||
self._all_extruders_settings = {
|
||||
"-1": self._buildReplacementTokens(global_stack)
|
||||
}
|
||||
for extruder_stack in ExtruderManager.getInstance().getActiveExtruderStacks():
|
||||
extruder_nr = extruder_stack.getProperty("extruder_nr", "value")
|
||||
self._all_extruders_settings[str(extruder_nr)] = self._buildReplacementTokens(extruder_stack)
|
||||
|
||||
## Replace setting tokens in a piece of g-code.
|
||||
# \param value A piece of g-code to replace tokens in.
|
||||
# \param default_extruder_nr Stack nr to use when no stack nr is specified, defaults to the global stack
|
||||
def _expandGcodeTokens(self, value: str, default_extruder_nr: int = -1) -> str:
|
||||
if not self._all_extruders_settings:
|
||||
global_stack = cast(ContainerStack, CuraApplication.getInstance().getGlobalContainerStack())
|
||||
|
||||
# NB: keys must be strings for the string formatter
|
||||
self._all_extruders_settings = {
|
||||
"-1": self._buildReplacementTokens(global_stack)
|
||||
}
|
||||
|
||||
for extruder_stack in ExtruderManager.getInstance().getActiveExtruderStacks():
|
||||
extruder_nr = extruder_stack.getProperty("extruder_nr", "value")
|
||||
self._all_extruders_settings[str(extruder_nr)] = self._buildReplacementTokens(extruder_stack)
|
||||
self._cacheAllExtruderSettings()
|
||||
|
||||
try:
|
||||
# any setting can be used as a token
|
||||
fmt = GcodeStartEndFormatter(default_extruder_nr = default_extruder_nr)
|
||||
if self._all_extruders_settings is None:
|
||||
return ""
|
||||
settings = self._all_extruders_settings.copy()
|
||||
settings["default_extruder_nr"] = default_extruder_nr
|
||||
return str(fmt.format(value, **settings))
|
||||
|
@ -364,8 +365,14 @@ class StartSliceJob(Job):
|
|||
def _buildExtruderMessage(self, stack: ContainerStack) -> None:
|
||||
message = self._slice_message.addRepeatedMessage("extruders")
|
||||
message.id = int(stack.getMetaDataEntry("position"))
|
||||
if not self._all_extruders_settings:
|
||||
self._cacheAllExtruderSettings()
|
||||
|
||||
settings = self._buildReplacementTokens(stack)
|
||||
if self._all_extruders_settings is None:
|
||||
return
|
||||
|
||||
extruder_nr = stack.getProperty("extruder_nr", "value")
|
||||
settings = self._all_extruders_settings[str(extruder_nr)].copy()
|
||||
|
||||
# Also send the material GUID. This is a setting in fdmprinter, but we have no interface for it.
|
||||
settings["material_guid"] = stack.material.getMetaDataEntry("GUID", "")
|
||||
|
@ -389,7 +396,13 @@ class StartSliceJob(Job):
|
|||
# The settings are taken from the global stack. This does not include any
|
||||
# per-extruder settings or per-object settings.
|
||||
def _buildGlobalSettingsMessage(self, stack: ContainerStack) -> None:
|
||||
settings = self._buildReplacementTokens(stack)
|
||||
if not self._all_extruders_settings:
|
||||
self._cacheAllExtruderSettings()
|
||||
|
||||
if self._all_extruders_settings is None:
|
||||
return
|
||||
|
||||
settings = self._all_extruders_settings["-1"].copy()
|
||||
|
||||
# Pre-compute material material_bed_temp_prepend and material_print_temp_prepend
|
||||
start_gcode = settings["machine_start_gcode"]
|
||||
|
|
|
@ -370,6 +370,8 @@ class FlavorParser:
|
|||
self._layer_type = LayerPolygon.InfillType
|
||||
elif type == "SUPPORT-INTERFACE":
|
||||
self._layer_type = LayerPolygon.SupportInterfaceType
|
||||
elif type == "PRIME-TOWER":
|
||||
self._layer_type = LayerPolygon.PrimeTowerType
|
||||
else:
|
||||
Logger.log("w", "Encountered a unknown type (%s) while parsing g-code.", type)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ Item
|
|||
|
||||
property int columnWidth: ((parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2) | 0
|
||||
property int columnSpacing: 3 * screenScaleFactor
|
||||
property int propertyStoreIndex: manager.storeContainerIndex // definition_changes
|
||||
property int propertyStoreIndex: manager ? manager.storeContainerIndex : 1 // definition_changes
|
||||
|
||||
property string extruderStackId: ""
|
||||
property int extruderPosition: 0
|
||||
|
|
|
@ -26,7 +26,7 @@ Item
|
|||
|
||||
property int columnWidth: ((parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2) | 0
|
||||
property int columnSpacing: 3 * screenScaleFactor
|
||||
property int propertyStoreIndex: manager.storeContainerIndex // definition_changes
|
||||
property int propertyStoreIndex: manager ? manager.storeContainerIndex : 1 // definition_changes
|
||||
|
||||
property string machineStackId: Cura.MachineManager.activeMachineId
|
||||
|
||||
|
@ -285,18 +285,30 @@ Item
|
|||
optionModel: ListModel
|
||||
{
|
||||
id: extruderCountModel
|
||||
|
||||
Component.onCompleted:
|
||||
{
|
||||
extruderCountModel.clear()
|
||||
update()
|
||||
}
|
||||
|
||||
function update()
|
||||
{
|
||||
clear()
|
||||
for (var i = 1; i <= Cura.MachineManager.activeMachine.maxExtruderCount; i++)
|
||||
{
|
||||
// Use String as value. JavaScript only has Number. PropertyProvider.setPropertyValue()
|
||||
// takes a QVariant as value, and Number gets translated into a float. This will cause problem
|
||||
// for integer settings such as "Number of Extruders".
|
||||
extruderCountModel.append({ text: String(i), value: String(i) })
|
||||
append({ text: String(i), value: String(i) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections
|
||||
{
|
||||
target: Cura.MachineManager
|
||||
onGlobalContainerChanged: extruderCountModel.update()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,15 @@ Rectangle
|
|||
id: viewportOverlay
|
||||
|
||||
property bool isConnected: Cura.MachineManager.activeMachineHasNetworkConnection || Cura.MachineManager.activeMachineHasCloudConnection
|
||||
property bool isNetworkConfigurable: ["Ultimaker 3", "Ultimaker 3 Extended", "Ultimaker S5"].indexOf(Cura.MachineManager.activeMachineDefinitionName) > -1
|
||||
property bool isNetworkConfigurable:
|
||||
{
|
||||
if(Cura.MachineManager.activeMachine === null)
|
||||
{
|
||||
return false
|
||||
}
|
||||
return Cura.MachineManager.activeMachine.supportsNetworkConnection
|
||||
}
|
||||
|
||||
property bool isNetworkConfigured:
|
||||
{
|
||||
// Readability:
|
||||
|
@ -98,7 +106,6 @@ Rectangle
|
|||
width: contentWidth
|
||||
}
|
||||
|
||||
// CASE 3: CAN NOT MONITOR
|
||||
Label
|
||||
{
|
||||
id: noNetworkLabel
|
||||
|
@ -106,24 +113,8 @@ Rectangle
|
|||
{
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
visible: !isNetworkConfigured
|
||||
text: catalog.i18nc("@info", "Please select a network connected printer to monitor.")
|
||||
font: UM.Theme.getFont("medium")
|
||||
color: UM.Theme.getColor("monitor_text_primary")
|
||||
wrapMode: Text.WordWrap
|
||||
width: contentWidth
|
||||
lineHeight: UM.Theme.getSize("monitor_text_line_large").height
|
||||
lineHeightMode: Text.FixedHeight
|
||||
}
|
||||
Label
|
||||
{
|
||||
id: noNetworkUltimakerLabel
|
||||
anchors
|
||||
{
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
visible: !isNetworkConfigured && isNetworkConfigurable
|
||||
text: catalog.i18nc("@info", "Please connect your Ultimaker printer to your local network.")
|
||||
text: catalog.i18nc("@info", "Please connect your printer to the network.")
|
||||
font: UM.Theme.getFont("medium")
|
||||
color: UM.Theme.getColor("monitor_text_primary")
|
||||
wrapMode: Text.WordWrap
|
||||
|
@ -135,7 +126,7 @@ Rectangle
|
|||
{
|
||||
anchors
|
||||
{
|
||||
left: noNetworkUltimakerLabel.left
|
||||
left: noNetworkLabel.left
|
||||
}
|
||||
visible: !isNetworkConfigured && isNetworkConfigurable
|
||||
height: UM.Theme.getSize("monitor_text_line").height
|
||||
|
@ -160,7 +151,7 @@ Rectangle
|
|||
verticalCenter: externalLinkIcon.verticalCenter
|
||||
}
|
||||
color: UM.Theme.getColor("monitor_text_link")
|
||||
font: UM.Theme.getFont("medium") // 14pt, regular
|
||||
font: UM.Theme.getFont("medium")
|
||||
linkColor: UM.Theme.getColor("monitor_text_link")
|
||||
text: catalog.i18nc("@label link to technical assistance", "View user manuals online")
|
||||
renderType: Text.NativeRendering
|
||||
|
@ -170,14 +161,8 @@ Rectangle
|
|||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: Qt.openUrlExternally("https://ultimaker.com/en/resources/manuals/ultimaker-3d-printers")
|
||||
onEntered:
|
||||
{
|
||||
manageQueueText.font.underline = true
|
||||
}
|
||||
onExited:
|
||||
{
|
||||
manageQueueText.font.underline = false
|
||||
}
|
||||
onEntered: manageQueueText.font.underline = true
|
||||
onExited: manageQueueText.font.underline = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# The PostProcessingPlugin is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from UM.Logger import Logger
|
||||
from typing import List
|
||||
from ..Script import Script
|
||||
|
||||
class FilamentChange(Script):
|
||||
|
@ -65,9 +63,10 @@ class FilamentChange(Script):
|
|||
}
|
||||
}"""
|
||||
|
||||
def execute(self, data: list):
|
||||
|
||||
"""data is a list. Each index contains a layer"""
|
||||
## Inserts the filament change g-code at specific layer numbers.
|
||||
# \param data A list of layers of g-code.
|
||||
# \return A similar list, with filament change commands inserted.
|
||||
def execute(self, data: List[str]):
|
||||
layer_nums = self.getSettingValueByKey("layer_number")
|
||||
initial_retract = self.getSettingValueByKey("initial_retract")
|
||||
later_retract = self.getSettingValueByKey("later_retract")
|
||||
|
@ -88,32 +87,13 @@ class FilamentChange(Script):
|
|||
if y_pos is not None:
|
||||
color_change = color_change + (" Y%.2f" % y_pos)
|
||||
|
||||
color_change = color_change + " ; Generated by FilamentChange plugin"
|
||||
color_change = color_change + " ; Generated by FilamentChange plugin\n"
|
||||
|
||||
layer_targets = layer_nums.split(",")
|
||||
if len(layer_targets) > 0:
|
||||
for layer_num in layer_targets:
|
||||
layer_num = int(layer_num.strip())
|
||||
layer_num = int(layer_num.strip()) + 1
|
||||
if layer_num <= len(data):
|
||||
index, layer_data = self._searchLayerData(data, layer_num - 1)
|
||||
if layer_data is None:
|
||||
Logger.log("e", "Could not find the layer {layer_num}".format(layer_num = layer_num))
|
||||
continue
|
||||
lines = layer_data.split("\n")
|
||||
lines.insert(2, color_change)
|
||||
final_line = "\n".join(lines)
|
||||
data[index] = final_line
|
||||
data[layer_num] = color_change + data[layer_num]
|
||||
|
||||
return data
|
||||
|
||||
## This method returns the data corresponding with the indicated layer number, looking in the gcode for
|
||||
# the occurrence of this layer number.
|
||||
def _searchLayerData(self, data: list, layer_num: int) -> Tuple[int, Optional[str]]:
|
||||
for index, layer_data in enumerate(data):
|
||||
first_line = layer_data.split("\n")[0]
|
||||
# The first line should contain the layer number at the beginning.
|
||||
if first_line[:len(self._layer_keyword)] == self._layer_keyword:
|
||||
# If found the layer that we are looking for, then return the data
|
||||
if first_line[len(self._layer_keyword):] == str(layer_num):
|
||||
return index, layer_data
|
||||
return 0, None
|
||||
return data
|
|
@ -20,11 +20,19 @@ Item
|
|||
name: "cura"
|
||||
}
|
||||
|
||||
anchors
|
||||
{
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: UM.Theme.getSize("wide_margin").width
|
||||
rightMargin: UM.Theme.getSize("wide_margin").width
|
||||
}
|
||||
|
||||
// Item to ensure that all of the buttons are nicely centered.
|
||||
Item
|
||||
{
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: openFileButton.width + itemRow.width + UM.Theme.getSize("default_margin").width
|
||||
width: parent.width - 2 * UM.Theme.getSize("wide_margin").width
|
||||
height: parent.height
|
||||
|
||||
RowLayout
|
||||
|
@ -32,9 +40,9 @@ Item
|
|||
id: itemRow
|
||||
|
||||
anchors.left: openFileButton.right
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||
|
||||
width: Math.round(0.9 * prepareMenu.width)
|
||||
height: parent.height
|
||||
spacing: 0
|
||||
|
||||
|
|
|
@ -20,15 +20,21 @@ Item
|
|||
name: "cura"
|
||||
}
|
||||
|
||||
anchors
|
||||
{
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: UM.Theme.getSize("wide_margin").width
|
||||
rightMargin: UM.Theme.getSize("wide_margin").width
|
||||
}
|
||||
|
||||
Row
|
||||
{
|
||||
id: stageMenuRow
|
||||
anchors.centerIn: parent
|
||||
height: parent.height
|
||||
width: childrenRect.width
|
||||
|
||||
// We want this row to have a preferred with equals to the 85% of the parent
|
||||
property int preferredWidth: Math.round(0.85 * previewMenu.width)
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width - 2 * UM.Theme.getSize("wide_margin").width
|
||||
height: parent.height
|
||||
|
||||
Cura.ViewsSelector
|
||||
{
|
||||
|
@ -49,12 +55,12 @@ Item
|
|||
color: UM.Theme.getColor("lining")
|
||||
}
|
||||
|
||||
// This component will grow freely up to complete the preferredWidth of the row.
|
||||
// This component will grow freely up to complete the width of the row.
|
||||
Loader
|
||||
{
|
||||
id: viewPanel
|
||||
height: parent.height
|
||||
width: source != "" ? (stageMenuRow.preferredWidth - viewsSelector.width - printSetupSelectorItem.width - 2 * UM.Theme.getSize("default_lining").width) : 0
|
||||
width: source != "" ? (previewMenu.width - viewsSelector.width - printSetupSelectorItem.width - 2 * (UM.Theme.getSize("wide_margin").width + UM.Theme.getSize("default_lining").width)) : 0
|
||||
source: UM.Controller.activeView != null && UM.Controller.activeView.stageMenuComponent != null ? UM.Controller.activeView.stageMenuComponent : ""
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ Cura.ExpandableComponent
|
|||
{
|
||||
id: base
|
||||
|
||||
dragPreferencesNamePrefix: "view/colorscheme"
|
||||
|
||||
contentHeaderTitle: catalog.i18nc("@label", "Color scheme")
|
||||
|
||||
Connections
|
||||
|
|
|
@ -71,7 +71,7 @@ Window
|
|||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
text: catalog.i18nc("@text:window", "Cura sends anonymous data to Ultimaker in order to improve the print quality and user experience. Below is an example of all the data that is sent.")
|
||||
text: catalog.i18nc("@text:window", "Ultimaker Cura collects anonymous data in order to improve the print quality and user experience. Below is an example of all the data that is shared:")
|
||||
wrapMode: Text.WordWrap
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
@ -89,6 +89,8 @@ Window
|
|||
}
|
||||
|
||||
textArea.text: manager.getExampleData()
|
||||
textArea.textFormat: Text.RichText
|
||||
textArea.wrapMode: Text.Wrap
|
||||
textArea.readOnly: true
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +106,7 @@ Window
|
|||
Cura.RadioButton
|
||||
{
|
||||
id: dontSendButton
|
||||
text: catalog.i18nc("@text:window", "I don't want to send this data")
|
||||
text: catalog.i18nc("@text:window", "I don't want to send anonymous data")
|
||||
onClicked:
|
||||
{
|
||||
baseDialog.allowSendData = !checked
|
||||
|
@ -113,7 +115,7 @@ Window
|
|||
Cura.RadioButton
|
||||
{
|
||||
id: allowSendButton
|
||||
text: catalog.i18nc("@text:window", "Allow sending this data to Ultimaker and help us improve Cura")
|
||||
text: catalog.i18nc("@text:window", "Allow sending anonymous data")
|
||||
onClicked:
|
||||
{
|
||||
baseDialog.allowSendData = checked
|
||||
|
|
|
@ -77,7 +77,7 @@ class SliceInfo(QObject, Extension):
|
|||
if not plugin_path:
|
||||
Logger.log("e", "Could not get plugin path!", self.getPluginId())
|
||||
return None
|
||||
file_path = os.path.join(plugin_path, "example_data.json")
|
||||
file_path = os.path.join(plugin_path, "example_data.html")
|
||||
if file_path:
|
||||
with open(file_path, "r", encoding = "utf-8") as f:
|
||||
self._example_data_content = f.read()
|
||||
|
|
64
plugins/SliceInfoPlugin/example_data.html
Normal file
64
plugins/SliceInfoPlugin/example_data.html
Normal file
|
@ -0,0 +1,64 @@
|
|||
<html>
|
||||
<body>
|
||||
<b>Cura Version:</b> 4.0<br/>
|
||||
<b>Operating System:</b> Windows 10<br/>
|
||||
<b>Language:</b> en_US<br/>
|
||||
<b>Machine Type:</b> Ultimaker S5<br/>
|
||||
<b>Quality Profile:</b> Fast<br/>
|
||||
<b>Using Custom Settings:</b> No
|
||||
|
||||
<h3>Extruder 1:</h3>
|
||||
<ul>
|
||||
<li><b>Material Type:</b> PLA</li>
|
||||
<li><b>Print Core:</b> AA 0.4</li>
|
||||
<li><b>Material Used:</b> 1240 mm</li>
|
||||
</ul>
|
||||
|
||||
<h3>Extruder 2:</h3>
|
||||
<ul>
|
||||
<li><b>Material Type:</b> PVA</li>
|
||||
<li><b>Print Core:</b> BB 0.4</li>
|
||||
<li><b>Material Used:</b> 432 mm</li>
|
||||
</ul>
|
||||
|
||||
<h3>Print Settings:</h3>
|
||||
<ul>
|
||||
<li><b>Layer Height:</b> 0.15</li>
|
||||
<li><b>Wall Line Count:</b> 3</li>
|
||||
<li><b>Enable Retraction:</b> no</li>
|
||||
<li><b>Infill Density:</b> 20%</li>
|
||||
<li><b>Infill Pattern:</b> triangles</li>
|
||||
<li><b>Gradual Infill Steps:</b> 0</li>
|
||||
<li><b>Printing Temperature:</b> 220 °C</li>
|
||||
<li><b>Generate Support:</b> yes</li>
|
||||
<li><b>Support Extruder:</b> 1</li>
|
||||
<li><b>Build Plate Adhesion Type:</b> brim</li>
|
||||
<li><b>Enable Prime Tower:</b> yes</li>
|
||||
<li><b>Print Sequence:</b> All at once</li>
|
||||
<li>...</li>
|
||||
</ul>
|
||||
|
||||
<h3>Model Information:</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<b>Model 1</b>
|
||||
<ul>
|
||||
<li><b>Hash:</b> b72789b9b...</li>
|
||||
<li><b>Transformation:</b> [transformation matrix]</li>
|
||||
<li><b>Bounding Box:</b> [minimum x, y, z; maximum x, y, z]</li>
|
||||
<li><b>Is Helper Mesh:</b> no</li>
|
||||
<li><b>Helper Mesh Type:</b> support mesh</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Print Times:</h3>
|
||||
<ul>
|
||||
<li>Infill: 61200 sec.</li>
|
||||
<li>Support: 25480 sec.</li>
|
||||
<li>Travel: 6224 sec.</li>
|
||||
<li>Walls: 10225 sec.</li>
|
||||
<li>Total: 103129 sec.</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -1,114 +0,0 @@
|
|||
{
|
||||
"time_stamp": 1523973715.486928,
|
||||
"schema_version": 0,
|
||||
"cura_version": "3.3",
|
||||
"active_mode": "custom",
|
||||
"machine_settings_changed_by_user": true,
|
||||
"language": "en_US",
|
||||
"os": {
|
||||
"type": "Linux",
|
||||
"version": "#43~16.04.1-Ubuntu SMP Wed Mar 14 17:48:43 UTC 2018"
|
||||
},
|
||||
"active_machine": {
|
||||
"definition_id": "ultimaker3",
|
||||
"manufacturer": "Ultimaker B.V."
|
||||
},
|
||||
"extruders": [
|
||||
{
|
||||
"active": true,
|
||||
"material": {
|
||||
"GUID": "506c9f0d-e3aa-4bd4-b2d2-23e2425b1aa9",
|
||||
"type": "PLA",
|
||||
"brand": "Generic"
|
||||
},
|
||||
"material_used": 0.84,
|
||||
"variant": "AA 0.4",
|
||||
"nozzle_size": 0.4,
|
||||
"extruder_settings": {
|
||||
"wall_line_count": 3,
|
||||
"retraction_enable": true,
|
||||
"infill_sparse_density": 30,
|
||||
"infill_pattern": "triangles",
|
||||
"gradual_infill_steps": 0,
|
||||
"default_material_print_temperature": 200,
|
||||
"material_print_temperature": 200
|
||||
}
|
||||
},
|
||||
{
|
||||
"active": false,
|
||||
"material": {
|
||||
"GUID": "86a89ceb-4159-47f6-ab97-e9953803d70f",
|
||||
"type": "PVA",
|
||||
"brand": "Generic"
|
||||
},
|
||||
"material_used": 0.5,
|
||||
"variant": "BB 0.4",
|
||||
"nozzle_size": 0.4,
|
||||
"extruder_settings": {
|
||||
"wall_line_count": 3,
|
||||
"retraction_enable": true,
|
||||
"infill_sparse_density": 20,
|
||||
"infill_pattern": "triangles",
|
||||
"gradual_infill_steps": 0,
|
||||
"default_material_print_temperature": 215,
|
||||
"material_print_temperature": 220
|
||||
}
|
||||
}
|
||||
],
|
||||
"quality_profile": "fast",
|
||||
"user_modified_setting_keys": ["layer_height", "wall_line_width", "infill_sparse_density"],
|
||||
"models": [
|
||||
{
|
||||
"hash": "b72789b9beb5366dff20b1cf501020c3d4d4df7dc2295ecd0fddd0a6436df070",
|
||||
"bounding_box": {
|
||||
"minimum": {
|
||||
"x": -10.0,
|
||||
"y": 0.0,
|
||||
"z": -5.0
|
||||
},
|
||||
"maximum": {
|
||||
"x": 9.999999046325684,
|
||||
"y": 40.0,
|
||||
"z": 5.0
|
||||
}
|
||||
},
|
||||
"transformation": {
|
||||
"data": "[[ 1. 0. 0. 0.] [ 0. 1. 0. 20.] [ 0. 0. 1. 0.] [ 0. 0. 0. 1.]]"
|
||||
},
|
||||
"extruder": 0,
|
||||
"model_settings": {
|
||||
"support_enabled": true,
|
||||
"support_extruder_nr": 1,
|
||||
"infill_mesh": false,
|
||||
"cutting_mesh": false,
|
||||
"support_mesh": false,
|
||||
"anti_overhang_mesh": false,
|
||||
"wall_line_count": 3,
|
||||
"retraction_enable": true,
|
||||
"infill_sparse_density": 30,
|
||||
"infill_pattern": "triangles",
|
||||
"gradual_infill_steps": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"print_times": {
|
||||
"travel": 187,
|
||||
"support": 825,
|
||||
"infill": 351,
|
||||
"total": 7234
|
||||
},
|
||||
"print_settings": {
|
||||
"layer_height": 0.15,
|
||||
"support_enabled": true,
|
||||
"support_extruder_nr": 1,
|
||||
"adhesion_type": "brim",
|
||||
"wall_line_count": 3,
|
||||
"retraction_enable": true,
|
||||
"prime_tower_enable": true,
|
||||
"infill_sparse_density": 20,
|
||||
"infill_pattern": "triangles",
|
||||
"gradual_infill_steps": 0,
|
||||
"print_sequence": "all_at_once"
|
||||
},
|
||||
"output_to": "LocalFileOutputDevice"
|
||||
}
|
|
@ -19,7 +19,7 @@ import math
|
|||
class SolidView(View):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
application = Application.getInstance()
|
||||
application = Application.getInstance()
|
||||
application.getPreferences().addPreference("view/show_overhang", True)
|
||||
application.globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||
self._enabled_shader = None
|
||||
|
@ -58,7 +58,7 @@ class SolidView(View):
|
|||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
if global_container_stack:
|
||||
support_extruder_nr = global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr")
|
||||
support_angle_stack = Application.getInstance().getExtruderManager().getExtruderStack(support_extruder_nr)
|
||||
support_angle_stack = global_container_stack.extruders.get(str(support_extruder_nr))
|
||||
if support_angle_stack:
|
||||
self._support_angle = support_angle_stack.getProperty("support_angle", "value")
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ Item
|
|||
top: description.bottom
|
||||
left: properties.right
|
||||
leftMargin: UM.Theme.getSize("default_margin").width
|
||||
right: parent.right
|
||||
rightMargin: UM.Theme.getSize("default_margin").width
|
||||
topMargin: UM.Theme.getSize("default_margin").height
|
||||
}
|
||||
spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
|
||||
|
@ -123,6 +125,8 @@ Item
|
|||
}
|
||||
return ""
|
||||
}
|
||||
width: parent.width
|
||||
elide: Text.ElideRight
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
linkColor: UM.Theme.getColor("text_link")
|
||||
|
|
|
@ -40,6 +40,7 @@ Column
|
|||
|
||||
Cura.SecondaryButton
|
||||
{
|
||||
id: installedButton
|
||||
visible: installed
|
||||
onClicked: toolbox.viewCategory = "installed"
|
||||
text: catalog.i18nc("@action:button", "Installed")
|
||||
|
|
|
@ -105,6 +105,7 @@ class Toolbox(QObject, Extension):
|
|||
|
||||
self._application.initializationFinished.connect(self._onAppInitialized)
|
||||
self._application.getCuraAPI().account.loginStateChanged.connect(self._updateRequestHeader)
|
||||
self._application.getCuraAPI().account.accessTokenChanged.connect(self._updateRequestHeader)
|
||||
|
||||
# Signals:
|
||||
# --------------------------------------------------------------------------
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
#Copyright (c) 2019 Ultimaker B.V.
|
||||
#Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import sys
|
||||
|
||||
from UM.Logger import Logger
|
||||
try:
|
||||
from . import UFPReader
|
||||
except ImportError:
|
||||
Logger.log("w", "Could not import UFPReader; libCharon may be missing")
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
|
||||
from . import UFPReader
|
||||
|
||||
i18n_catalog = i18nCatalog("cura")
|
||||
|
||||
|
||||
|
@ -21,6 +26,9 @@ def getMetaData():
|
|||
|
||||
|
||||
def register(app):
|
||||
if "UFPReader.UFPReader" not in sys.modules:
|
||||
return {}
|
||||
|
||||
app.addNonSliceableExtension(".ufp")
|
||||
return {"mesh_reader": UFPReader.UFPReader()}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright (c) 2018 Ultimaker B.V.
|
||||
// Copyright (c) 2019 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
import Cura 1.5 as Cura
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.1
|
||||
|
@ -14,22 +14,27 @@ Cura.MachineAction
|
|||
{
|
||||
id: base
|
||||
anchors.fill: parent;
|
||||
property alias currentItemIndex: listview.currentIndex
|
||||
property var selectedDevice: null
|
||||
property bool completeProperties: true
|
||||
|
||||
// For validating IP addresses
|
||||
property var networkingUtil: Cura.NetworkingUtil {}
|
||||
|
||||
function connectToPrinter()
|
||||
{
|
||||
if(base.selectedDevice && base.completeProperties)
|
||||
{
|
||||
var printerKey = base.selectedDevice.key
|
||||
var printerName = base.selectedDevice.name // TODO To change when the groups have a name
|
||||
if (manager.getStoredKey() != printerKey)
|
||||
if (Cura.API.machines.getCurrentMachine().um_network_key != printerKey) // TODO: change to hostname
|
||||
{
|
||||
// Check if there is another instance with the same key
|
||||
if (!manager.existsKey(printerKey))
|
||||
{
|
||||
manager.associateActiveMachineWithPrinterDevice(base.selectedDevice)
|
||||
manager.setGroupName(printerName) // TODO To change when the groups have a name
|
||||
Cura.API.machines.addOutputDeviceToCurrentMachine(base.selectedDevice)
|
||||
Cura.API.machines.setCurrentMachineGroupName(printerName) // TODO To change when the groups have a name
|
||||
manager.refreshConnections()
|
||||
completed()
|
||||
}
|
||||
else
|
||||
|
@ -152,7 +157,7 @@ Cura.MachineAction
|
|||
var selectedKey = manager.getLastManualEntryKey()
|
||||
// If there is no last manual entry key, then we select the stored key (if any)
|
||||
if (selectedKey == "")
|
||||
selectedKey = manager.getStoredKey()
|
||||
selectedKey = Cura.API.machines.getCurrentMachine().um_network_key // TODO: change to host name
|
||||
for(var i = 0; i < model.length; i++) {
|
||||
if(model[i].key == selectedKey)
|
||||
{
|
||||
|
@ -342,6 +347,17 @@ Cura.MachineAction
|
|||
}
|
||||
}
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: invalidIPAddressMessageDialog
|
||||
x: (parent.x + (parent.width) / 2) | 0
|
||||
y: (parent.y + (parent.height) / 2) | 0
|
||||
title: catalog.i18nc("@title:window", "Invalid IP address")
|
||||
text: catalog.i18nc("@text", "Please enter a valid IP address.")
|
||||
icon: StandardIcon.Warning
|
||||
standardButtons: StandardButton.Ok
|
||||
}
|
||||
|
||||
UM.Dialog
|
||||
{
|
||||
id: manualPrinterDialog
|
||||
|
@ -404,6 +420,26 @@ Cura.MachineAction
|
|||
text: catalog.i18nc("@action:button", "OK")
|
||||
onClicked:
|
||||
{
|
||||
// Validate the input first
|
||||
if (!networkingUtil.isValidIP(manualPrinterDialog.addressText))
|
||||
{
|
||||
invalidIPAddressMessageDialog.open()
|
||||
return
|
||||
}
|
||||
|
||||
// if the entered IP address has already been discovered, switch the current item to that item
|
||||
// and do nothing else.
|
||||
for (var i = 0; i < manager.foundDevices.length; i++)
|
||||
{
|
||||
var device = manager.foundDevices[i]
|
||||
if (device.address == manualPrinterDialog.addressText)
|
||||
{
|
||||
currentItemIndex = i
|
||||
manualPrinterDialog.hide()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
manager.setManualDevice(manualPrinterDialog.printerKey, manualPrinterDialog.addressText)
|
||||
manualPrinterDialog.hide()
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,21 @@ UM.Dialog
|
|||
OutputDevice.forceSendJob(printer.activePrintJob.key)
|
||||
overrideConfirmationDialog.close()
|
||||
}
|
||||
visible:
|
||||
{
|
||||
if (!printer || !printer.activePrintJob)
|
||||
{
|
||||
return true
|
||||
}
|
||||
|
||||
var canOverride = false
|
||||
for (var i = 0; i < printer.activePrintJob.configurationChanges.length; i++)
|
||||
{
|
||||
var change = printer.activePrintJob.configurationChanges[i]
|
||||
canOverride = canOverride || change.typeOfChange === "material_change";
|
||||
}
|
||||
return canOverride
|
||||
}
|
||||
},
|
||||
Button
|
||||
{
|
||||
|
@ -52,6 +67,7 @@ UM.Dialog
|
|||
bottomMargin: 56 * screenScaleFactor // TODO: Theme!
|
||||
}
|
||||
wrapMode: Text.WordWrap
|
||||
renderType: Text.NativeRendering
|
||||
text:
|
||||
{
|
||||
if (!printer || !printer.activePrintJob)
|
||||
|
|
|
@ -23,6 +23,7 @@ Button
|
|||
horizontalAlignment: Text.AlignHCenter
|
||||
text: base.text
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering;
|
||||
}
|
||||
height: width
|
||||
hoverEnabled: enabled
|
||||
|
|
|
@ -66,6 +66,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: parent.height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +96,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: parent.height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,5 +48,6 @@ Item
|
|||
x: Math.round(size * 0.25)
|
||||
y: Math.round(size * 0.15625)
|
||||
visible: position >= 0
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
|
@ -40,6 +40,7 @@ Item
|
|||
width: 240 * screenScaleFactor // TODO: Theme!
|
||||
color: UM.Theme.getColor("monitor_tooltip_text")
|
||||
font: UM.Theme.getFont("default")
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: parent.height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -98,6 +99,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,6 +145,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: parent.height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
||||
Row
|
||||
|
@ -158,14 +161,9 @@ Item
|
|||
spacing: 6 // TODO: Theme!
|
||||
visible: printJob
|
||||
|
||||
Repeater
|
||||
MonitorPrinterPill
|
||||
{
|
||||
id: compatiblePills
|
||||
delegate: MonitorPrinterPill
|
||||
{
|
||||
text: modelData
|
||||
}
|
||||
model: printJob ? printJob.compatibleMachineFamilies : []
|
||||
text: printJob.configuration.printerType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,6 +200,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
Label
|
||||
{
|
||||
|
@ -99,5 +100,6 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
|
@ -112,6 +112,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: parent.height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,6 +316,7 @@ Item
|
|||
return ""
|
||||
}
|
||||
visible: text !== ""
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
||||
Item
|
||||
|
@ -356,6 +358,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
||||
Label
|
||||
|
@ -376,6 +379,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,6 +407,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,6 +442,7 @@ Item
|
|||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
implicitHeight: 32 * screenScaleFactor // TODO: Theme!
|
||||
implicitWidth: 96 * screenScaleFactor // TODO: Theme!
|
||||
|
|
|
@ -43,5 +43,6 @@ Item
|
|||
text: tagText
|
||||
font.pointSize: 10 // TODO: Theme!
|
||||
visible: text !== ""
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ Item
|
|||
color: UM.Theme.getColor("monitor_text_primary")
|
||||
font: UM.Theme.getFont("large")
|
||||
text: catalog.i18nc("@label", "Queued")
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
||||
Item
|
||||
|
@ -109,6 +110,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
||||
Label
|
||||
|
@ -123,6 +125,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
||||
Label
|
||||
|
@ -137,6 +140,7 @@ Item
|
|||
// FIXED-LINE-HEIGHT:
|
||||
height: 18 * screenScaleFactor // TODO: Theme!
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,6 +217,7 @@ Item
|
|||
text: i18n.i18nc("@info", "All jobs are printed.")
|
||||
color: UM.Theme.getColor("monitor_text_primary")
|
||||
font: UM.Theme.getFont("medium") // 14pt, regular
|
||||
renderType: Text.NativeRendering
|
||||
}
|
||||
|
||||
Item
|
||||
|
|
|
@ -16,6 +16,7 @@ Button {
|
|||
text: parent.text
|
||||
horizontalAlignment: Text.AlignLeft;
|
||||
verticalAlignment: Text.AlignVCenter;
|
||||
renderType: Text.NativeRendering;
|
||||
}
|
||||
height: visible ? 39 * screenScaleFactor : 0; // TODO: Theme!
|
||||
hoverEnabled: true;
|
||||
|
|
|
@ -78,6 +78,7 @@ UM.Dialog {
|
|||
height: 20 * screenScaleFactor;
|
||||
text: catalog.i18nc("@label", "Printer selection");
|
||||
wrapMode: Text.Wrap;
|
||||
renderType: Text.NativeRendering;
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
|
|
|
@ -535,6 +535,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
|
|||
extruder.setMaterial(self._createMaterialOutputModel(extruder_data.get("material", {})))
|
||||
|
||||
configuration.setExtruderConfigurations(extruders)
|
||||
configuration.setPrinterType(data.get("machine_variant", ""))
|
||||
print_job.updateConfiguration(configuration)
|
||||
print_job.setCompatibleMachineFamilies(data.get("compatible_machine_families", []))
|
||||
print_job.stateChanged.connect(self._printJobStateChanged)
|
||||
|
|
|
@ -34,7 +34,10 @@ class DiscoverUM3Action(MachineAction):
|
|||
|
||||
self.__additional_components_view = None #type: Optional[QObject]
|
||||
|
||||
CuraApplication.getInstance().engineCreatedSignal.connect(self._createAdditionalComponentsView)
|
||||
self._application = CuraApplication.getInstance()
|
||||
self._api = self._application.getCuraAPI()
|
||||
|
||||
self._application.engineCreatedSignal.connect(self._createAdditionalComponentsView)
|
||||
|
||||
self._last_zero_conf_event_time = time.time() #type: float
|
||||
|
||||
|
@ -50,7 +53,7 @@ class DiscoverUM3Action(MachineAction):
|
|||
def startDiscovery(self):
|
||||
if not self._network_plugin:
|
||||
Logger.log("d", "Starting device discovery.")
|
||||
self._network_plugin = CuraApplication.getInstance().getOutputDeviceManager().getOutputDevicePlugin("UM3NetworkPrinting")
|
||||
self._network_plugin = self._application.getOutputDeviceManager().getOutputDevicePlugin("UM3NetworkPrinting")
|
||||
self._network_plugin.discoveredDevicesChanged.connect(self._onDeviceDiscoveryChanged)
|
||||
self.discoveredDevicesChanged.emit()
|
||||
|
||||
|
@ -105,72 +108,27 @@ class DiscoverUM3Action(MachineAction):
|
|||
else:
|
||||
return []
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setGroupName(self, group_name: str) -> None:
|
||||
Logger.log("d", "Attempting to set the group name of the active machine to %s", group_name)
|
||||
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
||||
if global_container_stack:
|
||||
meta_data = global_container_stack.getMetaData()
|
||||
if "group_name" in meta_data:
|
||||
previous_connect_group_name = meta_data["group_name"]
|
||||
global_container_stack.setMetaDataEntry("group_name", group_name)
|
||||
# Find all the places where there is the same group name and change it accordingly
|
||||
self._replaceContainersMetadata(key = "group_name", value = previous_connect_group_name, new_value = group_name)
|
||||
else:
|
||||
global_container_stack.setMetaDataEntry("group_name", group_name)
|
||||
# Set the default value for "hidden", which is used when you have a group with multiple types of printers
|
||||
global_container_stack.setMetaDataEntry("hidden", False)
|
||||
|
||||
@pyqtSlot()
|
||||
def refreshConnections(self) -> None:
|
||||
if self._network_plugin:
|
||||
# Ensure that the connection states are refreshed.
|
||||
self._network_plugin.refreshConnections()
|
||||
|
||||
## Find all container stacks that has the pair 'key = value' in its metadata and replaces the value with 'new_value'
|
||||
def _replaceContainersMetadata(self, key: str, value: str, new_value: str) -> None:
|
||||
machines = CuraContainerRegistry.getInstance().findContainerStacks(type="machine")
|
||||
for machine in machines:
|
||||
if machine.getMetaDataEntry(key) == value:
|
||||
machine.setMetaDataEntry(key, new_value)
|
||||
|
||||
# Associates the currently active machine with the given printer device. The network connection information will be
|
||||
# stored into the metadata of the currently active machine.
|
||||
@pyqtSlot(QObject)
|
||||
def associateActiveMachineWithPrinterDevice(self, printer_device: Optional["PrinterOutputDevice"]) -> None:
|
||||
if self._network_plugin:
|
||||
self._network_plugin.associateActiveMachineWithPrinterDevice(printer_device)
|
||||
|
||||
@pyqtSlot(result = str)
|
||||
def getStoredKey(self) -> str:
|
||||
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
||||
if global_container_stack:
|
||||
meta_data = global_container_stack.getMetaData()
|
||||
if "um_network_key" in meta_data:
|
||||
return global_container_stack.getMetaDataEntry("um_network_key")
|
||||
|
||||
return ""
|
||||
|
||||
# TODO: Improve naming
|
||||
# TODO: CHANGE TO HOSTNAME
|
||||
@pyqtSlot(result = str)
|
||||
def getLastManualEntryKey(self) -> str:
|
||||
if self._network_plugin:
|
||||
return self._network_plugin.getLastManualDevice()
|
||||
return ""
|
||||
|
||||
# TODO: Better naming needed. Exists where? On the current machine? On all machines?
|
||||
# TODO: CHANGE TO HOSTNAME
|
||||
@pyqtSlot(str, result = bool)
|
||||
def existsKey(self, key: str) -> bool:
|
||||
metadata_filter = {"um_network_key": key}
|
||||
containers = CuraContainerRegistry.getInstance().findContainerStacks(type="machine", **metadata_filter)
|
||||
return bool(containers)
|
||||
|
||||
@pyqtSlot()
|
||||
def loadConfigurationFromPrinter(self) -> None:
|
||||
machine_manager = CuraApplication.getInstance().getMachineManager()
|
||||
hotend_ids = machine_manager.printerOutputDevices[0].hotendIds
|
||||
for index in range(len(hotend_ids)):
|
||||
machine_manager.printerOutputDevices[0].hotendIdChanged.emit(index, hotend_ids[index])
|
||||
material_ids = machine_manager.printerOutputDevices[0].materialIds
|
||||
for index in range(len(material_ids)):
|
||||
machine_manager.printerOutputDevices[0].materialIdChanged.emit(index, material_ids[index])
|
||||
|
||||
def _createAdditionalComponentsView(self) -> None:
|
||||
Logger.log("d", "Creating additional ui components for UM3.")
|
||||
|
||||
|
@ -179,10 +137,10 @@ class DiscoverUM3Action(MachineAction):
|
|||
if not plugin_path:
|
||||
return
|
||||
path = os.path.join(plugin_path, "resources/qml/UM3InfoComponents.qml")
|
||||
self.__additional_components_view = CuraApplication.getInstance().createQmlComponent(path, {"manager": self})
|
||||
self.__additional_components_view = self._application.createQmlComponent(path, {"manager": self})
|
||||
if not self.__additional_components_view:
|
||||
Logger.log("w", "Could not create ui components for UM3.")
|
||||
return
|
||||
|
||||
# Create extra components
|
||||
CuraApplication.getInstance().addAdditionalComponent("monitorButtons", self.__additional_components_view.findChild(QObject, "networkPrinterConnectButton"))
|
||||
self._application.addAdditionalComponent("monitorButtons", self.__additional_components_view.findChild(QObject, "networkPrinterConnectButton"))
|
||||
|
|
|
@ -5,11 +5,11 @@ import os
|
|||
from queue import Queue
|
||||
from threading import Event, Thread
|
||||
from time import time
|
||||
from typing import Optional, TYPE_CHECKING, Dict
|
||||
from typing import Optional, TYPE_CHECKING, Dict, Callable
|
||||
|
||||
from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, ServiceInfo
|
||||
|
||||
from PyQt5.QtNetwork import QNetworkRequest, QNetworkAccessManager
|
||||
from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply, QNetworkAccessManager
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
|
||||
|
@ -39,6 +39,22 @@ if TYPE_CHECKING:
|
|||
i18n_catalog = i18nCatalog("cura")
|
||||
|
||||
|
||||
#
|
||||
# Represents a request for adding a manual printer. It has the following fields:
|
||||
# - address: The string of the (IP) address of the manual printer
|
||||
# - callback: (Optional) Once the HTTP request to the printer to get printer information is done, whether successful
|
||||
# or not, this callback will be invoked to notify about the result. The callback must have a signature of
|
||||
# func(success: bool, address: str) -> None
|
||||
# - network_reply: This is the QNetworkReply instance for this request if the request has been issued and still in
|
||||
# progress. It is kept here so we can cancel a request when needed.
|
||||
#
|
||||
class ManualPrinterRequest:
|
||||
def __init__(self, address: str, callback: Optional[Callable[[bool, str], None]] = None) -> None:
|
||||
self.address = address
|
||||
self.callback = callback
|
||||
self.network_reply = None # type: Optional["QNetworkReply"]
|
||||
|
||||
|
||||
## This plugin handles the connection detection & creation of output device objects for the UM3 printer.
|
||||
# Zero-Conf is used to detect printers, which are saved in a dict.
|
||||
# If we discover a printer that has the same key as the active machine instance a connection is made.
|
||||
|
@ -51,11 +67,11 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self._zero_conf = None
|
||||
self._zero_conf_browser = None
|
||||
|
||||
self._application = CuraApplication.getInstance()
|
||||
self._api = self._application.getCuraAPI()
|
||||
|
||||
# Create a cloud output device manager that abstracts all cloud connection logic away.
|
||||
self._cloud_output_device_manager = CloudOutputDeviceManager()
|
||||
|
@ -80,14 +96,16 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self._cluster_api_prefix = "/cluster-api/v" + self._cluster_api_version + "/"
|
||||
|
||||
# Get list of manual instances from preferences
|
||||
self._preferences = CuraApplication.getInstance().getPreferences()
|
||||
self._preferences = self._application.getPreferences()
|
||||
self._preferences.addPreference("um3networkprinting/manual_instances",
|
||||
"") # A comma-separated list of ip adresses or hostnames
|
||||
|
||||
self._manual_instances = self._preferences.getValue("um3networkprinting/manual_instances").split(",")
|
||||
manual_instances = self._preferences.getValue("um3networkprinting/manual_instances").split(",")
|
||||
self._manual_instances = {address: ManualPrinterRequest(address)
|
||||
for address in manual_instances} # type: Dict[str, ManualPrinterRequest]
|
||||
|
||||
# Store the last manual entry key
|
||||
self._last_manual_entry_key = "" # type: str
|
||||
self._last_manual_entry_key = "" # type: str
|
||||
|
||||
# The zero-conf service changed requests are handled in a separate thread, so we can re-schedule the requests
|
||||
# which fail to get detailed service info.
|
||||
|
@ -98,7 +116,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self._service_changed_request_thread = Thread(target=self._handleOnServiceChangedRequests, daemon=True)
|
||||
self._service_changed_request_thread.start()
|
||||
|
||||
self._account = self._application.getCuraAPI().account
|
||||
self._account = self._api.account
|
||||
|
||||
# Check if cloud flow is possible when user logs in
|
||||
self._account.loginStateChanged.connect(self.checkCloudFlowIsPossible)
|
||||
|
@ -149,10 +167,11 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
for address in self._manual_instances:
|
||||
if address:
|
||||
self.addManualDevice(address)
|
||||
self.resetLastManualDevice()
|
||||
|
||||
self.resetLastManu
|
||||
|
||||
# TODO: CHANGE TO HOSTNAME
|
||||
def refreshConnections(self):
|
||||
active_machine = CuraApplication.getInstance().getGlobalContainerStack()
|
||||
active_machine = self._application.getGlobalContainerStack()
|
||||
if not active_machine:
|
||||
return
|
||||
|
||||
|
@ -179,14 +198,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
return
|
||||
if self._discovered_devices[key].isConnected():
|
||||
# Sometimes the status changes after changing the global container and maybe the device doesn't belong to this machine
|
||||
um_network_key = CuraApplication.getInstance().getGlobalContainerStack().getMetaDataEntry("um_network_key")
|
||||
um_network_key = self._application.getGlobalContainerStack().getMetaDataEntry("um_network_key")
|
||||
if key == um_network_key:
|
||||
self.getOutputDeviceManager().addOutputDevice(self._discovered_devices[key])
|
||||
self.checkCloudFlowIsPossible(None)
|
||||
else:
|
||||
self.getOutputDeviceManager().removeOutputDevice(key)
|
||||
if key.startswith("manual:"):
|
||||
self.removeManualDeviceSignal.emit(self.getPluginId(), key, self._discovered_devices[key].address)
|
||||
|
||||
def stop(self):
|
||||
if self._zero_conf is not None:
|
||||
|
@ -198,7 +215,10 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
# This plugin should always be the fallback option (at least try it):
|
||||
return ManualDeviceAdditionAttempt.POSSIBLE
|
||||
|
||||
def removeManualDevice(self, key, address = None):
|
||||
def removeManualDevice(self, key: str, address: Optional[str] = None) -> None:
|
||||
if key not in self._discovered_devices and address is not None:
|
||||
key = "manual:%s" % address
|
||||
|
||||
if key in self._discovered_devices:
|
||||
if not address:
|
||||
address = self._discovered_devices[key].ipAddress
|
||||
|
@ -206,15 +226,22 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self.resetLastManualDevice()
|
||||
|
||||
if address in self._manual_instances:
|
||||
self._manual_instances.remove(address)
|
||||
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances))
|
||||
manual_printer_request = self._manual_instances.pop(address)
|
||||
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances.keys()))
|
||||
|
||||
self.removeManualDeviceSignal.emit(self.getPluginId(), key, address)
|
||||
if manual_printer_request.network_reply is not None:
|
||||
manual_printer_request.network_reply.abort()
|
||||
|
||||
def addManualDevice(self, address):
|
||||
if address not in self._manual_instances:
|
||||
self._manual_instances.append(address)
|
||||
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances))
|
||||
if manual_printer_request.callback is not None:
|
||||
self._application.callLater(manual_printer_request.callback, False, address)
|
||||
|
||||
def addManualDevice(self, address: str, callback: Optional[Callable[[bool, str], None]] = None) -> None:
|
||||
if address in self._manual_instances:
|
||||
Logger.log("i", "Manual printer with address [%s] has already been added, do nothing", address)
|
||||
return
|
||||
|
||||
self._manual_instances[address] = ManualPrinterRequest(address, callback = callback)
|
||||
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances.keys()))
|
||||
|
||||
instance_name = "manual:%s" % address
|
||||
properties = {
|
||||
|
@ -230,7 +257,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self._onAddDevice(instance_name, address, properties)
|
||||
self._last_manual_entry_key = instance_name
|
||||
|
||||
self._checkManualDevice(address)
|
||||
reply = self._checkManualDevice(address)
|
||||
self._manual_instances[address].network_reply = reply
|
||||
|
||||
def _createMachineFromDiscoveredPrinter(self, key: str) -> None:
|
||||
discovered_device = self._discovered_devices.get(key)
|
||||
|
@ -245,56 +273,22 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
key, group_name, machine_type_id)
|
||||
|
||||
self._application.getMachineManager().addMachine(machine_type_id, group_name)
|
||||
|
||||
# connect the new machine to that network printer
|
||||
self.associateActiveMachineWithPrinterDevice(discovered_device)
|
||||
self._api.machines.addOutputDeviceToCurrentMachine(discovered_device)
|
||||
|
||||
# ensure that the connection states are refreshed.
|
||||
self.refreshConnections()
|
||||
|
||||
def associateActiveMachineWithPrinterDevice(self, printer_device: Optional["PrinterOutputDevice"]) -> None:
|
||||
if not printer_device:
|
||||
return
|
||||
|
||||
Logger.log("d", "Attempting to set the network key of the active machine to %s", printer_device.key)
|
||||
|
||||
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
||||
if not global_container_stack:
|
||||
return
|
||||
|
||||
meta_data = global_container_stack.getMetaData()
|
||||
|
||||
if "um_network_key" in meta_data: # Global stack already had a connection, but it's changed.
|
||||
old_network_key = meta_data["um_network_key"]
|
||||
# Since we might have a bunch of hidden stacks, we also need to change it there.
|
||||
metadata_filter = {"um_network_key": old_network_key}
|
||||
containers = self._application.getContainerRegistry().findContainerStacks(type = "machine", **metadata_filter)
|
||||
|
||||
for container in containers:
|
||||
container.setMetaDataEntry("um_network_key", printer_device.key)
|
||||
|
||||
# Delete old authentication data.
|
||||
Logger.log("d", "Removing old authentication id %s for device %s",
|
||||
global_container_stack.getMetaDataEntry("network_authentication_id", None), printer_device.key)
|
||||
|
||||
container.removeMetaDataEntry("network_authentication_id")
|
||||
container.removeMetaDataEntry("network_authentication_key")
|
||||
|
||||
# Ensure that these containers do know that they are configured for network connection
|
||||
container.addConfiguredConnectionType(printer_device.connectionType.value)
|
||||
|
||||
else: # Global stack didn't have a connection yet, configure it.
|
||||
global_container_stack.setMetaDataEntry("um_network_key", printer_device.key)
|
||||
global_container_stack.addConfiguredConnectionType(printer_device.connectionType.value)
|
||||
|
||||
self.refreshConnections()
|
||||
|
||||
def _checkManualDevice(self, address: str) -> None:
|
||||
def _checkManualDevice(self, address: str) -> Optional[QNetworkReply]:
|
||||
# Check if a UM3 family device exists at this address.
|
||||
# If a printer responds, it will replace the preliminary printer created above
|
||||
# origin=manual is for tracking back the origin of the call
|
||||
url = QUrl("http://" + address + self._api_prefix + "system")
|
||||
name_request = QNetworkRequest(url)
|
||||
self._network_manager.get(name_request)
|
||||
return self._network_manager.get(name_request)
|
||||
|
||||
## This is the function which handles the above network request's reply when it comes back.
|
||||
def _onNetworkRequestFinished(self, reply: "QNetworkReply") -> None:
|
||||
reply_url = reply.url().toString()
|
||||
|
||||
|
@ -319,6 +313,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
Logger.log("e", "Something went wrong converting the JSON.")
|
||||
return
|
||||
|
||||
if address in self._manual_instances:
|
||||
manual_printer_request = self._manual_instances[address]
|
||||
manual_printer_request.network_reply = None
|
||||
if manual_printer_request.callback is not None:
|
||||
self._application.callLater(manual_printer_request.callback, True, address)
|
||||
|
||||
has_cluster_capable_firmware = Version(system_info["firmware"]) > self._min_cluster_version
|
||||
instance_name = "manual:%s" % address
|
||||
properties = {
|
||||
|
@ -362,10 +362,6 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self._onRemoveDevice(instance_name)
|
||||
self._onAddDevice(instance_name, address, properties)
|
||||
|
||||
if device and address in self._manual_instances:
|
||||
self.getOutputDeviceManager().addOutputDevice(device)
|
||||
self.addManualDeviceSignal.emit(self.getPluginId(), device.getId(), address, properties)
|
||||
|
||||
def _onRemoveDevice(self, device_id: str) -> None:
|
||||
device = self._discovered_devices.pop(device_id, None)
|
||||
if device:
|
||||
|
@ -401,11 +397,13 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
device = ClusterUM3OutputDevice.ClusterUM3OutputDevice(name, address, properties)
|
||||
else:
|
||||
device = LegacyUM3OutputDevice.LegacyUM3OutputDevice(name, address, properties)
|
||||
self._application.getDiscoveredPrintersModel().addDiscoveredPrinter(address, device.getId(), name, self._createMachineFromDiscoveredPrinter, properties[b"printer_type"].decode("utf-8"), device)
|
||||
self._application.getDiscoveredPrintersModel().addDiscoveredPrinter(
|
||||
address, device.getId(), properties[b"name"].decode("utf-8"), self._createMachineFromDiscoveredPrinter,
|
||||
properties[b"printer_type"].decode("utf-8"), device)
|
||||
self._discovered_devices[device.getId()] = device
|
||||
self.discoveredDevicesChanged.emit()
|
||||
|
||||
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
||||
global_container_stack = self._application.getGlobalContainerStack()
|
||||
if global_container_stack and device.getId() == global_container_stack.getMetaDataEntry("um_network_key"):
|
||||
# Ensure that the configured connection type is set.
|
||||
global_container_stack.addConfiguredConnectionType(device.connectionType.value)
|
||||
|
@ -425,7 +423,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self._service_changed_request_event.wait(timeout = 5.0)
|
||||
|
||||
# Stop if the application is shutting down
|
||||
if CuraApplication.getInstance().isShuttingDown():
|
||||
if self._application.isShuttingDown():
|
||||
return
|
||||
|
||||
self._service_changed_request_event.clear()
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
import threading
|
||||
import time
|
||||
import serial.tools.list_ports
|
||||
from os import environ
|
||||
from re import search
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSignal
|
||||
|
||||
|
@ -112,6 +114,27 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
|
|||
port = (port.device, port.description, port.hwid)
|
||||
if only_list_usb and not port[2].startswith("USB"):
|
||||
continue
|
||||
|
||||
# To prevent cura from messing with serial ports of other devices,
|
||||
# filter by regular expressions passed in as environment variables.
|
||||
# Get possible patterns with python3 -m serial.tools.list_ports -v
|
||||
|
||||
# set CURA_DEVICENAMES=USB[1-9] -> e.g. not matching /dev/ttyUSB0
|
||||
pattern = environ.get('CURA_DEVICENAMES')
|
||||
if pattern and not search(pattern, port[0]):
|
||||
continue
|
||||
|
||||
# set CURA_DEVICETYPES=CP2102 -> match a type of serial converter
|
||||
pattern = environ.get('CURA_DEVICETYPES')
|
||||
if pattern and not search(pattern, port[1]):
|
||||
continue
|
||||
|
||||
# set CURA_DEVICEINFOS=LOCATION=2-1.4 -> match a physical port
|
||||
# set CURA_DEVICEINFOS=VID:PID=10C4:EA60 -> match a vendor:product
|
||||
pattern = environ.get('CURA_DEVICEINFOS')
|
||||
if pattern and not search(pattern, port[2]):
|
||||
continue
|
||||
|
||||
base_list += [port[0]]
|
||||
|
||||
return list(base_list)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import configparser
|
||||
import io
|
||||
import uuid
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
from UM.VersionUpgrade import VersionUpgrade
|
||||
|
@ -18,6 +19,7 @@ _renamed_quality_profiles = {
|
|||
"gmax15plus_pla_very_thick": "gmax15plus_global_very_thick"
|
||||
} # type: Dict[str, str]
|
||||
|
||||
|
||||
## Upgrades configurations from the state they were in at version 4.0 to the
|
||||
# state they should be in at version 4.1.
|
||||
class VersionUpgrade40to41(VersionUpgrade):
|
||||
|
@ -95,6 +97,13 @@ class VersionUpgrade40to41(VersionUpgrade):
|
|||
if parser["containers"]["4"] in _renamed_quality_profiles:
|
||||
parser["containers"]["4"] = _renamed_quality_profiles[parser["containers"]["4"]]
|
||||
|
||||
# Assign a GlobalStack to a unique group_id. If the GlobalStack has a UM network connection, use the UM network
|
||||
# key as the group_id.
|
||||
if "um_network_key" in parser["metadata"]:
|
||||
parser["metadata"]["group_id"] = parser["metadata"]["um_network_key"]
|
||||
elif "group_id" not in parser["metadata"]:
|
||||
parser["metadata"]["group_id"] = str(uuid.uuid4())
|
||||
|
||||
result = io.StringIO()
|
||||
parser.write(result)
|
||||
return [filename], [result.getvalue()]
|
||||
|
|
|
@ -10,21 +10,21 @@ from UM.Math.Color import Color
|
|||
from UM.PluginRegistry import PluginRegistry
|
||||
from UM.Platform import Platform
|
||||
from UM.Event import Event
|
||||
from UM.View.View import View
|
||||
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||
|
||||
from UM.View.RenderBatch import RenderBatch
|
||||
from UM.View.GL.OpenGL import OpenGL
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.CuraView import CuraView
|
||||
from cura.Scene.ConvexHullNode import ConvexHullNode
|
||||
|
||||
from . import XRayPass
|
||||
|
||||
## View used to display a see-through version of objects with errors highlighted.
|
||||
class XRayView(View):
|
||||
class XRayView(CuraView):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
super().__init__(parent = None, use_empty_menu_placeholder = True)
|
||||
|
||||
self._xray_shader = None
|
||||
self._xray_pass = None
|
||||
|
|
|
@ -144,7 +144,7 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
# setting_version is derived from the "version" tag in the schema, so don't serialize it into a file
|
||||
if ignored_metadata_keys is None:
|
||||
ignored_metadata_keys = set()
|
||||
ignored_metadata_keys |= {"setting_version", "definition", "status", "variant", "type", "base_file", "approximate_diameter", "id", "container_type", "name"}
|
||||
ignored_metadata_keys |= {"setting_version", "definition", "status", "variant", "type", "base_file", "approximate_diameter", "id", "container_type", "name", "compatible"}
|
||||
# remove the keys that we want to ignore in the metadata
|
||||
for key in ignored_metadata_keys:
|
||||
if key in metadata:
|
||||
|
@ -1179,6 +1179,7 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
"adhesion tendency": "material_adhesion_tendency",
|
||||
"surface energy": "material_surface_energy",
|
||||
"shrinkage percentage": "material_shrinkage_percentage",
|
||||
"build volume temperature": "build_volume_temperature",
|
||||
}
|
||||
__unmapped_settings = [
|
||||
"hardware compatible",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue