From 51ebb351ebef0577f7b110679c3a0db0a822bec0 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 1 May 2018 12:35:02 +0200 Subject: [PATCH 1/9] Add some missing units to machine settings --- resources/definitions/fdmprinter.def.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 1ec210b99e..d85e06ffd9 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -227,6 +227,7 @@ { "label": "Outer nozzle diameter", "description": "The outer diameter of the tip of the nozzle.", + "unit": "mm", "default_value": 1, "type": "float", "settable_per_mesh": false, @@ -238,6 +239,7 @@ { "label": "Nozzle length", "description": "The height difference between the tip of the nozzle and the lowest part of the print head.", + "unit": "mm", "default_value": 3, "type": "float", "settable_per_mesh": false, @@ -261,6 +263,7 @@ { "label": "Heat zone length", "description": "The distance from the tip of the nozzle in which heat from the nozzle is transferred to the filament.", + "unit": "mm", "default_value": 16, "type": "float", "settable_per_mesh": false, @@ -271,6 +274,7 @@ { "label": "Filament Park Distance", "description": "The distance from the tip of the nozzle where to park the filament when an extruder is no longer used.", + "unit": "mm", "default_value": 16, "value": "machine_heat_zone_length", "type": "float", From 8c4dc1cc2b5d7cf3b18c311da81b11df444a0153 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 4 May 2018 14:59:59 +0200 Subject: [PATCH 2/9] CURA-5264 Don't need the if statement since the hardware-typeid is the right value to look at and it is in the firmware api. --- plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py index 2add388db6..74a4b044ff 100644 --- a/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py @@ -189,14 +189,10 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): b"name": system_info["name"].encode("utf-8"), b"address": address.encode("utf-8"), b"firmware_version": system_info["firmware"].encode("utf-8"), - b"manual": b"true" + b"manual": b"true", + b"machine": str(system_info['hardware']["typeid"]).encode("utf-8") } - if "hardware" in system_info and 'typeid' in system_info["hardware"]: - properties[b"machine"] = str(system_info['hardware']["typeid"]).encode("utf-8") - else: - properties[b"machine"] = system_info["variant"].encode("utf-8") - if has_cluster_capable_firmware: # Cluster needs an additional request, before it's completed. properties[b"incomplete"] = b"true" From 2283bb530debdcbe6ac4c544f7920377c1cb01dc Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 4 May 2018 15:49:37 +0200 Subject: [PATCH 3/9] CURA-4644 Fix unselectable item in the Toolbox --- plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml index 12578d15f6..3dc36db365 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml @@ -11,7 +11,7 @@ Column { // HACK: GridLayouts don't render to the correct height with odd numbers of // items, so if odd, add some extra space. - height: grid.model.items.length % 2 == 0 ? childrenRect.height : childrenRect.height + UM.Theme.getSize("toolbox_thumbnail_small").height + height: childrenRect.height width: parent.width spacing: UM.Theme.getSize("default_margin").height Label @@ -36,6 +36,7 @@ Column delegate: ToolboxDownloadsGridTile { Layout.preferredWidth: (grid.width - (grid.columns - 1) * grid.columnSpacing) / grid.columns + Layout.preferredHeight: UM.Theme.getSize("toolbox_thumbnail_small").height } } } From ffd1c5cc09e988f098060e97db551230edd2d1a8 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 4 May 2018 15:49:34 +0200 Subject: [PATCH 4/9] Run Mypy as normal automated test This tests all code for good style. Contributes to issue CURA-5330. --- cmake/CuraTests.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/CuraTests.cmake b/cmake/CuraTests.cmake index ffe4616bf3..801f054bc3 100644 --- a/cmake/CuraTests.cmake +++ b/cmake/CuraTests.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. enable_testing() @@ -53,3 +53,9 @@ foreach(_plugin ${_plugins}) cura_add_test(NAME pytest-${_plugin_name} DIRECTORY ${_plugin_directory} PYTHONPATH "${_plugin_directory}|${CMAKE_SOURCE_DIR}|${URANIUM_DIR}") endif() endforeach() + +#Add code style test. +add_test( + NAME "code-style" + COMMAND ${PYTHON_EXECUTABLE} run_mypy.py WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} +) \ No newline at end of file From 651f2ffbc929a9984d2f1cc24a052f83444d27f1 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 4 May 2018 15:50:05 +0200 Subject: [PATCH 5/9] Return proper exit value if test failed Return 1 then. Contributes to issue CURA-5330. --- run_mypy.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/run_mypy.py b/run_mypy.py index 88adea8db9..a72c555b8a 100644 --- a/run_mypy.py +++ b/run_mypy.py @@ -46,14 +46,9 @@ def main(): print("------------- Checking module {mod}".format(**locals())) result = subprocess.run([sys.executable, mypyModule, "-p", mod]) if result.returncode != 0: - print(""" - Module {mod} failed checking. :( - """.format(**locals())) - break + print("\nModule {mod} failed checking. :(".format(**locals())) + return 1 else: - print(""" - - Done checking. All is good. - """) + print("\n\nDone checking. All is good.") return 0 sys.exit(main()) From 551cfa9d719d921c03d8afb7daf584b6973db859 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 4 May 2018 15:53:51 +0200 Subject: [PATCH 6/9] Ignore Mypy cache Don't want to commit that accidentally after running tests. Contributes to issue CURA-5330. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c0cb27efe0..d991fedb73 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ CuraEngine.exe LC_MESSAGES .cache *.qmlc +.mypy_cache #MacOS .DS_Store From 58289a7b45b2654b7b0b128f3ca4b1ed5ffa9e9e Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 4 May 2018 17:28:39 +0200 Subject: [PATCH 7/9] Remove useful comment --- plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml index 3dc36db365..5b9697eda2 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGrid.qml @@ -9,8 +9,6 @@ import UM 1.1 as UM Column { - // HACK: GridLayouts don't render to the correct height with odd numbers of - // items, so if odd, add some extra space. height: childrenRect.height width: parent.width spacing: UM.Theme.getSize("default_margin").height From 00d8427e423b073a10d31e5cc3037dd0978d1696 Mon Sep 17 00:00:00 2001 From: Jack Ha Date: Mon, 7 May 2018 10:30:45 +0200 Subject: [PATCH 8/9] Add sanity check for GlobalStack CURA-5045 --- cura/Settings/ExtruderManager.py | 3 ++- cura/Settings/GlobalStack.py | 17 +++++++++++++++++ cura/Settings/MachineManager.py | 7 +++++-- .../MachineSettingsAction.py | 2 -- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index c2fe929957..51e7e81fef 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -402,7 +402,8 @@ class ExtruderManager(QObject): # Register the extruder trains by position for extruder_train in extruder_trains: - self._extruder_trains[global_stack_id][extruder_train.getMetaDataEntry("position")] = extruder_train + extruder_position = extruder_train.getMetaDataEntry("position") + self._extruder_trains[global_stack_id][extruder_position] = extruder_train # regardless of what the next stack is, we have to set it again, because of signal routing. ??? extruder_train.setParent(global_stack) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index 5d8a4505a5..cea59bcb70 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -153,6 +153,23 @@ class GlobalStack(CuraContainerStack): return True + ## Perform some sanity checks on the global stack + # Sanity check for extruders; they must have positions 0 and up to machine_extruder_count - 1 + def isValid(self): + container_registry = ContainerRegistry.getInstance() + extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = self.getId()) + + machine_extruder_count = self.getProperty("machine_extruder_count", "value") + extruder_check_position = set() + for extruder_train in extruder_trains: + extruder_position = extruder_train.getMetaDataEntry("position") + extruder_check_position.add(extruder_position) + + for check_position in range(machine_extruder_count): + if str(check_position) not in extruder_check_position: + return False + return True + ## private: global_stack_mime = MimeType( diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 14f4f5fc33..c2b1e6dc5f 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -6,6 +6,7 @@ import time #Type hinting. from typing import List, Dict, TYPE_CHECKING, Optional +from UM.ConfigurationErrorMessage import ConfigurationErrorMessage from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Signal import Signal @@ -165,8 +166,6 @@ class MachineManager(QObject): if active_machine_id != "" and ContainerRegistry.getInstance().findContainerStacksMetadata(id = active_machine_id): # An active machine was saved, so restore it. self.setActiveMachine(active_machine_id) - # Make sure _active_container_stack is properly initiated - ExtruderManager.getInstance().setActiveExtruderIndex(0) def _onOutputDevicesChanged(self) -> None: self._printer_output_devices = [] @@ -357,6 +356,10 @@ class MachineManager(QObject): return global_stack = containers[0] + if not global_stack.isValid(): + # Mark global stack as invalid + ConfigurationErrorMessage.getInstance().addFaultyContainers(global_stack.getId()) + return # We're done here ExtruderManager.getInstance().setActiveExtruderIndex(0) # Switch to first extruder self._global_container_stack = global_stack Application.getInstance().setGlobalContainerStack(global_stack) diff --git a/plugins/MachineSettingsAction/MachineSettingsAction.py b/plugins/MachineSettingsAction/MachineSettingsAction.py index ded59bf934..7d5b317475 100755 --- a/plugins/MachineSettingsAction/MachineSettingsAction.py +++ b/plugins/MachineSettingsAction/MachineSettingsAction.py @@ -56,8 +56,6 @@ class MachineSettingsAction(MachineAction): if self._isEmptyDefinitionChanges(definition_changes_id): return - self._container_registry.removeContainer(definition_changes_id) - def _reset(self): if not self._global_container_stack: return From b5764237473d8a18e416d330536423f901f83c5f Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 7 May 2018 11:49:30 +0200 Subject: [PATCH 9/9] Adapt ovewritten method signature --- cura/Settings/ExtruderStack.py | 2 +- cura/Settings/GlobalStack.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/Settings/ExtruderStack.py b/cura/Settings/ExtruderStack.py index 8dcaaf302e..5e944b401f 100644 --- a/cura/Settings/ExtruderStack.py +++ b/cura/Settings/ExtruderStack.py @@ -38,7 +38,7 @@ class ExtruderStack(CuraContainerStack): # # This will set the next stack and ensure that we register this stack as an extruder. @override(ContainerStack) - def setNextStack(self, stack: CuraContainerStack) -> None: + def setNextStack(self, stack: CuraContainerStack, connect_signals: bool = True) -> None: super().setNextStack(stack) stack.addExtruder(self) self.addMetaDataEntry("machine", stack.id) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index 5d8a4505a5..2e10863a81 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -125,7 +125,7 @@ class GlobalStack(CuraContainerStack): # # This will simply raise an exception since the Global stack cannot have a next stack. @override(ContainerStack) - def setNextStack(self, next_stack: ContainerStack) -> None: + def setNextStack(self, stack: CuraContainerStack, connect_signals: bool = True) -> None: raise Exceptions.InvalidOperationError("Global stack cannot have a next stack!") # protected: