Merge branch 'master' into fixes_toolbox

This commit is contained in:
Diego Prado Gesto 2019-07-23 15:15:02 +02:00
commit 1d6ba3ffb0
1432 changed files with 55649 additions and 45174 deletions

43
.github/ISSUE_TEMPLATE/bug-report.md vendored Normal file
View file

@ -0,0 +1,43 @@
---
name: Bug report
about: Create a report to help us fix issues.
title: ''
labels: 'Type: Bug'
assignees: ''
---
<!--
Processing an issue will go much faster when this is filled out, and issues which do not use this template WILL BE REMOVED and no fix will be considered!
Before filing, PLEASE check if the issue already exists (either open or closed) by using the search bar on the issues page. If it does, comment there. Even if it's closed, we can reopen it based on your comment.
Also, please note the application version in the title of the issue. For example: "[3.2.1] Cannot connect to 3rd-party printer". Please do NOT write things like "Request:" or "[BUG]" in the title; this is what labels are for.
It is also helpful to attach a project (.3mf or .curaproject) file and Cura log file so we can debug issues quicker. Information about how to find the log file can be found at https://github.com/Ultimaker/Cura#logging-issues
To upload a project, try changing the extension to e.g. .curaproject.3mf.zip so that GitHub accepts uploading the file. Otherwise, we recommend http://wetransfer.com, but other file hosts like Google Drive or Dropbox work well too.
Thank you for using Cura!
-->
**Application version**
<!-- The version of the application this issue occurs with -->
**Platform**
<!-- Information about the operating system the issue occurs on. Include at least the operating system. In the case of visual glitches/issues, also include information about your graphics drivers and GPU. -->
**Printer**
<!-- Which printer was selected in Cura? If possible, please attach project file as .curaproject.3mf.zip -->
**Reproduction steps**
<!-- How did you encounter the bug? -->
**Actual results**
<!-- What happens after the above steps have been followed -->
**Expected results**
<!-- What should happen after the above steps have been followed -->
**Additional information**
<!-- Extra information relevant to the issue, like screenshots. Don't forget to attach the log files with this issue report. -->

View file

@ -0,0 +1,22 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'Type: New Feature'
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
**Describe the solution you'd like**
<!--A clear and concise description of what you want to happen. If possible, describe why you think this is a good solution.-->
**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. Again, if possible, think about why these alternatives are not working out. -->
**Affected users and/or printers**
<!-- Who do you think will benefit from this? Is everyone going to benefit from these changes? Only a few people? -->
**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->

View file

@ -10,3 +10,10 @@ build-and-test:
artifacts: artifacts:
paths: paths:
- build - build
build-and-test_merge-requests:
stage: build
script:
- docker/build.sh
only:
- merge_requests

View file

@ -20,11 +20,12 @@ set(CURA_APP_NAME "cura" CACHE STRING "Short name of Cura, used for configuratio
set(CURA_APP_DISPLAY_NAME "Ultimaker Cura" CACHE STRING "Display name of Cura") set(CURA_APP_DISPLAY_NAME "Ultimaker Cura" CACHE STRING "Display name of Cura")
set(CURA_VERSION "master" CACHE STRING "Version name of Cura") set(CURA_VERSION "master" CACHE STRING "Version name of Cura")
set(CURA_BUILDTYPE "" CACHE STRING "Build type of Cura, eg. 'PPA'") set(CURA_BUILDTYPE "" CACHE STRING "Build type of Cura, eg. 'PPA'")
set(CURA_SDK_VERSION "" CACHE STRING "SDK version of Cura")
set(CURA_CLOUD_API_ROOT "" CACHE STRING "Alternative Cura cloud API root") set(CURA_CLOUD_API_ROOT "" CACHE STRING "Alternative Cura cloud API root")
set(CURA_CLOUD_API_VERSION "" CACHE STRING "Alternative Cura cloud API version") set(CURA_CLOUD_API_VERSION "" CACHE STRING "Alternative Cura cloud API version")
set(CURA_CLOUD_ACCOUNT_API_ROOT "" CACHE STRING "Alternative Cura cloud account API version")
configure_file(${CMAKE_SOURCE_DIR}/cura.desktop.in ${CMAKE_BINARY_DIR}/cura.desktop @ONLY) configure_file(${CMAKE_SOURCE_DIR}/cura.desktop.in ${CMAKE_BINARY_DIR}/cura.desktop @ONLY)
configure_file(cura/CuraVersion.py.in CuraVersion.py @ONLY) configure_file(cura/CuraVersion.py.in CuraVersion.py @ONLY)

View file

@ -9,7 +9,7 @@ DEFAULT_CURA_DISPLAY_NAME = "Ultimaker Cura"
DEFAULT_CURA_VERSION = "master" DEFAULT_CURA_VERSION = "master"
DEFAULT_CURA_BUILD_TYPE = "" DEFAULT_CURA_BUILD_TYPE = ""
DEFAULT_CURA_DEBUG_MODE = False DEFAULT_CURA_DEBUG_MODE = False
DEFAULT_CURA_SDK_VERSION = "6.0.0" DEFAULT_CURA_SDK_VERSION = "6.1.0"
try: try:
from cura.CuraVersion import CuraAppName # type: ignore from cura.CuraVersion import CuraAppName # type: ignore
@ -42,9 +42,7 @@ try:
except ImportError: except ImportError:
CuraDebugMode = DEFAULT_CURA_DEBUG_MODE CuraDebugMode = DEFAULT_CURA_DEBUG_MODE
try: # Each release has a fixed SDK version coupled with it. It doesn't make sense to make it configurable because, for
from cura.CuraVersion import CuraSDKVersion # type: ignore # example Cura 3.2 with SDK version 6.1 will not work. So the SDK version is hard-coded here and left out of the
if CuraSDKVersion == "": # CuraVersion.py.in template.
CuraSDKVersion = DEFAULT_CURA_SDK_VERSION CuraSDKVersion = "6.1.0"
except ImportError:
CuraSDKVersion = DEFAULT_CURA_SDK_VERSION

View file

@ -1,12 +1,18 @@
#Copyright (c) 2019 Ultimaker B.V.
#Cura is released under the terms of the LGPLv3 or higher.
import numpy import numpy
import copy import copy
from typing import Optional, Tuple, TYPE_CHECKING
from UM.Math.Polygon import Polygon from UM.Math.Polygon import Polygon
if TYPE_CHECKING:
from UM.Scene.SceneNode import SceneNode
## Polygon representation as an array for use with Arrange ## Polygon representation as an array for use with Arrange
class ShapeArray: class ShapeArray:
def __init__(self, arr, offset_x, offset_y, scale = 1): def __init__(self, arr: numpy.array, offset_x: float, offset_y: float, scale: float = 1) -> None:
self.arr = arr self.arr = arr
self.offset_x = offset_x self.offset_x = offset_x
self.offset_y = offset_y self.offset_y = offset_y
@ -16,7 +22,7 @@ class ShapeArray:
# \param vertices # \param vertices
# \param scale scale the coordinates # \param scale scale the coordinates
@classmethod @classmethod
def fromPolygon(cls, vertices, scale = 1): def fromPolygon(cls, vertices: numpy.array, scale: float = 1) -> "ShapeArray":
# scale # scale
vertices = vertices * scale vertices = vertices * scale
# flip y, x -> x, y # flip y, x -> x, y
@ -42,7 +48,7 @@ class ShapeArray:
# \param min_offset offset for the offset ShapeArray # \param min_offset offset for the offset ShapeArray
# \param scale scale the coordinates # \param scale scale the coordinates
@classmethod @classmethod
def fromNode(cls, node, min_offset, scale = 0.5, include_children = False): def fromNode(cls, node: "SceneNode", min_offset: float, scale: float = 0.5, include_children: bool = False) -> Tuple[Optional["ShapeArray"], Optional["ShapeArray"]]:
transform = node._transformation transform = node._transformation
transform_x = transform._data[0][3] transform_x = transform._data[0][3]
transform_y = transform._data[2][3] transform_y = transform._data[2][3]
@ -88,7 +94,7 @@ class ShapeArray:
# \param shape numpy format shape, [x-size, y-size] # \param shape numpy format shape, [x-size, y-size]
# \param vertices # \param vertices
@classmethod @classmethod
def arrayFromPolygon(cls, shape, vertices): def arrayFromPolygon(cls, shape: Tuple[int, int], vertices: numpy.array) -> numpy.array:
base_array = numpy.zeros(shape, dtype = numpy.int32) # Initialize your array of zeros base_array = numpy.zeros(shape, dtype = numpy.int32) # Initialize your array of zeros
fill = numpy.ones(base_array.shape) * True # Initialize boolean array defining shape fill fill = numpy.ones(base_array.shape) * True # Initialize boolean array defining shape fill
@ -111,9 +117,9 @@ class ShapeArray:
# \param p2 2-tuple with x, y for point 2 # \param p2 2-tuple with x, y for point 2
# \param base_array boolean array to project the line on # \param base_array boolean array to project the line on
@classmethod @classmethod
def _check(cls, p1, p2, base_array): def _check(cls, p1: numpy.array, p2: numpy.array, base_array: numpy.array) -> bool:
if p1[0] == p2[0] and p1[1] == p2[1]: if p1[0] == p2[0] and p1[1] == p2[1]:
return return False
idxs = numpy.indices(base_array.shape) # Create 3D array of indices idxs = numpy.indices(base_array.shape) # Create 3D array of indices
p1 = p1.astype(float) p1 = p1.astype(float)
@ -132,4 +138,3 @@ class ShapeArray:
max_col_idx = (idxs[0] - p1[0]) / (p2[0] - p1[0]) * (p2[1] - p1[1]) + p1[1] max_col_idx = (idxs[0] - p1[0]) / (p2[0] - p1[0]) * (p2[1] - p1[1]) + p1[1]
sign = numpy.sign(p2[0] - p1[0]) sign = numpy.sign(p2[0] - p1[0])
return idxs[1] * sign <= max_col_idx * sign return idxs[1] * sign <= max_col_idx * sign

View file

@ -1,4 +1,4 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import QTimer from PyQt5.QtCore import QTimer
@ -16,7 +16,7 @@ class AutoSave:
self._application.getPreferences().addPreference("cura/autosave_delay", 1000 * 10) self._application.getPreferences().addPreference("cura/autosave_delay", 1000 * 10)
self._change_timer = QTimer() self._change_timer = QTimer()
self._change_timer.setInterval(self._application.getPreferences().getValue("cura/autosave_delay")) self._change_timer.setInterval(int(self._application.getPreferences().getValue("cura/autosave_delay")))
self._change_timer.setSingleShot(True) self._change_timer.setSingleShot(True)
self._enabled = True self._enabled = True

View file

@ -148,5 +148,9 @@ class Backup:
Logger.log("d", "Removing current data in location: %s", target_path) Logger.log("d", "Removing current data in location: %s", target_path)
Resources.factoryReset() Resources.factoryReset()
Logger.log("d", "Extracting backup to location: %s", target_path) Logger.log("d", "Extracting backup to location: %s", target_path)
archive.extractall(target_path) try:
archive.extractall(target_path)
except PermissionError:
Logger.logException("e", "Unable to extract the backup due to permission errors")
return False
return True return True

View file

@ -51,8 +51,18 @@ class BackupsManager:
## Here we try to disable the auto-save plug-in as it might interfere with ## Here we try to disable the auto-save plug-in as it might interfere with
# restoring a back-up. # restoring a back-up.
def _disableAutoSave(self) -> None: def _disableAutoSave(self) -> None:
self._application.getAutoSave().setEnabled(False) auto_save = self._application.getAutoSave()
# The auto save is only not created if the application has not yet started.
if auto_save:
auto_save.setEnabled(False)
else:
Logger.log("e", "Unable to disable the autosave as application init has not been completed")
## Re-enable auto-save after we're done. ## Re-enable auto-save after we're done.
def _enableAutoSave(self) -> None: def _enableAutoSave(self) -> None:
self._application.getAutoSave().setEnabled(True) auto_save = self._application.getAutoSave()
# The auto save is only not created if the application has not yet started.
if auto_save:
auto_save.setEnabled(True)
else:
Logger.log("e", "Unable to enable the autosave as application init has not been completed")

File diff suppressed because it is too large Load diff

View file

@ -319,7 +319,8 @@ class CrashHandler:
def _userDescriptionWidget(self): def _userDescriptionWidget(self):
group = QGroupBox() group = QGroupBox()
group.setTitle(catalog.i18nc("@title:groupbox", "User description")) group.setTitle(catalog.i18nc("@title:groupbox", "User description" +
" (Note: Developers may not speak your language, please use English if possible)"))
layout = QVBoxLayout() layout = QVBoxLayout()
# When sending the report, the user comments will be collected # When sending the report, the user comments will be collected

View file

@ -3,7 +3,7 @@
from PyQt5.QtCore import QObject, QUrl from PyQt5.QtCore import QObject, QUrl
from PyQt5.QtGui import QDesktopServices from PyQt5.QtGui import QDesktopServices
from typing import List, TYPE_CHECKING, cast from typing import List, cast
from UM.Event import CallFunctionEvent from UM.Event import CallFunctionEvent
from UM.FlameProfiler import pyqtSlot from UM.FlameProfiler import pyqtSlot
@ -23,9 +23,8 @@ from cura.Settings.ExtruderManager import ExtruderManager
from cura.Operations.SetBuildPlateNumberOperation import SetBuildPlateNumberOperation from cura.Operations.SetBuildPlateNumberOperation import SetBuildPlateNumberOperation
from UM.Logger import Logger from UM.Logger import Logger
from UM.Scene.SceneNode import SceneNode
if TYPE_CHECKING:
from UM.Scene.SceneNode import SceneNode
class CuraActions(QObject): class CuraActions(QObject):
def __init__(self, parent: QObject = None) -> None: def __init__(self, parent: QObject = None) -> None:

View file

@ -114,6 +114,7 @@ from cura.UI.MachineSettingsManager import MachineSettingsManager
from cura.UI.ObjectsModel import ObjectsModel from cura.UI.ObjectsModel import ObjectsModel
from cura.UI.TextManager import TextManager from cura.UI.TextManager import TextManager
from cura.UI.AddPrinterPagesModel import AddPrinterPagesModel from cura.UI.AddPrinterPagesModel import AddPrinterPagesModel
from cura.UI.RecommendedMode import RecommendedMode
from cura.UI.WelcomePagesModel import WelcomePagesModel from cura.UI.WelcomePagesModel import WelcomePagesModel
from cura.UI.WhatsNewPagesModel import WhatsNewPagesModel from cura.UI.WhatsNewPagesModel import WhatsNewPagesModel
@ -143,7 +144,7 @@ class CuraApplication(QtApplication):
# SettingVersion represents the set of settings available in the machine/extruder definitions. # SettingVersion represents the set of settings available in the machine/extruder definitions.
# You need to make sure that this version number needs to be increased if there is any non-backwards-compatible # You need to make sure that this version number needs to be increased if there is any non-backwards-compatible
# changes of the settings. # changes of the settings.
SettingVersion = 7 SettingVersion = 8
Created = False Created = False
@ -260,7 +261,7 @@ class CuraApplication(QtApplication):
self._plugins_loaded = False self._plugins_loaded = False
# Backups # Backups
self._auto_save = None self._auto_save = None # type: Optional[AutoSave]
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
self._container_registry_class = CuraContainerRegistry self._container_registry_class = CuraContainerRegistry
@ -420,7 +421,7 @@ class CuraApplication(QtApplication):
# Add empty variant, material and quality containers. # Add empty variant, material and quality containers.
# Since they are empty, they should never be serialized and instead just programmatically created. # Since they are empty, they should never be serialized and instead just programmatically created.
# We need them to simplify the switching between materials. # We need them to simplify the switching between materials.
self.empty_container = cura.Settings.cura_empty_instance_containers.empty_container # type: EmptyInstanceContainer self.empty_container = cura.Settings.cura_empty_instance_containers.empty_container
self._container_registry.addContainer( self._container_registry.addContainer(
cura.Settings.cura_empty_instance_containers.empty_definition_changes_container) cura.Settings.cura_empty_instance_containers.empty_definition_changes_container)
@ -523,6 +524,7 @@ class CuraApplication(QtApplication):
preferences.addPreference("cura/choice_on_profile_override", "always_ask") preferences.addPreference("cura/choice_on_profile_override", "always_ask")
preferences.addPreference("cura/choice_on_open_project", "always_ask") preferences.addPreference("cura/choice_on_open_project", "always_ask")
preferences.addPreference("cura/use_multi_build_plate", False) preferences.addPreference("cura/use_multi_build_plate", False)
preferences.addPreference("cura/show_list_of_objects", False)
preferences.addPreference("view/settings_list_height", 400) preferences.addPreference("view/settings_list_height", 400)
preferences.addPreference("view/settings_visible", False) preferences.addPreference("view/settings_visible", False)
preferences.addPreference("view/settings_xpos", 0) preferences.addPreference("view/settings_xpos", 0)
@ -837,7 +839,6 @@ class CuraApplication(QtApplication):
if diagonal < 1: #No printer added yet. Set a default camera distance for normal-sized printers. if diagonal < 1: #No printer added yet. Set a default camera distance for normal-sized printers.
diagonal = 375 diagonal = 375
camera.setPosition(Vector(-80, 250, 700) * diagonal / 375) camera.setPosition(Vector(-80, 250, 700) * diagonal / 375)
camera.setPerspective(True)
camera.lookAt(Vector(0, 0, 0)) camera.lookAt(Vector(0, 0, 0))
controller.getScene().setActiveCamera("3d") controller.getScene().setActiveCamera("3d")
@ -929,7 +930,7 @@ class CuraApplication(QtApplication):
def getObjectsModel(self, *args): def getObjectsModel(self, *args):
if self._object_manager is None: if self._object_manager is None:
self._object_manager = ObjectsModel.createObjectsModel() self._object_manager = ObjectsModel(self)
return self._object_manager return self._object_manager
@pyqtSlot(result = QObject) @pyqtSlot(result = QObject)
@ -988,7 +989,7 @@ class CuraApplication(QtApplication):
return super().event(event) return super().event(event)
def getAutoSave(self): def getAutoSave(self) -> Optional[AutoSave]:
return self._auto_save return self._auto_save
## Get print information (duration / material used) ## Get print information (duration / material used)
@ -1036,10 +1037,11 @@ class CuraApplication(QtApplication):
qmlRegisterType(WhatsNewPagesModel, "Cura", 1, 0, "WhatsNewPagesModel") qmlRegisterType(WhatsNewPagesModel, "Cura", 1, 0, "WhatsNewPagesModel")
qmlRegisterType(AddPrinterPagesModel, "Cura", 1, 0, "AddPrinterPagesModel") qmlRegisterType(AddPrinterPagesModel, "Cura", 1, 0, "AddPrinterPagesModel")
qmlRegisterType(TextManager, "Cura", 1, 0, "TextManager") qmlRegisterType(TextManager, "Cura", 1, 0, "TextManager")
qmlRegisterType(RecommendedMode, "Cura", 1, 0, "RecommendedMode")
qmlRegisterType(NetworkMJPGImage, "Cura", 1, 0, "NetworkMJPGImage") qmlRegisterType(NetworkMJPGImage, "Cura", 1, 0, "NetworkMJPGImage")
qmlRegisterSingletonType(ObjectsModel, "Cura", 1, 0, "ObjectsModel", self.getObjectsModel) qmlRegisterType(ObjectsModel, "Cura", 1, 0, "ObjectsModel")
qmlRegisterType(BuildPlateModel, "Cura", 1, 0, "BuildPlateModel") qmlRegisterType(BuildPlateModel, "Cura", 1, 0, "BuildPlateModel")
qmlRegisterType(MultiBuildPlateModel, "Cura", 1, 0, "MultiBuildPlateModel") qmlRegisterType(MultiBuildPlateModel, "Cura", 1, 0, "MultiBuildPlateModel")
qmlRegisterType(InstanceContainer, "Cura", 1, 0, "InstanceContainer") qmlRegisterType(InstanceContainer, "Cura", 1, 0, "InstanceContainer")

View file

@ -6,7 +6,6 @@ CuraAppDisplayName = "@CURA_APP_DISPLAY_NAME@"
CuraVersion = "@CURA_VERSION@" CuraVersion = "@CURA_VERSION@"
CuraBuildType = "@CURA_BUILDTYPE@" CuraBuildType = "@CURA_BUILDTYPE@"
CuraDebugMode = True if "@_cura_debugmode@" == "ON" else False CuraDebugMode = True if "@_cura_debugmode@" == "ON" else False
CuraSDKVersion = "@CURA_SDK_VERSION@"
CuraCloudAPIRoot = "@CURA_CLOUD_API_ROOT@" CuraCloudAPIRoot = "@CURA_CLOUD_API_ROOT@"
CuraCloudAPIVersion = "@CURA_CLOUD_API_VERSION@" CuraCloudAPIVersion = "@CURA_CLOUD_API_VERSION@"
CuraCloudAccountAPIRoot = "@CURA_CLOUD_ACCOUNT_API_ROOT@" CuraCloudAccountAPIRoot = "@CURA_CLOUD_ACCOUNT_API_ROOT@"

View file

@ -18,8 +18,8 @@ class CuraView(View):
def __init__(self, parent = None, use_empty_menu_placeholder: bool = False) -> None: def __init__(self, parent = None, use_empty_menu_placeholder: bool = False) -> None:
super().__init__(parent) super().__init__(parent)
self._empty_menu_placeholder_url = QUrl(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, self._empty_menu_placeholder_url = QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles,
"EmptyViewMenuComponent.qml")) "EmptyViewMenuComponent.qml"))
self._use_empty_menu_placeholder = use_empty_menu_placeholder self._use_empty_menu_placeholder = use_empty_menu_placeholder
@pyqtProperty(QUrl, constant = True) @pyqtProperty(QUrl, constant = True)

View file

@ -1,4 +1,4 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from UM.Application import Application from UM.Application import Application
@ -20,7 +20,7 @@ class LayerPolygon:
MoveCombingType = 8 MoveCombingType = 8
MoveRetractionType = 9 MoveRetractionType = 9
SupportInterfaceType = 10 SupportInterfaceType = 10
PrimeTower = 11 PrimeTowerType = 11
__number_of_types = 12 __number_of_types = 12
__jump_map = numpy.logical_or(numpy.logical_or(numpy.arange(__number_of_types) == NoneType, numpy.arange(__number_of_types) == MoveCombingType), numpy.arange(__number_of_types) == MoveRetractionType) __jump_map = numpy.logical_or(numpy.logical_or(numpy.arange(__number_of_types) == NoneType, numpy.arange(__number_of_types) == MoveCombingType), numpy.arange(__number_of_types) == MoveRetractionType)
@ -61,19 +61,19 @@ class LayerPolygon:
# When type is used as index returns true if type == LayerPolygon.InfillType or type == LayerPolygon.SkinType or type == LayerPolygon.SupportInfillType # When type is used as index returns true if type == LayerPolygon.InfillType or type == LayerPolygon.SkinType or type == LayerPolygon.SupportInfillType
# Should be generated in better way, not hardcoded. # Should be generated in better way, not hardcoded.
self._isInfillOrSkinTypeMap = numpy.array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1], dtype=numpy.bool) self._isInfillOrSkinTypeMap = numpy.array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1], dtype = numpy.bool)
self._build_cache_line_mesh_mask = None # type: Optional[numpy.ndarray] self._build_cache_line_mesh_mask = None # type: Optional[numpy.ndarray]
self._build_cache_needed_points = None # type: Optional[numpy.ndarray] self._build_cache_needed_points = None # type: Optional[numpy.ndarray]
def buildCache(self) -> None: def buildCache(self) -> None:
# For the line mesh we do not draw Infill or Jumps. Therefore those lines are filtered out. # For the line mesh we do not draw Infill or Jumps. Therefore those lines are filtered out.
self._build_cache_line_mesh_mask = numpy.ones(self._jump_mask.shape, dtype=bool) self._build_cache_line_mesh_mask = numpy.ones(self._jump_mask.shape, dtype = bool)
mesh_line_count = numpy.sum(self._build_cache_line_mesh_mask) mesh_line_count = numpy.sum(self._build_cache_line_mesh_mask)
self._index_begin = 0 self._index_begin = 0
self._index_end = mesh_line_count self._index_end = mesh_line_count
self._build_cache_needed_points = numpy.ones((len(self._types), 2), dtype=numpy.bool) self._build_cache_needed_points = numpy.ones((len(self._types), 2), dtype = numpy.bool)
# Only if the type of line segment changes do we need to add an extra vertex to change colors # Only if the type of line segment changes do we need to add an extra vertex to change colors
self._build_cache_needed_points[1:, 0][:, numpy.newaxis] = self._types[1:] != self._types[:-1] self._build_cache_needed_points[1:, 0][:, numpy.newaxis] = self._types[1:] != self._types[:-1]
# Mark points as unneeded if they are of types we don't want in the line mesh according to the calculated mask # Mark points as unneeded if they are of types we don't want in the line mesh according to the calculated mask
@ -136,9 +136,9 @@ class LayerPolygon:
self._index_begin += index_offset self._index_begin += index_offset
self._index_end += index_offset self._index_end += index_offset
indices[self._index_begin:self._index_end, :] = numpy.arange(self._index_end-self._index_begin, dtype=numpy.int32).reshape((-1, 1)) indices[self._index_begin:self._index_end, :] = numpy.arange(self._index_end-self._index_begin, dtype = numpy.int32).reshape((-1, 1))
# When the line type changes the index needs to be increased by 2. # When the line type changes the index needs to be increased by 2.
indices[self._index_begin:self._index_end, :] += numpy.cumsum(needed_points_list[line_mesh_mask.ravel(), 0], dtype=numpy.int32).reshape((-1, 1)) indices[self._index_begin:self._index_end, :] += numpy.cumsum(needed_points_list[line_mesh_mask.ravel(), 0], dtype = numpy.int32).reshape((-1, 1))
# Each line segment goes from it's starting point p to p+1, offset by the vertex index. # Each line segment goes from it's starting point p to p+1, offset by the vertex index.
# The -1 is to compensate for the neccecarily True value of needed_points_list[0,0] which causes an unwanted +1 in cumsum above. # The -1 is to compensate for the neccecarily True value of needed_points_list[0,0] which causes an unwanted +1 in cumsum above.
indices[self._index_begin:self._index_end, :] += numpy.array([self._vertex_begin - 1, self._vertex_begin]) indices[self._index_begin:self._index_end, :] += numpy.array([self._vertex_begin - 1, self._vertex_begin])
@ -245,7 +245,7 @@ class LayerPolygon:
theme.getColor("layerview_move_combing").getRgbF(), # MoveCombingType theme.getColor("layerview_move_combing").getRgbF(), # MoveCombingType
theme.getColor("layerview_move_retraction").getRgbF(), # MoveRetractionType theme.getColor("layerview_move_retraction").getRgbF(), # MoveRetractionType
theme.getColor("layerview_support_interface").getRgbF(), # SupportInterfaceType theme.getColor("layerview_support_interface").getRgbF(), # SupportInterfaceType
theme.getColor("layerview_prime_tower").getRgbF() theme.getColor("layerview_prime_tower").getRgbF() # PrimeTowerType
]) ])
return cls.__color_map return cls.__color_map

View file

@ -2,8 +2,9 @@
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import os import os
from typing import Optional
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal from PyQt5.QtCore import QObject, QUrl, pyqtSlot, pyqtProperty, pyqtSignal
from UM.Logger import Logger from UM.Logger import Logger
from UM.PluginObject import PluginObject from UM.PluginObject import PluginObject
@ -72,18 +73,26 @@ class MachineAction(QObject, PluginObject):
return self._finished return self._finished
## Protected helper to create a view object based on provided QML. ## Protected helper to create a view object based on provided QML.
def _createViewFromQML(self) -> None: def _createViewFromQML(self) -> Optional["QObject"]:
plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId()) plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId())
if plugin_path is None: if plugin_path is None:
Logger.log("e", "Cannot create QML view: cannot find plugin path for plugin [%s]", self.getPluginId()) Logger.log("e", "Cannot create QML view: cannot find plugin path for plugin [%s]", self.getPluginId())
return return None
path = os.path.join(plugin_path, self._qml_url) path = os.path.join(plugin_path, self._qml_url)
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
self._view = CuraApplication.getInstance().createQmlComponent(path, {"manager": self}) view = CuraApplication.getInstance().createQmlComponent(path, {"manager": self})
return view
@pyqtProperty(QObject, constant = True) @pyqtProperty(QUrl, constant = True)
def displayItem(self): def qmlPath(self) -> "QUrl":
if not self._view: plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId())
self._createViewFromQML() if plugin_path is None:
return self._view Logger.log("e", "Cannot create QML view: cannot find plugin path for plugin [%s]", self.getPluginId())
return QUrl("")
path = os.path.join(plugin_path, self._qml_url)
return QUrl.fromLocalFile(path)
@pyqtSlot(result = QObject)
def getDisplayItem(self) -> Optional["QObject"]:
return self._createViewFromQML()

View file

@ -168,7 +168,7 @@ class MachineErrorChecker(QObject):
if validator_type: if validator_type:
validator = validator_type(key) validator = validator_type(key)
validation_state = validator(stack) validation_state = validator(stack)
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError): if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError, ValidatorState.Invalid):
# Finish # Finish
self._setResult(True) self._setResult(True)
return return

View file

@ -93,7 +93,7 @@ class MaterialManager(QObject):
self._container_registry.findContainersMetadata(type = "material") if self._container_registry.findContainersMetadata(type = "material") if
metadata.get("GUID")} # type: Dict[str, Dict[str, Any]] metadata.get("GUID")} # type: Dict[str, Dict[str, Any]]
self._material_group_map = dict() # type: Dict[str, MaterialGroup] self._material_group_map = dict()
# Map #1 # Map #1
# root_material_id -> MaterialGroup # root_material_id -> MaterialGroup
@ -120,7 +120,7 @@ class MaterialManager(QObject):
# Map #1.5 # Map #1.5
# GUID -> material group list # GUID -> material group list
self._guid_material_groups_map = defaultdict(list) # type: Dict[str, List[MaterialGroup]] self._guid_material_groups_map = defaultdict(list)
for root_material_id, material_group in self._material_group_map.items(): for root_material_id, material_group in self._material_group_map.items():
guid = material_group.root_material_node.getMetaDataEntry("GUID", "") guid = material_group.root_material_node.getMetaDataEntry("GUID", "")
self._guid_material_groups_map[guid].append(material_group) self._guid_material_groups_map[guid].append(material_group)
@ -202,7 +202,7 @@ class MaterialManager(QObject):
# Map #4 # Map #4
# "machine" -> "nozzle name" -> "buildplate name" -> "root material ID" -> specific material InstanceContainer # "machine" -> "nozzle name" -> "buildplate name" -> "root material ID" -> specific material InstanceContainer
self._diameter_machine_nozzle_buildplate_material_map = dict() # type: Dict[str, Dict[str, MaterialNode]] self._diameter_machine_nozzle_buildplate_material_map = dict()
for material_metadata in material_metadatas.values(): for material_metadata in material_metadatas.values():
self.__addMaterialMetadataIntoLookupTree(material_metadata) self.__addMaterialMetadataIntoLookupTree(material_metadata)

View file

@ -62,6 +62,14 @@ class DiscoveredPrinter(QObject):
self._machine_type = machine_type self._machine_type = machine_type
self.machineTypeChanged.emit() self.machineTypeChanged.emit()
# Checks if the given machine type name in the available machine list.
# The machine type is a code name such as "ultimaker_3", while the machine type name is the human-readable name of
# the machine type, which is "Ultimaker 3" for "ultimaker_3".
def _hasHumanReadableMachineTypeName(self, machine_type_name: str) -> bool:
from cura.CuraApplication import CuraApplication
results = CuraApplication.getInstance().getContainerRegistry().findDefinitionContainersMetadata(name = machine_type_name)
return len(results) > 0
# Human readable machine type string # Human readable machine type string
@pyqtProperty(str, notify = machineTypeChanged) @pyqtProperty(str, notify = machineTypeChanged)
def readableMachineType(self) -> str: def readableMachineType(self) -> str:
@ -70,24 +78,30 @@ class DiscoveredPrinter(QObject):
# In ClusterUM3OutputDevice, when it updates a printer information, it updates the machine type using the field # In ClusterUM3OutputDevice, when it updates a printer information, it updates the machine type using the field
# "machine_variant", and for some reason, it's not the machine type ID/codename/... but a human-readable string # "machine_variant", and for some reason, it's not the machine type ID/codename/... but a human-readable string
# like "Ultimaker 3". The code below handles this case. # like "Ultimaker 3". The code below handles this case.
if machine_manager.hasHumanReadableMachineTypeName(self._machine_type): if self._hasHumanReadableMachineTypeName(self._machine_type):
readable_type = self._machine_type readable_type = self._machine_type
else: else:
readable_type = machine_manager.getMachineTypeNameFromId(self._machine_type) readable_type = self._getMachineTypeNameFromId(self._machine_type)
if not readable_type: if not readable_type:
readable_type = catalog.i18nc("@label", "Unknown") readable_type = catalog.i18nc("@label", "Unknown")
return readable_type return readable_type
@pyqtProperty(bool, notify = machineTypeChanged) @pyqtProperty(bool, notify = machineTypeChanged)
def isUnknownMachineType(self) -> bool: def isUnknownMachineType(self) -> bool:
from cura.CuraApplication import CuraApplication if self._hasHumanReadableMachineTypeName(self._machine_type):
machine_manager = CuraApplication.getInstance().getMachineManager()
if machine_manager.hasHumanReadableMachineTypeName(self._machine_type):
readable_type = self._machine_type readable_type = self._machine_type
else: else:
readable_type = machine_manager.getMachineTypeNameFromId(self._machine_type) readable_type = self._getMachineTypeNameFromId(self._machine_type)
return not readable_type return not readable_type
def _getMachineTypeNameFromId(self, machine_type_id: str) -> str:
machine_type_name = ""
from cura.CuraApplication import CuraApplication
results = CuraApplication.getInstance().getContainerRegistry().findDefinitionContainersMetadata(id = machine_type_id)
if results:
machine_type_name = results[0]["name"]
return machine_type_name
@pyqtProperty(QObject, constant = True) @pyqtProperty(QObject, constant = True)
def device(self) -> "NetworkedPrinterOutputDevice": def device(self) -> "NetworkedPrinterOutputDevice":
return self._device return self._device

View file

@ -100,7 +100,7 @@ class FirstStartMachineActionsModel(ListModel):
item_list = [] item_list = []
for item in first_start_actions: for item in first_start_actions:
item_list.append({"title": item.label, item_list.append({"title": item.label,
"content": item.displayItem, "content": item.getDisplayItem(),
"action": item, "action": item,
}) })
item.reset() item.reset()

View file

@ -202,9 +202,6 @@ class QualityManager(QObject):
def getQualityGroups(self, machine: "GlobalStack") -> Dict[str, QualityGroup]: def getQualityGroups(self, machine: "GlobalStack") -> Dict[str, QualityGroup]:
machine_definition_id = getMachineDefinitionIDForQualitySearch(machine.definition) machine_definition_id = getMachineDefinitionIDForQualitySearch(machine.definition)
# This determines if we should only get the global qualities for the global stack and skip the global qualities for the extruder stacks
has_machine_specific_qualities = machine.getHasMachineQuality()
# To find the quality container for the GlobalStack, check in the following fall-back manner: # To find the quality container for the GlobalStack, check in the following fall-back manner:
# (1) the machine-specific node # (1) the machine-specific node
# (2) the generic node # (2) the generic node

View file

@ -76,7 +76,7 @@ class PlatformPhysics:
move_vector = move_vector.set(y = -bbox.bottom + z_offset) move_vector = move_vector.set(y = -bbox.bottom + z_offset)
# If there is no convex hull for the node, start calculating it and continue. # If there is no convex hull for the node, start calculating it and continue.
if not node.getDecorator(ConvexHullDecorator): if not node.getDecorator(ConvexHullDecorator) and not node.callDecoration("isNonPrintingMesh"):
node.addDecorator(ConvexHullDecorator()) node.addDecorator(ConvexHullDecorator())
# only push away objects if this node is a printing mesh # only push away objects if this node is a printing mesh

View file

@ -84,29 +84,30 @@ class PreviewPass(RenderPass):
# Fill up the batch with objects that can be sliced. # Fill up the batch with objects that can be sliced.
for node in DepthFirstIterator(self._scene.getRoot()): #type: ignore #Ignore type error because iter() should get called automatically by Python syntax. for node in DepthFirstIterator(self._scene.getRoot()): #type: ignore #Ignore type error because iter() should get called automatically by Python syntax.
if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible(): if hasattr(node, "_outside_buildarea") and not node._outside_buildarea:
per_mesh_stack = node.callDecoration("getStack") if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible():
if node.callDecoration("isNonThumbnailVisibleMesh"): per_mesh_stack = node.callDecoration("getStack")
# Non printing mesh if node.callDecoration("isNonThumbnailVisibleMesh"):
continue # Non printing mesh
elif per_mesh_stack is not None and per_mesh_stack.getProperty("support_mesh", "value"): continue
# Support mesh elif per_mesh_stack is not None and per_mesh_stack.getProperty("support_mesh", "value"):
uniforms = {} # Support mesh
shade_factor = 0.6 uniforms = {}
diffuse_color = node.getDiffuseColor() shade_factor = 0.6
diffuse_color2 = [ diffuse_color = node.getDiffuseColor()
diffuse_color[0] * shade_factor, diffuse_color2 = [
diffuse_color[1] * shade_factor, diffuse_color[0] * shade_factor,
diffuse_color[2] * shade_factor, diffuse_color[1] * shade_factor,
1.0] diffuse_color[2] * shade_factor,
uniforms["diffuse_color"] = prettier_color(diffuse_color) 1.0]
uniforms["diffuse_color_2"] = diffuse_color2 uniforms["diffuse_color"] = prettier_color(diffuse_color)
batch_support_mesh.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms) uniforms["diffuse_color_2"] = diffuse_color2
else: batch_support_mesh.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
# Normal scene node else:
uniforms = {} # Normal scene node
uniforms["diffuse_color"] = prettier_color(node.getDiffuseColor()) uniforms = {}
batch.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms) uniforms["diffuse_color"] = prettier_color(node.getDiffuseColor())
batch.addItem(node.getWorldTransformation(), node.getMeshData(), uniforms = uniforms)
self.bind() self.bind()

View file

@ -55,7 +55,7 @@ class GenericOutputController(PrinterOutputController):
self._preheat_hotends_timer.stop() self._preheat_hotends_timer.stop()
for extruder in self._preheat_hotends: for extruder in self._preheat_hotends:
extruder.updateIsPreheating(False) extruder.updateIsPreheating(False)
self._preheat_hotends = set() # type: Set[ExtruderOutputModel] self._preheat_hotends = set()
def moveHead(self, printer: "PrinterOutputModel", x, y, z, speed) -> None: def moveHead(self, printer: "PrinterOutputModel", x, y, z, speed) -> None:
self._output_device.sendCommand("G91") self._output_device.sendCommand("G91")
@ -159,7 +159,7 @@ class GenericOutputController(PrinterOutputController):
def _onPreheatHotendsTimerFinished(self) -> None: def _onPreheatHotendsTimerFinished(self) -> None:
for extruder in self._preheat_hotends: for extruder in self._preheat_hotends:
self.setTargetHotendTemperature(extruder.getPrinter(), extruder.getPosition(), 0) self.setTargetHotendTemperature(extruder.getPrinter(), extruder.getPosition(), 0)
self._preheat_hotends = set() #type: Set[ExtruderOutputModel] self._preheat_hotends = set()
# Cancel any ongoing preheating timers, without setting back the temperature to 0 # Cancel any ongoing preheating timers, without setting back the temperature to 0
# This can be used eg at the start of a print # This can be used eg at the start of a print
@ -167,7 +167,7 @@ class GenericOutputController(PrinterOutputController):
if self._preheat_hotends_timer.isActive(): if self._preheat_hotends_timer.isActive():
for extruder in self._preheat_hotends: for extruder in self._preheat_hotends:
extruder.updateIsPreheating(False) extruder.updateIsPreheating(False)
self._preheat_hotends = set() #type: Set[ExtruderOutputModel] self._preheat_hotends = set()
self._preheat_hotends_timer.stop() self._preheat_hotends_timer.stop()

View file

@ -2,13 +2,13 @@
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot, QUrl from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot, QUrl
from typing import List, Dict, Optional from typing import List, Dict, Optional, TYPE_CHECKING
from UM.Math.Vector import Vector from UM.Math.Vector import Vector
from cura.PrinterOutput.Peripheral import Peripheral
from cura.PrinterOutput.Models.PrinterConfigurationModel import PrinterConfigurationModel from cura.PrinterOutput.Models.PrinterConfigurationModel import PrinterConfigurationModel
from cura.PrinterOutput.Models.ExtruderOutputModel import ExtruderOutputModel from cura.PrinterOutput.Models.ExtruderOutputModel import ExtruderOutputModel
MYPY = False if TYPE_CHECKING:
if MYPY:
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
@ -45,6 +45,7 @@ class PrinterOutputModel(QObject):
self._is_preheating = False self._is_preheating = False
self._printer_type = "" self._printer_type = ""
self._buildplate = "" self._buildplate = ""
self._peripherals = [] # type: List[Peripheral]
self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in self._printer_configuration.extruderConfigurations = [extruder.extruderConfiguration for extruder in
self._extruders] self._extruders]
@ -295,3 +296,17 @@ class PrinterOutputModel(QObject):
if self._printer_configuration.isValid(): if self._printer_configuration.isValid():
return self._printer_configuration return self._printer_configuration
return None return None
peripheralsChanged = pyqtSignal()
@pyqtProperty(str, notify = peripheralsChanged)
def peripherals(self) -> str:
return ", ".join(*[peripheral.name for peripheral in self._peripherals])
def addPeripheral(self, peripheral: Peripheral) -> None:
self._peripherals.append(peripheral)
self.peripheralsChanged.emit()
def removePeripheral(self, peripheral: Peripheral) -> None:
self._peripherals.remove(peripheral)
self.peripheralsChanged.emit()

View file

@ -60,8 +60,8 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
self._gcode = [] # type: List[str] self._gcode = [] # type: List[str]
self._connection_state_before_timeout = None # type: Optional[ConnectionState] self._connection_state_before_timeout = None # type: Optional[ConnectionState]
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
file_handler: Optional[FileHandler] = None, **kwargs: str) -> None: file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
raise NotImplementedError("requestWrite needs to be implemented") raise NotImplementedError("requestWrite needs to be implemented")
def setAuthenticationState(self, authentication_state: AuthState) -> None: def setAuthenticationState(self, authentication_state: AuthState) -> None:

View file

@ -0,0 +1,16 @@
# Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
## Data class that represents a peripheral for a printer.
#
# Output device plug-ins may specify that the printer has a certain set of
# peripherals. This set is then possibly shown in the interface of the monitor
# stage.
class Peripheral:
## Constructs the peripheral.
# \param type A unique ID for the type of peripheral.
# \param name A human-readable name for the peripheral.
def __init__(self, peripheral_type: str, name: str) -> None:
self.type = peripheral_type
self.name = name

View file

@ -1,4 +1,4 @@
import warnings import warnings
warnings.warn("Importing cura.PrinterOutput.PrintJobOutputModel has been deprecated since 4.1, use cura.PrinterOutput.Models.PrintJobOutputModel inststad", DeprecationWarning, stacklevel=2) warnings.warn("Importing cura.PrinterOutput.PrintJobOutputModel has been deprecated since 4.1, use cura.PrinterOutput.Models.PrintJobOutputModel instead", DeprecationWarning, stacklevel=2)
# We moved the the models to one submodule deeper # We moved the the models to one submodule deeper
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel

View file

@ -144,7 +144,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
return None return None
def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False, def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
file_handler: Optional["FileHandler"] = None, **kwargs: str) -> None: file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
raise NotImplementedError("requestWrite needs to be implemented") raise NotImplementedError("requestWrite needs to be implemented")
@pyqtProperty(QObject, notify = printersChanged) @pyqtProperty(QObject, notify = printersChanged)

View file

@ -1,4 +1,4 @@
import warnings import warnings
warnings.warn("Importing cura.PrinterOutput.PrinterOutputModel has been deprecated since 4.1, use cura.PrinterOutput.Models.PrinterOutputModel inststad", DeprecationWarning, stacklevel=2) warnings.warn("Importing cura.PrinterOutput.PrinterOutputModel has been deprecated since 4.1, use cura.PrinterOutput.Models.PrinterOutputModel instead", DeprecationWarning, stacklevel=2)
# We moved the the models to one submodule deeper # We moved the the models to one submodule deeper
from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel from cura.PrinterOutput.Models.PrinterOutputModel import PrinterOutputModel

View file

@ -1,4 +1,4 @@
import warnings import warnings
warnings.warn("Importing cura.PrinterOutputDevice has been deprecated since 4.1, use cura.PrinterOutput.PrinterOutputDevice inststad", DeprecationWarning, stacklevel=2) warnings.warn("Importing cura.PrinterOutputDevice has been deprecated since 4.1, use cura.PrinterOutput.PrinterOutputDevice instead", DeprecationWarning, stacklevel=2)
# We moved the PrinterOutput device to it's own submodule. # We moved the PrinterOutput device to it's own submodule.
from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionState from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionState

View file

@ -66,6 +66,10 @@ class ConvexHullDecorator(SceneNodeDecorator):
node.boundingBoxChanged.connect(self._onChanged) node.boundingBoxChanged.connect(self._onChanged)
per_object_stack = node.callDecoration("getStack")
if per_object_stack:
per_object_stack.propertyChanged.connect(self._onSettingValueChanged)
self._onChanged() self._onChanged()
## Force that a new (empty) object is created upon copy. ## Force that a new (empty) object is created upon copy.
@ -76,7 +80,8 @@ class ConvexHullDecorator(SceneNodeDecorator):
def getConvexHull(self) -> Optional[Polygon]: def getConvexHull(self) -> Optional[Polygon]:
if self._node is None: if self._node is None:
return None return None
if self._node.callDecoration("isNonPrintingMesh"):
return None
hull = self._compute2DConvexHull() hull = self._compute2DConvexHull()
if self._global_stack and self._node is not None and hull is not None: if self._global_stack and self._node is not None and hull is not None:
@ -106,7 +111,8 @@ class ConvexHullDecorator(SceneNodeDecorator):
def getConvexHullHead(self) -> Optional[Polygon]: def getConvexHullHead(self) -> Optional[Polygon]:
if self._node is None: if self._node is None:
return None return None
if self._node.callDecoration("isNonPrintingMesh"):
return None
if self._global_stack: if self._global_stack:
if self._global_stack.getProperty("print_sequence", "value") == "one_at_a_time" and not self.hasGroupAsParent(self._node): if self._global_stack.getProperty("print_sequence", "value") == "one_at_a_time" and not self.hasGroupAsParent(self._node):
head_with_fans = self._compute2DConvexHeadMin() head_with_fans = self._compute2DConvexHeadMin()
@ -123,6 +129,9 @@ class ConvexHullDecorator(SceneNodeDecorator):
if self._node is None: if self._node is None:
return None return None
if self._node.callDecoration("isNonPrintingMesh"):
return None
if self._global_stack: if self._global_stack:
if self._global_stack.getProperty("print_sequence", "value") == "one_at_a_time" and not self.hasGroupAsParent(self._node): if self._global_stack.getProperty("print_sequence", "value") == "one_at_a_time" and not self.hasGroupAsParent(self._node):
# Printing one at a time and it's not an object in a group # Printing one at a time and it's not an object in a group
@ -398,4 +407,4 @@ class ConvexHullDecorator(SceneNodeDecorator):
## Settings that change the convex hull. ## Settings that change the convex hull.
# #
# If these settings change, the convex hull should be recalculated. # If these settings change, the convex hull should be recalculated.
_influencing_settings = {"xy_offset", "xy_offset_layer_0", "mold_enabled", "mold_width"} _influencing_settings = {"xy_offset", "xy_offset_layer_0", "mold_enabled", "mold_width", "anti_overhang_mesh", "infill_mesh", "cutting_mesh"}

View file

@ -1,4 +1,4 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from copy import deepcopy from copy import deepcopy
@ -6,13 +6,14 @@ from typing import cast, Dict, List, Optional
from UM.Application import Application from UM.Application import Application
from UM.Math.AxisAlignedBox import AxisAlignedBox from UM.Math.AxisAlignedBox import AxisAlignedBox
from UM.Math.Polygon import Polygon #For typing. from UM.Math.Polygon import Polygon # For typing.
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
from UM.Scene.SceneNodeDecorator import SceneNodeDecorator #To cast the deepcopy of every decorator back to SceneNodeDecorator. from UM.Scene.SceneNodeDecorator import SceneNodeDecorator # To cast the deepcopy of every decorator back to SceneNodeDecorator.
import cura.CuraApplication # To get the build plate.
from cura.Settings.ExtruderStack import ExtruderStack # For typing.
from cura.Settings.SettingOverrideDecorator import SettingOverrideDecorator # For per-object settings.
import cura.CuraApplication #To get the build plate.
from cura.Settings.ExtruderStack import ExtruderStack #For typing.
from cura.Settings.SettingOverrideDecorator import SettingOverrideDecorator #For per-object settings.
## Scene nodes that are models are only seen when selecting the corresponding build plate ## Scene nodes that are models are only seen when selecting the corresponding build plate
# Note that many other nodes can just be UM SceneNode objects. # Note that many other nodes can just be UM SceneNode objects.
@ -20,7 +21,7 @@ class CuraSceneNode(SceneNode):
def __init__(self, parent: Optional["SceneNode"] = None, visible: bool = True, name: str = "", no_setting_override: bool = False) -> None: def __init__(self, parent: Optional["SceneNode"] = None, visible: bool = True, name: str = "", no_setting_override: bool = False) -> None:
super().__init__(parent = parent, visible = visible, name = name) super().__init__(parent = parent, visible = visible, name = name)
if not no_setting_override: if not no_setting_override:
self.addDecorator(SettingOverrideDecorator()) # now we always have a getActiveExtruderPosition, unless explicitly disabled self.addDecorator(SettingOverrideDecorator()) # Now we always have a getActiveExtruderPosition, unless explicitly disabled
self._outside_buildarea = False self._outside_buildarea = False
def setOutsideBuildArea(self, new_value: bool) -> None: def setOutsideBuildArea(self, new_value: bool) -> None:
@ -58,7 +59,7 @@ class CuraSceneNode(SceneNode):
if extruder_id is not None: if extruder_id is not None:
if extruder_id == extruder.getId(): if extruder_id == extruder.getId():
return extruder return extruder
else: # If the id is unknown, then return the extruder in the position 0 else: # If the id is unknown, then return the extruder in the position 0
try: try:
if extruder.getMetaDataEntry("position", default = "0") == "0": # Check if the position is zero if extruder.getMetaDataEntry("position", default = "0") == "0": # Check if the position is zero
return extruder return extruder
@ -85,24 +86,14 @@ class CuraSceneNode(SceneNode):
1.0 1.0
] ]
## Return if the provided bbox collides with the bbox of this scene node
def collidesWithBbox(self, check_bbox: AxisAlignedBox) -> bool:
bbox = self.getBoundingBox()
if bbox is not None:
# Mark the node as outside the build volume if the bounding box test fails.
if check_bbox.intersectsBox(bbox) != AxisAlignedBox.IntersectionResult.FullIntersection:
return True
return False
## Return if any area collides with the convex hull of this scene node ## Return if any area collides with the convex hull of this scene node
def collidesWithArea(self, areas: List[Polygon]) -> bool: def collidesWithAreas(self, areas: List[Polygon]) -> bool:
convex_hull = self.callDecoration("getConvexHull") convex_hull = self.callDecoration("getConvexHull")
if convex_hull: if convex_hull:
if not convex_hull.isValid(): if not convex_hull.isValid():
return False return False
# Check for collisions between disallowed areas and the object # Check for collisions between provided areas and the object
for area in areas: for area in areas:
overlap = convex_hull.intersectsPolygon(area) overlap = convex_hull.intersectsPolygon(area)
if overlap is None: if overlap is None:
@ -115,12 +106,15 @@ class CuraSceneNode(SceneNode):
self._aabb = None self._aabb = None
if self._mesh_data: if self._mesh_data:
self._aabb = self._mesh_data.getExtents(self.getWorldTransformation()) self._aabb = self._mesh_data.getExtents(self.getWorldTransformation())
else: # If there is no mesh_data, use a boundingbox that encompasses the local (0,0,0)
position = self.getWorldPosition()
self._aabb = AxisAlignedBox(minimum=position, maximum=position)
for child in self._children: for child in self.getAllChildren():
if child.callDecoration("isNonPrintingMesh"): if child.callDecoration("isNonPrintingMesh"):
# Non-printing-meshes inside a group should not affect push apart or drop to build plate # Non-printing-meshes inside a group should not affect push apart or drop to build plate
continue continue
if not child._mesh_data: if not child.getMeshData():
# Nodes without mesh data should not affect bounding boxes of their parents. # Nodes without mesh data should not affect bounding boxes of their parents.
continue continue
if self._aabb is None: if self._aabb is None:

View file

@ -103,13 +103,14 @@ class CuraContainerRegistry(ContainerRegistry):
# \param instance_ids \type{list} the IDs of the profiles to export. # \param instance_ids \type{list} the IDs of the profiles to export.
# \param file_name \type{str} the full path and filename to export to. # \param file_name \type{str} the full path and filename to export to.
# \param file_type \type{str} the file type with the format "<description> (*.<extension>)" # \param file_type \type{str} the file type with the format "<description> (*.<extension>)"
def exportQualityProfile(self, container_list, file_name, file_type): # \return True if the export succeeded, false otherwise.
def exportQualityProfile(self, container_list, file_name, file_type) -> bool:
# Parse the fileType to deduce what plugin can save the file format. # Parse the fileType to deduce what plugin can save the file format.
# fileType has the format "<description> (*.<extension>)" # fileType has the format "<description> (*.<extension>)"
split = file_type.rfind(" (*.") # Find where the description ends and the extension starts. split = file_type.rfind(" (*.") # Find where the description ends and the extension starts.
if split < 0: # Not found. Invalid format. if split < 0: # Not found. Invalid format.
Logger.log("e", "Invalid file format identifier %s", file_type) Logger.log("e", "Invalid file format identifier %s", file_type)
return return False
description = file_type[:split] description = file_type[:split]
extension = file_type[split + 4:-1] # Leave out the " (*." and ")". extension = file_type[split + 4:-1] # Leave out the " (*." and ")".
if not file_name.endswith("." + extension): # Auto-fill the extension if the user did not provide any. if not file_name.endswith("." + extension): # Auto-fill the extension if the user did not provide any.
@ -121,7 +122,7 @@ class CuraContainerRegistry(ContainerRegistry):
result = QMessageBox.question(None, catalog.i18nc("@title:window", "File Already Exists"), result = QMessageBox.question(None, catalog.i18nc("@title:window", "File Already Exists"),
catalog.i18nc("@label Don't translate the XML tag <filename>!", "The file <filename>{0}</filename> already exists. Are you sure you want to overwrite it?").format(file_name)) catalog.i18nc("@label Don't translate the XML tag <filename>!", "The file <filename>{0}</filename> already exists. Are you sure you want to overwrite it?").format(file_name))
if result == QMessageBox.No: if result == QMessageBox.No:
return return False
profile_writer = self._findProfileWriter(extension, description) profile_writer = self._findProfileWriter(extension, description)
try: try:
@ -132,17 +133,18 @@ class CuraContainerRegistry(ContainerRegistry):
lifetime = 0, lifetime = 0,
title = catalog.i18nc("@info:title", "Error")) title = catalog.i18nc("@info:title", "Error"))
m.show() m.show()
return return False
if not success: if not success:
Logger.log("w", "Failed to export profile to %s: Writer plugin reported failure.", file_name) Logger.log("w", "Failed to export profile to %s: Writer plugin reported failure.", file_name)
m = Message(catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Failed to export profile to <filename>{0}</filename>: Writer plugin reported failure.", file_name), m = Message(catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Failed to export profile to <filename>{0}</filename>: Writer plugin reported failure.", file_name),
lifetime = 0, lifetime = 0,
title = catalog.i18nc("@info:title", "Error")) title = catalog.i18nc("@info:title", "Error"))
m.show() m.show()
return return False
m = Message(catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Exported profile to <filename>{0}</filename>", file_name), m = Message(catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Exported profile to <filename>{0}</filename>", file_name),
title = catalog.i18nc("@info:title", "Export succeeded")) title = catalog.i18nc("@info:title", "Export succeeded"))
m.show() m.show()
return True
## Gets the plugin object matching the criteria ## Gets the plugin object matching the criteria
# \param extension # \param extension
@ -169,9 +171,6 @@ class CuraContainerRegistry(ContainerRegistry):
if not file_name: if not file_name:
return { "status": "error", "message": catalog.i18nc("@info:status Don't translate the XML tags <filename>!", "Failed to import profile from <filename>{0}</filename>: {1}", file_name, "Invalid path")} return { "status": "error", "message": catalog.i18nc("@info:status Don't translate the XML tags <filename>!", "Failed to import profile from <filename>{0}</filename>: {1}", file_name, "Invalid path")}
plugin_registry = PluginRegistry.getInstance()
extension = file_name.split(".")[-1]
global_stack = Application.getInstance().getGlobalContainerStack() global_stack = Application.getInstance().getGlobalContainerStack()
if not global_stack: if not global_stack:
return {"status": "error", "message": catalog.i18nc("@info:status Don't translate the XML tags <filename>!", "Can't import profile from <filename>{0}</filename> before a printer is added.", file_name)} return {"status": "error", "message": catalog.i18nc("@info:status Don't translate the XML tags <filename>!", "Can't import profile from <filename>{0}</filename> before a printer is added.", file_name)}
@ -180,6 +179,9 @@ class CuraContainerRegistry(ContainerRegistry):
for position in sorted(global_stack.extruders): for position in sorted(global_stack.extruders):
machine_extruders.append(global_stack.extruders[position]) machine_extruders.append(global_stack.extruders[position])
plugin_registry = PluginRegistry.getInstance()
extension = file_name.split(".")[-1]
for plugin_id, meta_data in self._getIOPlugins("profile_reader"): for plugin_id, meta_data in self._getIOPlugins("profile_reader"):
if meta_data["profile_reader"][0]["extension"] != extension: if meta_data["profile_reader"][0]["extension"] != extension:
continue continue
@ -281,7 +283,7 @@ class CuraContainerRegistry(ContainerRegistry):
profile.addInstance(new_instance) profile.addInstance(new_instance)
profile.setDirty(True) profile.setDirty(True)
global_profile.removeInstance(qc_setting_key, postpone_emit=True) global_profile.removeInstance(qc_setting_key, postpone_emit = True)
extruder_profiles.append(profile) extruder_profiles.append(profile)
for profile in extruder_profiles: for profile in extruder_profiles:

View file

@ -12,7 +12,7 @@ from UM.Scene.SceneNode import SceneNode
from UM.Scene.Selection import Selection from UM.Scene.Selection import Selection
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
from UM.Settings.ContainerRegistry import ContainerRegistry # Finding containers by ID. from UM.Settings.ContainerRegistry import ContainerRegistry # Finding containers by ID.
from UM.Settings.ContainerStack import ContainerStack from UM.Decorators import deprecated
from typing import Any, cast, Dict, List, Optional, TYPE_CHECKING, Union from typing import Any, cast, Dict, List, Optional, TYPE_CHECKING, Union
@ -95,6 +95,7 @@ class ExtruderManager(QObject):
# #
# \param index The index of the extruder whose name to get. # \param index The index of the extruder whose name to get.
@pyqtSlot(int, result = str) @pyqtSlot(int, result = str)
@deprecated("Use Cura.MachineManager.activeMachine.extruders[index].name instead", "4.3")
def getExtruderName(self, index: int) -> str: def getExtruderName(self, index: int) -> str:
try: try:
return self.getActiveExtruderStacks()[index].getName() return self.getActiveExtruderStacks()[index].getName()
@ -131,7 +132,7 @@ class ExtruderManager(QObject):
elif current_extruder_trains: elif current_extruder_trains:
object_extruders.add(current_extruder_trains[0].getId()) object_extruders.add(current_extruder_trains[0].getId())
self._selected_object_extruders = list(object_extruders) # type: List[Union[str, "ExtruderStack"]] self._selected_object_extruders = list(object_extruders)
return self._selected_object_extruders return self._selected_object_extruders
@ -140,7 +141,7 @@ class ExtruderManager(QObject):
# This will trigger a recalculation of the extruders used for the # This will trigger a recalculation of the extruders used for the
# selection. # selection.
def resetSelectedObjectExtruders(self) -> None: def resetSelectedObjectExtruders(self) -> None:
self._selected_object_extruders = [] # type: List[Union[str, "ExtruderStack"]] self._selected_object_extruders = []
self.selectedObjectExtrudersChanged.emit() self.selectedObjectExtrudersChanged.emit()
@pyqtSlot(result = QObject) @pyqtSlot(result = QObject)
@ -180,7 +181,7 @@ class ExtruderManager(QObject):
# \param setting_key \type{str} The setting to get the property of. # \param setting_key \type{str} The setting to get the property of.
# \param property \type{str} The property to get. # \param property \type{str} The property to get.
# \return \type{List} the list of results # \return \type{List} the list of results
def getAllExtruderSettings(self, setting_key: str, prop: str) -> List: def getAllExtruderSettings(self, setting_key: str, prop: str) -> List[Any]:
result = [] result = []
for extruder_stack in self.getActiveExtruderStacks(): for extruder_stack in self.getActiveExtruderStacks():
@ -205,7 +206,7 @@ class ExtruderManager(QObject):
# list. # list.
# #
# \return A list of extruder stacks. # \return A list of extruder stacks.
def getUsedExtruderStacks(self) -> List["ContainerStack"]: def getUsedExtruderStacks(self) -> List["ExtruderStack"]:
global_stack = self._application.getGlobalContainerStack() global_stack = self._application.getGlobalContainerStack()
container_registry = ContainerRegistry.getInstance() container_registry = ContainerRegistry.getInstance()
@ -279,7 +280,8 @@ class ExtruderManager(QObject):
extruder_str_nr = str(global_stack.getProperty("adhesion_extruder_nr", "value")) extruder_str_nr = str(global_stack.getProperty("adhesion_extruder_nr", "value"))
if extruder_str_nr == "-1": if extruder_str_nr == "-1":
extruder_str_nr = self._application.getMachineManager().defaultExtruderPosition extruder_str_nr = self._application.getMachineManager().defaultExtruderPosition
used_extruder_stack_ids.add(self.extruderIds[extruder_str_nr]) if extruder_str_nr in self.extruderIds:
used_extruder_stack_ids.add(self.extruderIds[extruder_str_nr])
try: try:
return [container_registry.findContainerStacks(id = stack_id)[0] for stack_id in used_extruder_stack_ids] return [container_registry.findContainerStacks(id = stack_id)[0] for stack_id in used_extruder_stack_ids]

View file

@ -264,18 +264,18 @@ class GlobalStack(CuraContainerStack):
def getHeadAndFansCoordinates(self): def getHeadAndFansCoordinates(self):
return self.getProperty("machine_head_with_fans_polygon", "value") return self.getProperty("machine_head_with_fans_polygon", "value")
def getHasMaterials(self) -> bool: @pyqtProperty(int, constant=True)
def hasMaterials(self):
return parseBool(self.getMetaDataEntry("has_materials", False)) return parseBool(self.getMetaDataEntry("has_materials", False))
def getHasVariants(self) -> bool: @pyqtProperty(int, constant=True)
def hasVariants(self):
return parseBool(self.getMetaDataEntry("has_variants", False)) return parseBool(self.getMetaDataEntry("has_variants", False))
def getHasVariantsBuildPlates(self) -> bool: @pyqtProperty(int, constant=True)
def hasVariantBuildplates(self) -> bool:
return parseBool(self.getMetaDataEntry("has_variant_buildplates", False)) return parseBool(self.getMetaDataEntry("has_variant_buildplates", False))
def getHasMachineQuality(self) -> bool:
return parseBool(self.getMetaDataEntry("has_machine_quality", False))
## Get default firmware file name if one is specified in the firmware ## Get default firmware file name if one is specified in the firmware
@pyqtSlot(result = str) @pyqtSlot(result = str)
def getDefaultFirmwareName(self) -> str: def getDefaultFirmwareName(self) -> str:

View file

@ -38,11 +38,10 @@ from .CuraStackBuilder import CuraStackBuilder
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
from cura.Settings.GlobalStack import GlobalStack
if TYPE_CHECKING: if TYPE_CHECKING:
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from cura.Settings.CuraContainerStack import CuraContainerStack from cura.Settings.CuraContainerStack import CuraContainerStack
from cura.Settings.GlobalStack import GlobalStack
from cura.Machines.MaterialManager import MaterialManager from cura.Machines.MaterialManager import MaterialManager
from cura.Machines.QualityManager import QualityManager from cura.Machines.QualityManager import QualityManager
from cura.Machines.VariantManager import VariantManager from cura.Machines.VariantManager import VariantManager
@ -388,12 +387,13 @@ class MachineManager(QObject):
machines = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter) machines = CuraContainerRegistry.getInstance().findContainerStacks(type = "machine", **metadata_filter)
for machine in machines: for machine in machines:
if machine.definition.getId() == definition_id: if machine.definition.getId() == definition_id:
return machine return cast(GlobalStack, machine)
return None return None
@pyqtSlot(str) @pyqtSlot(str)
@pyqtSlot(str, str) @pyqtSlot(str, str)
def addMachine(self, definition_id: str, name: Optional[str] = None) -> None: def addMachine(self, definition_id: str, name: Optional[str] = None) -> None:
Logger.log("i", "Trying to add a machine with the definition id [%s]", definition_id)
if name is None: if name is None:
definitions = CuraContainerRegistry.getInstance().findDefinitionContainers(id = definition_id) definitions = CuraContainerRegistry.getInstance().findDefinitionContainers(id = definition_id)
if definitions: if definitions:
@ -464,6 +464,7 @@ class MachineManager(QObject):
# \param key \type{str} the name of the key to delete # \param key \type{str} the name of the key to delete
@pyqtSlot(str) @pyqtSlot(str)
def clearUserSettingAllCurrentStacks(self, key: str) -> None: def clearUserSettingAllCurrentStacks(self, key: str) -> None:
Logger.log("i", "Clearing the setting [%s] from all stacks", key)
if not self._global_container_stack: if not self._global_container_stack:
return return
@ -536,6 +537,7 @@ class MachineManager(QObject):
return bool(self._printer_output_devices) return bool(self._printer_output_devices)
@pyqtProperty(bool, notify = printerConnectedStatusChanged) @pyqtProperty(bool, notify = printerConnectedStatusChanged)
@deprecated("use Cura.MachineManager.activeMachine.configuredConnectionTypes instead", "4.2")
def activeMachineHasRemoteConnection(self) -> bool: def activeMachineHasRemoteConnection(self) -> bool:
if self._global_container_stack: if self._global_container_stack:
has_remote_connection = False has_remote_connection = False
@ -786,6 +788,7 @@ class MachineManager(QObject):
@pyqtSlot(str) @pyqtSlot(str)
def removeMachine(self, machine_id: str) -> None: def removeMachine(self, machine_id: str) -> None:
Logger.log("i", "Attempting to remove a machine with the id [%s]", machine_id)
# If the machine that is being removed is the currently active machine, set another machine as the active machine. # If the machine that is being removed is the currently active machine, set another machine as the active machine.
activate_new_machine = (self._global_container_stack and self._global_container_stack.getId() == machine_id) activate_new_machine = (self._global_container_stack and self._global_container_stack.getId() == machine_id)
@ -813,21 +816,24 @@ class MachineManager(QObject):
self.removeMachine(hidden_containers[0].getId()) self.removeMachine(hidden_containers[0].getId())
@pyqtProperty(bool, notify = globalContainerChanged) @pyqtProperty(bool, notify = globalContainerChanged)
@deprecated("use Cura.MachineManager.activeMachine.hasMaterials instead", "4.2")
def hasMaterials(self) -> bool: def hasMaterials(self) -> bool:
if self._global_container_stack: if self._global_container_stack:
return self._global_container_stack.getHasMaterials() return self._global_container_stack.hasMaterials
return False return False
@pyqtProperty(bool, notify = globalContainerChanged) @pyqtProperty(bool, notify = globalContainerChanged)
@deprecated("use Cura.MachineManager.activeMachine.hasVariants instead", "4.2")
def hasVariants(self) -> bool: def hasVariants(self) -> bool:
if self._global_container_stack: if self._global_container_stack:
return self._global_container_stack.getHasVariants() return self._global_container_stack.hasVariants
return False return False
@pyqtProperty(bool, notify = globalContainerChanged) @pyqtProperty(bool, notify = globalContainerChanged)
@deprecated("use Cura.MachineManager.activeMachine.hasVariantBuildplates instead", "4.2")
def hasVariantBuildplates(self) -> bool: def hasVariantBuildplates(self) -> bool:
if self._global_container_stack: if self._global_container_stack:
return self._global_container_stack.getHasVariantsBuildPlates() return self._global_container_stack.hasVariantBuildplates
return False return False
## The selected buildplate is compatible if it is compatible with all the materials in all the extruders ## The selected buildplate is compatible if it is compatible with all the materials in all the extruders
@ -890,17 +896,12 @@ class MachineManager(QObject):
result = [] # type: List[str] result = [] # type: List[str]
for setting_instance in container.findInstances(): for setting_instance in container.findInstances():
setting_key = setting_instance.definition.key setting_key = setting_instance.definition.key
setting_enabled = self._global_container_stack.getProperty(setting_key, "enabled")
if not setting_enabled:
# A setting is not visible anymore
result.append(setting_key)
Logger.log("d", "Reset setting [%s] from [%s] because the setting is no longer enabled", setting_key, container)
continue
if not self._global_container_stack.getProperty(setting_key, "type") in ("extruder", "optional_extruder"): if not self._global_container_stack.getProperty(setting_key, "type") in ("extruder", "optional_extruder"):
continue continue
old_value = container.getProperty(setting_key, "value") old_value = container.getProperty(setting_key, "value")
if isinstance(old_value, SettingFunction):
old_value = old_value(self._global_container_stack)
if int(old_value) < 0: if int(old_value) < 0:
continue continue
if int(old_value) >= extruder_count or not self._global_container_stack.extruders[str(old_value)].isEnabled: if int(old_value) >= extruder_count or not self._global_container_stack.extruders[str(old_value)].isEnabled:
@ -919,9 +920,8 @@ class MachineManager(QObject):
# Apply quality changes that are incompatible to user changes, so we do not change the quality changes itself. # Apply quality changes that are incompatible to user changes, so we do not change the quality changes itself.
self._global_container_stack.userChanges.setProperty(setting_key, "value", self._default_extruder_position) self._global_container_stack.userChanges.setProperty(setting_key, "value", self._default_extruder_position)
if add_user_changes: if add_user_changes:
caution_message = Message(catalog.i18nc( caution_message = Message(
"@info:generic", catalog.i18nc("@info:message Followed by a list of settings.", "Settings have been changed to match the current availability of extruders:") + " [{settings_list}]".format(settings_list = ", ".join(add_user_changes)),
"Settings have been changed to match the current availability of extruders: [%s]" % ", ".join(add_user_changes)),
lifetime = 0, lifetime = 0,
title = catalog.i18nc("@info:title", "Settings updated")) title = catalog.i18nc("@info:title", "Settings updated"))
caution_message.show() caution_message.show()
@ -985,6 +985,8 @@ class MachineManager(QObject):
self._application.globalContainerStackChanged.emit() self._application.globalContainerStackChanged.emit()
self.forceUpdateAllSettings() self.forceUpdateAllSettings()
# Note that this function is deprecated, but the decorators for this don't play well together!
# @deprecated("use Cura.MachineManager.activeMachine.extruders instead", "4.2")
@pyqtSlot(int, result = QObject) @pyqtSlot(int, result = QObject)
def getExtruder(self, position: int) -> Optional[ExtruderStack]: def getExtruder(self, position: int) -> Optional[ExtruderStack]:
if self._global_container_stack: if self._global_container_stack:
@ -1099,6 +1101,7 @@ class MachineManager(QObject):
container.removeInstance(setting_name) container.removeInstance(setting_name)
@pyqtProperty("QVariantList", notify = globalContainerChanged) @pyqtProperty("QVariantList", notify = globalContainerChanged)
@deprecated("use Cura.MachineManager.activeMachine.extruders instead", "4.2")
def currentExtruderPositions(self) -> List[str]: def currentExtruderPositions(self) -> List[str]:
if self._global_container_stack is None: if self._global_container_stack is None:
return [] return []
@ -1108,9 +1111,17 @@ class MachineManager(QObject):
def _onRootMaterialChanged(self) -> None: def _onRootMaterialChanged(self) -> None:
self._current_root_material_id = {} self._current_root_material_id = {}
changed = False
if self._global_container_stack: if self._global_container_stack:
for position in self._global_container_stack.extruders: for position in self._global_container_stack.extruders:
self._current_root_material_id[position] = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file") material_id = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file")
if position not in self._current_root_material_id or material_id != self._current_root_material_id[position]:
changed = True
self._current_root_material_id[position] = material_id
if changed:
self.activeMaterialChanged.emit()
@pyqtProperty("QVariant", notify = rootMaterialChanged) @pyqtProperty("QVariant", notify = rootMaterialChanged)
def currentRootMaterialId(self) -> Dict[str, str]: def currentRootMaterialId(self) -> Dict[str, str]:
@ -1263,8 +1274,8 @@ class MachineManager(QObject):
if self._global_container_stack is not None: if self._global_container_stack is not None:
if Util.parseBool(self._global_container_stack.getMetaDataEntry("has_materials", False)): if Util.parseBool(self._global_container_stack.getMetaDataEntry("has_materials", False)):
for position, extruder in self._global_container_stack.extruders.items(): for position, extruder in self._global_container_stack.extruders.items():
if extruder.isEnabled and not extruder.material.getMetaDataEntry("compatible"): if not extruder.isEnabled:
return False continue
if not extruder.material.getMetaDataEntry("compatible"): if not extruder.material.getMetaDataEntry("compatible"):
return False return False
return True return True
@ -1273,7 +1284,7 @@ class MachineManager(QObject):
def _updateQualityWithMaterial(self, *args: Any) -> None: def _updateQualityWithMaterial(self, *args: Any) -> None:
if self._global_container_stack is None: if self._global_container_stack is None:
return return
Logger.log("i", "Updating quality/quality_changes due to material change") Logger.log("d", "Updating quality/quality_changes due to material change")
current_quality_type = None current_quality_type = None
if self._current_quality_group: if self._current_quality_group:
current_quality_type = self._current_quality_group.quality_type current_quality_type = self._current_quality_group.quality_type
@ -1354,6 +1365,7 @@ class MachineManager(QObject):
# instance with the same network key. # instance with the same network key.
@pyqtSlot(str) @pyqtSlot(str)
def switchPrinterType(self, machine_name: str) -> None: def switchPrinterType(self, machine_name: str) -> None:
Logger.log("i", "Attempting to switch the printer type to [%s]", machine_name)
# Don't switch if the user tries to change to the same type of printer # Don't switch if the user tries to change to the same type of printer
if self._global_container_stack is None or self.activeMachineDefinitionName == machine_name: if self._global_container_stack is None or self.activeMachineDefinitionName == machine_name:
return return
@ -1643,21 +1655,6 @@ class MachineManager(QObject):
return abbr_machine return abbr_machine
# Checks if the given machine type name in the available machine list.
# The machine type is a code name such as "ultimaker_3", while the machine type name is the human-readable name of
# the machine type, which is "Ultimaker 3" for "ultimaker_3".
def hasHumanReadableMachineTypeName(self, machine_type_name: str) -> bool:
results = self._container_registry.findDefinitionContainersMetadata(name = machine_type_name)
return len(results) > 0
@pyqtSlot(str, result = str)
def getMachineTypeNameFromId(self, machine_type_id: str) -> str:
machine_type_name = ""
results = self._container_registry.findDefinitionContainersMetadata(id = machine_type_id)
if results:
machine_type_name = results[0]["name"]
return machine_type_name
# Gets all machines that belong to the given group_id. # Gets all machines that belong to the given group_id.
def getMachinesInGroup(self, group_id: str) -> List["GlobalStack"]: def getMachinesInGroup(self, group_id: str) -> List["GlobalStack"]:
return self._container_registry.findContainerStacks(type = "machine", group_id = group_id) return self._container_registry.findContainerStacks(type = "machine", group_id = group_id)

View file

@ -114,14 +114,9 @@ class SettingOverrideDecorator(SceneNodeDecorator):
def _onSettingChanged(self, setting_key, property_name): # Reminder: 'property' is a built-in function def _onSettingChanged(self, setting_key, property_name): # Reminder: 'property' is a built-in function
# We're only interested in a few settings and only if it's value changed. # We're only interested in a few settings and only if it's value changed.
if property_name == "value": if property_name == "value":
if setting_key in self._non_printing_mesh_settings or setting_key in self._non_thumbnail_visible_settings: # Trigger slice/need slicing if the value has changed.
# Trigger slice/need slicing if the value has changed. self._is_non_printing_mesh = self._evaluateIsNonPrintingMesh()
new_is_non_printing_mesh = self._evaluateIsNonPrintingMesh() self._is_non_thumbnail_visible_mesh = self._evaluateIsNonThumbnailVisibleMesh()
self._is_non_thumbnail_visible_mesh = self._evaluateIsNonThumbnailVisibleMesh()
if self._is_non_printing_mesh != new_is_non_printing_mesh:
self._is_non_printing_mesh = new_is_non_printing_mesh
Application.getInstance().getBackend().needsSlicing() Application.getInstance().getBackend().needsSlicing()
Application.getInstance().getBackend().tickle() Application.getInstance().getBackend().tickle()

View file

@ -1,9 +1,11 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import copy import copy
from UM.Settings.constant_instance_containers import EMPTY_CONTAINER_ID, empty_container from UM.Settings.constant_instance_containers import EMPTY_CONTAINER_ID, empty_container
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
# Empty definition changes # Empty definition changes
@ -28,7 +30,7 @@ empty_material_container.setMetaDataEntry("type", "material")
EMPTY_QUALITY_CONTAINER_ID = "empty_quality" EMPTY_QUALITY_CONTAINER_ID = "empty_quality"
empty_quality_container = copy.deepcopy(empty_container) empty_quality_container = copy.deepcopy(empty_container)
empty_quality_container.setMetaDataEntry("id", EMPTY_QUALITY_CONTAINER_ID) empty_quality_container.setMetaDataEntry("id", EMPTY_QUALITY_CONTAINER_ID)
empty_quality_container.setName("Not Supported") empty_quality_container.setName(catalog.i18nc("@info:not supported profile", "Not supported"))
empty_quality_container.setMetaDataEntry("quality_type", "not_supported") empty_quality_container.setMetaDataEntry("quality_type", "not_supported")
empty_quality_container.setMetaDataEntry("type", "quality") empty_quality_container.setMetaDataEntry("type", "quality")
empty_quality_container.setMetaDataEntry("supported", False) empty_quality_container.setMetaDataEntry("supported", False)

View file

@ -48,12 +48,12 @@ class Snapshot:
# determine zoom and look at # determine zoom and look at
bbox = None bbox = None
for node in DepthFirstIterator(root): for node in DepthFirstIterator(root):
if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible() and not node.callDecoration("isNonThumbnailVisibleMesh"): if not getattr(node, "_outside_buildarea", False):
if bbox is None: if node.callDecoration("isSliceable") and node.getMeshData() and node.isVisible() and not node.callDecoration("isNonThumbnailVisibleMesh"):
bbox = node.getBoundingBox() if bbox is None:
else: bbox = node.getBoundingBox()
bbox = bbox + node.getBoundingBox() else:
bbox = bbox + node.getBoundingBox()
# If there is no bounding box, it means that there is no model in the buildplate # If there is no bounding box, it means that there is no model in the buildplate
if bbox is None: if bbox is None:
return None return None
@ -66,7 +66,7 @@ class Snapshot:
looking_from_offset = Vector(-1, 1, 2) looking_from_offset = Vector(-1, 1, 2)
if size > 0: if size > 0:
# determine the watch distance depending on the size # determine the watch distance depending on the size
looking_from_offset = looking_from_offset * size * 1.3 looking_from_offset = looking_from_offset * size * 1.75
camera.setPosition(look_at + looking_from_offset) camera.setPosition(look_at + looking_from_offset)
camera.lookAt(look_at) camera.lookAt(look_at)

View file

@ -1,10 +1,10 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from UM.Logger import Logger
import re
from typing import Any, Dict, List, Optional, Union
from collections import defaultdict from PyQt5.QtCore import QTimer, Qt
from typing import Dict
from PyQt5.QtCore import QTimer
from UM.Application import Application from UM.Application import Application
from UM.Qt.ListModel import ListModel from UM.Qt.ListModel import ListModel
@ -17,13 +17,40 @@ from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
# Simple convenience class to keep stuff together. Since we're still stuck on python 3.5, we can't use the full
# typed named tuple, so we have to do it like this.
# Once we are at python 3.6, feel free to change this to a named tuple.
class _NodeInfo:
def __init__(self, index_to_node: Optional[Dict[int, SceneNode]] = None, nodes_to_rename: Optional[List[SceneNode]] = None, is_group: bool = False) -> None:
if index_to_node is None:
index_to_node = {}
if nodes_to_rename is None:
nodes_to_rename = []
self.index_to_node = index_to_node # type: Dict[int, SceneNode]
self.nodes_to_rename = nodes_to_rename # type: List[SceneNode]
self.is_group = is_group # type: bool
## Keep track of all objects in the project ## Keep track of all objects in the project
class ObjectsModel(ListModel): class ObjectsModel(ListModel):
def __init__(self) -> None: NameRole = Qt.UserRole + 1
super().__init__() SelectedRole = Qt.UserRole + 2
OutsideAreaRole = Qt.UserRole + 3
BuilplateNumberRole = Qt.UserRole + 4
NodeRole = Qt.UserRole + 5
def __init__(self, parent = None) -> None:
super().__init__(parent)
self.addRoleName(self.NameRole, "name")
self.addRoleName(self.SelectedRole, "selected")
self.addRoleName(self.OutsideAreaRole, "outside_build_area")
self.addRoleName(self.BuilplateNumberRole, "buildplate_number")
self.addRoleName(self.NodeRole, "node")
Application.getInstance().getController().getScene().sceneChanged.connect(self._updateSceneDelayed) Application.getInstance().getController().getScene().sceneChanged.connect(self._updateSceneDelayed)
Application.getInstance().getPreferences().preferenceChanged.connect(self._updateDelayed) Application.getInstance().getPreferences().preferenceChanged.connect(self._updateDelayed)
Selection.selectionChanged.connect(self._updateDelayed)
self._update_timer = QTimer() self._update_timer = QTimer()
self._update_timer.setInterval(200) self._update_timer.setInterval(200)
@ -32,6 +59,11 @@ class ObjectsModel(ListModel):
self._build_plate_number = -1 self._build_plate_number = -1
self._group_name_template = catalog.i18nc("@label", "Group #{group_nr}")
self._group_name_prefix = self._group_name_template.split("#")[0]
self._naming_regex = re.compile("^(.+)\(([0-9]+)\)$")
def setActiveBuildPlate(self, nr: int) -> None: def setActiveBuildPlate(self, nr: int) -> None:
if self._build_plate_number != nr: if self._build_plate_number != nr:
self._build_plate_number = nr self._build_plate_number = nr
@ -44,61 +76,109 @@ class ObjectsModel(ListModel):
def _updateDelayed(self, *args) -> None: def _updateDelayed(self, *args) -> None:
self._update_timer.start() self._update_timer.start()
def _shouldNodeBeHandled(self, node: SceneNode) -> bool:
is_group = bool(node.callDecoration("isGroup"))
if not node.callDecoration("isSliceable") and not is_group:
return False
parent = node.getParent()
if parent and parent.callDecoration("isGroup"):
return False # Grouped nodes don't need resetting as their parent (the group) is resetted)
node_build_plate_number = node.callDecoration("getBuildPlateNumber")
if Application.getInstance().getPreferences().getValue("view/filter_current_build_plate") and node_build_plate_number != self._build_plate_number:
return False
return True
def _renameNodes(self, node_info_dict: Dict[str, _NodeInfo]) -> List[SceneNode]:
# Go through all names and find out the names for all nodes that need to be renamed.
all_nodes = [] # type: List[SceneNode]
for name, node_info in node_info_dict.items():
# First add the ones that do not need to be renamed.
for node in node_info.index_to_node.values():
all_nodes.append(node)
# Generate new names for the nodes that need to be renamed
current_index = 0
for node in node_info.nodes_to_rename:
current_index += 1
while current_index in node_info.index_to_node:
current_index += 1
if not node_info.is_group:
new_group_name = "{0}({1})".format(name, current_index)
else:
new_group_name = "{0}#{1}".format(name, current_index)
old_name = node.getName()
node.setName(new_group_name)
Logger.log("d", "Node [%s] renamed to [%s]", old_name, new_group_name)
all_nodes.append(node)
return all_nodes
def _update(self, *args) -> None: def _update(self, *args) -> None:
nodes = [] nodes = [] # type: List[Dict[str, Union[str, int, bool, SceneNode]]]
filter_current_build_plate = Application.getInstance().getPreferences().getValue("view/filter_current_build_plate") name_to_node_info_dict = {} # type: Dict[str, _NodeInfo]
active_build_plate_number = self._build_plate_number
group_nr = 1
name_count_dict = defaultdict(int) # type: Dict[str, int]
for node in DepthFirstIterator(Application.getInstance().getController().getScene().getRoot()): # type: ignore for node in DepthFirstIterator(Application.getInstance().getController().getScene().getRoot()): # type: ignore
if not isinstance(node, SceneNode): if not self._shouldNodeBeHandled(node):
continue
if (not node.getMeshData() and not node.callDecoration("getLayerData")) and not node.callDecoration("isGroup"):
continue continue
parent = node.getParent() is_group = bool(node.callDecoration("isGroup"))
if parent and parent.callDecoration("isGroup"):
continue # Grouped nodes don't need resetting as their parent (the group) is resetted)
if not node.callDecoration("isSliceable") and not node.callDecoration("isGroup"):
continue
node_build_plate_number = node.callDecoration("getBuildPlateNumber")
if filter_current_build_plate and node_build_plate_number != active_build_plate_number:
continue
if not node.callDecoration("isGroup"): force_rename = False
if not is_group:
# Handle names for individual nodes
name = node.getName() name = node.getName()
name_match = self._naming_regex.fullmatch(name)
if name_match is None:
original_name = name
name_index = 0
else:
original_name = name_match.groups()[0]
name_index = int(name_match.groups()[1])
else: else:
name = catalog.i18nc("@label", "Group #{group_nr}").format(group_nr = str(group_nr)) # Handle names for grouped nodes
group_nr += 1 original_name = self._group_name_prefix
current_name = node.getName()
if current_name.startswith(self._group_name_prefix):
name_index = int(current_name.split("#")[-1])
else:
# Force rename this group because this node has not been named as a group yet, probably because
# it's a newly created group.
name_index = 0
force_rename = True
if original_name not in name_to_node_info_dict:
# Keep track of 2 things:
# - known indices for nodes which doesn't need to be renamed
# - a list of nodes that need to be renamed. When renaming then, we should avoid using the known indices.
name_to_node_info_dict[original_name] = _NodeInfo(is_group = is_group)
node_info = name_to_node_info_dict[original_name]
if not force_rename and name_index not in node_info.index_to_node:
node_info.index_to_node[name_index] = node
else:
node_info.nodes_to_rename.append(node)
all_nodes = self._renameNodes(name_to_node_info_dict)
for node in all_nodes:
if hasattr(node, "isOutsideBuildArea"): if hasattr(node, "isOutsideBuildArea"):
is_outside_build_area = node.isOutsideBuildArea() # type: ignore is_outside_build_area = node.isOutsideBuildArea() # type: ignore
else: else:
is_outside_build_area = False is_outside_build_area = False
#check if we already have an instance of the object based on name node_build_plate_number = node.callDecoration("getBuildPlateNumber")
name_count_dict[name] += 1
name_count = name_count_dict[name]
if name_count > 1:
name = "{0}({1})".format(name, name_count-1)
node.setName(name)
nodes.append({ nodes.append({
"name": name, "name": node.getName(),
"isSelected": Selection.isSelected(node), "selected": Selection.isSelected(node),
"isOutsideBuildArea": is_outside_build_area, "outside_build_area": is_outside_build_area,
"buildPlateNumber": node_build_plate_number, "buildplate_number": node_build_plate_number,
"node": node "node": node
}) })
nodes = sorted(nodes, key=lambda n: n["name"]) nodes = sorted(nodes, key=lambda n: n["name"])
self.setItems(nodes) self.setItems(nodes)
self.itemsChanged.emit()
@staticmethod
def createObjectsModel():
return ObjectsModel()

View file

@ -81,6 +81,7 @@ class PrintInformation(QObject):
"support_interface": catalog.i18nc("@tooltip", "Support Interface"), "support_interface": catalog.i18nc("@tooltip", "Support Interface"),
"support": catalog.i18nc("@tooltip", "Support"), "support": catalog.i18nc("@tooltip", "Support"),
"skirt": catalog.i18nc("@tooltip", "Skirt"), "skirt": catalog.i18nc("@tooltip", "Skirt"),
"prime_tower": catalog.i18nc("@tooltip", "Prime Tower"),
"travel": catalog.i18nc("@tooltip", "Travel"), "travel": catalog.i18nc("@tooltip", "Travel"),
"retract": catalog.i18nc("@tooltip", "Retractions"), "retract": catalog.i18nc("@tooltip", "Retractions"),
"none": catalog.i18nc("@tooltip", "Other") "none": catalog.i18nc("@tooltip", "Other")

View file

@ -0,0 +1,49 @@
# Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import QObject, pyqtSlot
from cura import CuraApplication
#
# This object contains helper/convenience functions for Recommended mode.
#
class RecommendedMode(QObject):
# Sets to use the adhesion or not for the "Adhesion" CheckBox in Recommended mode.
@pyqtSlot(bool)
def setAdhesion(self, checked: bool) -> None:
application = CuraApplication.CuraApplication.getInstance()
global_stack = application.getMachineManager().activeMachine
if global_stack is None:
return
# Remove the adhesion type value set by the user.
adhesion_type_key = "adhesion_type"
user_changes_container = global_stack.userChanges
if adhesion_type_key in user_changes_container.getAllKeys():
user_changes_container.removeInstance(adhesion_type_key)
# Get the default value of adhesion type after user's value has been removed.
# skirt and none are counted as "no adhesion", the others are considered as "with adhesion". The conditions are
# as the following:
# - if the user checks the adhesion checkbox, get the default value (including the custom quality) for adhesion
# type.
# (1) If the default value is "skirt" or "none" (no adhesion), set adhesion_type to "brim".
# (2) If the default value is "with adhesion", do nothing.
# - if the user unchecks the adhesion checkbox, get the default value (including the custom quality) for
# adhesion type.
# (1) If the default value is "skirt" or "none" (no adhesion), do nothing.
# (2) Otherwise, set adhesion_type to "skirt".
value = global_stack.getProperty(adhesion_type_key, "value")
if checked:
if value in ("skirt", "none"):
value = "brim"
else:
if value not in ("skirt", "none"):
value = "skirt"
user_changes_container.setProperty(adhesion_type_key, "value", value)
__all__ = ["RecommendedMode"]

View file

@ -32,7 +32,8 @@ if not known_args["debug"]:
elif Platform.isOSX(): elif Platform.isOSX():
return os.path.expanduser("~/Library/Logs/" + CuraAppName) return os.path.expanduser("~/Library/Logs/" + CuraAppName)
if hasattr(sys, "frozen"): # Do not redirect stdout and stderr to files if we are running CLI.
if hasattr(sys, "frozen") and "cli" not in os.path.basename(sys.argv[0]).lower():
dirpath = get_cura_dir_path() dirpath = get_cura_dir_path()
os.makedirs(dirpath, exist_ok = True) os.makedirs(dirpath, exist_ok = True)
sys.stdout = open(os.path.join(dirpath, "stdout.log"), "w", encoding = "utf-8") sys.stdout = open(os.path.join(dirpath, "stdout.log"), "w", encoding = "utf-8")

View file

@ -419,13 +419,17 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
if parser.has_option("metadata", "enabled"): if parser.has_option("metadata", "enabled"):
extruder_info.enabled = parser["metadata"]["enabled"] extruder_info.enabled = parser["metadata"]["enabled"]
if variant_id not in ("empty", "empty_variant"): if variant_id not in ("empty", "empty_variant"):
extruder_info.variant_info = instance_container_info_dict[variant_id] if variant_id in instance_container_info_dict:
extruder_info.variant_info = instance_container_info_dict[variant_id]
if material_id not in ("empty", "empty_material"): if material_id not in ("empty", "empty_material"):
root_material_id = reverse_material_id_dict[material_id] root_material_id = reverse_material_id_dict[material_id]
extruder_info.root_material_id = root_material_id extruder_info.root_material_id = root_material_id
definition_changes_id = parser["containers"][str(_ContainerIndexes.DefinitionChanges)] definition_changes_id = parser["containers"][str(_ContainerIndexes.DefinitionChanges)]
if definition_changes_id not in ("empty", "empty_definition_changes"): if definition_changes_id not in ("empty", "empty_definition_changes"):
extruder_info.definition_changes_info = instance_container_info_dict[definition_changes_id] extruder_info.definition_changes_info = instance_container_info_dict[definition_changes_id]
user_changes_id = parser["containers"][str(_ContainerIndexes.UserChanges)] user_changes_id = parser["containers"][str(_ContainerIndexes.UserChanges)]
if user_changes_id not in ("empty", "empty_user_changes"): if user_changes_id not in ("empty", "empty_user_changes"):
extruder_info.user_changes_info = instance_container_info_dict[user_changes_id] extruder_info.user_changes_info = instance_container_info_dict[user_changes_id]
@ -905,6 +909,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
continue continue
extruder_info = self._machine_info.extruder_info_dict[position] extruder_info = self._machine_info.extruder_info_dict[position]
if extruder_info.variant_info is None: if extruder_info.variant_info is None:
# If there is no variant_info, try to use the default variant. Otherwise, leave it be.
node = variant_manager.getDefaultVariantNode(global_stack.definition, VariantType.NOZZLE, global_stack)
if node is not None and node.getContainer() is not None:
extruder_stack.variant = node.getContainer()
continue continue
parser = extruder_info.variant_info.parser parser = extruder_info.variant_info.parser

View file

@ -207,7 +207,7 @@ class CuraEngineBackend(QObject, Backend):
self._createSocket() self._createSocket()
if self._process_layers_job is not None: # We were processing layers. Stop that, the layers are going to change soon. if self._process_layers_job is not None: # We were processing layers. Stop that, the layers are going to change soon.
Logger.log("d", "Aborting process layers job...") Logger.log("i", "Aborting process layers job...")
self._process_layers_job.abort() self._process_layers_job.abort()
self._process_layers_job = None self._process_layers_job = None
@ -222,7 +222,7 @@ class CuraEngineBackend(QObject, Backend):
## Perform a slice of the scene. ## Perform a slice of the scene.
def slice(self) -> None: def slice(self) -> None:
Logger.log("d", "Starting to slice...") Logger.log("i", "Starting to slice...")
self._slice_start_time = time() self._slice_start_time = time()
if not self._build_plates_to_be_sliced: if not self._build_plates_to_be_sliced:
self.processingProgress.emit(1.0) self.processingProgress.emit(1.0)
@ -517,9 +517,6 @@ class CuraEngineBackend(QObject, Backend):
self._build_plates_to_be_sliced.append(build_plate_number) self._build_plates_to_be_sliced.append(build_plate_number)
self.printDurationMessage.emit(source_build_plate_number, {}, []) self.printDurationMessage.emit(source_build_plate_number, {}, [])
self.processingProgress.emit(0.0) 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._clearLayerData(build_plate_changed)
self._invokeSlice() self._invokeSlice()
@ -563,10 +560,10 @@ class CuraEngineBackend(QObject, Backend):
## Convenient function: mark everything to slice, emit state and clear layer data ## Convenient function: mark everything to slice, emit state and clear layer data
def needsSlicing(self) -> None: def needsSlicing(self) -> None:
self.determineAutoSlicing()
self.stopSlicing() self.stopSlicing()
self.markSliceAll() self.markSliceAll()
self.processingProgress.emit(0.0) self.processingProgress.emit(0.0)
self.setState(BackendState.NotStarted)
if not self._use_timer: if not self._use_timer:
# With manually having to slice, we want to clear the old invalid layer data. # With manually having to slice, we want to clear the old invalid layer data.
self._clearLayerData() self._clearLayerData()
@ -735,6 +732,7 @@ class CuraEngineBackend(QObject, Backend):
"support_interface": message.time_support_interface, "support_interface": message.time_support_interface,
"support": message.time_support, "support": message.time_support,
"skirt": message.time_skirt, "skirt": message.time_skirt,
"prime_tower": message.time_prime_tower,
"travel": message.time_travel, "travel": message.time_travel,
"retract": message.time_retract, "retract": message.time_retract,
"none": message.time_none "none": message.time_none

View file

@ -1,4 +1,4 @@
#Copyright (c) 2017 Ultimaker B.V. #Copyright (c) 2019 Ultimaker B.V.
#Cura is released under the terms of the LGPLv3 or higher. #Cura is released under the terms of the LGPLv3 or higher.
import gc import gc
@ -136,23 +136,23 @@ class ProcessSlicedLayersJob(Job):
extruder = polygon.extruder extruder = polygon.extruder
line_types = numpy.fromstring(polygon.line_type, dtype="u1") # Convert bytearray to numpy array line_types = numpy.fromstring(polygon.line_type, dtype = "u1") # Convert bytearray to numpy array
line_types = line_types.reshape((-1,1)) line_types = line_types.reshape((-1,1))
points = numpy.fromstring(polygon.points, dtype="f4") # Convert bytearray to numpy array points = numpy.fromstring(polygon.points, dtype = "f4") # Convert bytearray to numpy array
if polygon.point_type == 0: # Point2D if polygon.point_type == 0: # Point2D
points = points.reshape((-1,2)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly. points = points.reshape((-1,2)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly.
else: # Point3D else: # Point3D
points = points.reshape((-1,3)) points = points.reshape((-1,3))
line_widths = numpy.fromstring(polygon.line_width, dtype="f4") # Convert bytearray to numpy array line_widths = numpy.fromstring(polygon.line_width, dtype = "f4") # Convert bytearray to numpy array
line_widths = line_widths.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly. line_widths = line_widths.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly.
line_thicknesses = numpy.fromstring(polygon.line_thickness, dtype="f4") # Convert bytearray to numpy array line_thicknesses = numpy.fromstring(polygon.line_thickness, dtype = "f4") # Convert bytearray to numpy array
line_thicknesses = line_thicknesses.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly. line_thicknesses = line_thicknesses.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly.
line_feedrates = numpy.fromstring(polygon.line_feedrate, dtype="f4") # Convert bytearray to numpy array line_feedrates = numpy.fromstring(polygon.line_feedrate, dtype = "f4") # Convert bytearray to numpy array
line_feedrates = line_feedrates.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly. line_feedrates = line_feedrates.reshape((-1,1)) # We get a linear list of pairs that make up the points, so make numpy interpret them correctly.
# Create a new 3D-array, copy the 2D points over and insert the right height. # Create a new 3D-array, copy the 2D points over and insert the right height.
@ -194,7 +194,7 @@ class ProcessSlicedLayersJob(Job):
manager = ExtruderManager.getInstance() manager = ExtruderManager.getInstance()
extruders = manager.getActiveExtruderStacks() extruders = manager.getActiveExtruderStacks()
if extruders: if extruders:
material_color_map = numpy.zeros((len(extruders), 4), dtype=numpy.float32) material_color_map = numpy.zeros((len(extruders), 4), dtype = numpy.float32)
for extruder in extruders: for extruder in extruders:
position = int(extruder.getMetaDataEntry("position", default = "0")) position = int(extruder.getMetaDataEntry("position", default = "0"))
try: try:
@ -206,8 +206,8 @@ class ProcessSlicedLayersJob(Job):
material_color_map[position, :] = color material_color_map[position, :] = color
else: else:
# Single extruder via global stack. # Single extruder via global stack.
material_color_map = numpy.zeros((1, 4), dtype=numpy.float32) material_color_map = numpy.zeros((1, 4), dtype = numpy.float32)
color_code = global_container_stack.material.getMetaDataEntry("color_code", default="#e0e000") color_code = global_container_stack.material.getMetaDataEntry("color_code", default = "#e0e000")
color = colorCodeToRGBA(color_code) color = colorCodeToRGBA(color_code)
material_color_map[0, :] = color material_color_map[0, :] = color

View file

@ -107,7 +107,7 @@ class StartSliceJob(Job):
for key in stack.getAllKeys(): for key in stack.getAllKeys():
validation_state = stack.getProperty(key, "validationState") validation_state = stack.getProperty(key, "validationState")
if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError): if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError, ValidatorState.Invalid):
Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state) Logger.log("w", "Setting %s is not valid, but %s. Aborting slicing.", key, validation_state)
return True return True
Job.yieldThread() Job.yieldThread()

View file

@ -1,11 +1,14 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
import configparser import configparser
from typing import List, Optional, Tuple
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from UM.Logger import Logger from UM.Logger import Logger
from UM.Settings.ContainerFormatError import ContainerFormatError from UM.Settings.ContainerFormatError import ContainerFormatError
from UM.Settings.InstanceContainer import InstanceContainer # The new profile to make. from UM.Settings.InstanceContainer import InstanceContainer # The new profile to make.
from cura.CuraApplication import CuraApplication
from cura.ReaderWriters.ProfileReader import ProfileReader from cura.ReaderWriters.ProfileReader import ProfileReader
import zipfile import zipfile
@ -17,39 +20,43 @@ import zipfile
class CuraProfileReader(ProfileReader): class CuraProfileReader(ProfileReader):
## Initialises the cura profile reader. ## Initialises the cura profile reader.
# This does nothing since the only other function is basically stateless. # This does nothing since the only other function is basically stateless.
def __init__(self): def __init__(self) -> None:
super().__init__() super().__init__()
## Reads a cura profile from a file and returns it. ## Reads a cura profile from a file and returns it.
# #
# \param file_name The file to read the cura profile from. # \param file_name The file to read the cura profile from.
# \return The cura profile that was in the file, if any. If the file could # \return The cura profiles that were in the file, if any. If the file
# not be read or didn't contain a valid profile, \code None \endcode is # could not be read or didn't contain a valid profile, ``None`` is
# returned. # returned.
def read(self, file_name): def read(self, file_name: str) -> List[Optional[InstanceContainer]]:
try: try:
with zipfile.ZipFile(file_name, "r") as archive: with zipfile.ZipFile(file_name, "r") as archive:
results = [] results = [] # type: List[Optional[InstanceContainer]]
for profile_id in archive.namelist(): for profile_id in archive.namelist():
with archive.open(profile_id) as f: with archive.open(profile_id) as f:
serialized = f.read() serialized = f.read()
profile = self._loadProfile(serialized.decode("utf-8"), profile_id) upgraded_profiles = self._upgradeProfile(serialized.decode("utf-8"), profile_id) #After upgrading it may split into multiple profiles.
if profile is not None: for upgraded_profile in upgraded_profiles:
results.append(profile) serialization, new_id = upgraded_profile
profile = self._loadProfile(serialization, new_id)
if profile is not None:
results.append(profile)
return results return results
except zipfile.BadZipFile: except zipfile.BadZipFile:
# It must be an older profile from Cura 2.1. # It must be an older profile from Cura 2.1.
with open(file_name, encoding = "utf-8") as fhandle: with open(file_name, encoding = "utf-8") as fhandle:
serialized = fhandle.read() serialized_bytes = fhandle.read()
return [self._loadProfile(serialized, profile_id) for serialized, profile_id in self._upgradeProfile(serialized, file_name)] return [self._loadProfile(serialized, profile_id) for serialized, profile_id in self._upgradeProfile(serialized_bytes, file_name)]
## Convert a profile from an old Cura to this Cura if needed. ## Convert a profile from an old Cura to this Cura if needed.
# #
# \param serialized \type{str} The profile data to convert in the serialized on-disk format. # \param serialized The profile data to convert in the serialized on-disk
# \param profile_id \type{str} The name of the profile. # format.
# \return \type{List[Tuple[str,str]]} List of serialized profile strings and matching profile names. # \param profile_id The name of the profile.
def _upgradeProfile(self, serialized, profile_id): # \return List of serialized profile strings and matching profile names.
def _upgradeProfile(self, serialized: str, profile_id: str) -> List[Tuple[str, str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)
@ -61,18 +68,19 @@ class CuraProfileReader(ProfileReader):
return [] return []
version = int(parser["general"]["version"]) version = int(parser["general"]["version"])
setting_version = int(parser["metadata"].get("setting_version", "0"))
if InstanceContainer.Version != version: if InstanceContainer.Version != version:
name = parser["general"]["name"] name = parser["general"]["name"]
return self._upgradeProfileVersion(serialized, name, version) return self._upgradeProfileVersion(serialized, name, version, setting_version)
else: else:
return [(serialized, profile_id)] return [(serialized, profile_id)]
## Load a profile from a serialized string. ## Load a profile from a serialized string.
# #
# \param serialized \type{str} The profile data to read. # \param serialized The profile data to read.
# \param profile_id \type{str} The name of the profile. # \param profile_id The name of the profile.
# \return \type{InstanceContainer|None} # \return The profile that was stored in the string.
def _loadProfile(self, serialized, profile_id): def _loadProfile(self, serialized: str, profile_id: str) -> Optional[InstanceContainer]:
# Create an empty profile. # Create an empty profile.
profile = InstanceContainer(profile_id) profile = InstanceContainer(profile_id)
profile.setMetaDataEntry("type", "quality_changes") profile.setMetaDataEntry("type", "quality_changes")
@ -88,21 +96,31 @@ class CuraProfileReader(ProfileReader):
## Upgrade a serialized profile to the current profile format. ## Upgrade a serialized profile to the current profile format.
# #
# \param serialized \type{str} The profile data to convert. # \param serialized The profile data to convert.
# \param profile_id \type{str} The name of the profile. # \param profile_id The name of the profile.
# \param source_version \type{int} The profile version of 'serialized'. # \param source_version The profile version of 'serialized'.
# \return \type{List[Tuple[str,str]]} List of serialized profile strings and matching profile names. # \return List of serialized profile strings and matching profile names.
def _upgradeProfileVersion(self, serialized, profile_id, source_version): def _upgradeProfileVersion(self, serialized: str, profile_id: str, main_version: int, setting_version: int) -> List[Tuple[str, str]]:
converter_plugins = PluginRegistry.getInstance().getAllMetaData(filter={"version_upgrade": {} }, active_only=True) source_version = main_version * 1000000 + setting_version
source_format = ("profile", source_version) from UM.VersionUpgradeManager import VersionUpgradeManager
profile_convert_funcs = [plugin["version_upgrade"][source_format][2] for plugin in converter_plugins results = VersionUpgradeManager.getInstance().updateFilesData("quality_changes", source_version, [serialized], [profile_id])
if source_format in plugin["version_upgrade"] and plugin["version_upgrade"][source_format][1] == InstanceContainer.Version] if results is None:
if not profile_convert_funcs:
return [] return []
filenames, outputs = profile_convert_funcs[0](serialized, profile_id) serialized = results.files_data[0]
if filenames is None and outputs is None:
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized)
if "general" not in parser:
Logger.log("w", "Missing required section 'general'.")
return [] return []
return list(zip(outputs, filenames))
new_source_version = results.version
if int(new_source_version / 1000000) != InstanceContainer.Version or new_source_version % 1000000 != CuraApplication.SettingVersion:
Logger.log("e", "Failed to upgrade profile [%s]", profile_id)
if int(parser["general"]["version"]) != InstanceContainer.Version:
Logger.log("e", "Failed to upgrade profile [%s]", profile_id)
return []
return [(serialized, profile_id)]

View file

@ -104,7 +104,7 @@ class FirmwareUpdateCheckerJob(Job):
# because the new version of Cura will be release before the firmware and we don't want to # because the new version of Cura will be release before the firmware and we don't want to
# notify the user when no new firmware version is available. # notify the user when no new firmware version is available.
if (checked_version != "") and (checked_version != current_version): if (checked_version != "") and (checked_version != current_version):
Logger.log("i", "SHOWING FIRMWARE UPDATE MESSAGE") Logger.log("i", "Showing firmware update message for new version: {version}".format(current_version))
message = FirmwareUpdateCheckerMessage(machine_id, self._machine_name, message = FirmwareUpdateCheckerMessage(machine_id, self._machine_name,
self._lookups.getRedirectUserUrl()) self._lookups.getRedirectUserUrl())
message.actionTriggered.connect(self._callback) message.actionTriggered.connect(self._callback)

View file

@ -371,7 +371,7 @@ class FlavorParser:
elif type == "SUPPORT-INTERFACE": elif type == "SUPPORT-INTERFACE":
self._layer_type = LayerPolygon.SupportInterfaceType self._layer_type = LayerPolygon.SupportInterfaceType
elif type == "PRIME-TOWER": elif type == "PRIME-TOWER":
self._layer_type = LayerPolygon.SkirtType self._layer_type = LayerPolygon.PrimeTowerType
else: else:
Logger.log("w", "Encountered a unknown type (%s) while parsing g-code.", type) Logger.log("w", "Encountered a unknown type (%s) while parsing g-code.", type)

View file

@ -22,11 +22,11 @@ Item
property int labelWidth: 210 * screenScaleFactor property int labelWidth: 210 * screenScaleFactor
property int controlWidth: (UM.Theme.getSize("setting_control").width * 3 / 4) | 0 property int controlWidth: (UM.Theme.getSize("setting_control").width * 3 / 4) | 0
property var labelFont: UM.Theme.getFont("medium") property var labelFont: UM.Theme.getFont("default")
property int columnWidth: ((parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2) | 0 property int columnWidth: ((parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2) | 0
property int columnSpacing: 3 * screenScaleFactor 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 string extruderStackId: ""
property int extruderPosition: 0 property int extruderPosition: 0
@ -107,6 +107,7 @@ Item
labelWidth: base.labelWidth labelWidth: base.labelWidth
controlWidth: base.controlWidth controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm") unitText: catalog.i18nc("@label", "mm")
allowNegativeValue: true
forceUpdateOnChangeFunction: forceUpdateFunction forceUpdateOnChangeFunction: forceUpdateFunction
} }
@ -121,6 +122,7 @@ Item
labelWidth: base.labelWidth labelWidth: base.labelWidth
controlWidth: base.controlWidth controlWidth: base.controlWidth
unitText: catalog.i18nc("@label", "mm") unitText: catalog.i18nc("@label", "mm")
allowNegativeValue: true
forceUpdateOnChangeFunction: forceUpdateFunction forceUpdateOnChangeFunction: forceUpdateFunction
} }

View file

@ -20,13 +20,13 @@ Item
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
property int labelWidth: 120 * screenScaleFactor
property int controlWidth: (UM.Theme.getSize("setting_control").width * 3 / 4) | 0
property var labelFont: UM.Theme.getFont("default")
property int columnWidth: ((parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2) | 0 property int columnWidth: ((parent.width - 2 * UM.Theme.getSize("default_margin").width) / 2) | 0
property int columnSpacing: 3 * screenScaleFactor property int columnSpacing: 3 * screenScaleFactor
property int propertyStoreIndex: manager.storeContainerIndex // definition_changes property int propertyStoreIndex: manager ? manager.storeContainerIndex : 1 // definition_changes
property int labelWidth: (columnWidth * 2 / 3 - UM.Theme.getSize("default_margin").width * 2) | 0
property int controlWidth: (columnWidth / 3) | 0
property var labelFont: UM.Theme.getFont("default")
property string machineStackId: Cura.MachineManager.activeMachineId property string machineStackId: Cura.MachineManager.activeMachineId
@ -59,6 +59,8 @@ Item
font: UM.Theme.getFont("medium_bold") font: UM.Theme.getFont("medium_bold")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
renderType: Text.NativeRendering renderType: Text.NativeRendering
width: parent.width
elide: Text.ElideRight
} }
Cura.NumericTextFieldWithUnit // "X (Width)" Cura.NumericTextFieldWithUnit // "X (Width)"
@ -175,6 +177,8 @@ Item
font: UM.Theme.getFont("medium_bold") font: UM.Theme.getFont("medium_bold")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
renderType: Text.NativeRendering renderType: Text.NativeRendering
width: parent.width
elide: Text.ElideRight
} }
Cura.PrintHeadMinMaxTextField // "X min" Cura.PrintHeadMinMaxTextField // "X min"
@ -191,6 +195,7 @@ Item
axisName: "x" axisName: "x"
axisMinOrMax: "min" axisMinOrMax: "min"
allowNegativeValue: true
forceUpdateOnChangeFunction: forceUpdateFunction forceUpdateOnChangeFunction: forceUpdateFunction
} }
@ -209,6 +214,7 @@ Item
axisName: "y" axisName: "y"
axisMinOrMax: "min" axisMinOrMax: "min"
allowNegativeValue: true
forceUpdateOnChangeFunction: forceUpdateFunction forceUpdateOnChangeFunction: forceUpdateFunction
} }
@ -227,6 +233,7 @@ Item
axisName: "x" axisName: "x"
axisMinOrMax: "max" axisMinOrMax: "max"
allowNegativeValue: true
forceUpdateOnChangeFunction: forceUpdateFunction forceUpdateOnChangeFunction: forceUpdateFunction
} }
@ -247,6 +254,7 @@ Item
axisName: "y" axisName: "y"
axisMinOrMax: "max" axisMinOrMax: "max"
allowNegativeValue: true
forceUpdateOnChangeFunction: forceUpdateFunction forceUpdateOnChangeFunction: forceUpdateFunction
} }

View file

@ -97,7 +97,7 @@ Rectangle
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
} }
visible: isNetworkConfigured && !isConnected visible: isNetworkConfigured && !isConnected
text: catalog.i18nc("@info", "Please make sure your printer has a connection:\n- Check if the printer is turned on.\n- Check if the printer is connected to the network.") text: catalog.i18nc("@info", "Please make sure your printer has a connection:\n- Check if the printer is turned on.\n- Check if the printer is connected to the network.\n- Check if you are signed in to discover cloud-connected printers.")
font: UM.Theme.getFont("medium") font: UM.Theme.getFont("medium")
color: UM.Theme.getColor("monitor_text_primary") color: UM.Theme.getColor("monitor_text_primary")
wrapMode: Text.WordWrap wrapMode: Text.WordWrap

View file

@ -160,7 +160,7 @@ Item {
model: UM.SettingDefinitionsModel model: UM.SettingDefinitionsModel
{ {
id: addedSettingsModel; id: addedSettingsModel;
containerId: Cura.MachineManager.activeDefinitionId containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
expanded: [ "*" ] expanded: [ "*" ]
filter: filter:
{ {
@ -467,7 +467,7 @@ Item {
model: UM.SettingDefinitionsModel model: UM.SettingDefinitionsModel
{ {
id: definitionsModel; id: definitionsModel;
containerId: Cura.MachineManager.activeDefinitionId containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
visibilityHandler: UM.SettingPreferenceVisibilityHandler {} visibilityHandler: UM.SettingPreferenceVisibilityHandler {}
expanded: [ "*" ] expanded: [ "*" ]
exclude: exclude:

View file

@ -219,6 +219,7 @@ class PostProcessingPlugin(QObject, Extension):
self._script_list.clear() self._script_list.clear()
if not new_stack.getMetaDataEntry("post_processing_scripts"): # Missing or empty. if not new_stack.getMetaDataEntry("post_processing_scripts"): # Missing or empty.
self.scriptListChanged.emit() # Even emit this if it didn't change. We want it to write the empty list to the stack's metadata. self.scriptListChanged.emit() # Even emit this if it didn't change. We want it to write the empty list to the stack's metadata.
self.setSelectedScriptIndex(-1)
return return
self._script_list.clear() self._script_list.clear()

View file

@ -100,8 +100,8 @@ class ChangeAtZ(Script):
}, },
"d_twLayers": "d_twLayers":
{ {
"label": "No. Layers", "label": "Layer Spread",
"description": "No. of layers used to change", "description": "The change will be gradual over this many layers. Enter 1 to make the change immediate.",
"unit": "", "unit": "",
"type": "int", "type": "int",
"default_value": 1, "default_value": 1,
@ -330,7 +330,7 @@ class ChangeAtZ(Script):
"extruderOne": self.getSettingValueByKey("i2_extruderOne"), "extruderOne": self.getSettingValueByKey("i2_extruderOne"),
"extruderTwo": self.getSettingValueByKey("i4_extruderTwo"), "extruderTwo": self.getSettingValueByKey("i4_extruderTwo"),
"fanSpeed": self.getSettingValueByKey("j2_fanSpeed")} "fanSpeed": self.getSettingValueByKey("j2_fanSpeed")}
old = {"speed": -1, "flowrate": -1, "flowrateOne": -1, "flowrateTwo": -1, "platformTemp": -1, "extruderOne": -1, old = {"speed": -1, "flowrate": 100, "flowrateOne": -1, "flowrateTwo": -1, "platformTemp": -1, "extruderOne": -1,
"extruderTwo": -1, "bedTemp": -1, "fanSpeed": -1, "state": -1} "extruderTwo": -1, "bedTemp": -1, "fanSpeed": -1, "state": -1}
twLayers = self.getSettingValueByKey("d_twLayers") twLayers = self.getSettingValueByKey("d_twLayers")
if self.getSettingValueByKey("c_behavior") == "single_layer": if self.getSettingValueByKey("c_behavior") == "single_layer":
@ -410,6 +410,8 @@ class ChangeAtZ(Script):
tmp_extruder = self.getValue(line, "T", None) tmp_extruder = self.getValue(line, "T", None)
if tmp_extruder == None: #check if extruder is specified if tmp_extruder == None: #check if extruder is specified
old["flowrate"] = self.getValue(line, "S", old["flowrate"]) old["flowrate"] = self.getValue(line, "S", old["flowrate"])
if old["flowrate"] == -1:
old["flowrate"] = 100.0
elif tmp_extruder == 0: #first extruder elif tmp_extruder == 0: #first extruder
old["flowrateOne"] = self.getValue(line, "S", old["flowrateOne"]) old["flowrateOne"] = self.getValue(line, "S", old["flowrateOne"])
elif tmp_extruder == 1: #second extruder elif tmp_extruder == 1: #second extruder
@ -481,9 +483,9 @@ class ChangeAtZ(Script):
state = 2 state = 2
done_layers = 0 done_layers = 0
if targetL_i > -100000: if targetL_i > -100000:
modified_gcode += ";ChangeAtZ V%s: reset below Layer %d\n" % (self.version,targetL_i) modified_gcode += ";ChangeAtZ V%s: reset below Layer %d\n" % (self.version, targetL_i)
else: else:
modified_gcode += ";ChangeAtZ V%s: reset below %1.2f mm\n" % (self.version,targetZ) modified_gcode += ";ChangeAtZ V%s: reset below %1.2f mm\n" % (self.version, targetZ)
if IsUM2 and oldValueUnknown: #executes on UM2 with Ultigcode and machine setting if IsUM2 and oldValueUnknown: #executes on UM2 with Ultigcode and machine setting
modified_gcode += "M606 S%d;recalls saved settings\n" % (TWinstances-1) modified_gcode += "M606 S%d;recalls saved settings\n" % (TWinstances-1)
else: #executes on RepRap, UM2 with Ultigcode and Cura setting else: #executes on RepRap, UM2 with Ultigcode and Cura setting

View file

@ -1,9 +1,7 @@
# Copyright (c) 2019 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# The PostProcessingPlugin is released under the terms of the AGPLv3 or higher. # The PostProcessingPlugin is released under the terms of the AGPLv3 or higher.
from typing import Optional, Tuple from typing import List
from UM.Logger import Logger
from ..Script import Script from ..Script import Script
class FilamentChange(Script): class FilamentChange(Script):
@ -65,9 +63,10 @@ class FilamentChange(Script):
} }
}""" }"""
def execute(self, data: list): ## Inserts the filament change g-code at specific layer numbers.
# \param data A list of layers of g-code.
"""data is a list. Each index contains a layer""" # \return A similar list, with filament change commands inserted.
def execute(self, data: List[str]):
layer_nums = self.getSettingValueByKey("layer_number") layer_nums = self.getSettingValueByKey("layer_number")
initial_retract = self.getSettingValueByKey("initial_retract") initial_retract = self.getSettingValueByKey("initial_retract")
later_retract = self.getSettingValueByKey("later_retract") later_retract = self.getSettingValueByKey("later_retract")
@ -88,32 +87,16 @@ class FilamentChange(Script):
if y_pos is not None: if y_pos is not None:
color_change = color_change + (" Y%.2f" % y_pos) 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(",") layer_targets = layer_nums.split(",")
if len(layer_targets) > 0: if len(layer_targets) > 0:
for layer_num in layer_targets: for layer_num in layer_targets:
layer_num = int(layer_num.strip()) try:
if layer_num <= len(data): layer_num = int(layer_num.strip()) + 1 #Needs +1 because the 1st layer is reserved for start g-code.
index, layer_data = self._searchLayerData(data, layer_num - 1) except ValueError: #Layer number is not an integer.
if layer_data is None: continue
Logger.log("e", "Could not find the layer {layer_num}".format(layer_num = layer_num)) if 0 < layer_num < len(data):
continue data[layer_num] = color_change + data[layer_num]
lines = layer_data.split("\n")
lines.insert(2, color_change)
final_line = "\n".join(lines)
data[index] = final_line
return data 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

View file

@ -145,6 +145,7 @@ class Stretcher():
current.readStep(line) current.readStep(line)
onestep = GCodeStep(-1, in_relative_movement) onestep = GCodeStep(-1, in_relative_movement)
onestep.copyPosFrom(current) onestep.copyPosFrom(current)
onestep.comment = line
else: else:
onestep = GCodeStep(-1, in_relative_movement) onestep = GCodeStep(-1, in_relative_movement)
onestep.copyPosFrom(current) onestep.copyPosFrom(current)

View file

@ -572,14 +572,14 @@ class SimulationView(CuraView):
self._current_layer_jumps = job.getResult().get("jumps") self._current_layer_jumps = job.getResult().get("jumps")
self._controller.getScene().sceneChanged.emit(self._controller.getScene().getRoot()) self._controller.getScene().sceneChanged.emit(self._controller.getScene().getRoot())
self._top_layers_job = None # type: Optional["_CreateTopLayersJob"] self._top_layers_job = None
def _updateWithPreferences(self) -> None: def _updateWithPreferences(self) -> None:
self._solid_layers = int(Application.getInstance().getPreferences().getValue("view/top_layer_count")) self._solid_layers = int(Application.getInstance().getPreferences().getValue("view/top_layer_count"))
self._only_show_top_layers = bool(Application.getInstance().getPreferences().getValue("view/only_show_top_layers")) self._only_show_top_layers = bool(Application.getInstance().getPreferences().getValue("view/only_show_top_layers"))
self._compatibility_mode = self._evaluateCompatibilityMode() self._compatibility_mode = self._evaluateCompatibilityMode()
self.setSimulationViewType(int(float(Application.getInstance().getPreferences().getValue("layerview/layer_view_type")))); self.setSimulationViewType(int(float(Application.getInstance().getPreferences().getValue("layerview/layer_view_type"))))
for extruder_nr, extruder_opacity in enumerate(Application.getInstance().getPreferences().getValue("layerview/extruder_opacities").split("|")): for extruder_nr, extruder_opacity in enumerate(Application.getInstance().getPreferences().getValue("layerview/extruder_opacities").split("|")):
try: try:

View file

@ -1,6 +1,9 @@
[shaders] [shaders]
vertex = vertex =
uniform highp mat4 u_modelViewProjectionMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
uniform lowp float u_active_extruder; uniform lowp float u_active_extruder;
uniform lowp float u_shade_factor; uniform lowp float u_shade_factor;
uniform highp int u_layer_view_type; uniform highp int u_layer_view_type;
@ -16,7 +19,7 @@ vertex =
void main() void main()
{ {
gl_Position = u_modelViewProjectionMatrix * a_vertex; gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
// shade the color depending on the extruder index // shade the color depending on the extruder index
v_color = a_color; v_color = a_color;
// 8 and 9 are travel moves // 8 and 9 are travel moves
@ -76,7 +79,10 @@ fragment =
vertex41core = vertex41core =
#version 410 #version 410
uniform highp mat4 u_modelViewProjectionMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
uniform lowp float u_active_extruder; uniform lowp float u_active_extruder;
uniform lowp float u_shade_factor; uniform lowp float u_shade_factor;
uniform highp int u_layer_view_type; uniform highp int u_layer_view_type;
@ -92,7 +98,7 @@ vertex41core =
void main() void main()
{ {
gl_Position = u_modelViewProjectionMatrix * a_vertex; gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
v_color = a_color; v_color = a_color;
if ((a_line_type != 8) && (a_line_type != 9)) { if ((a_line_type != 8) && (a_line_type != 9)) {
v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a); v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
@ -154,7 +160,9 @@ u_show_skin = 1
u_show_infill = 1 u_show_infill = 1
[bindings] [bindings]
u_modelViewProjectionMatrix = model_view_projection_matrix u_modelMatrix = model_matrix
u_viewMatrix = view_matrix
u_projectionMatrix = projection_matrix
[attributes] [attributes]
a_vertex = vertex a_vertex = vertex

View file

@ -1,10 +1,10 @@
[shaders] [shaders]
vertex41core = vertex41core =
#version 410 #version 410
uniform highp mat4 u_modelViewProjectionMatrix;
uniform highp mat4 u_modelMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewProjectionMatrix; uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
uniform lowp float u_active_extruder; uniform lowp float u_active_extruder;
uniform lowp float u_max_feedrate; uniform lowp float u_max_feedrate;
uniform lowp float u_min_feedrate; uniform lowp float u_min_feedrate;
@ -104,7 +104,10 @@ vertex41core =
geometry41core = geometry41core =
#version 410 #version 410
uniform highp mat4 u_viewProjectionMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
uniform int u_show_travel_moves; uniform int u_show_travel_moves;
uniform int u_show_helpers; uniform int u_show_helpers;
uniform int u_show_skin; uniform int u_show_skin;
@ -136,6 +139,8 @@ geometry41core =
void main() void main()
{ {
highp mat4 viewProjectionMatrix = u_projectionMatrix * u_viewMatrix;
vec4 g_vertex_delta; vec4 g_vertex_delta;
vec3 g_vertex_normal_horz; // horizontal and vertical in respect to layers vec3 g_vertex_normal_horz; // horizontal and vertical in respect to layers
vec4 g_vertex_offset_horz; // vec4 to match gl_in[x].gl_Position vec4 g_vertex_offset_horz; // vec4 to match gl_in[x].gl_Position
@ -183,65 +188,83 @@ geometry41core =
g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0); g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0);
if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) { if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) {
vec4 va_head = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert);
vec4 va_up = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert);
vec4 va_down = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert);
vec4 vb_head = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head + g_vertex_offset_vert);
vec4 vb_down = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert);
vec4 vb_up = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert);
// Travels: flat plane with pointy ends // Travels: flat plane with pointy ends
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_head);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_down);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_down);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_up);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_head);
//And reverse so that the line is also visible from the back side. //And reverse so that the line is also visible from the back side.
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_up);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_down);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_down);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_head);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
EndPrimitive(); EndPrimitive();
} else { } else {
vec4 va_m_horz = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz);
vec4 vb_m_horz = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz);
vec4 va_p_vert = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert);
vec4 vb_p_vert = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert);
vec4 va_p_horz = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz);
vec4 vb_p_horz = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz);
vec4 va_m_vert = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert);
vec4 vb_m_vert = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert);
vec4 va_head = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head);
vec4 vb_head = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head);
// All normal lines are rendered as 3d tubes. // All normal lines are rendered as 3d tubes.
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_p_vert);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_p_vert);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, va_m_vert);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, vb_m_vert);
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
EndPrimitive(); EndPrimitive();
// left side // left side
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_p_vert);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, va_head);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
EndPrimitive(); EndPrimitive();
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, va_m_vert);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, va_head);
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
EndPrimitive(); EndPrimitive();
// right side // right side
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_p_vert);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, vb_head);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
EndPrimitive(); EndPrimitive();
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, vb_m_vert);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, vb_head);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
EndPrimitive(); EndPrimitive();
} }
@ -301,9 +324,9 @@ u_min_thickness = 0
u_max_thickness = 1 u_max_thickness = 1
[bindings] [bindings]
u_modelViewProjectionMatrix = model_view_projection_matrix
u_modelMatrix = model_matrix u_modelMatrix = model_matrix
u_viewProjectionMatrix = view_projection_matrix u_viewMatrix = view_matrix
u_projectionMatrix = projection_matrix
u_normalMatrix = normal_matrix u_normalMatrix = normal_matrix
u_lightPosition = light_0_position u_lightPosition = light_0_position

View file

@ -1,10 +1,10 @@
[shaders] [shaders]
vertex41core = vertex41core =
#version 410 #version 410
uniform highp mat4 u_modelViewProjectionMatrix;
uniform highp mat4 u_modelMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewProjectionMatrix; uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
uniform lowp float u_active_extruder; uniform lowp float u_active_extruder;
uniform lowp vec4 u_extruder_opacity; // currently only for max 4 extruders, others always visible uniform lowp vec4 u_extruder_opacity; // currently only for max 4 extruders, others always visible
@ -58,7 +58,10 @@ vertex41core =
geometry41core = geometry41core =
#version 410 #version 410
uniform highp mat4 u_viewProjectionMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
uniform int u_show_travel_moves; uniform int u_show_travel_moves;
uniform int u_show_helpers; uniform int u_show_helpers;
uniform int u_show_skin; uniform int u_show_skin;
@ -90,6 +93,8 @@ geometry41core =
void main() void main()
{ {
highp mat4 viewProjectionMatrix = u_projectionMatrix * u_viewMatrix;
vec4 g_vertex_delta; vec4 g_vertex_delta;
vec3 g_vertex_normal_horz; // horizontal and vertical in respect to layers vec3 g_vertex_normal_horz; // horizontal and vertical in respect to layers
vec4 g_vertex_offset_horz; // vec4 to match gl_in[x].gl_Position vec4 g_vertex_offset_horz; // vec4 to match gl_in[x].gl_Position
@ -137,65 +142,83 @@ geometry41core =
g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0); g_vertex_offset_vert = vec4(g_vertex_normal_vert * size_y, 0.0);
if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) { if ((v_line_type[0] == 8) || (v_line_type[0] == 9)) {
vec4 va_head = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert);
vec4 va_up = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert);
vec4 va_down = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert);
vec4 vb_head = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head + g_vertex_offset_vert);
vec4 vb_down = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert);
vec4 vb_up = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert);
// Travels: flat plane with pointy ends // Travels: flat plane with pointy ends
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_head);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_down);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_down);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_up);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_head);
//And reverse so that the line is also visible from the back side. //And reverse so that the line is also visible from the back side.
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_up);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_down);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_down);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_head);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_up);
EndPrimitive(); EndPrimitive();
} else { } else {
vec4 va_m_horz = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz);
vec4 vb_m_horz = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz);
vec4 va_p_vert = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert);
vec4 vb_p_vert = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert);
vec4 va_p_horz = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz);
vec4 vb_p_horz = viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz);
vec4 va_m_vert = viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert);
vec4 vb_m_vert = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert);
vec4 va_head = viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head);
vec4 vb_head = viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head);
// All normal lines are rendered as 3d tubes. // All normal lines are rendered as 3d tubes.
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_p_vert);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_p_vert);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, va_m_vert);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, vb_m_vert);
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
EndPrimitive(); EndPrimitive();
// left side // left side
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_vert, va_p_vert);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, va_head);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
EndPrimitive(); EndPrimitive();
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz, va_p_horz);
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_vert)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_vert, va_m_vert);
myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[0].gl_Position + g_vertex_offset_horz_head)); myEmitVertex(v_vertex[0], v_color[0], g_vertex_normal_horz_head, va_head);
myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[0].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[0], v_color[0], -g_vertex_normal_horz, va_m_horz);
EndPrimitive(); EndPrimitive();
// right side // right side
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_vert, vb_p_vert);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, vb_head);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
EndPrimitive(); EndPrimitive();
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz, vb_m_horz);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_vert)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_vert, vb_m_vert);
myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, u_viewProjectionMatrix * (gl_in[1].gl_Position - g_vertex_offset_horz_head)); myEmitVertex(v_vertex[1], v_color[1], -g_vertex_normal_horz_head, vb_head);
myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, u_viewProjectionMatrix * (gl_in[1].gl_Position + g_vertex_offset_horz)); myEmitVertex(v_vertex[1], v_color[1], g_vertex_normal_horz, vb_p_horz);
EndPrimitive(); EndPrimitive();
} }
@ -246,9 +269,9 @@ u_show_skin = 1
u_show_infill = 1 u_show_infill = 1
[bindings] [bindings]
u_modelViewProjectionMatrix = model_view_projection_matrix
u_modelMatrix = model_matrix u_modelMatrix = model_matrix
u_viewProjectionMatrix = view_projection_matrix u_viewMatrix = view_matrix
u_projectionMatrix = projection_matrix
u_normalMatrix = normal_matrix u_normalMatrix = normal_matrix
u_lightPosition = light_0_position u_lightPosition = light_0_position

View file

@ -1,6 +1,9 @@
[shaders] [shaders]
vertex = vertex =
uniform highp mat4 u_modelViewProjectionMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
uniform lowp float u_active_extruder; uniform lowp float u_active_extruder;
uniform lowp float u_shade_factor; uniform lowp float u_shade_factor;
uniform highp int u_layer_view_type; uniform highp int u_layer_view_type;
@ -16,7 +19,7 @@ vertex =
void main() void main()
{ {
gl_Position = u_modelViewProjectionMatrix * a_vertex; gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
// shade the color depending on the extruder index // shade the color depending on the extruder index
v_color = vec4(0.4, 0.4, 0.4, 0.9); // default color for not current layer; v_color = vec4(0.4, 0.4, 0.4, 0.9); // default color for not current layer;
// 8 and 9 are travel moves // 8 and 9 are travel moves
@ -80,7 +83,10 @@ fragment =
vertex41core = vertex41core =
#version 410 #version 410
uniform highp mat4 u_modelViewProjectionMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
uniform lowp float u_active_extruder; uniform lowp float u_active_extruder;
uniform lowp float u_shade_factor; uniform lowp float u_shade_factor;
uniform highp int u_layer_view_type; uniform highp int u_layer_view_type;
@ -96,7 +102,7 @@ vertex41core =
void main() void main()
{ {
gl_Position = u_modelViewProjectionMatrix * a_vertex; gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
v_color = vec4(0.4, 0.4, 0.4, 0.9); // default color for not current layer v_color = vec4(0.4, 0.4, 0.4, 0.9); // default color for not current layer
// if ((a_line_type != 8) && (a_line_type != 9)) { // if ((a_line_type != 8) && (a_line_type != 9)) {
// v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a); // v_color = (a_extruder == u_active_extruder) ? v_color : vec4(u_shade_factor * v_color.rgb, v_color.a);
@ -159,7 +165,9 @@ u_show_skin = 1
u_show_infill = 1 u_show_infill = 1
[bindings] [bindings]
u_modelViewProjectionMatrix = model_view_projection_matrix u_modelMatrix = model_matrix
u_viewMatrix = view_matrix
u_projectionMatrix = projection_matrix
[attributes] [attributes]
a_vertex = vertex a_vertex = vertex

View file

@ -126,6 +126,8 @@ class SliceInfo(QObject, Extension):
else: else:
data["active_mode"] = "custom" data["active_mode"] = "custom"
data["camera_view"] = application.getPreferences().getValue("general/camera_perspective_mode")
definition_changes = global_stack.definitionChanges definition_changes = global_stack.definitionChanges
machine_settings_changed_by_user = False machine_settings_changed_by_user = False
if definition_changes.getId() != "empty": if definition_changes.getId() != "empty":

View file

@ -98,8 +98,10 @@ class SupportEraser(Tool):
node.setName("Eraser") node.setName("Eraser")
node.setSelectable(True) node.setSelectable(True)
node.setCalculateBoundingBox(True)
mesh = self._createCube(10) mesh = self._createCube(10)
node.setMeshData(mesh.build()) node.setMeshData(mesh.build())
node.calculateBoundingBoxMesh()
active_build_plate = CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate active_build_plate = CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate
node.addDecorator(BuildPlateDecorator(active_build_plate)) node.addDecorator(BuildPlateDecorator(active_build_plate))

View file

@ -109,6 +109,8 @@ Item
top: description.bottom top: description.bottom
left: properties.right left: properties.right
leftMargin: UM.Theme.getSize("default_margin").width leftMargin: UM.Theme.getSize("default_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("default_margin").width
topMargin: UM.Theme.getSize("default_margin").height topMargin: UM.Theme.getSize("default_margin").height
} }
spacing: Math.floor(UM.Theme.getSize("narrow_margin").height) spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
@ -123,6 +125,8 @@ Item
} }
return "" return ""
} }
width: parent.width
elide: Text.ElideRight
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
linkColor: UM.Theme.getColor("text_link") linkColor: UM.Theme.getColor("text_link")

View file

@ -89,6 +89,7 @@ Item
Label Label
{ {
text: catalog.i18nc("@label", "Your rating") + ":" text: catalog.i18nc("@label", "Your rating") + ":"
visible: details.type == "plugin"
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text_medium") color: UM.Theme.getColor("text_medium")
renderType: Text.NativeRendering renderType: Text.NativeRendering

View file

@ -48,7 +48,6 @@ Item
{ {
text: model.name text: model.name
width: parent.width width: parent.width
height: Math.floor(UM.Theme.getSize("toolbox_property_label").height)
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
font: UM.Theme.getFont("large_bold") font: UM.Theme.getFont("large_bold")
color: pluginInfo.color color: pluginInfo.color

View file

@ -278,7 +278,7 @@ class Toolbox(QObject, Extension):
for plugin_id in old_plugin_ids: for plugin_id in old_plugin_ids:
# Neither the installed packages nor the packages that are scheduled to remove are old plugins # Neither the installed packages nor the packages that are scheduled to remove are old plugins
if plugin_id not in installed_package_ids and plugin_id not in scheduled_to_remove_package_ids: if plugin_id not in installed_package_ids and plugin_id not in scheduled_to_remove_package_ids:
Logger.log("i", "Found a plugin that was installed with the old plugin browser: %s", plugin_id) Logger.log("d", "Found a plugin that was installed with the old plugin browser: %s", plugin_id)
old_metadata = self._plugin_registry.getMetaData(plugin_id) old_metadata = self._plugin_registry.getMetaData(plugin_id)
new_metadata = self._convertPluginMetadata(old_metadata) new_metadata = self._convertPluginMetadata(old_metadata)
@ -526,7 +526,7 @@ class Toolbox(QObject, Extension):
# Make API Calls # Make API Calls
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
def _makeRequestByType(self, request_type: str) -> None: def _makeRequestByType(self, request_type: str) -> None:
Logger.log("i", "Requesting %s metadata from server.", request_type) Logger.log("d", "Requesting %s metadata from server.", request_type)
request = QNetworkRequest(self._request_urls[request_type]) request = QNetworkRequest(self._request_urls[request_type])
for header_name, header_value in self._request_headers: for header_name, header_value in self._request_headers:
request.setRawHeader(header_name, header_value) request.setRawHeader(header_name, header_value)

View file

@ -78,7 +78,7 @@ Cura.MachineAction
width: parent.width width: parent.width
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
renderType: Text.NativeRendering renderType: Text.NativeRendering
text: catalog.i18nc("@label", "To print directly to your printer over the network, please make sure your printer is connected to the network using a network cable or by connecting your printer to your WIFI network. If you don't connect Cura with your printer, you can still use a USB drive to transfer g-code files to your printer.\n\nSelect your printer from the list below:") text: catalog.i18nc("@label", "To print directly to your printer over the network, please make sure your printer is connected to the network using a network cable or by connecting your printer to your WIFI network. If you don't connect Cura with your printer, you can still use a USB drive to transfer g-code files to your printer.") + "\n\n" + catalog.i18nc("@label", "Select your printer from the list below:")
} }
Row Row

View file

@ -30,6 +30,26 @@ UM.Dialog
OutputDevice.forceSendJob(printer.activePrintJob.key) OutputDevice.forceSendJob(printer.activePrintJob.key)
overrideConfirmationDialog.close() overrideConfirmationDialog.close()
} }
visible:
{
// Don't show the button if we're missing a printer or print job
if (!printer || !printer.activePrintJob)
{
return false
}
// Check each required change...
for (var i = 0; i < printer.activePrintJob.configurationChanges.length; i++)
{
var change = printer.activePrintJob.configurationChanges[i]
// If that type of change is in the list of blocking changes, hide the button
if (!change.canOverride)
{
return false
}
}
return true
}
}, },
Button Button
{ {

View file

@ -81,7 +81,7 @@ Item
enabled: visible && !(printJob.state == "pausing" || printJob.state == "resuming"); enabled: visible && !(printJob.state == "pausing" || printJob.state == "resuming");
onClicked: { onClicked: {
if (printJob.state == "paused") { if (printJob.state == "paused") {
printJob.setState("print"); printJob.setState("resume");
popUp.close(); popUp.close();
return; return;
} }

View file

@ -22,10 +22,6 @@ Item
// The print job which all other data is derived from // The print job which all other data is derived from
property var printJob: null property var printJob: null
// If the printer is a cloud printer or not. Other items base their enabled state off of this boolean. In the future
// they might not need to though.
property bool cloudConnection: Cura.MachineManager.activeMachineIsUsingCloudConnection
width: parent.width width: parent.width
height: childrenRect.height height: childrenRect.height
@ -51,7 +47,7 @@ Item
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: 18 * screenScaleFactor // TODO: Theme! height: 18 * screenScaleFactor // TODO: Theme!
width: 216 * screenScaleFactor // TODO: Theme! (Should match column size) width: UM.Theme.getSize("monitor_column").width
Rectangle Rectangle
{ {
color: UM.Theme.getColor("monitor_skeleton_loading") color: UM.Theme.getColor("monitor_skeleton_loading")
@ -79,7 +75,7 @@ Item
{ {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
height: 18 * screenScaleFactor // TODO: Theme! height: 18 * screenScaleFactor // TODO: Theme!
width: 216 * screenScaleFactor // TODO: Theme! (Should match column size) width: UM.Theme.getSize("monitor_column").width
Rectangle Rectangle
{ {
color: UM.Theme.getColor("monitor_skeleton_loading") color: UM.Theme.getColor("monitor_skeleton_loading")
@ -217,7 +213,7 @@ Item
} }
width: 32 * screenScaleFactor // TODO: Theme! width: 32 * screenScaleFactor // TODO: Theme!
height: 32 * screenScaleFactor // TODO: Theme! height: 32 * screenScaleFactor // TODO: Theme!
enabled: !cloudConnection enabled: OutputDevice.supportsPrintJobActions
onClicked: enabled ? contextMenu.switchPopupState() : {} onClicked: enabled ? contextMenu.switchPopupState() : {}
visible: visible:
{ {
@ -250,7 +246,7 @@ Item
MonitorInfoBlurb MonitorInfoBlurb
{ {
id: contextMenuDisabledInfo id: contextMenuDisabledInfo
text: catalog.i18nc("@info", "These options are not available because you are monitoring a cloud printer.") text: catalog.i18nc("@info", "Please update your printer's firmware to manage the queue remotely.")
target: contextMenuButton target: contextMenuButton
} }
} }

View file

@ -28,9 +28,12 @@ Item
anchors anchors
{ {
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
left: parent.left
} }
value: printJob ? printJob.progress : 0 value: printJob ? printJob.progress : 0
width: UM.Theme.getSize("monitor_column").width
} }
Label Label
{ {
id: percentLabel id: percentLabel
@ -38,6 +41,7 @@ Item
{ {
left: progressBar.right left: progressBar.right
leftMargin: 18 * screenScaleFactor // TODO: Theme! leftMargin: 18 * screenScaleFactor // TODO: Theme!
verticalCenter: parent.verticalCenter
} }
text: printJob ? Math.round(printJob.progress * 100) + "%" : "0%" text: printJob ? Math.round(printJob.progress * 100) + "%" : "0%"
color: printJob && printJob.isActive ? UM.Theme.getColor("monitor_text_primary") : UM.Theme.getColor("monitor_text_disabled") color: printJob && printJob.isActive ? UM.Theme.getColor("monitor_text_primary") : UM.Theme.getColor("monitor_text_disabled")
@ -56,6 +60,7 @@ Item
{ {
left: percentLabel.right left: percentLabel.right
leftMargin: 18 * screenScaleFactor // TODO: Theme! leftMargin: 18 * screenScaleFactor // TODO: Theme!
verticalCenter: parent.verticalCenter
} }
color: UM.Theme.getColor("monitor_text_primary") color: UM.Theme.getColor("monitor_text_primary")
font: UM.Theme.getFont("medium") // 14pt, regular font: UM.Theme.getFont("medium") // 14pt, regular

View file

@ -172,8 +172,7 @@ Item
} }
width: 36 * screenScaleFactor // TODO: Theme! width: 36 * screenScaleFactor // TODO: Theme!
height: 36 * screenScaleFactor // TODO: Theme! height: 36 * screenScaleFactor // TODO: Theme!
enabled: !cloudConnection enabled: OutputDevice.supportsPrintJobActions
onClicked: enabled ? contextMenu.switchPopupState() : {} onClicked: enabled ? contextMenu.switchPopupState() : {}
visible: visible:
{ {
@ -206,7 +205,7 @@ Item
MonitorInfoBlurb MonitorInfoBlurb
{ {
id: contextMenuDisabledInfo id: contextMenuDisabledInfo
text: catalog.i18nc("@info", "These options are not available because you are monitoring a cloud printer.") text: catalog.i18nc("@info", "Please update your printer's firmware to manage the queue remotely.")
target: contextMenuButton target: contextMenuButton
} }
@ -244,7 +243,6 @@ Item
} }
} }
// Divider // Divider
Rectangle Rectangle
{ {

View file

@ -42,7 +42,6 @@ Item
} }
height: 18 * screenScaleFactor // TODO: Theme! height: 18 * screenScaleFactor // TODO: Theme!
width: childrenRect.width width: childrenRect.width
visible: !cloudConnection
UM.RecolorImage UM.RecolorImage
{ {
@ -65,7 +64,7 @@ Item
color: UM.Theme.getColor("monitor_text_link") color: UM.Theme.getColor("monitor_text_link")
font: UM.Theme.getFont("medium") // 14pt, regular font: UM.Theme.getFont("medium") // 14pt, regular
linkColor: UM.Theme.getColor("monitor_text_link") linkColor: UM.Theme.getColor("monitor_text_link")
text: catalog.i18nc("@label link to connect manager", "Go to Cura Connect") text: catalog.i18nc("@label link to connect manager", "Manage in browser")
renderType: Text.NativeRendering renderType: Text.NativeRendering
} }
} }
@ -73,9 +72,7 @@ Item
MouseArea MouseArea
{ {
anchors.fill: manageQueueLabel anchors.fill: manageQueueLabel
enabled: !cloudConnection onClicked: OutputDevice.openPrintJobControlPanel()
hoverEnabled: !cloudConnection
onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel()
onEntered: onEntered:
{ {
manageQueueText.font.underline = true manageQueueText.font.underline = true
@ -98,6 +95,22 @@ Item
} }
spacing: 18 * screenScaleFactor // TODO: Theme! spacing: 18 * screenScaleFactor // TODO: Theme!
Label
{
text: catalog.i18nc("@label", "There are no print jobs in the queue. Slice and send a job to add one.")
color: UM.Theme.getColor("monitor_text_primary")
elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular
anchors.verticalCenter: parent.verticalCenter
width: 600 * screenScaleFactor // TODO: Theme! (Should match column size)
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
visible: printJobList.count === 0
}
Label Label
{ {
text: catalog.i18nc("@label", "Print jobs") text: catalog.i18nc("@label", "Print jobs")
@ -111,6 +124,7 @@ Item
height: 18 * screenScaleFactor // TODO: Theme! height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering renderType: Text.NativeRendering
visible: printJobList.count > 0
} }
Label Label
@ -120,12 +134,13 @@ Item
elide: Text.ElideRight elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular font: UM.Theme.getFont("medium") // 14pt, regular
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 216 * screenScaleFactor // TODO: Theme! (Should match column size) width: UM.Theme.getSize("monitor_column").width
// FIXED-LINE-HEIGHT: // FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme! height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering renderType: Text.NativeRendering
visible: printJobList.count > 0
} }
Label Label
@ -135,12 +150,13 @@ Item
elide: Text.ElideRight elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular font: UM.Theme.getFont("medium") // 14pt, regular
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 216 * screenScaleFactor // TODO: Theme! (Should match column size) width: UM.Theme.getSize("monitor_column").width
// FIXED-LINE-HEIGHT: // FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme! height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering renderType: Text.NativeRendering
visible: printJobList.count > 0
} }
} }
@ -184,89 +200,4 @@ Item
spacing: 6 // TODO: Theme! spacing: 6 // TODO: Theme!
} }
} }
Rectangle
{
anchors
{
horizontalCenter: parent.horizontalCenter
top: printJobQueueHeadings.bottom
topMargin: 12 * screenScaleFactor // TODO: Theme!
}
height: 48 * screenScaleFactor // TODO: Theme!
width: parent.width
color: UM.Theme.getColor("monitor_card_background")
border.color: UM.Theme.getColor("monitor_card_border")
radius: 2 * screenScaleFactor // TODO: Theme!
visible: printJobList.model.length == 0
Row
{
anchors
{
left: parent.left
leftMargin: 18 * screenScaleFactor // TODO: Theme!
verticalCenter: parent.verticalCenter
}
spacing: 18 * screenScaleFactor // TODO: Theme!
height: 18 * screenScaleFactor // TODO: Theme!
Label
{
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
{
id: viewPrintHistoryLabel
height: 18 * screenScaleFactor // TODO: Theme!
width: childrenRect.width
visible: !cloudConnection
UM.RecolorImage
{
id: printHistoryIcon
anchors.verticalCenter: parent.verticalCenter
color: UM.Theme.getColor("monitor_text_link")
source: UM.Theme.getIcon("external_link")
width: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)
height: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)
}
Label
{
id: viewPrintHistoryText
anchors
{
left: printHistoryIcon.right
leftMargin: 6 * screenScaleFactor // TODO: Theme!
verticalCenter: printHistoryIcon.verticalCenter
}
color: UM.Theme.getColor("monitor_text_link")
font: UM.Theme.getFont("medium") // 14pt, regular
linkColor: UM.Theme.getColor("monitor_text_link")
text: catalog.i18nc("@label link to connect manager", "View print history")
renderType: Text.NativeRendering
}
MouseArea
{
anchors.fill: parent
hoverEnabled: true
onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel()
onEntered:
{
viewPrintHistoryText.font.underline = true
}
onExited:
{
viewPrintHistoryText.font.underline = false
}
}
}
}
}
} }

View file

@ -96,6 +96,21 @@ class CloudApiClient:
reply = self._manager.post(self._createEmptyRequest(url), b"") reply = self._manager.post(self._createEmptyRequest(url), b"")
self._addCallback(reply, on_finished, CloudPrintResponse) self._addCallback(reply, on_finished, CloudPrintResponse)
## Send a print job action to the cluster for the given print job.
# \param cluster_id: The ID of the cluster.
# \param cluster_job_id: The ID of the print job within the cluster.
# \param action: The name of the action to execute.
def doPrintJobAction(self, cluster_id: str, cluster_job_id: str, action: str, data: Optional[Dict[str, Any]] = None) -> None:
body = b""
if data:
try:
body = json.dumps({"data": data}).encode()
except JSONDecodeError as err:
Logger.log("w", "Could not encode body: %s", err)
return
url = "{}/clusters/{}/print_jobs/{}/action/{}".format(self.CLUSTER_API_ROOT, cluster_id, cluster_job_id, action)
self._manager.post(self._createEmptyRequest(url), body)
## We override _createEmptyRequest in order to add the user credentials. ## We override _createEmptyRequest in order to add the user credentials.
# \param url: The URL to request # \param url: The URL to request
# \param content_type: The type of the body contents. # \param content_type: The type of the body contents.

View file

@ -1,5 +1,6 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
from cura.PrinterOutput.PrinterOutputController import PrinterOutputController from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -13,10 +14,13 @@ class CloudOutputController(PrinterOutputController):
# The cloud connection only supports fetching the printer and queue status and adding a job to the queue. # The cloud connection only supports fetching the printer and queue status and adding a job to the queue.
# To let the UI know this we mark all features below as False. # To let the UI know this we mark all features below as False.
self.can_pause = False self.can_pause = True
self.can_abort = False self.can_abort = True
self.can_pre_heat_bed = False self.can_pre_heat_bed = False
self.can_pre_heat_hotends = False self.can_pre_heat_hotends = False
self.can_send_raw_gcode = False self.can_send_raw_gcode = False
self.can_control_manually = False self.can_control_manually = False
self.can_update_firmware = False self.can_update_firmware = False
def setJobState(self, job: "PrintJobOutputModel", state: str):
self._output_device.setJobState(job.key, state)

View file

@ -6,6 +6,7 @@ from time import time
from typing import Dict, List, Optional, Set, cast from typing import Dict, List, Optional, Set, cast
from PyQt5.QtCore import QObject, QUrl, pyqtProperty, pyqtSignal, pyqtSlot from PyQt5.QtCore import QObject, QUrl, pyqtProperty, pyqtSignal, pyqtSlot
from PyQt5.QtGui import QDesktopServices
from UM import i18nCatalog from UM import i18nCatalog
from UM.Backend.Backend import BackendState from UM.Backend.Backend import BackendState
@ -15,6 +16,7 @@ from UM.Message import Message
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from UM.Qt.Duration import Duration, DurationFormat from UM.Qt.Duration import Duration, DurationFormat
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
from UM.Version import Version
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState, NetworkedPrinterOutputDevice from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState, NetworkedPrinterOutputDevice
@ -33,8 +35,7 @@ from .Models.CloudPrintResponse import CloudPrintResponse
from .Models.CloudPrintJobResponse import CloudPrintJobResponse from .Models.CloudPrintJobResponse import CloudPrintJobResponse
from .Models.CloudClusterPrinterStatus import CloudClusterPrinterStatus from .Models.CloudClusterPrinterStatus import CloudClusterPrinterStatus
from .Models.CloudClusterPrintJobStatus import CloudClusterPrintJobStatus from .Models.CloudClusterPrintJobStatus import CloudClusterPrintJobStatus
from .Utils import findChanges, formatDateCompleted, formatTimeCompleted from .Utils import formatDateCompleted, formatTimeCompleted
I18N_CATALOG = i18nCatalog("cura") I18N_CATALOG = i18nCatalog("cura")
@ -44,10 +45,12 @@ I18N_CATALOG = i18nCatalog("cura")
# As such, those methods have been implemented here. # As such, those methods have been implemented here.
# Note that this device represents a single remote cluster, not a list of multiple clusters. # Note that this device represents a single remote cluster, not a list of multiple clusters.
class CloudOutputDevice(NetworkedPrinterOutputDevice): class CloudOutputDevice(NetworkedPrinterOutputDevice):
# The interval with which the remote clusters are checked # The interval with which the remote clusters are checked
CHECK_CLUSTER_INTERVAL = 10.0 # seconds CHECK_CLUSTER_INTERVAL = 10.0 # seconds
# The minimum version of firmware that support print job actions over cloud.
PRINT_JOB_ACTIONS_MIN_VERSION = Version("5.3.0")
# Signal triggered when the print jobs in the queue were changed. # Signal triggered when the print jobs in the queue were changed.
printJobsChanged = pyqtSignal() printJobsChanged = pyqtSignal()
@ -58,14 +61,6 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
# Therefore we create a private signal used to trigger the printersChanged signal. # Therefore we create a private signal used to trigger the printersChanged signal.
_clusterPrintersChanged = pyqtSignal() _clusterPrintersChanged = pyqtSignal()
# Map of Cura Connect machine_variant field to Cura machine types.
# Needed for printer discovery stack creation.
_host_machine_variant_to_machine_type_map = {
"Ultimaker 3": "ultimaker3",
"Ultimaker 3 Extended": "ultimaker3_extended",
"Ultimaker S5": "ultimaker_s5"
}
## Creates a new cloud output device ## Creates a new cloud output device
# \param api_client: The client that will run the API calls # \param api_client: The client that will run the API calls
# \param cluster: The device response received from the cloud API. # \param cluster: The device response received from the cloud API.
@ -79,11 +74,12 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
b"address": cluster.host_internal_ip.encode() if cluster.host_internal_ip else b"", b"address": cluster.host_internal_ip.encode() if cluster.host_internal_ip else b"",
b"name": cluster.friendly_name.encode() if cluster.friendly_name else b"", b"name": cluster.friendly_name.encode() if cluster.friendly_name else b"",
b"firmware_version": cluster.host_version.encode() if cluster.host_version else b"", b"firmware_version": cluster.host_version.encode() if cluster.host_version else b"",
b"printer_type": cluster.printer_type.encode() if cluster.printer_type else b"",
b"cluster_size": b"1" # cloud devices are always clusters of at least one b"cluster_size": b"1" # cloud devices are always clusters of at least one
} }
super().__init__(device_id = cluster.cluster_id, address = "", super().__init__(device_id=cluster.cluster_id, address="",
connection_type = ConnectionType.CloudConnection, properties = properties, parent = parent) connection_type=ConnectionType.CloudConnection, properties=properties, parent=parent)
self._api = api_client self._api = api_client
self._cluster = cluster self._cluster = cluster
@ -104,7 +100,6 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
# We keep track of which printer is visible in the monitor page. # We keep track of which printer is visible in the monitor page.
self._active_printer = None # type: Optional[PrinterOutputModel] self._active_printer = None # type: Optional[PrinterOutputModel]
self._host_machine_type = ""
# Properties to populate later on with received cloud data. # Properties to populate later on with received cloud data.
self._print_jobs = [] # type: List[UM3PrintJobOutputModel] self._print_jobs = [] # type: List[UM3PrintJobOutputModel]
@ -176,15 +171,16 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
self.setConnectionText(I18N_CATALOG.i18nc("@info:status", "Connected via Cloud")) self.setConnectionText(I18N_CATALOG.i18nc("@info:status", "Connected via Cloud"))
## Called when Cura requests an output device to receive a (G-code) file. ## Called when Cura requests an output device to receive a (G-code) file.
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
file_handler: Optional[FileHandler] = None, **kwargs: str) -> None: file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
# Show an error message if we're already sending a job. # Show an error message if we're already sending a job.
if self._progress.visible: if self._progress.visible:
message = Message( message = Message(
text = I18N_CATALOG.i18nc("@info:status", "Sending new jobs (temporarily) blocked, still sending the previous print job."), text=I18N_CATALOG.i18nc("@info:status",
title = I18N_CATALOG.i18nc("@info:title", "Cloud error"), "Sending new jobs (temporarily) blocked, still sending the previous print job."),
lifetime = 10 title=I18N_CATALOG.i18nc("@info:title", "Cloud error"),
lifetime=10
) )
message.show() message.show()
return return
@ -206,9 +202,9 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
self._tool_path = mesh self._tool_path = mesh
request = CloudPrintJobUploadRequest( request = CloudPrintJobUploadRequest(
job_name = file_name or mesh_format.file_extension, job_name=file_name or mesh_format.file_extension,
file_size = len(mesh), file_size=len(mesh),
content_type = mesh_format.mime_type, content_type=mesh_format.mime_type,
) )
self._api.requestUpload(request, self._onPrintJobCreated) self._api.requestUpload(request, self._onPrintJobCreated)
@ -240,70 +236,74 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
self._updatePrintJobs(status.print_jobs) self._updatePrintJobs(status.print_jobs)
## Updates the local list of printers with the list received from the cloud. ## Updates the local list of printers with the list received from the cloud.
# \param jobs: The printers received from the cloud. # \param remote_printers: The printers received from the cloud.
def _updatePrinters(self, printers: List[CloudClusterPrinterStatus]) -> None: def _updatePrinters(self, remote_printers: List[CloudClusterPrinterStatus]) -> None:
previous = {p.key: p for p in self._printers} # type: Dict[str, PrinterOutputModel]
received = {p.uuid: p for p in printers} # type: Dict[str, CloudClusterPrinterStatus]
if len(printers) > 0: # Keep track of the new printers to show.
# We need the machine type of the host (1st list entry) to allow discovery to work. # We create a new list instead of changing the existing one to get the correct order.
self._host_machine_type = printers[0].machine_variant new_printers = []
removed_printers, added_printers, updated_printers = findChanges(previous, received) # Check which printers need to be created or updated.
for index, printer_data in enumerate(remote_printers):
printer = next(iter(printer for printer in self._printers if printer.key == printer_data.uuid), None)
if not printer:
new_printers.append(printer_data.createOutputModel(CloudOutputController(self)))
else:
printer_data.updateOutputModel(printer)
new_printers.append(printer)
# Check which printers need to be removed (de-referenced).
remote_printers_keys = [printer_data.uuid for printer_data in remote_printers]
removed_printers = [printer for printer in self._printers if printer.key not in remote_printers_keys]
for removed_printer in removed_printers: for removed_printer in removed_printers:
if self._active_printer == removed_printer: if self._active_printer and self._active_printer.key == removed_printer.key:
self.setActivePrinter(None) self.setActivePrinter(None)
self._printers.remove(removed_printer)
for added_printer in added_printers: self._printers = new_printers
self._printers.append(added_printer.createOutputModel(CloudOutputController(self))) if self._printers and not self.activePrinter:
for model, printer in updated_printers:
printer.updateOutputModel(model)
# Always have an active printer
if self._printers and not self._active_printer:
self.setActivePrinter(self._printers[0]) self.setActivePrinter(self._printers[0])
if added_printers or removed_printers: self.printersChanged.emit()
self.printersChanged.emit()
## Updates the local list of print jobs with the list received from the cloud. ## Updates the local list of print jobs with the list received from the cloud.
# \param jobs: The print jobs received from the cloud. # \param remote_jobs: The print jobs received from the cloud.
def _updatePrintJobs(self, jobs: List[CloudClusterPrintJobStatus]) -> None: def _updatePrintJobs(self, remote_jobs: List[CloudClusterPrintJobStatus]) -> None:
received = {j.uuid: j for j in jobs} # type: Dict[str, CloudClusterPrintJobStatus]
previous = {j.key: j for j in self._print_jobs} # type: Dict[str, UM3PrintJobOutputModel]
removed_jobs, added_jobs, updated_jobs = findChanges(previous, received) # Keep track of the new print jobs to show.
# We create a new list instead of changing the existing one to get the correct order.
new_print_jobs = []
# Check which print jobs need to be created or updated.
for index, print_job_data in enumerate(remote_jobs):
print_job = next(
iter(print_job for print_job in self._print_jobs if print_job.key == print_job_data.uuid), None)
if not print_job:
new_print_jobs.append(self._createPrintJobModel(print_job_data))
else:
print_job_data.updateOutputModel(print_job)
if print_job_data.printer_uuid:
self._updateAssignedPrinter(print_job, print_job_data.printer_uuid)
new_print_jobs.append(print_job)
# Check which print job need to be removed (de-referenced).
remote_job_keys = [print_job_data.uuid for print_job_data in remote_jobs]
removed_jobs = [print_job for print_job in self._print_jobs if print_job.key not in remote_job_keys]
for removed_job in removed_jobs: for removed_job in removed_jobs:
if removed_job.assignedPrinter: if removed_job.assignedPrinter:
removed_job.assignedPrinter.updateActivePrintJob(None) removed_job.assignedPrinter.updateActivePrintJob(None)
removed_job.stateChanged.disconnect(self._onPrintJobStateChanged) removed_job.stateChanged.disconnect(self._onPrintJobStateChanged)
self._print_jobs.remove(removed_job)
for added_job in added_jobs: self._print_jobs = new_print_jobs
self._addPrintJob(added_job) self.printJobsChanged.emit()
for model, job in updated_jobs: ## Create a new print job model based on the remote status of the job.
job.updateOutputModel(model) # \param remote_job: The remote print job data.
if job.printer_uuid: def _createPrintJobModel(self, remote_job: CloudClusterPrintJobStatus) -> UM3PrintJobOutputModel:
self._updateAssignedPrinter(model, job.printer_uuid) model = remote_job.createOutputModel(CloudOutputController(self))
# We only have to update when jobs are added or removed
# updated jobs push their changes via their output model
if added_jobs or removed_jobs:
self.printJobsChanged.emit()
## Registers a new print job received via the cloud API.
# \param job: The print job received.
def _addPrintJob(self, job: CloudClusterPrintJobStatus) -> None:
model = job.createOutputModel(CloudOutputController(self))
model.stateChanged.connect(self._onPrintJobStateChanged) model.stateChanged.connect(self._onPrintJobStateChanged)
if job.printer_uuid: if remote_job.printer_uuid:
self._updateAssignedPrinter(model, job.printer_uuid) self._updateAssignedPrinter(model, remote_job.printer_uuid)
self._print_jobs.append(model) return model
## Handles the event of a change in a print job state ## Handles the event of a change in a print job state
def _onPrintJobStateChanged(self) -> None: def _onPrintJobStateChanged(self) -> None:
@ -313,14 +313,15 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
if job.state == "wait_cleanup" and job.key not in self._finished_jobs and job.owner == user_name: if job.state == "wait_cleanup" and job.key not in self._finished_jobs and job.owner == user_name:
self._finished_jobs.add(job.key) self._finished_jobs.add(job.key)
Message( Message(
title = I18N_CATALOG.i18nc("@info:status", "Print finished"), title=I18N_CATALOG.i18nc("@info:status", "Print finished"),
text = (I18N_CATALOG.i18nc("@info:status", "Printer '{printer_name}' has finished printing '{job_name}'.").format( text=(I18N_CATALOG.i18nc("@info:status",
printer_name = job.assignedPrinter.name, "Printer '{printer_name}' has finished printing '{job_name}'.").format(
job_name = job.name printer_name=job.assignedPrinter.name,
job_name=job.name
) if job.assignedPrinter else ) if job.assignedPrinter else
I18N_CATALOG.i18nc("@info:status", "The print job '{job_name}' was finished.").format( I18N_CATALOG.i18nc("@info:status", "The print job '{job_name}' was finished.").format(
job_name = job.name job_name=job.name
)), )),
).show() ).show()
## Updates the printer assignment for the given print job model. ## Updates the printer assignment for the given print job model.
@ -328,9 +329,8 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
printer = next((p for p in self._printers if printer_uuid == p.key), None) printer = next((p for p in self._printers if printer_uuid == p.key), None)
if not printer: if not printer:
Logger.log("w", "Missing printer %s for job %s in %s", model.assignedPrinter, model.key, Logger.log("w", "Missing printer %s for job %s in %s", model.assignedPrinter, model.key,
[p.key for p in self._printers]) [p.key for p in self._printers])
return return
printer.updateActivePrintJob(model) printer.updateActivePrintJob(model)
model.updateAssignedPrinter(printer) model.updateAssignedPrinter(printer)
@ -340,7 +340,8 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
self._progress.show() self._progress.show()
self._uploaded_print_job = job_response self._uploaded_print_job = job_response
tool_path = cast(bytes, self._tool_path) tool_path = cast(bytes, self._tool_path)
self._api.uploadToolPath(job_response, tool_path, self._onPrintJobUploaded, self._progress.update, self._onUploadError) self._api.uploadToolPath(job_response, tool_path, self._onPrintJobUploaded, self._progress.update,
self._onUploadError)
## Requests the print to be sent to the printer when we finished uploading the mesh. ## Requests the print to be sent to the printer when we finished uploading the mesh.
def _onPrintJobUploaded(self) -> None: def _onPrintJobUploaded(self) -> None:
@ -354,9 +355,9 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
self._progress.hide() self._progress.hide()
self._uploaded_print_job = None self._uploaded_print_job = None
Message( Message(
text = message or I18N_CATALOG.i18nc("@info:text", "Could not upload the data to the printer."), text=message or I18N_CATALOG.i18nc("@info:text", "Could not upload the data to the printer."),
title = I18N_CATALOG.i18nc("@info:title", "Cloud error"), title=I18N_CATALOG.i18nc("@info:title", "Cloud error"),
lifetime = 10 lifetime=10
).show() ).show()
self.writeError.emit() self.writeError.emit()
@ -366,22 +367,24 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
Logger.log("d", "The cluster will be printing this print job with the ID %s", response.cluster_job_id) Logger.log("d", "The cluster will be printing this print job with the ID %s", response.cluster_job_id)
self._progress.hide() self._progress.hide()
Message( Message(
text = I18N_CATALOG.i18nc("@info:status", "Print job was successfully sent to the printer."), text=I18N_CATALOG.i18nc("@info:status", "Print job was successfully sent to the printer."),
title = I18N_CATALOG.i18nc("@info:title", "Data Sent"), title=I18N_CATALOG.i18nc("@info:title", "Data Sent"),
lifetime = 5 lifetime=5
).show() ).show()
self.writeFinished.emit() self.writeFinished.emit()
## Gets the printer type of the cluster host. Falls back to the printer type in the device properties. ## Whether the printer that this output device represents supports print job actions via the cloud.
@pyqtProperty(str, notify=_clusterPrintersChanged) @pyqtProperty(bool, notify=_clusterPrintersChanged)
def printerType(self) -> str: def supportsPrintJobActions(self) -> bool:
if self._printers and self._host_machine_type in self._host_machine_variant_to_machine_type_map: if not self._printers:
return self._host_machine_variant_to_machine_type_map[self._host_machine_type] return False
return super().printerType version_number = self.printers[0].firmwareVersion.split(".")
firmware_version = Version([version_number[0], version_number[1], version_number[2]])
return firmware_version >= self.PRINT_JOB_ACTIONS_MIN_VERSION
## Gets the number of printers in the cluster. ## Gets the number of printers in the cluster.
# We use a minimum of 1 because cloud devices are always a cluster and printer discovery needs it. # We use a minimum of 1 because cloud devices are always a cluster and printer discovery needs it.
@pyqtProperty(int, notify = _clusterPrintersChanged) @pyqtProperty(int, notify=_clusterPrintersChanged)
def clusterSize(self) -> int: def clusterSize(self) -> int:
return max(1, len(self._printers)) return max(1, len(self._printers))
@ -391,7 +394,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
return self._printers return self._printers
## Get the active printer in the UI (monitor page). ## Get the active printer in the UI (monitor page).
@pyqtProperty(QObject, notify = activePrinterChanged) @pyqtProperty(QObject, notify=activePrinterChanged)
def activePrinter(self) -> Optional[PrinterOutputModel]: def activePrinter(self) -> Optional[PrinterOutputModel]:
return self._active_printer return self._active_printer
@ -403,38 +406,67 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
self.activePrinterChanged.emit() self.activePrinterChanged.emit()
## Get remote print jobs. ## Get remote print jobs.
@pyqtProperty("QVariantList", notify = printJobsChanged) @pyqtProperty("QVariantList", notify=printJobsChanged)
def printJobs(self) -> List[UM3PrintJobOutputModel]: def printJobs(self) -> List[UM3PrintJobOutputModel]:
return self._print_jobs return self._print_jobs
## Get remote print jobs that are still in the print queue. ## Get remote print jobs that are still in the print queue.
@pyqtProperty("QVariantList", notify = printJobsChanged) @pyqtProperty("QVariantList", notify=printJobsChanged)
def queuedPrintJobs(self) -> List[UM3PrintJobOutputModel]: def queuedPrintJobs(self) -> List[UM3PrintJobOutputModel]:
return [print_job for print_job in self._print_jobs return [print_job for print_job in self._print_jobs
if print_job.state == "queued" or print_job.state == "error"] if print_job.state == "queued" or print_job.state == "error"]
## Get remote print jobs that are assigned to a printer. ## Get remote print jobs that are assigned to a printer.
@pyqtProperty("QVariantList", notify = printJobsChanged) @pyqtProperty("QVariantList", notify=printJobsChanged)
def activePrintJobs(self) -> List[UM3PrintJobOutputModel]: def activePrintJobs(self) -> List[UM3PrintJobOutputModel]:
return [print_job for print_job in self._print_jobs if return [print_job for print_job in self._print_jobs if
print_job.assignedPrinter is not None and print_job.state != "queued"] print_job.assignedPrinter is not None and print_job.state != "queued"]
@pyqtSlot(int, result = str) ## Set the remote print job state.
def setJobState(self, print_job_uuid: str, state: str) -> None:
self._api.doPrintJobAction(self._cluster.cluster_id, print_job_uuid, state)
@pyqtSlot(str)
def sendJobToTop(self, print_job_uuid: str) -> None:
self._api.doPrintJobAction(self._cluster.cluster_id, print_job_uuid, "move",
{"list": "queued", "to_position": 0})
@pyqtSlot(str)
def deleteJobFromQueue(self, print_job_uuid: str) -> None:
self._api.doPrintJobAction(self._cluster.cluster_id, print_job_uuid, "remove")
@pyqtSlot(str)
def forceSendJob(self, print_job_uuid: str) -> None:
self._api.doPrintJobAction(self._cluster.cluster_id, print_job_uuid, "force")
@pyqtSlot(int, result=str)
def formatDuration(self, seconds: int) -> str: def formatDuration(self, seconds: int) -> str:
return Duration(seconds).getDisplayString(DurationFormat.Format.Short) return Duration(seconds).getDisplayString(DurationFormat.Format.Short)
@pyqtSlot(int, result = str) @pyqtSlot(int, result=str)
def getTimeCompleted(self, time_remaining: int) -> str: def getTimeCompleted(self, time_remaining: int) -> str:
return formatTimeCompleted(time_remaining) return formatTimeCompleted(time_remaining)
@pyqtSlot(int, result = str) @pyqtSlot(int, result=str)
def getDateCompleted(self, time_remaining: int) -> str: def getDateCompleted(self, time_remaining: int) -> str:
return formatDateCompleted(time_remaining) return formatDateCompleted(time_remaining)
@pyqtProperty(bool, notify=printJobsChanged)
def receivedPrintJobs(self) -> bool:
return bool(self._print_jobs)
@pyqtSlot()
def openPrintJobControlPanel(self) -> None:
QDesktopServices.openUrl(QUrl("https://mycloud.ultimaker.com"))
@pyqtSlot()
def openPrinterControlPanel(self) -> None:
QDesktopServices.openUrl(QUrl("https://mycloud.ultimaker.com"))
## TODO: The following methods are required by the monitor page QML, but are not actually available using cloud. ## TODO: The following methods are required by the monitor page QML, but are not actually available using cloud.
# TODO: We fake the methods here to not break the monitor page. # TODO: We fake the methods here to not break the monitor page.
@pyqtProperty(QUrl, notify = _clusterPrintersChanged) @pyqtProperty(QUrl, notify=_clusterPrintersChanged)
def activeCameraUrl(self) -> "QUrl": def activeCameraUrl(self) -> "QUrl":
return QUrl() return QUrl()
@ -442,30 +474,6 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
def setActiveCameraUrl(self, camera_url: "QUrl") -> None: def setActiveCameraUrl(self, camera_url: "QUrl") -> None:
pass pass
@pyqtProperty(bool, notify = printJobsChanged) @pyqtProperty("QVariantList", notify=_clusterPrintersChanged)
def receivedPrintJobs(self) -> bool:
return bool(self._print_jobs)
@pyqtSlot()
def openPrintJobControlPanel(self) -> None:
pass
@pyqtSlot()
def openPrinterControlPanel(self) -> None:
pass
@pyqtSlot(str)
def sendJobToTop(self, print_job_uuid: str) -> None:
pass
@pyqtSlot(str)
def deleteJobFromQueue(self, print_job_uuid: str) -> None:
pass
@pyqtSlot(str)
def forceSendJob(self, print_job_uuid: str) -> None:
pass
@pyqtProperty("QVariantList", notify = _clusterPrintersChanged)
def connectedPrintersTypeCount(self) -> List[Dict[str, str]]: def connectedPrintersTypeCount(self) -> List[Dict[str, str]]:
return [] return []

View file

@ -96,7 +96,7 @@ class CloudOutputDeviceManager:
device = CloudOutputDevice(self._api, cluster) device = CloudOutputDevice(self._api, cluster)
self._remote_clusters[cluster.cluster_id] = device self._remote_clusters[cluster.cluster_id] = device
self._application.getDiscoveredPrintersModel().addDiscoveredPrinter( self._application.getDiscoveredPrintersModel().addDiscoveredPrinter(
cluster.cluster_id, device.key,
device.key, device.key,
cluster.friendly_name, cluster.friendly_name,
self._createMachineFromDiscoveredPrinter, self._createMachineFromDiscoveredPrinter,
@ -109,7 +109,7 @@ class CloudOutputDeviceManager:
for device, cluster in updates: for device, cluster in updates:
device.clusterData = cluster device.clusterData = cluster
self._application.getDiscoveredPrintersModel().updateDiscoveredPrinter( self._application.getDiscoveredPrintersModel().updateDiscoveredPrinter(
cluster.cluster_id, device.key,
cluster.friendly_name, cluster.friendly_name,
device.printerType, device.printerType,
) )

View file

@ -91,7 +91,6 @@ class CloudClusterPrintJobStatus(BaseCloudModel):
def createOutputModel(self, controller: CloudOutputController) -> UM3PrintJobOutputModel: def createOutputModel(self, controller: CloudOutputController) -> UM3PrintJobOutputModel:
model = UM3PrintJobOutputModel(controller, self.uuid, self.name) model = UM3PrintJobOutputModel(controller, self.uuid, self.name)
self.updateOutputModel(model) self.updateOutputModel(model)
return model return model
## Creates a new configuration model ## Creates a new configuration model

View file

@ -15,9 +15,12 @@ class CloudClusterResponse(BaseCloudModel):
# \param is_online: Whether this cluster is currently connected to the cloud. # \param is_online: Whether this cluster is currently connected to the cloud.
# \param status: The status of the cluster authentication (active or inactive). # \param status: The status of the cluster authentication (active or inactive).
# \param host_version: The firmware version of the cluster host. This is where the Stardust client is running on. # \param host_version: The firmware version of the cluster host. This is where the Stardust client is running on.
# \param host_internal_ip: The internal IP address of the host printer.
# \param friendly_name: The human readable name of the host printer.
# \param printer_type: The machine type of the host printer.
def __init__(self, cluster_id: str, host_guid: str, host_name: str, is_online: bool, status: str, def __init__(self, cluster_id: str, host_guid: str, host_name: str, is_online: bool, status: str,
host_internal_ip: Optional[str] = None, host_version: Optional[str] = None, host_internal_ip: Optional[str] = None, host_version: Optional[str] = None,
friendly_name: Optional[str] = None, **kwargs) -> None: friendly_name: Optional[str] = None, printer_type: str = "ultimaker3", **kwargs) -> None:
self.cluster_id = cluster_id self.cluster_id = cluster_id
self.host_guid = host_guid self.host_guid = host_guid
self.host_name = host_name self.host_name = host_name
@ -26,6 +29,7 @@ class CloudClusterResponse(BaseCloudModel):
self.host_version = host_version self.host_version = host_version
self.host_internal_ip = host_internal_ip self.host_internal_ip = host_internal_ip
self.friendly_name = friendly_name self.friendly_name = friendly_name
self.printer_type = printer_type
super().__init__(**kwargs) super().__init__(**kwargs)
# Validates the model, raising an exception if the model is invalid. # Validates the model, raising an exception if the model is invalid.

View file

@ -106,8 +106,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
self._active_camera_url = QUrl() # type: QUrl self._active_camera_url = QUrl() # type: QUrl
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
file_handler: Optional[FileHandler] = None, **kwargs: str) -> None: file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
self.writeStarted.emit(self) self.writeStarted.emit(self)
self.sendMaterialProfiles() self.sendMaterialProfiles()
@ -140,6 +140,11 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
if self._printer_selection_dialog is not None: if self._printer_selection_dialog is not None:
self._printer_selection_dialog.show() self._printer_selection_dialog.show()
## Whether the printer that this output device represents supports print job actions via the local network.
@pyqtProperty(bool, constant=True)
def supportsPrintJobActions(self) -> bool:
return True
@pyqtProperty(int, constant=True) @pyqtProperty(int, constant=True)
def clusterSize(self) -> int: def clusterSize(self) -> int:
return self._cluster_size return self._cluster_size
@ -385,6 +390,13 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
data = "{\"force\": true}" data = "{\"force\": true}"
self.put("print_jobs/{uuid}".format(uuid=print_job_uuid), data, on_finished=None) self.put("print_jobs/{uuid}".format(uuid=print_job_uuid), data, on_finished=None)
# Set the remote print job state.
def setJobState(self, print_job_uuid: str, state: str) -> None:
# We rewrite 'resume' to 'print' here because we are using the old print job action endpoints.
action = "print" if state == "resume" else state
data = "{\"action\": \"%s\"}" % action
self.put("print_jobs/%s/action" % print_job_uuid, data, on_finished=None)
def _printJobStateChanged(self) -> None: def _printJobStateChanged(self) -> None:
username = self._getUserName() username = self._getUserName()

View file

@ -7,6 +7,7 @@ MYPY = False
if MYPY: if MYPY:
from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.Models.PrintJobOutputModel import PrintJobOutputModel
class ClusterUM3PrinterOutputController(PrinterOutputController): class ClusterUM3PrinterOutputController(PrinterOutputController):
def __init__(self, output_device): def __init__(self, output_device):
super().__init__(output_device) super().__init__(output_device)
@ -15,6 +16,5 @@ class ClusterUM3PrinterOutputController(PrinterOutputController):
self.can_control_manually = False self.can_control_manually = False
self.can_send_raw_gcode = False self.can_send_raw_gcode = False
def setJobState(self, job: "PrintJobOutputModel", state: str): def setJobState(self, job: "PrintJobOutputModel", state: str) -> None:
data = "{\"action\": \"%s\"}" % state self._output_device.setJobState(job.key, state)
self._output_device.put("print_jobs/%s/action" % job.key, data, on_finished=None)

View file

@ -3,11 +3,16 @@
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot
BLOCKING_CHANGE_TYPES = [
"material_insert", "buildplate_change"
]
class ConfigurationChangeModel(QObject): class ConfigurationChangeModel(QObject):
def __init__(self, type_of_change: str, index: int, target_name: str, origin_name: str) -> None: def __init__(self, type_of_change: str, index: int, target_name: str, origin_name: str) -> None:
super().__init__() super().__init__()
self._type_of_change = type_of_change self._type_of_change = type_of_change
# enum = ["material", "print_core_change"] # enum = ["material", "print_core_change"]
self._can_override = self._type_of_change not in BLOCKING_CHANGE_TYPES
self._index = index self._index = index
self._target_name = target_name self._target_name = target_name
self._origin_name = origin_name self._origin_name = origin_name
@ -27,3 +32,7 @@ class ConfigurationChangeModel(QObject):
@pyqtProperty(str, constant = True) @pyqtProperty(str, constant = True)
def originName(self) -> str: def originName(self) -> str:
return self._origin_name return self._origin_name
@pyqtProperty(bool, constant = True)
def canOverride(self) -> bool:
return self._can_override

View file

@ -178,7 +178,8 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice):
# NotImplementedError. We can simply ignore these. # NotImplementedError. We can simply ignore these.
pass pass
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None: def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
if not self.activePrinter: if not self.activePrinter:
# No active printer. Unable to write # No active printer. Unable to write
return return

View file

@ -27,7 +27,7 @@ from UM.Version import Version
from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice
from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager
from .Cloud.CloudOutputDevice import CloudOutputDevice # typing from .Cloud.CloudOutputDevice import CloudOutputDevice # typing
if TYPE_CHECKING: if TYPE_CHECKING:
from PyQt5.QtNetwork import QNetworkReply from PyQt5.QtNetwork import QNetworkReply
@ -169,6 +169,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
self.addManualDevice(address) self.addManualDevice(address)
self.resetLastManualDevice() self.resetLastManualDevice()
# TODO: CHANGE TO HOSTNAME
def refreshConnections(self): def refreshConnections(self):
active_machine = CuraApplication.getInstance().getGlobalContainerStack() active_machine = CuraApplication.getInstance().getGlobalContainerStack()
if not active_machine: if not active_machine:
@ -235,10 +236,6 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
self._application.callLater(manual_printer_request.callback, False, address) self._application.callLater(manual_printer_request.callback, False, address)
def addManualDevice(self, address: str, callback: Optional[Callable[[bool, str], None]] = None) -> None: 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._manual_instances[address] = ManualPrinterRequest(address, callback = callback)
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances.keys())) self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances.keys()))

View file

@ -72,9 +72,9 @@ class TestCloudOutputDevice(TestCase):
controller_fields = { controller_fields = {
"_output_device": self.device, "_output_device": self.device,
"can_abort": False, "can_abort": True,
"can_control_manually": False, "can_control_manually": False,
"can_pause": False, "can_pause": True,
"can_pre_heat_bed": False, "can_pre_heat_bed": False,
"can_pre_heat_hotends": False, "can_pre_heat_hotends": False,
"can_send_raw_gcode": False, "can_send_raw_gcode": False,

View file

@ -6,6 +6,7 @@ import os
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
from UM.Logger import Logger from UM.Logger import Logger
from UM.Mesh.MeshWriter import MeshWriter #To get the g-code output. from UM.Mesh.MeshWriter import MeshWriter #To get the g-code output.
from UM.Message import Message #Show an error when already printing.
from UM.PluginRegistry import PluginRegistry #To get the g-code output. from UM.PluginRegistry import PluginRegistry #To get the g-code output.
from UM.Qt.Duration import DurationFormat from UM.Qt.Duration import DurationFormat
@ -23,11 +24,15 @@ from queue import Queue
from serial import Serial, SerialException, SerialTimeoutException from serial import Serial, SerialException, SerialTimeoutException
from threading import Thread, Event from threading import Thread, Event
from time import time from time import time
from typing import Union, Optional, List, cast from typing import Union, Optional, List, cast, TYPE_CHECKING
import re import re
import functools # Used for reduce import functools # Used for reduce
if TYPE_CHECKING:
from UM.FileHandler.FileHandler import FileHandler
from UM.Scene.SceneNode import SceneNode
catalog = i18nCatalog("cura") catalog = i18nCatalog("cura")
@ -112,16 +117,20 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
## Request the current scene to be sent to a USB-connected printer. ## Request the current scene to be sent to a USB-connected printer.
# #
# \param nodes A collection of scene nodes to send. This is ignored. # \param nodes A collection of scene nodes to send. This is ignored.
# \param file_name \type{string} A suggestion for a file name to write. # \param file_name A suggestion for a file name to write.
# \param filter_by_machine Whether to filter MIME types by machine. This # \param filter_by_machine Whether to filter MIME types by machine. This
# is ignored. # is ignored.
# \param kwargs Keyword arguments. # \param kwargs Keyword arguments.
def requestWrite(self, nodes, file_name = None, filter_by_machine = False, file_handler = None, **kwargs): def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
if self._is_printing: if self._is_printing:
message = Message(text = catalog.i18nc("@message", "A print is still in progress. Cura cannot start another print via USB until the previous print has completed."), title = catalog.i18nc("@message", "Print in Progress"))
message.show()
return # Already printing return # Already printing
self.writeStarted.emit(self) self.writeStarted.emit(self)
# cancel any ongoing preheat timer before starting a print # cancel any ongoing preheat timer before starting a print
self._printers[0].getController().stopPreheatTimers() controller = cast(GenericOutputController, self._printers[0].getController())
controller.stopPreheatTimers()
CuraApplication.getInstance().getController().setActiveStage("MonitorStage") CuraApplication.getInstance().getController().setActiveStage("MonitorStage")
@ -181,7 +190,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
try: try:
self._serial = Serial(str(self._serial_port), self._baud_rate, timeout=self._timeout, writeTimeout=self._timeout) self._serial = Serial(str(self._serial_port), self._baud_rate, timeout=self._timeout, writeTimeout=self._timeout)
except SerialException: except SerialException:
Logger.log("w", "An exception occured while trying to create serial connection") Logger.log("w", "An exception occurred while trying to create serial connection")
return return
CuraApplication.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged) CuraApplication.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)
self._onGlobalContainerStackChanged() self._onGlobalContainerStackChanged()

View file

@ -4,6 +4,8 @@
import threading import threading
import time import time
import serial.tools.list_ports import serial.tools.list_ports
from os import environ
from re import search
from PyQt5.QtCore import QObject, pyqtSignal from PyQt5.QtCore import QObject, pyqtSignal
@ -112,6 +114,27 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
port = (port.device, port.description, port.hwid) port = (port.device, port.description, port.hwid)
if only_list_usb and not port[2].startswith("USB"): if only_list_usb and not port[2].startswith("USB"):
continue 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]] base_list += [port[0]]
return list(base_list) return list(base_list)

View file

@ -52,7 +52,7 @@ class VersionUpgrade40to41(VersionUpgrade):
parser["metadata"]["setting_version"] = "7" parser["metadata"]["setting_version"] = "7"
# Limit Maximum Deviation instead of Maximum Resolution. This should have approximately the same effect as before the algorithm change, only more consistent. # Limit Maximum Deviation instead of Maximum Resolution. This should have approximately the same effect as before the algorithm change, only more consistent.
if "meshfix_maximum_resolution" in parser["values"]: if "values" in parser and "meshfix_maximum_resolution" in parser["values"]:
resolution = parser["values"]["meshfix_maximum_resolution"] resolution = parser["values"]["meshfix_maximum_resolution"]
if resolution.startswith("="): if resolution.startswith("="):
resolution = resolution[1:] resolution = resolution[1:]

View file

@ -14,7 +14,7 @@ def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
("preferences", 6000006): ("preferences", 6000007, upgrade.upgradePreferences), ("preferences", 6000006): ("preferences", 6000007, upgrade.upgradePreferences),
("machine_stack", 4000006): ("machine_stack", 4000007, upgrade.upgradeStack), ("machine_stack", 4000006): ("machine_stack", 4000007, upgrade.upgradeStack),
("extruder_train", 4000006): ("extruder_train", 4000007, upgrade.upgradeStack), ("extruder_train", 4000006): ("extruder_train", 4000007, upgrade.upgradeStack),
("definition_changes", 4000006): ("definition_changes", 4000007, upgrade.upgradeInstanceContainer), ("definition_changes", 4000006): ("definition_changes", 4000007, upgrade.upgradeInstanceContainer),

View file

@ -0,0 +1,337 @@
# Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import configparser
import io
import os.path # To get the file ID.
from typing import Dict, List, Tuple
from UM.VersionUpgrade import VersionUpgrade
_renamed_settings = {
"support_minimal_diameter": "support_tower_maximum_supported_diameter"
} # type: Dict[str, str]
_removed_settings = ["prime_tower_circular", "max_feedrate_z_override"] # type: List[str]
_renamed_profiles = {
# Include CreawsomeMod profiles here as well for the people who installed that.
# Definitions.
"creawsome_base": "creality_base",
"creawsome_cr10": "creality_cr10",
"creawsome_cr10mini": "creality_cr10mini",
"creawsome_cr10s": "creality_cr10s",
"creawsome_cr10s4": "creality_cr10s4",
"creawsome_cr10s5": "creality_cr10s5",
"creawsome_cr10spro": "creality_cr10spro",
"creawsome_cr20": "creality_cr20",
"creawsome_cr20pro": "creality_cr20pro",
"creawsome_ender2": "creality_ender2",
"creawsome_ender3": "creality_ender3",
"creawsome_ender4": "creality_ender4",
"creawsome_ender5": "creality_ender5",
# Extruder definitions.
"creawsome_base_extruder_0": "creality_base_extruder_0",
# Variants.
"creawsome_base_0.2": "creality_base_0.2",
"creawsome_base_0.3": "creality_base_0.3",
"creawsome_base_0.4": "creality_base_0.4",
"creawsome_base_0.5": "creality_base_0.5",
"creawsome_base_0.6": "creality_base_0.6",
"creawsome_base_0.8": "creality_base_0.8",
"creawsome_base_1.0": "creality_base_1.0",
"creawsome_cr10_0.2": "creality_cr10_0.2",
"creawsome_cr10_0.3": "creality_cr10_0.3",
"creawsome_cr10_0.4": "creality_cr10_0.4",
"creawsome_cr10_0.5": "creality_cr10_0.5",
"creawsome_cr10_0.6": "creality_cr10_0.6",
"creawsome_cr10_0.8": "creality_cr10_0.8",
"creawsome_cr10_1.0": "creality_cr10_1.0",
"creawsome_cr10mini_0.2": "creality_cr10mini_0.2",
"creawsome_cr10mini_0.3": "creality_cr10mini_0.3",
"creawsome_cr10mini_0.4": "creality_cr10mini_0.4",
"creawsome_cr10mini_0.5": "creality_cr10mini_0.5",
"creawsome_cr10mini_0.6": "creality_cr10mini_0.6",
"creawsome_cr10mini_0.8": "creality_cr10mini_0.8",
"creawsome_cr10mini_1.0": "creality_cr10mini_1.0",
"creawsome_cr10s4_0.2": "creality_cr10s4_0.2",
"creawsome_cr10s4_0.3": "creality_cr10s4_0.3",
"creawsome_cr10s4_0.4": "creality_cr10s4_0.4",
"creawsome_cr10s4_0.5": "creality_cr10s4_0.5",
"creawsome_cr10s4_0.6": "creality_cr10s4_0.6",
"creawsome_cr10s4_0.8": "creality_cr10s4_0.8",
"creawsome_cr10s4_1.0": "creality_cr10s4_1.0",
"creawsome_cr10s5_0.2": "creality_cr10s5_0.2",
"creawsome_cr10s5_0.3": "creality_cr10s5_0.3",
"creawsome_cr10s5_0.4": "creality_cr10s5_0.4",
"creawsome_cr10s5_0.5": "creality_cr10s5_0.5",
"creawsome_cr10s5_0.6": "creality_cr10s5_0.6",
"creawsome_cr10s5_0.8": "creality_cr10s5_0.8",
"creawsome_cr10s5_1.0": "creality_cr10s5_1.0",
"creawsome_cr10s_0.2": "creality_cr10s_0.2",
"creawsome_cr10s_0.3": "creality_cr10s_0.3",
"creawsome_cr10s_0.4": "creality_cr10s_0.4",
"creawsome_cr10s_0.5": "creality_cr10s_0.5",
"creawsome_cr10s_0.6": "creality_cr10s_0.6",
"creawsome_cr10s_0.8": "creality_cr10s_0.8",
"creawsome_cr10s_1.0": "creality_cr10s_1.0",
"creawsome_cr10spro_0.2": "creality_cr10spro_0.2",
"creawsome_cr10spro_0.3": "creality_cr10spro_0.3",
"creawsome_cr10spro_0.4": "creality_cr10spro_0.4",
"creawsome_cr10spro_0.5": "creality_cr10spro_0.5",
"creawsome_cr10spro_0.6": "creality_cr10spro_0.6",
"creawsome_cr10spro_0.8": "creality_cr10spro_0.8",
"creawsome_cr10spro_1.0": "creality_cr10spro_1.0",
"creawsome_cr20_0.2": "creality_cr20_0.2",
"creawsome_cr20_0.3": "creality_cr20_0.3",
"creawsome_cr20_0.4": "creality_cr20_0.4",
"creawsome_cr20_0.5": "creality_cr20_0.5",
"creawsome_cr20_0.6": "creality_cr20_0.6",
"creawsome_cr20_0.8": "creality_cr20_0.8",
"creawsome_cr20_1.0": "creality_cr20_1.0",
"creawsome_cr20pro_0.2": "creality_cr20pro_0.2",
"creawsome_cr20pro_0.3": "creality_cr20pro_0.3",
"creawsome_cr20pro_0.4": "creality_cr20pro_0.4",
"creawsome_cr20pro_0.5": "creality_cr20pro_0.5",
"creawsome_cr20pro_0.6": "creality_cr20pro_0.6",
"creawsome_cr20pro_0.8": "creality_cr20pro_0.8",
"creawsome_cr20pro_1.0": "creality_cr20pro_1.0",
"creawsome_ender2_0.2": "creality_ender2_0.2",
"creawsome_ender2_0.3": "creality_ender2_0.3",
"creawsome_ender2_0.4": "creality_ender2_0.4",
"creawsome_ender2_0.5": "creality_ender2_0.5",
"creawsome_ender2_0.6": "creality_ender2_0.6",
"creawsome_ender2_0.8": "creality_ender2_0.8",
"creawsome_ender2_1.0": "creality_ender2_1.0",
"creawsome_ender3_0.2": "creality_ender3_0.2",
"creawsome_ender3_0.3": "creality_ender3_0.3",
"creawsome_ender3_0.4": "creality_ender3_0.4",
"creawsome_ender3_0.5": "creality_ender3_0.5",
"creawsome_ender3_0.6": "creality_ender3_0.6",
"creawsome_ender3_0.8": "creality_ender3_0.8",
"creawsome_ender3_1.0": "creality_ender3_1.0",
"creawsome_ender4_0.2": "creality_ender4_0.2",
"creawsome_ender4_0.3": "creality_ender4_0.3",
"creawsome_ender4_0.4": "creality_ender4_0.4",
"creawsome_ender4_0.5": "creality_ender4_0.5",
"creawsome_ender4_0.6": "creality_ender4_0.6",
"creawsome_ender4_0.8": "creality_ender4_0.8",
"creawsome_ender4_1.0": "creality_ender4_1.0",
"creawsome_ender5_0.2": "creality_ender5_0.2",
"creawsome_ender5_0.3": "creality_ender5_0.3",
"creawsome_ender5_0.4": "creality_ender5_0.4",
"creawsome_ender5_0.5": "creality_ender5_0.5",
"creawsome_ender5_0.6": "creality_ender5_0.6",
"creawsome_ender5_0.8": "creality_ender5_0.8",
"creawsome_ender5_1.0": "creality_ender5_1.0",
# Upgrade for people who had the original Creality profiles from 4.1 and earlier.
"creality_cr10_extruder_0": "creality_base_extruder_0",
"creality_cr10s4_extruder_0": "creality_base_extruder_0",
"creality_cr10s5_extruder_0": "creality_base_extruder_0",
"creality_ender3_extruder_0": "creality_base_extruder_0"
}
# For legacy Creality printers, select the correct quality profile depending on the material.
_creality_quality_per_material = {
# Since legacy Creality printers didn't have different variants, we always pick the 0.4mm variant.
"generic_abs_175": {
"high": "base_0.4_ABS_super",
"normal": "base_0.4_ABS_super",
"fast": "base_0.4_ABS_super",
"draft": "base_0.4_ABS_standard",
"extra_fast": "base_0.4_ABS_low",
"coarse": "base_0.4_ABS_low",
"extra_coarse": "base_0.4_ABS_low"
},
"generic_petg_175": {
"high": "base_0.4_PETG_super",
"normal": "base_0.4_PETG_super",
"fast": "base_0.4_PETG_super",
"draft": "base_0.4_PETG_standard",
"extra_fast": "base_0.4_PETG_low",
"coarse": "base_0.4_PETG_low",
"extra_coarse": "base_0.4_PETG_low"
},
"generic_pla_175": {
"high": "base_0.4_PLA_super",
"normal": "base_0.4_PLA_super",
"fast": "base_0.4_PLA_super",
"draft": "base_0.4_PLA_standard",
"extra_fast": "base_0.4_PLA_low",
"coarse": "base_0.4_PLA_low",
"extra_coarse": "base_0.4_PLA_low"
},
"generic_tpu_175": {
"high": "base_0.4_TPU_super",
"normal": "base_0.4_TPU_super",
"fast": "base_0.4_TPU_super",
"draft": "base_0.4_TPU_standard",
"extra_fast": "base_0.4_TPU_standard",
"coarse": "base_0.4_TPU_standard",
"extra_coarse": "base_0.4_TPU_standard"
},
"empty_material": { # For the global stack.
"high": "base_global_super",
"normal": "base_global_super",
"fast": "base_global_super",
"draft": "base_global_standard",
"extra_fast": "base_global_low",
"coarse": "base_global_low",
"extra_coarse": "base_global_low"
}
}
# Default variant to select for legacy Creality printers, now that we have variants.
_default_variants = {
"creality_cr10_extruder_0": "creality_cr10_0.4",
"creality_cr10s4_extruder_0": "creality_cr10s4_0.4",
"creality_cr10s5_extruder_0": "creality_cr10s5_0.4",
"creality_ender3_extruder_0": "creality_ender3_0.4"
}
# Whether the quality changes profile belongs to one of the upgraded printers can only be recognised by how they start.
# If they are, they must use the creality base definition so that they still belong to those printers.
_quality_changes_to_creality_base = {
"creality_cr10_extruder_0",
"creality_cr10s4_extruder_0",
"creality_cr10s5_extruder_0",
"creality_ender3_extruder_0"
"creality_cr10",
"creality_cr10s4",
"creality_cr10s5",
"creality_ender3",
}
_creality_limited_quality_type = {
"high": "super",
"normal": "super",
"fast": "super",
"draft": "draft",
"extra_fast": "draft",
"coarse": "draft",
"extra_coarse": "draft"
}
## Upgrades configurations from the state they were in at version 4.1 to the
# state they should be in at version 4.2.
class VersionUpgrade41to42(VersionUpgrade):
## Gets the version number from a CFG file in Uranium's 4.1 format.
#
# Since the format may change, this is implemented for the 4.1 format only
# and needs to be included in the version upgrade system rather than
# globally in Uranium.
#
# \param serialised The serialised form of a CFG file.
# \return The version number stored in the CFG file.
# \raises ValueError The format of the version number in the file is
# incorrect.
# \raises KeyError The format of the file is incorrect.
def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised)
format_version = int(parser.get("general", "version")) # Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version
## Upgrades instance containers to have the new version
# number.
#
# This renames the renamed settings in the containers.
def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized)
# Update version number.
parser["metadata"]["setting_version"] = "8"
# Certain instance containers (such as definition changes) reference to a certain definition container
# Since a number of those changed name, we also need to update those.
old_definition = parser["general"]["definition"]
if old_definition in _renamed_profiles:
parser["general"]["definition"] = _renamed_profiles[old_definition]
# Rename settings.
if "values" in parser:
for old_name, new_name in _renamed_settings.items():
if old_name in parser["values"]:
parser["values"][new_name] = parser["values"][old_name]
del parser["values"][old_name]
# Remove settings.
for key in _removed_settings:
if key in parser["values"]:
del parser["values"][key]
# For quality-changes profiles made for Creality printers, change the definition to the creality_base and make sure that the quality is something we have a profile for.
if parser["metadata"].get("type", "") == "quality_changes":
for possible_printer in _quality_changes_to_creality_base:
if os.path.basename(filename).startswith(possible_printer + "_"):
parser["general"]["definition"] = "creality_base"
parser["metadata"]["quality_type"] = _creality_limited_quality_type.get(parser["metadata"]["quality_type"], "draft")
break
result = io.StringIO()
parser.write(result)
return [filename], [result.getvalue()]
## Upgrades Preferences to have the new version number.
#
# This renames the renamed settings in the list of visible settings.
def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized)
# Update version number.
parser["metadata"]["setting_version"] = "8"
# Renamed settings.
if "visible_settings" in parser["general"]:
visible_settings = parser["general"]["visible_settings"]
visible_setting_set = set(visible_settings.split(";"))
for old_name, new_name in _renamed_settings.items():
if old_name in visible_setting_set:
visible_setting_set.remove(old_name)
visible_setting_set.add(new_name)
for removed_key in _removed_settings:
if removed_key in visible_setting_set:
visible_setting_set.remove(removed_key)
parser["general"]["visible_settings"] = ";".join(visible_setting_set)
result = io.StringIO()
parser.write(result)
return [filename], [result.getvalue()]
## Upgrades stacks to have the new version number.
def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized)
# Update version number.
parser["metadata"]["setting_version"] = "8"
# Change renamed profiles.
if "containers" in parser:
# For legacy Creality printers, change the variant to 0.4.
definition_id = parser["containers"]["6"]
if parser["metadata"].get("type", "machine") == "extruder_train":
if parser["containers"]["4"] == "empty_variant": # Necessary for people entering from CreawsomeMod who already had a variant.
if definition_id in _default_variants:
parser["containers"]["4"] = _default_variants[definition_id]
if definition_id == "creality_cr10_extruder_0": # We can't disambiguate between Creality CR-10 and Creality-CR10S since they share the same extruder definition. Have to go by the name.
if "cr-10s" in parser["metadata"].get("machine", "Creality CR-10").lower(): # Not perfect, since the user can change this name :(
parser["containers"]["4"] = "creality_cr10s_0.4"
# Also change the quality to go along with it.
material_id = parser["containers"]["3"]
old_quality_id = parser["containers"]["2"]
if material_id in _creality_quality_per_material and old_quality_id in _creality_quality_per_material[material_id]:
parser["containers"]["2"] = _creality_quality_per_material[material_id][old_quality_id]
stack_copy = {} # type: Dict[str, str] # Make a copy so that we don't modify the dict we're iterating over.
stack_copy.update(parser["containers"])
for position, profile_id in stack_copy.items():
if profile_id in _renamed_profiles:
parser["containers"][position] = _renamed_profiles[profile_id]
result = io.StringIO()
parser.write(result)
return [filename], [result.getvalue()]

View file

@ -0,0 +1,59 @@
# Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import Any, Dict, TYPE_CHECKING
from . import VersionUpgrade41to42
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade41to42.VersionUpgrade41to42()
def getMetaData() -> Dict[str, Any]:
return {
"version_upgrade": {
# From To Upgrade function
("preferences", 6000007): ("preferences", 6000008, upgrade.upgradePreferences),
("machine_stack", 4000007): ("machine_stack", 4000008, upgrade.upgradeStack),
("extruder_train", 4000007): ("extruder_train", 4000008, upgrade.upgradeStack),
("definition_changes", 4000007): ("definition_changes", 4000008, upgrade.upgradeInstanceContainer),
("quality_changes", 4000007): ("quality_changes", 4000008, upgrade.upgradeInstanceContainer),
("quality", 4000007): ("quality", 4000008, upgrade.upgradeInstanceContainer),
("user", 4000007): ("user", 4000008, upgrade.upgradeInstanceContainer),
},
"sources": {
"preferences": {
"get_version": upgrade.getCfgVersion,
"location": {"."}
},
"machine_stack": {
"get_version": upgrade.getCfgVersion,
"location": {"./machine_instances"}
},
"extruder_train": {
"get_version": upgrade.getCfgVersion,
"location": {"./extruders"}
},
"definition_changes": {
"get_version": upgrade.getCfgVersion,
"location": {"./definition_changes"}
},
"quality_changes": {
"get_version": upgrade.getCfgVersion,
"location": {"./quality_changes"}
},
"quality": {
"get_version": upgrade.getCfgVersion,
"location": {"./quality"}
},
"user": {
"get_version": upgrade.getCfgVersion,
"location": {"./user"}
}
}
}
def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade }

View file

@ -0,0 +1,8 @@
{
"name": "Version Upgrade 4.1 to 4.2",
"author": "Ultimaker B.V.",
"version": "1.0.0",
"description": "Upgrades configurations from Cura 4.1 to Cura 4.2.",
"api": "6.0",
"i18n-catalog": "cura"
}

View file

@ -1,12 +1,14 @@
[shaders] [shaders]
vertex = vertex =
uniform highp mat4 u_modelViewProjectionMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
attribute highp vec4 a_vertex; attribute highp vec4 a_vertex;
void main() void main()
{ {
gl_Position = u_modelViewProjectionMatrix * a_vertex; gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
} }
fragment = fragment =
@ -19,13 +21,15 @@ fragment =
vertex41core = vertex41core =
#version 410 #version 410
uniform highp mat4 u_modelViewProjectionMatrix; uniform highp mat4 u_modelMatrix;
uniform highp mat4 u_viewMatrix;
uniform highp mat4 u_projectionMatrix;
in highp vec4 a_vertex; in highp vec4 a_vertex;
void main() void main()
{ {
gl_Position = u_modelViewProjectionMatrix * a_vertex; gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_vertex;
} }
fragment41core = fragment41core =
@ -43,7 +47,9 @@ fragment41core =
u_color = [0.02, 0.02, 0.02, 1.0] u_color = [0.02, 0.02, 0.02, 1.0]
[bindings] [bindings]
u_modelViewProjectionMatrix = model_view_projection_matrix u_modelMatrix = model_matrix
u_viewMatrix = view_matrix
u_projectionMatrix = projection_matrix
[attributes] [attributes]
a_vertex = vertex a_vertex = vertex

View file

@ -63,9 +63,19 @@ class XmlMaterialProfile(InstanceContainer):
Logger.log("w", "Can't change metadata {key} of material {material_id} because it's read-only.".format(key = key, material_id = self.getId())) Logger.log("w", "Can't change metadata {key} of material {material_id} because it's read-only.".format(key = key, material_id = self.getId()))
return return
# Some metadata such as diameter should also be instantiated to be a setting. Go though all values for the
# "properties" field and apply the new values to SettingInstances as well.
new_setting_values_dict = {}
if key == "properties":
for k, v in value.items():
if k in self.__material_properties_setting_map:
new_setting_values_dict[self.__material_properties_setting_map[k]] = v
# Prevent recursion # Prevent recursion
if not apply_to_all: if not apply_to_all:
super().setMetaDataEntry(key, value) super().setMetaDataEntry(key, value)
for k, v in new_setting_values_dict.items():
self.setProperty(k, "value", v)
return return
# Get the MaterialGroup # Get the MaterialGroup
@ -74,17 +84,23 @@ class XmlMaterialProfile(InstanceContainer):
material_group = material_manager.getMaterialGroup(root_material_id) material_group = material_manager.getMaterialGroup(root_material_id)
if not material_group: #If the profile is not registered in the registry but loose/temporary, it will not have a base file tree. if not material_group: #If the profile is not registered in the registry but loose/temporary, it will not have a base file tree.
super().setMetaDataEntry(key, value) super().setMetaDataEntry(key, value)
for k, v in new_setting_values_dict.items():
self.setProperty(k, "value", v)
return return
# Update the root material container # Update the root material container
root_material_container = material_group.root_material_node.getContainer() root_material_container = material_group.root_material_node.getContainer()
if root_material_container is not None: if root_material_container is not None:
root_material_container.setMetaDataEntry(key, value, apply_to_all = False) root_material_container.setMetaDataEntry(key, value, apply_to_all = False)
for k, v in new_setting_values_dict.items():
root_material_container.setProperty(k, "value", v)
# Update all containers derived from it # Update all containers derived from it
for node in material_group.derived_material_node_list: for node in material_group.derived_material_node_list:
container = node.getContainer() container = node.getContainer()
if container is not None: if container is not None:
container.setMetaDataEntry(key, value, apply_to_all = False) container.setMetaDataEntry(key, value, apply_to_all = False)
for k, v in new_setting_values_dict.items():
container.setProperty(k, "value", v)
## Overridden from InstanceContainer, similar to setMetaDataEntry. ## Overridden from InstanceContainer, similar to setMetaDataEntry.
# without this function the setName would only set the name of the specific nozzle / material / machine combination container # without this function the setName would only set the name of the specific nozzle / material / machine combination container
@ -174,13 +190,16 @@ class XmlMaterialProfile(InstanceContainer):
## End Name Block ## End Name Block
for key, value in metadata.items(): for key, value in metadata.items():
builder.start(key) # type: ignore key_to_use = key
if key in self._metadata_tags_that_have_cura_namespace:
key_to_use = "cura:" + key_to_use
builder.start(key_to_use) # type: ignore
if value is not None: #Nones get handled well by the builder. if value is not None: #Nones get handled well by the builder.
#Otherwise the builder always expects a string. #Otherwise the builder always expects a string.
#Deserialize expects the stringified version. #Deserialize expects the stringified version.
value = str(value) value = str(value)
builder.data(value) builder.data(value)
builder.end(key) builder.end(key_to_use)
builder.end("metadata") builder.end("metadata")
## End Metadata Block ## End Metadata Block
@ -950,7 +969,7 @@ class XmlMaterialProfile(InstanceContainer):
machine_compatibility = cls._parseCompatibleValue(entry.text) machine_compatibility = cls._parseCompatibleValue(entry.text)
for identifier in machine.iterfind("./um:machine_identifier", cls.__namespaces): for identifier in machine.iterfind("./um:machine_identifier", cls.__namespaces):
machine_id_list = product_id_map.get(identifier.get("product"), []) machine_id_list = product_id_map.get(identifier.get("product", ""), [])
if not machine_id_list: if not machine_id_list:
machine_id_list = cls.getPossibleDefinitionIDsFromName(identifier.get("product")) machine_id_list = cls.getPossibleDefinitionIDsFromName(identifier.get("product"))
@ -982,7 +1001,7 @@ class XmlMaterialProfile(InstanceContainer):
result_metadata.append(new_material_metadata) result_metadata.append(new_material_metadata)
buildplates = machine.iterfind("./um:buildplate", cls.__namespaces) buildplates = machine.iterfind("./um:buildplate", cls.__namespaces)
buildplate_map = {} # type: Dict[str, Dict[str, bool]] buildplate_map = {} # type: Dict[str, Dict[str, bool]]
buildplate_map["buildplate_compatible"] = {} buildplate_map["buildplate_compatible"] = {}
buildplate_map["buildplate_recommended"] = {} buildplate_map["buildplate_recommended"] = {}
for buildplate in buildplates: for buildplate in buildplates:
@ -1167,6 +1186,8 @@ class XmlMaterialProfile(InstanceContainer):
def __str__(self): def __str__(self):
return "<XmlMaterialProfile '{my_id}' ('{name}') from base file '{base_file}'>".format(my_id = self.getId(), name = self.getName(), base_file = self.getMetaDataEntry("base_file")) return "<XmlMaterialProfile '{my_id}' ('{name}') from base file '{base_file}'>".format(my_id = self.getId(), name = self.getName(), base_file = self.getMetaDataEntry("base_file"))
_metadata_tags_that_have_cura_namespace = {"pva_compatible", "breakaway_compatible"}
# Map XML file setting names to internal names # Map XML file setting names to internal names
__material_settings_setting_map = { __material_settings_setting_map = {
"print temperature": "default_material_print_temperature", "print temperature": "default_material_print_temperature",
@ -1180,6 +1201,13 @@ class XmlMaterialProfile(InstanceContainer):
"surface energy": "material_surface_energy", "surface energy": "material_surface_energy",
"shrinkage percentage": "material_shrinkage_percentage", "shrinkage percentage": "material_shrinkage_percentage",
"build volume temperature": "build_volume_temperature", "build volume temperature": "build_volume_temperature",
"anti ooze retract position": "material_anti_ooze_retracted_position",
"anti ooze retract speed": "material_anti_ooze_retraction_speed",
"break preparation position": "material_break_preparation_retracted_position",
"break preparation speed": "material_break_preparation_speed",
"break position": "material_break_retracted_position",
"break speed": "material_break_speed",
"break temperature": "material_break_temperature"
} }
__unmapped_settings = [ __unmapped_settings = [
"hardware compatible", "hardware compatible",

View file

@ -764,6 +764,23 @@
} }
} }
}, },
"VersionUpgrade41to42": {
"package_info": {
"package_id": "VersionUpgrade41to42",
"package_type": "plugin",
"display_name": "Version Upgrade 4.1 to 4.2",
"description": "Upgrades configurations from Cura 4.1 to Cura 4.2.",
"package_version": "1.0.0",
"sdk_version": "6.0.0",
"website": "https://ultimaker.com",
"author": {
"author_id": "UltimakerPackages",
"display_name": "Ultimaker B.V.",
"email": "plugins@ultimaker.com",
"website": "https://ultimaker.com"
}
}
},
"X3DReader": { "X3DReader": {
"package_info": { "package_info": {
"package_id": "X3DReader", "package_id": "X3DReader",

Some files were not shown because too many files have changed in this diff Show more