From 633d14d92585e67749b736b0f400af3d1066472d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 28 Apr 2016 17:21:09 +0200 Subject: [PATCH 001/112] Added first stubs of MachineActions CURA-1385 --- cura/MachineAction.py | 8 ++++++ cura/MachineActionManager.py | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 cura/MachineAction.py create mode 100644 cura/MachineActionManager.py diff --git a/cura/MachineAction.py b/cura/MachineAction.py new file mode 100644 index 0000000000..6c2e4db32c --- /dev/null +++ b/cura/MachineAction.py @@ -0,0 +1,8 @@ +from PyQt5.QtCore import QObject +from UM.PluginObject import PluginObject + + +class MachineAction(QObject, PluginObject): + def __init__(self, key, label = ""): + self._key = key + self._label = label diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py new file mode 100644 index 0000000000..b8d1c4f9b2 --- /dev/null +++ b/cura/MachineActionManager.py @@ -0,0 +1,53 @@ +from UM.Logger import Logger + + +class MachineActionManager: + def __init__(self): + ## Dict of all known machine actions + self._machine_actions = {} + + ## Dict of all required actions by machine reference. + self._required_actions = {} + + ## Dict of all supported actions by machine reference + self._supported_actions = {} + + ## Dict of all actions that need to be done when first added by machine reference. + self._first_start_actions = {} + + ## Add a required action + def addRequiredAction(self, machine, action_key): + if action_key in self._machine_actions: + if machine in self._required_actions: + self._required_actions[machine].append(action_key) + else: + self._required_actions[machine] = set(action_key) + else: + # Todo: define specific Exception types (instead of general type) + raise Exception("Action %s, which is required for %s is not known." % (action_key, machine.getKey())) + + ## Add a (unique) MachineAction + # if the Key of the action is not unique, an exception is raised. + def addMachineAction(self, action): + if action.getKey() not in self._machine_action: + self._machine_action[action.getKey()] = action + else: + # Todo: define specific Exception types (instead of general type) + raise Exception("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey()) + + ## Remove Machine action from manager + # \param action to remove + def removeMachineAction(self, action): + try: + del self._machine_actions[action.getKey()] + except KeyError: + Logger.log("w", "Trying to remove MachineAction (%s) that was already removed", action.getKey()) + + ## Get MachineAction by key + # \param key String of key to select + # \return Machine action if found, None otherwise + def getMachineAction(self, key): + if key in self._machine_actions: + return self._machine_actions[key] + else: + return None \ No newline at end of file From 978536162cc80f552efc704c8f1ae0d30996b5d0 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 28 Apr 2016 17:30:14 +0200 Subject: [PATCH 002/112] Save reference to the action instead of key CURA-1385 --- cura/MachineActionManager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index b8d1c4f9b2..e3cdb690dd 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -15,13 +15,14 @@ class MachineActionManager: ## Dict of all actions that need to be done when first added by machine reference. self._first_start_actions = {} - ## Add a required action + ## Add a required action to a machine + # Raises an exception when the action is not recognised. def addRequiredAction(self, machine, action_key): if action_key in self._machine_actions: if machine in self._required_actions: - self._required_actions[machine].append(action_key) + self._required_actions[machine].append(self._machine_actions[action_key]) else: - self._required_actions[machine] = set(action_key) + self._required_actions[machine] = set(self._machine_actions[action_key]) else: # Todo: define specific Exception types (instead of general type) raise Exception("Action %s, which is required for %s is not known." % (action_key, machine.getKey())) From be7a8ca9b250f392cd49ff7cdadc9388c9e9d237 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 28 Apr 2016 17:35:40 +0200 Subject: [PATCH 003/112] Added other add action functions CURA-1385 --- cura/MachineActionManager.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index e3cdb690dd..fed798181b 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -27,6 +27,26 @@ class MachineActionManager: # Todo: define specific Exception types (instead of general type) raise Exception("Action %s, which is required for %s is not known." % (action_key, machine.getKey())) + ## Add a supported action to a machine. + def addSupportedAction(self, machine, action_key): + if action_key in self._machine_actions: + if machine in self._supported_actions: + self._supported_actions[machine].append(self._machine_actions[action_key]) + else: + self._supported_actions[machine] = set(self._machine_actions[action_key]) + else: + Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine.getKey()) + + ## Add an action to the first start list of a machine. + def addFirstStartAction(self, machine, action_key, index = None): + if action_key in self._machine_actions: + if machine in self._supported_actions and index is not None: + self._supported_actions[machine].insert(index, self._machine_actions[action_key]) + else: + self._supported_actions[machine] = [self._machine_actions[action_key]] + else: + Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine.getKey()) + ## Add a (unique) MachineAction # if the Key of the action is not unique, an exception is raised. def addMachineAction(self, action): From 958918e03349fa52d7e9a60370002227f22011e5 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 10:21:27 +0200 Subject: [PATCH 004/112] Added copyright notice CURA-1385 --- cura/MachineAction.py | 3 +++ cura/MachineActionManager.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/cura/MachineAction.py b/cura/MachineAction.py index 6c2e4db32c..c6ce9d0083 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -1,3 +1,6 @@ +# Copyright (c) 2016 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. + from PyQt5.QtCore import QObject from UM.PluginObject import PluginObject diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index fed798181b..ade4ee2fe7 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -1,3 +1,5 @@ +# Copyright (c) 2016 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. from UM.Logger import Logger From 5a1af3b1eae50d3966cf5f5f2f4052f6500c3ac9 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 11:11:25 +0200 Subject: [PATCH 005/112] Added getters for required & supported actions CURA-1385 --- cura/MachineActionManager.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index ade4ee2fe7..520fb94d1e 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -58,6 +58,24 @@ class MachineActionManager: # Todo: define specific Exception types (instead of general type) raise Exception("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey()) + ## Get all actions supported by given machine + # \param machine The machine you want the supported actions of + # \returns set of supported actions. + def getSupportedActions(self, machine): + if machine in self._supported_actions: + return self._supported_actions[machine] + else: + return set() + + ## Get all actions required by given machine + # \param machine The machine you want the required actions of + # \returns set of required actions. + def getRequiredActions(self, machine): + if machine in self._required_actions: + return self._required_actions[machine] + else: + return set() + ## Remove Machine action from manager # \param action to remove def removeMachineAction(self, action): From ae0e05182b3eea4271c1127962fff5925e83f545 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 11:12:22 +0200 Subject: [PATCH 006/112] First start actions are now added to correct list CURA-1385 --- cura/MachineActionManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index 520fb94d1e..ff57a42803 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -43,9 +43,9 @@ class MachineActionManager: def addFirstStartAction(self, machine, action_key, index = None): if action_key in self._machine_actions: if machine in self._supported_actions and index is not None: - self._supported_actions[machine].insert(index, self._machine_actions[action_key]) + self._first_start_actions[machine].insert(index, self._machine_actions[action_key]) else: - self._supported_actions[machine] = [self._machine_actions[action_key]] + self._first_start_actions[machine] = [self._machine_actions[action_key]] else: Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine.getKey()) From 46ff3f44089ea30c759133c4b563e5864c34241c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 11:32:33 +0200 Subject: [PATCH 007/112] Added unit test stub --- CMakeLists.txt | 6 ++++++ pytest.ini | 4 ++++ tests/TestMachineAction.py | 1 + 3 files changed, 11 insertions(+) create mode 100644 pytest.ini create mode 100644 tests/TestMachineAction.py diff --git a/CMakeLists.txt b/CMakeLists.txt index dc9f37c76e..ad2315070c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,12 @@ include(GNUInstallDirs) set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY "The location of the scripts directory of the Uranium repository") +# Tests +# Note that we use exit 0 here to not mark the build as a failure on test failure +add_custom_target(tests) +add_custom_command(TARGET tests POST_BUILD COMMAND "PYTHONPATH=${CMAKE_SOURCE_DIR}" ${PYTHON_EXECUTABLE} -m pytest -r a --junitxml=${CMAKE_BINARY_DIR}/junit.xml ${CMAKE_SOURCE_DIR} || exit 0) + + set(CURA_VERSION "master" CACHE STRING "Version name of Cura") configure_file(cura/CuraVersion.py.in CuraVersion.py @ONLY) diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000000..de6e8797fb --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +testpaths = tests +python_files = Test*.py +python_classes = Test diff --git a/tests/TestMachineAction.py b/tests/TestMachineAction.py new file mode 100644 index 0000000000..fe9b676d23 --- /dev/null +++ b/tests/TestMachineAction.py @@ -0,0 +1 @@ +#Todo: Write tests \ No newline at end of file From 06dfb7360242fb0523c975f8d728f9ef245560f5 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 11:36:06 +0200 Subject: [PATCH 008/112] Exceptions are no longer general typed CURA-1385 --- cura/MachineActionManager.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index ff57a42803..1975ba35bc 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -3,6 +3,16 @@ from UM.Logger import Logger +## Raised when trying to add an unknown machine action as a required action +class UnknownMachineAction(Exception): + pass + + +## Raised when trying to add a machine action that does not have an unique key. +class NotUniqueMachineAction(Exception): + pass + + class MachineActionManager: def __init__(self): ## Dict of all known machine actions @@ -26,8 +36,7 @@ class MachineActionManager: else: self._required_actions[machine] = set(self._machine_actions[action_key]) else: - # Todo: define specific Exception types (instead of general type) - raise Exception("Action %s, which is required for %s is not known." % (action_key, machine.getKey())) + raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine.getKey())) ## Add a supported action to a machine. def addSupportedAction(self, machine, action_key): @@ -55,8 +64,7 @@ class MachineActionManager: if action.getKey() not in self._machine_action: self._machine_action[action.getKey()] = action else: - # Todo: define specific Exception types (instead of general type) - raise Exception("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey()) + raise NotUniqueMachineAction("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey()) ## Get all actions supported by given machine # \param machine The machine you want the supported actions of From b899c65027793e691c2cac4354d47841ce97a280 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 12:01:24 +0200 Subject: [PATCH 009/112] Added getters for MachineAction CURA-1385 --- cura/MachineAction.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cura/MachineAction.py b/cura/MachineAction.py index c6ce9d0083..aaa3d9615d 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -7,5 +7,12 @@ from UM.PluginObject import PluginObject class MachineAction(QObject, PluginObject): def __init__(self, key, label = ""): + super().__init__() self._key = key self._label = label + + def getKey(self): + return self._key + + def getLabel(self): + return self._label From ea8015993954773b75e125836b66f71b883e3c58 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 12:02:24 +0200 Subject: [PATCH 010/112] Fixed silly typo CURA-1538 --- cura/MachineActionManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index 1975ba35bc..b7dc89ea8c 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -61,8 +61,8 @@ class MachineActionManager: ## Add a (unique) MachineAction # if the Key of the action is not unique, an exception is raised. def addMachineAction(self, action): - if action.getKey() not in self._machine_action: - self._machine_action[action.getKey()] = action + if action.getKey() not in self._machine_actions: + self._machine_actions[action.getKey()] = action else: raise NotUniqueMachineAction("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey()) From 69bd1a658685bbf3a84e033aeddc0fee1f24c6cf Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 12:10:36 +0200 Subject: [PATCH 011/112] Used {} instead of set This is because the one item I put in there is not considered iteratable. CURA-1385 --- cura/MachineActionManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index b7dc89ea8c..7bd22360e8 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -34,7 +34,7 @@ class MachineActionManager: if machine in self._required_actions: self._required_actions[machine].append(self._machine_actions[action_key]) else: - self._required_actions[machine] = set(self._machine_actions[action_key]) + self._required_actions[machine] = {self._machine_actions[action_key]} else: raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine.getKey())) @@ -44,7 +44,7 @@ class MachineActionManager: if machine in self._supported_actions: self._supported_actions[machine].append(self._machine_actions[action_key]) else: - self._supported_actions[machine] = set(self._machine_actions[action_key]) + self._supported_actions[machine] = {self._machine_actions[action_key]} else: Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine.getKey()) From 2b3c3b1b51ea3442c590edd8805af6b6b585ce5c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 12:14:05 +0200 Subject: [PATCH 012/112] Fixed python path for tests --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad2315070c..0ca4594947 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ set(URANIUM_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/../uranium/scripts" CACHE DIRECTORY # Tests # Note that we use exit 0 here to not mark the build as a failure on test failure add_custom_target(tests) -add_custom_command(TARGET tests POST_BUILD COMMAND "PYTHONPATH=${CMAKE_SOURCE_DIR}" ${PYTHON_EXECUTABLE} -m pytest -r a --junitxml=${CMAKE_BINARY_DIR}/junit.xml ${CMAKE_SOURCE_DIR} || exit 0) +add_custom_command(TARGET tests POST_BUILD COMMAND "PYTHONPATH=${CMAKE_SOURCE_DIR}/../Uranium/:${CMAKE_SOURCE_DIR}" ${PYTHON_EXECUTABLE} -m pytest -r a --junitxml=${CMAKE_BINARY_DIR}/junit.xml ${CMAKE_SOURCE_DIR} || exit 0) set(CURA_VERSION "master" CACHE STRING "Version name of Cura") From b1263e8d3348dc3b9a578ec3accd3e1a20299e23 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 12:14:15 +0200 Subject: [PATCH 013/112] Basic unit testing CURA-1385 --- tests/TestMachineAction.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/tests/TestMachineAction.py b/tests/TestMachineAction.py index fe9b676d23..2c3e7e95a6 100644 --- a/tests/TestMachineAction.py +++ b/tests/TestMachineAction.py @@ -1 +1,37 @@ -#Todo: Write tests \ No newline at end of file +#Todo: Write tests + +import pytest + +from cura.MachineAction import MachineAction +from cura.MachineActionManager import MachineActionManager, NotUniqueMachineAction + +class Machine: + def __init__(self, key = ""): + self._key = key + + def getKey(self): + return self._key + + +def test_addMachineAction(): + + machine_manager = MachineActionManager() + + test_action = MachineAction(key = "test") + test_machine = Machine("test_machine") + machine_manager.addMachineAction(test_action) + + assert machine_manager.getMachineAction("test") == test_action + + # Adding the same machine action is not allowed. + with pytest.raises(NotUniqueMachineAction): + machine_manager.addMachineAction(test_action) + + # Check if adding a supported action works. + machine_manager.addSupportedAction(test_machine, "test") + assert machine_manager.getSupportedActions(test_machine) == {test_action} + + # Check that adding a unknown action doesn't change anything. + machine_manager.addSupportedAction(test_machine, "key_that_doesnt_exist") + assert machine_manager.getSupportedActions(test_machine) == {test_action} + From 8cd0933b160b7df5938096f9d0e354c252f0331b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 12:23:05 +0200 Subject: [PATCH 014/112] Fixed issue with sets not being updated CURA-1385 --- cura/MachineActionManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index 7bd22360e8..d7a0478f37 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -32,7 +32,7 @@ class MachineActionManager: def addRequiredAction(self, machine, action_key): if action_key in self._machine_actions: if machine in self._required_actions: - self._required_actions[machine].append(self._machine_actions[action_key]) + self._required_actions[machine] |= {self._machine_actions[action_key]} else: self._required_actions[machine] = {self._machine_actions[action_key]} else: @@ -42,7 +42,7 @@ class MachineActionManager: def addSupportedAction(self, machine, action_key): if action_key in self._machine_actions: if machine in self._supported_actions: - self._supported_actions[machine].append(self._machine_actions[action_key]) + self._supported_actions[machine] |= {self._machine_actions[action_key]} else: self._supported_actions[machine] = {self._machine_actions[action_key]} else: From 9896cc181796331852e87babffb6a76d452287c3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 12:24:23 +0200 Subject: [PATCH 015/112] Added more tests to unit test CURA-1385 --- tests/TestMachineAction.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tests/TestMachineAction.py b/tests/TestMachineAction.py index 2c3e7e95a6..b6f041dff8 100644 --- a/tests/TestMachineAction.py +++ b/tests/TestMachineAction.py @@ -3,7 +3,7 @@ import pytest from cura.MachineAction import MachineAction -from cura.MachineActionManager import MachineActionManager, NotUniqueMachineAction +from cura.MachineActionManager import MachineActionManager, NotUniqueMachineAction, UnknownMachineAction class Machine: def __init__(self, key = ""): @@ -17,21 +17,46 @@ def test_addMachineAction(): machine_manager = MachineActionManager() - test_action = MachineAction(key = "test") + test_action = MachineAction(key = "test_action") + test_action_2 = MachineAction(key = "test_action_2") test_machine = Machine("test_machine") machine_manager.addMachineAction(test_action) + machine_manager.addMachineAction(test_action_2) - assert machine_manager.getMachineAction("test") == test_action + assert machine_manager.getMachineAction("test_action") == test_action + assert machine_manager.getMachineAction("key_that_doesnt_exist") is None # Adding the same machine action is not allowed. with pytest.raises(NotUniqueMachineAction): machine_manager.addMachineAction(test_action) + # Check that the machine has no supported actions yet. + assert machine_manager.getSupportedActions(test_machine) == set() + # Check if adding a supported action works. - machine_manager.addSupportedAction(test_machine, "test") + machine_manager.addSupportedAction(test_machine, "test_action") assert machine_manager.getSupportedActions(test_machine) == {test_action} # Check that adding a unknown action doesn't change anything. machine_manager.addSupportedAction(test_machine, "key_that_doesnt_exist") assert machine_manager.getSupportedActions(test_machine) == {test_action} + # Check if adding multiple supported actions works. + machine_manager.addSupportedAction(test_machine, "test_action_2") + assert machine_manager.getSupportedActions(test_machine) == {test_action, test_action_2} + + # Check that the machine has no required actions yet. + assert machine_manager.getRequiredActions(test_machine) == set() + + ## Ensure that only known actions can be added. + with pytest.raises(UnknownMachineAction): + machine_manager.addRequiredAction(test_machine, "key_that_doesnt_exist") + + ## Check if adding single required action works + machine_manager.addRequiredAction(test_machine, "test_action") + assert machine_manager.getRequiredActions(test_machine) == {test_action} + + # Check if adding multiple required actions works. + machine_manager.addRequiredAction(test_machine, "test_action_2") + assert machine_manager.getRequiredActions(test_machine) == {test_action, test_action_2} + From 32143ced4401d87a7326ef7a0ce24fe1229d9fdc Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 13:15:26 +0200 Subject: [PATCH 016/112] Fixed firstStart actions CURA-1385 --- cura/MachineActionManager.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index d7a0478f37..be94d1696c 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -51,8 +51,11 @@ class MachineActionManager: ## Add an action to the first start list of a machine. def addFirstStartAction(self, machine, action_key, index = None): if action_key in self._machine_actions: - if machine in self._supported_actions and index is not None: - self._first_start_actions[machine].insert(index, self._machine_actions[action_key]) + if machine in self._first_start_actions: + if index is not None: + self._first_start_actions[machine].insert(index, self._machine_actions[action_key]) + else: + self._first_start_actions[machine].append(self._machine_actions[action_key]) else: self._first_start_actions[machine] = [self._machine_actions[action_key]] else: @@ -84,6 +87,17 @@ class MachineActionManager: else: return set() + ## Get all actions that need to be perfomed upon first start of a given machine. + # Note that contrary to required / supported actions a list is returned (as it could be required to run the same + # action multiple times). + # \param machine The machine you want the first start actions of + # \returns List of actions. + def getFirstStartActions(self, machine): + if machine in self._first_start_actions: + return self._first_start_actions[machine] + else: + return [] + ## Remove Machine action from manager # \param action to remove def removeMachineAction(self, action): From 30182f295f753bb03d73db1eac9f82eaaa06f716 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 29 Apr 2016 13:19:07 +0200 Subject: [PATCH 017/112] Added tests for firstStart CURA-1385 --- tests/TestMachineAction.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/TestMachineAction.py b/tests/TestMachineAction.py index b6f041dff8..736f7015ac 100644 --- a/tests/TestMachineAction.py +++ b/tests/TestMachineAction.py @@ -12,7 +12,6 @@ class Machine: def getKey(self): return self._key - def test_addMachineAction(): machine_manager = MachineActionManager() @@ -60,3 +59,19 @@ def test_addMachineAction(): machine_manager.addRequiredAction(test_machine, "test_action_2") assert machine_manager.getRequiredActions(test_machine) == {test_action, test_action_2} + # Ensure that firstStart actions are empty by default. + assert machine_manager.getFirstStartActions(test_machine) == [] + + # Check if adding multiple (the same) actions to first start actions work. + machine_manager.addFirstStartAction(test_machine, "test_action") + machine_manager.addFirstStartAction(test_machine, "test_action") + assert machine_manager.getFirstStartActions(test_machine) == [test_action, test_action] + + # Check if inserting an action works + machine_manager.addFirstStartAction(test_machine, "test_action_2", index = 1) + assert machine_manager.getFirstStartActions(test_machine) == [test_action, test_action_2, test_action] + + # Check that adding a unknown action doesn't change anything. + machine_manager.addFirstStartAction(test_machine, "key_that_doesnt_exist", index = 1) + assert machine_manager.getFirstStartActions(test_machine) == [test_action, test_action_2, test_action] + From 7aefb671728f07616730bba71fd11e9e4577123b Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 10 May 2016 13:19:53 +0200 Subject: [PATCH 018/112] Make Vector an immutable class. Contributes to CURA-1504 --- cura/PlatformPhysics.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index 78f2b4938b..e2bca741a3 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -67,9 +67,9 @@ class PlatformPhysics: if not (node.getParent() and node.getParent().callDecoration("isGroup")): #If an object is grouped, don't move it down z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0 if bbox.bottom > 0: - move_vector.setY(-bbox.bottom + z_offset) + move_vector = move_vector.set(y=-bbox.bottom + z_offset) elif bbox.bottom < z_offset: - move_vector.setY((-bbox.bottom) - z_offset) + move_vector = move_vector.set(y=(-bbox.bottom) - z_offset) #if not Float.fuzzyCompare(bbox.bottom, 0.0): # pass#move_vector.setY(-bbox.bottom) @@ -125,8 +125,7 @@ class PlatformPhysics: if overlap is None: continue - move_vector.setX(overlap[0] * 1.1) - move_vector.setZ(overlap[1] * 1.1) + move_vector = move_vector.set(x=overlap[0] * 1.1, z=overlap[1] * 1.1) convex_hull = node.callDecoration("getConvexHull") if convex_hull: if not convex_hull.isValid(): From 43747f3f57aa4e0cc874cd372a7b72ed20794b31 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Thu, 12 May 2016 13:12:44 +0200 Subject: [PATCH 019/112] Fix up BuildVolume's override of the AABB. Contributes to CURA-1504 --- cura/BuildVolume.py | 6 +++++- cura/PlatformPhysics.py | 4 ---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index e700b8d7be..7072533ab9 100644 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -36,6 +36,7 @@ class BuildVolume(SceneNode): self._disallowed_area_mesh = None self.setCalculateBoundingBox(False) + self._volume_aabb = None self._active_profile = None self._active_instance = None @@ -144,7 +145,7 @@ class BuildVolume(SceneNode): else: self._disallowed_area_mesh = None - self._aabb = AxisAlignedBox(minimum = Vector(min_w, min_h - 1.0, min_d), maximum = Vector(max_w, max_h, max_d)) + self._volume_aabb = AxisAlignedBox(minimum = Vector(min_w, min_h - 1.0, min_d), maximum = Vector(max_w, max_h, max_d)) skirt_size = 0.0 @@ -162,6 +163,9 @@ class BuildVolume(SceneNode): Application.getInstance().getController().getScene()._maximum_bounds = scale_to_max_bounds + def getBoundingBox(self): + return self._volume_aabb + def _onActiveInstanceChanged(self): self._active_instance = Application.getInstance().getMachineManager().getActiveMachineInstance() diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index e2bca741a3..7b2a47eef5 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -27,7 +27,6 @@ class PlatformPhysics: self._controller.toolOperationStarted.connect(self._onToolOperationStarted) self._controller.toolOperationStopped.connect(self._onToolOperationStopped) self._build_volume = volume - self._enabled = True self._change_timer = QTimer() @@ -50,9 +49,6 @@ class PlatformPhysics: continue bbox = node.getBoundingBox() - if not bbox or not bbox.isValid(): - self._change_timer.start() - continue build_volume_bounding_box = copy.deepcopy(self._build_volume.getBoundingBox()) build_volume_bounding_box.setBottom(-9001) # Ignore intersections with the bottom From bac58ecc82968df88b43650f7c86f2d61098e953 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Thu, 12 May 2016 13:16:14 +0200 Subject: [PATCH 020/112] Prevent models from vibrating on the z axis due to fp errors, change the tolerance of the comparison. Contributes to CURA-1504 --- cura/PlatformPhysics.py | 2 +- cura/PlatformPhysicsOperation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index 7b2a47eef5..55cc3652e1 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -134,7 +134,7 @@ class PlatformPhysics: node._outside_buildarea = True - if move_vector != Vector(): + if not Vector.Null.equals(move_vector, epsilon=1e-5): op = PlatformPhysicsOperation.PlatformPhysicsOperation(node, move_vector) op.push() diff --git a/cura/PlatformPhysicsOperation.py b/cura/PlatformPhysicsOperation.py index 5d2089e8af..fa58e45d9c 100644 --- a/cura/PlatformPhysicsOperation.py +++ b/cura/PlatformPhysicsOperation.py @@ -28,4 +28,4 @@ class PlatformPhysicsOperation(Operation): return group def __repr__(self): - return "PlatformPhysicsOperation(t = {0})".format(self._position) + return "PlatformPhysicsOperation(new_position = {0})".format(self._new_position) From dfccbf636a1a27ec4efb4e4b30f476bc05559147 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Thu, 19 May 2016 15:10:31 +0200 Subject: [PATCH 021/112] Fixed up the ImageReader after the breaking changes else where. Contributes to CURA-1504 --- plugins/ImageReader/ImageReader.py | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/plugins/ImageReader/ImageReader.py b/plugins/ImageReader/ImageReader.py index 0d6c12b13d..9d70dde8e1 100644 --- a/plugins/ImageReader/ImageReader.py +++ b/plugins/ImageReader/ImageReader.py @@ -7,7 +7,7 @@ from PyQt5.QtGui import QImage, qRed, qGreen, qBlue from PyQt5.QtCore import Qt from UM.Mesh.MeshReader import MeshReader -from UM.Mesh.MeshData import MeshData +from UM.Mesh.MeshBuilder import MeshBuilder from UM.Scene.SceneNode import SceneNode from UM.Math.Vector import Vector from UM.Job import Job @@ -48,13 +48,9 @@ class ImageReader(MeshReader): return self._generateSceneNode(file_name, size, self._ui.peak_height, self._ui.base_height, self._ui.smoothing, 512, self._ui.image_color_invert) def _generateSceneNode(self, file_name, xz_size, peak_height, base_height, blur_iterations, max_size, image_color_invert): - mesh = None # TODO: @UnusedVariable - scene_node = None # TODO: @UnusedVariable - scene_node = SceneNode() - mesh = MeshData() - scene_node.setMeshData(mesh) + mesh = MeshBuilder() img = QImage(file_name) @@ -76,9 +72,9 @@ class ImageReader(MeshReader): scale_vector = Vector(xz_size, peak_height, xz_size) if width > height: - scale_vector.setZ(scale_vector.z * aspect) + scale_vector = scale_vector.set(z=scale_vector.z * aspect) elif height > width: - scale_vector.setX(scale_vector.x / aspect) + scale_vector = scale_vector.set(x=scale_vector.x / aspect) if width > max_size or height > max_size: scale_factor = max_size / width @@ -173,8 +169,8 @@ class ImageReader(MeshReader): geo_height = height_minus_one * texel_height # bottom - mesh.addFace(0, 0, 0, 0, 0, geo_height, geo_width, 0, geo_height) - mesh.addFace(geo_width, 0, geo_height, geo_width, 0, 0, 0, 0, 0) + mesh.addFaceByPoints(0, 0, 0, 0, 0, geo_height, geo_width, 0, geo_height) + mesh.addFaceByPoints(geo_width, 0, geo_height, geo_width, 0, 0, 0, 0, 0) # north and south walls for n in range(0, width_minus_one): @@ -187,11 +183,11 @@ class ImageReader(MeshReader): hs0 = height_data[height_minus_one, n] hs1 = height_data[height_minus_one, n + 1] - mesh.addFace(x, 0, 0, nx, 0, 0, nx, hn1, 0) - mesh.addFace(nx, hn1, 0, x, hn0, 0, x, 0, 0) + mesh.addFaceByPoints(x, 0, 0, nx, 0, 0, nx, hn1, 0) + mesh.addFaceByPoints(nx, hn1, 0, x, hn0, 0, x, 0, 0) - mesh.addFace(x, 0, geo_height, nx, 0, geo_height, nx, hs1, geo_height) - mesh.addFace(nx, hs1, geo_height, x, hs0, geo_height, x, 0, geo_height) + mesh.addFaceByPoints(x, 0, geo_height, nx, 0, geo_height, nx, hs1, geo_height) + mesh.addFaceByPoints(nx, hs1, geo_height, x, hs0, geo_height, x, 0, geo_height) # west and east walls for n in range(0, height_minus_one): @@ -204,12 +200,14 @@ class ImageReader(MeshReader): he0 = height_data[n, width_minus_one] he1 = height_data[n + 1, width_minus_one] - mesh.addFace(0, 0, y, 0, 0, ny, 0, hw1, ny) - mesh.addFace(0, hw1, ny, 0, hw0, y, 0, 0, y) + mesh.addFaceByPoints(0, 0, y, 0, 0, ny, 0, hw1, ny) + mesh.addFaceByPoints(0, hw1, ny, 0, hw0, y, 0, 0, y) - mesh.addFace(geo_width, 0, y, geo_width, 0, ny, geo_width, he1, ny) - mesh.addFace(geo_width, he1, ny, geo_width, he0, y, geo_width, 0, y) + mesh.addFaceByPoints(geo_width, 0, y, geo_width, 0, ny, geo_width, he1, ny) + mesh.addFaceByPoints(geo_width, he1, ny, geo_width, he0, y, geo_width, 0, y) mesh.calculateNormals(fast=True) + scene_node.setMeshData(mesh.build()) + return scene_node From a109396c0d3006b3c1b12175b5039df9a4a0ded4 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Thu, 19 May 2016 22:08:10 +0200 Subject: [PATCH 022/112] Update to handle the removal of MeshData.setCenterPosition and MeshData.setVertexUVCoordinates(). Contributes to CURA-1504 --- cura/BuildVolume.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index 7072533ab9..dd76095d9a 100644 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -113,10 +113,10 @@ class BuildVolume(SceneNode): Vector(max_w, min_h - 0.2, max_d), Vector(min_w, min_h - 0.2, max_d) ) - self._grid_mesh = mb.getData() for n in range(0, 6): - v = self._grid_mesh.getVertex(n) - self._grid_mesh.setVertexUVCoordinates(n, v[0], v[2]) + v = mb.getVertex(n) + mb.setVertexUVCoordinates(n, v[0], v[2]) + self._grid_mesh = mb.getData() disallowed_area_height = 0.1 disallowed_area_size = 0 From d1f68143a4ca346f6441832127cca26d6c8fbaad Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Sat, 21 May 2016 14:17:58 +0200 Subject: [PATCH 023/112] Adjustments to support immutable AxisAlignedBox. Contributes to CURA-1504 --- cura/CuraApplication.py | 4 ++-- cura/PlatformPhysics.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 9b113b7de8..72ff8aec8c 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -95,7 +95,7 @@ class CuraApplication(QtApplication): self._i18n_catalog = None self._previous_active_tool = None self._platform_activity = False - self._scene_boundingbox = AxisAlignedBox() + self._scene_boundingbox = AxisAlignedBox.Null self._job_name = None self._center_after_select = False self._camera_animation = None @@ -283,7 +283,7 @@ class CuraApplication(QtApplication): scene_boundingbox += node.getBoundingBox() if not scene_boundingbox: - scene_boundingbox = AxisAlignedBox() + scene_boundingbox = AxisAlignedBox.Null if repr(self._scene_boundingbox) != repr(scene_boundingbox): self._scene_boundingbox = scene_boundingbox diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index 55cc3652e1..57d8f4e0ba 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -50,8 +50,8 @@ class PlatformPhysics: bbox = node.getBoundingBox() - build_volume_bounding_box = copy.deepcopy(self._build_volume.getBoundingBox()) - build_volume_bounding_box.setBottom(-9001) # Ignore intersections with the bottom + # Ignore intersections with the bottom + build_volume_bounding_box = self._build_volume.getBoundingBox().set(bottom=-9001) node._outside_buildarea = False # Mark the node as outside the build volume if the bounding box test fails. From 0b858f38781847f79dc85181d27addf3e9365212 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Mon, 23 May 2016 09:49:31 +0200 Subject: [PATCH 024/112] Introduced a LayerDataBuilder. Made LayerData immutable just like its superclass. Fixed the layer view which broke. Contributes to CURA-1504 --- cura/LayerData.py | 61 +++------------- cura/LayerDataBuilder.py | 72 +++++++++++++++++++ .../ProcessSlicedLayersJob.py | 8 +-- plugins/LayerView/LayerView.py | 6 +- 4 files changed, 89 insertions(+), 58 deletions(-) create mode 100644 cura/LayerDataBuilder.py diff --git a/cura/LayerData.py b/cura/LayerData.py index 4aa7d1f4d4..ad5326373e 100644 --- a/cura/LayerData.py +++ b/cura/LayerData.py @@ -1,66 +1,25 @@ # Copyright (c) 2015 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -from .Layer import Layer -from .LayerPolygon import LayerPolygon from UM.Mesh.MeshData import MeshData -import numpy - - +## Class to holds the layer mesh and information about the layers. +# Immutable, use LayerDataBuilder to create one of these. class LayerData(MeshData): - def __init__(self): - super().__init__() - self._layers = {} - self._element_counts = {} - - def addLayer(self, layer): - if layer not in self._layers: - self._layers[layer] = Layer(layer) - - def addPolygon(self, layer, polygon_type, data, line_width): - if layer not in self._layers: - self.addLayer(layer) - - p = LayerPolygon(self, polygon_type, data, line_width) - self._layers[layer].polygons.append(p) + def __init__(self, vertices = None, normals = None, indices = None, colors = None, uvs = None, file_name = None, + center_position = None, layers=None, element_counts=None): + super().__init__(vertices=vertices, normals=normals, indices=indices, colors=colors, uvs=uvs, + file_name=file_name, center_position=center_position) + self._layers = layers + self._element_counts = element_counts def getLayer(self, layer): if layer in self._layers: return self._layers[layer] + else: + return None def getLayers(self): return self._layers def getElementCounts(self): return self._element_counts - - def setLayerHeight(self, layer, height): - if layer not in self._layers: - self.addLayer(layer) - - self._layers[layer].setHeight(height) - - def setLayerThickness(self, layer, thickness): - if layer not in self._layers: - self.addLayer(layer) - - self._layers[layer].setThickness(thickness) - - def build(self): - vertex_count = 0 - for layer, data in self._layers.items(): - vertex_count += data.vertexCount() - - vertices = numpy.empty((vertex_count, 3), numpy.float32) - colors = numpy.empty((vertex_count, 4), numpy.float32) - indices = numpy.empty((vertex_count, 2), numpy.int32) - - offset = 0 - for layer, data in self._layers.items(): - offset = data.build(offset, vertices, colors, indices) - self._element_counts[layer] = data.elementCount - - self.clear() - self.addVertices(vertices) - self.addColors(colors) - self.addIndices(indices.flatten()) diff --git a/cura/LayerDataBuilder.py b/cura/LayerDataBuilder.py new file mode 100644 index 0000000000..7e8e0e636b --- /dev/null +++ b/cura/LayerDataBuilder.py @@ -0,0 +1,72 @@ +# Copyright (c) 2015 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. + +from .Layer import Layer +from .LayerPolygon import LayerPolygon +from UM.Mesh.MeshBuilder import MeshBuilder +from .LayerData import LayerData + +import numpy + +## Builder class for constructing a LayerData object +class LayerDataBuilder(MeshBuilder): + def __init__(self): + super().__init__() + self._layers = {} + self._element_counts = {} + + def addLayer(self, layer): + if layer not in self._layers: + self._layers[layer] = Layer(layer) + + def addPolygon(self, layer, polygon_type, data, line_width): + if layer not in self._layers: + self.addLayer(layer) + + p = LayerPolygon(self, polygon_type, data, line_width) + self._layers[layer].polygons.append(p) + + def getLayer(self, layer): + if layer in self._layers: + return self._layers[layer] + + def getLayers(self): + return self._layers + + def getElementCounts(self): + return self._element_counts + + def setLayerHeight(self, layer, height): + if layer not in self._layers: + self.addLayer(layer) + + self._layers[layer].setHeight(height) + + def setLayerThickness(self, layer, thickness): + if layer not in self._layers: + self.addLayer(layer) + + self._layers[layer].setThickness(thickness) + + def build(self): + vertex_count = 0 + for layer, data in self._layers.items(): + vertex_count += data.vertexCount() + + vertices = numpy.empty((vertex_count, 3), numpy.float32) + colors = numpy.empty((vertex_count, 4), numpy.float32) + indices = numpy.empty((vertex_count, 2), numpy.int32) + + offset = 0 + for layer, data in self._layers.items(): + offset = data.build(offset, vertices, colors, indices) + self._element_counts[layer] = data.elementCount + + self.addVertices(vertices) + self.addColors(colors) + self.addIndices(indices.flatten()) + + return LayerData(vertices=self.getVertices(), normals=self.getNormals(), indices=self.getIndices(), + colors=self.getColors(), uvs=self.getUVCoordinates(), file_name=self.getFileName(), + center_position=self.getCenterPosition(), layers=self._layers, + element_counts=self._element_counts) diff --git a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py index 6a947866d3..cea4dedc9f 100644 --- a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py +++ b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py @@ -12,7 +12,7 @@ from UM.i18n import i18nCatalog from UM.Math.Vector import Vector -from cura import LayerData +from cura import LayerDataBuilder from cura import LayerDataDecorator import numpy @@ -65,7 +65,7 @@ class ProcessSlicedLayersJob(Job): settings = Application.getInstance().getMachineManager().getWorkingProfile() mesh = MeshData() - layer_data = LayerData.LayerData() + layer_data = LayerDataBuilder.LayerDataBuilder() layer_count = len(self._layers) # Find the minimum layer number @@ -117,7 +117,7 @@ class ProcessSlicedLayersJob(Job): self._progress.setProgress(progress) # We are done processing all the layers we got from the engine, now create a mesh out of the data - layer_data.build() + layer_mesh = layer_data.build() if self._abort_requested: if self._progress: @@ -126,7 +126,7 @@ class ProcessSlicedLayersJob(Job): # Add LayerDataDecorator to scene node to indicate that the node has layer data decorator = LayerDataDecorator.LayerDataDecorator() - decorator.setLayerData(layer_data) + decorator.setLayerData(layer_mesh) new_node.addDecorator(decorator) new_node.setMeshData(mesh) diff --git a/plugins/LayerView/LayerView.py b/plugins/LayerView/LayerView.py index a98fab5c8a..e024512579 100644 --- a/plugins/LayerView/LayerView.py +++ b/plugins/LayerView/LayerView.py @@ -8,7 +8,7 @@ from UM.Event import Event, KeyEvent from UM.Signal import Signal from UM.Scene.Selection import Selection from UM.Math.Color import Color -from UM.Mesh.MeshData import MeshData +from UM.Mesh.MeshBuilder import MeshBuilder from UM.Job import Job from UM.View.RenderBatch import RenderBatch @@ -228,7 +228,7 @@ class _CreateTopLayersJob(Job): if self._cancel or not layer_data: return - layer_mesh = MeshData() + layer_mesh = MeshBuilder() for i in range(self._solid_layers): layer_number = self._layer_number - i if layer_number < 0: @@ -263,7 +263,7 @@ class _CreateTopLayersJob(Job): if not jump_mesh or jump_mesh.getVertices() is None: jump_mesh = None - self.setResult({ "layers": layer_mesh, "jumps": jump_mesh }) + self.setResult({ "layers": layer_mesh.build(), "jumps": jump_mesh }) def cancel(self): self._cancel = True From d7127b800c24f85b7da9f9904d9f4e1eb74c7d97 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Mon, 23 May 2016 13:47:21 +0200 Subject: [PATCH 025/112] Finally, use the new convex hull code to compute the object 'shadow' and exclusion zones. Contributes to CURA-1504 --- cura/ConvexHullDecorator.py | 209 +++++++++++++++++++++++++----------- cura/ConvexHullJob.py | 62 ++++++++++- cura/ConvexHullNode.py | 11 +- cura/CuraApplication.py | 6 +- cura/PlatformPhysics.py | 13 +-- 5 files changed, 222 insertions(+), 79 deletions(-) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index b53737cc80..1d03c250e5 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -1,28 +1,20 @@ from UM.Scene.SceneNodeDecorator import SceneNodeDecorator from UM.Application import Application +from UM.Math.Polygon import Polygon +from UM.Logger import Logger +from . import ConvexHullNode + +import numpy ## The convex hull decorator is a scene node decorator that adds the convex hull functionality to a scene node. # If a scene node has a convex hull decorator, it will have a shadow in which other objects can not be printed. class ConvexHullDecorator(SceneNodeDecorator): - def __init__(self): + def __init__(self,): super().__init__() - self._convex_hull = None - - # In case of printing all at once this is the same as the convex hull. - # For one at the time this is the area without the head. - self._convex_hull_boundary = None - - # In case of printing all at once this is the same as the convex hull. - # For one at the time this is area with intersection of mirrored head - self._convex_hull_head = None - # In case of printing all at once this is the same as the convex hull. - # For one at the time this is area with intersection of full head - self._convex_hull_head_full = None - self._convex_hull_node = None - self._convex_hull_job = None + self._init2DConvexHullCache() self._profile = None Application.getInstance().getMachineManager().activeProfileChanged.connect(self._onActiveProfileChanged) @@ -31,59 +23,56 @@ class ConvexHullDecorator(SceneNodeDecorator): ## Force that a new (empty) object is created upon copy. def __deepcopy__(self, memo): - copy = ConvexHullDecorator() - return copy + return ConvexHullDecorator() - ## Get the unmodified convex hull of the node + ## Get the unmodified 2D projected convex hull of the node def getConvexHull(self): - return self._convex_hull + hull = self._compute2DConvexHull() + profile = Application.getInstance().getMachineManager().getWorkingProfile() + if profile: + if profile.getSettingValue("print_sequence") == "one_at_a_time" and not self._node.getParent().callDecoration("isGroup"): + hull = hull.getMinkowskiHull(Polygon(numpy.array(profile.getSettingValue("machine_head_polygon"), numpy.float32))) + return hull ## Get the convex hull of the node with the full head size def getConvexHullHeadFull(self): - if not self._convex_hull_head_full: - return self.getConvexHull() - return self._convex_hull_head_full + return self._compute2DConvexHeadFull() ## Get convex hull of the object + head size # In case of printing all at once this is the same as the convex hull. # For one at the time this is area with intersection of mirrored head def getConvexHullHead(self): - if not self._convex_hull_head: - return self.getConvexHull() - return self._convex_hull_head + profile = Application.getInstance().getMachineManager().getWorkingProfile() + if profile: + if profile.getSettingValue("print_sequence") == "one_at_a_time" and not self._node.getParent().callDecoration( + "isGroup"): + return self._compute2DConvexHeadMin() + return None ## Get convex hull of the node # In case of printing all at once this is the same as the convex hull. # For one at the time this is the area without the head. def getConvexHullBoundary(self): - if not self._convex_hull_boundary: - return self.getConvexHull() - return self._convex_hull_boundary - - def setConvexHullBoundary(self, hull): - self._convex_hull_boundary = hull + profile = Application.getInstance().getMachineManager().getWorkingProfile() + if profile: + if profile.getSettingValue("print_sequence") == "one_at_a_time" and not self._node.getParent().callDecoration( + "isGroup"): + # Printing one at a time and it's not an object in a group + return self._compute2DConvexHull() + return None - def setConvexHullHeadFull(self, hull): - self._convex_hull_head_full = hull + def recomputeConvexHull(self): + convex_hull = self.getConvexHull() + if self._convex_hull_node: + if self._convex_hull_node.getHull() == convex_hull: + Logger.log('d', 'ConvexHullDecorator not creating a new ConvexHullNode') + return + self._convex_hull_node.setParent(None) + Logger.log('d', 'ConvexHullDecorator creating ConvexHullNode') + hull_node = ConvexHullNode.ConvexHullNode(self._node, convex_hull, + Application.getInstance().getController().getScene().getRoot()) + self._convex_hull_node = hull_node - def setConvexHullHead(self, hull): - self._convex_hull_head = hull - - def setConvexHull(self, hull): - self._convex_hull = hull - - def getConvexHullJob(self): - return self._convex_hull_job - - def setConvexHullJob(self, job): - self._convex_hull_job = job - - def getConvexHullNode(self): - return self._convex_hull_node - - def setConvexHullNode(self, node): - self._convex_hull_node = node - def _onActiveProfileChanged(self): if self._profile: self._profile.settingValueChanged.disconnect(self._onSettingValueChanged) @@ -94,18 +83,118 @@ class ConvexHullDecorator(SceneNodeDecorator): self._profile.settingValueChanged.connect(self._onSettingValueChanged) def _onActiveMachineInstanceChanged(self): - if self._convex_hull_job: - self._convex_hull_job.cancel() - self.setConvexHull(None) if self._convex_hull_node: self._convex_hull_node.setParent(None) self._convex_hull_node = None def _onSettingValueChanged(self, setting): if setting == "print_sequence": - if self._convex_hull_job: - self._convex_hull_job.cancel() - self.setConvexHull(None) - if self._convex_hull_node: - self._convex_hull_node.setParent(None) - self._convex_hull_node = None + self.recomputeConvexHull() + + def _init2DConvexHullCache(self): + # Cache for the group code path in _compute2DConvexHull() + self._2d_convex_hull_group_child_polygon = None + self._2d_convex_hull_group_result = None + + # Cache for the mesh code path in _compute2DConvexHull() + self._2d_convex_hull_mesh = None + self._2d_convex_hull_mesh_world_transform = None + self._2d_convex_hull_mesh_result = None + + def _compute2DConvexHull(self): + if self._node.callDecoration("isGroup"): + points = numpy.zeros((0, 2), dtype=numpy.int32) + for child in self._node.getChildren(): + child_hull = child.callDecoration("_compute2DConvexHull") + if child_hull: + points = numpy.append(points, child_hull.getPoints(), axis = 0) + + if points.size < 3: + return None + child_polygon = Polygon(points) + + # Check the cache + if child_polygon == self._2d_convex_hull_group_child_polygon: + # Logger.log('d', 'Cache hit in _compute2DConvexHull group path') + return self._2d_convex_hull_group_result + + # First, calculate the normal convex hull around the points + convex_hull = child_polygon.getConvexHull() + + # Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull. + # This is done because of rounding errors. + rounded_hull = self._roundHull(convex_hull) + + # Store the result in the cache + self._2d_convex_hull_group_child_polygon = child_polygon + self._2d_convex_hull_group_result = rounded_hull + + return rounded_hull + + else: + if not self._node.getMeshData(): + return None + mesh = self._node.getMeshData() + world_transform = self._node.getWorldTransformation() + + # Check the cache + if mesh is self._2d_convex_hull_mesh and world_transform == self._2d_convex_hull_mesh_world_transform: + # Logger.log('d', 'Cache hit in _compute2DConvexHull mesh path') + return self._2d_convex_hull_mesh_result + + vertex_data = mesh.getConvexHullTransformedVertices(world_transform) + # Don't use data below 0. + # TODO; We need a better check for this as this gives poor results for meshes with long edges. + vertex_data = vertex_data[vertex_data[:,1] >= 0] + + # Round the vertex data to 1/10th of a mm, then remove all duplicate vertices + # This is done to greatly speed up further convex hull calculations as the convex hull + # becomes much less complex when dealing with highly detailed models. + vertex_data = numpy.round(vertex_data, 1) + + vertex_data = vertex_data[:, [0, 2]] # Drop the Y components to project to 2D. + + # Grab the set of unique points. + # + # This basically finds the unique rows in the array by treating them as opaque groups of bytes + # which are as long as the 2 float64s in each row, and giving this view to numpy.unique() to munch. + # See http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array + vertex_byte_view = numpy.ascontiguousarray(vertex_data).view( + numpy.dtype((numpy.void, vertex_data.dtype.itemsize * vertex_data.shape[1]))) + _, idx = numpy.unique(vertex_byte_view, return_index=True) + vertex_data = vertex_data[idx] # Select the unique rows by index. + + hull = Polygon(vertex_data) + + # First, calculate the normal convex hull around the points + convex_hull = hull.getConvexHull() + + # Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull. + # This is done because of rounding errors. + rounded_hull = convex_hull.getMinkowskiHull(Polygon(numpy.array([[-0.5, -0.5], [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]], numpy.float32))) + + # Store the result in the cache + self._2d_convex_hull_mesh = mesh + self._2d_convex_hull_mesh_world_transform = world_transform + self._2d_convex_hull_mesh_result = rounded_hull + + return rounded_hull + + def _getHeadAndFans(self): + profile = Application.getInstance().getMachineManager().getWorkingProfile() + return Polygon(numpy.array(profile.getSettingValue("machine_head_with_fans_polygon"), numpy.float32)) + + def _compute2DConvexHeadFull(self): + return self._compute2DConvexHull().getMinkowskiHull(self._getHeadAndFans()) + + def _compute2DConvexHeadMin(self): + headAndFans = self._getHeadAndFans() + mirrored = headAndFans.mirror([0, 0], [0, 1]).mirror([0, 0], [1, 0]) # Mirror horizontally & vertically. + head_and_fans = self._getHeadAndFans().intersectionConvexHulls(mirrored) + + # Min head hull is used for the push free + min_head_hull = self._compute2DConvexHull().getMinkowskiHull(head_and_fans) + return min_head_hull + + def _roundHull(self, convex_hull): + return convex_hull.getMinkowskiHull(Polygon(numpy.array([[-0.5, -0.5], [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]], numpy.float32))) diff --git a/cura/ConvexHullJob.py b/cura/ConvexHullJob.py index 9fb18981d3..09d23b7104 100644 --- a/cura/ConvexHullJob.py +++ b/cura/ConvexHullJob.py @@ -4,6 +4,7 @@ from UM.Job import Job from UM.Application import Application from UM.Math.Polygon import Polygon +from UM.Logger import Logger import numpy import copy @@ -19,6 +20,11 @@ class ConvexHullJob(Job): def run(self): if not self._node: return + + ################################################################# + # Node Convex Hull + ################################################################# + ## If the scene node is a group, use the hull of the children to calculate its hull. if self._node.callDecoration("isGroup"): hull = Polygon(numpy.zeros((0, 2), dtype=numpy.int32)) @@ -47,10 +53,20 @@ class ConvexHullJob(Job): # This is done to greatly speed up further convex hull calculations as the convex hull # becomes much less complex when dealing with highly detailed models. vertex_data = numpy.round(vertex_data, 1) - duplicates = (vertex_data[:,0] == vertex_data[:,1]) | (vertex_data[:,1] == vertex_data[:,2]) | (vertex_data[:,0] == vertex_data[:,2]) - vertex_data = numpy.delete(vertex_data, numpy.where(duplicates), axis = 0) - hull = Polygon(vertex_data[:, [0, 2]]) + vertex_data = vertex_data[:, [0, 2]] # Drop the Y components to project to 2D. + + # Grab the set of unique points. + # + # This basically finds the unique rows in the array by treating them as opaque groups of bytes + # which are as long as the 2 float64s in each row, and giving this view to numpy.unique() to munch. + # See http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array + vertex_byte_view = numpy.ascontiguousarray(vertex_data).view( + numpy.dtype((numpy.void, vertex_data.dtype.itemsize * vertex_data.shape[1]))) + _, idx = numpy.unique(vertex_byte_view, return_index=True) + vertex_data = vertex_data[idx] # Select the unique rows by index. + + hull = Polygon(vertex_data) # First, calculate the normal convex hull around the points hull = hull.getConvexHull() @@ -59,6 +75,16 @@ class ConvexHullJob(Job): # This is done because of rounding errors. hull = hull.getMinkowskiHull(Polygon(numpy.array([[-0.5, -0.5], [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]], numpy.float32))) + ################################################################# + # Print Head Exclusion Zone + ################################################################# + + + # + # TODO + # ConvexHullDecorator should use a memoization strategy in its getters. + # Make MeshData immutable + profile = Application.getInstance().getMachineManager().getWorkingProfile() if profile: if profile.getSettingValue("print_sequence") == "one_at_a_time" and not self._node.getParent().callDecoration("isGroup"): @@ -99,3 +125,33 @@ class ConvexHullJob(Job): hull_node = self._node.getParent().callDecoration("getConvexHullNode") if hull_node: hull_node.setParent(None) + + try: + Logger.log('d', 'ConvexHullJob getConvexHull:' + dumpPoly(self._node.callDecoration("getConvexHull"))) + Logger.log('d', 'ConvexHullJob new getConvexHull:' + dumpPoly(self._node.callDecoration("newGetConvexHull"))) + except Exception: + pass + + try: + Logger.log('d', 'ConvexHullJob getConvexHullHeadFull:' + dumpPoly(self._node.callDecoration("getConvexHullHeadFull"))) + Logger.log('d', 'ConvexHullJob new getConvexHullHeadFull:' + dumpPoly(self._node.callDecoration("newGetConvexHullHeadFull"))) + except Exception: + pass + + try: + Logger.log('d', 'ConvexHullJob getConvexHullHead:' + dumpPoly(self._node.callDecoration("getConvexHullHead"))) + Logger.log('d', 'ConvexHullJob new getConvexHullHead:' + dumpPoly(self._node.callDecoration("newGetConvexHullHead"))) + except Exception: + pass + + try: + Logger.log('d', 'ConvexHullJob getConvexHullBoundary:' + dumpPoly(self._node.callDecoration("getConvexHullBoundary"))) + Logger.log('d', 'ConvexHullJob new getConvexHullBoundary:' + dumpPoly(self._node.callDecoration("newGetConvexHullBoundary"))) + except Exception: + pass + +def dumpPoly(poly): + if poly is None: + return "None" + else: + return repr(poly.getPoints()) diff --git a/cura/ConvexHullNode.py b/cura/ConvexHullNode.py index 905aeb16d4..b5a2df518d 100644 --- a/cura/ConvexHullNode.py +++ b/cura/ConvexHullNode.py @@ -8,7 +8,7 @@ from UM.Math.Vector import Vector from UM.Mesh.MeshBuilder import MeshBuilder # To create a mesh to display the convex hull with. from UM.View.GL.OpenGL import OpenGL - +from UM.Logger import spy class ConvexHullNode(SceneNode): ## Convex hull node is a special type of scene node that is used to display a 2D area, to indicate the @@ -46,6 +46,9 @@ class ConvexHullNode(SceneNode): if convex_hull_head: self._convex_hull_head_mesh = self.createHullMesh(convex_hull_head.getPoints()) + def getHull(self): + return self._hull + ## Actually create the mesh from the hullpoints # /param hull_points list of xy values # /return meshData @@ -62,7 +65,7 @@ class ConvexHullNode(SceneNode): mesh_builder.addFace(point_first, point_previous, point_new, color = self._color) point_previous = point_new # Prepare point_previous for the next triangle. - return mesh_builder.getData() + return mesh_builder.build() def getWatchedNode(self): return self._node @@ -80,9 +83,7 @@ class ConvexHullNode(SceneNode): return True def _onNodePositionChanged(self, node): - if node.callDecoration("getConvexHull"): - node.callDecoration("setConvexHull", None) - node.callDecoration("setConvexHullNode", None) + if node.callDecoration("getConvexHull"): self.setParent(None) # Garbage collection should delete this node after a while. def _onNodeParentChanged(self, node): diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 72ff8aec8c..4977cc799b 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -278,9 +278,11 @@ class CuraApplication(QtApplication): count += 1 if not scene_boundingbox: - scene_boundingbox = copy.deepcopy(node.getBoundingBox()) + scene_boundingbox = node.getBoundingBox() else: - scene_boundingbox += node.getBoundingBox() + other_bb = node.getBoundingBox() + if other_bb is not None: + scene_boundingbox = scene_boundingbox + node.getBoundingBox() if not scene_boundingbox: scene_boundingbox = AxisAlignedBox.Null diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index 57d8f4e0ba..b0863ccfd7 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -45,7 +45,7 @@ class PlatformPhysics: root = self._controller.getScene().getRoot() for node in BreadthFirstIterator(root): - if node is root or type(node) is not SceneNode: + if node is root or type(node) is not SceneNode or node.getBoundingBox() is None: continue bbox = node.getBoundingBox() @@ -73,14 +73,9 @@ class PlatformPhysics: # If there is no convex hull for the node, start calculating it and continue. if not node.getDecorator(ConvexHullDecorator): node.addDecorator(ConvexHullDecorator()) - - if not node.callDecoration("getConvexHull"): - if not node.callDecoration("getConvexHullJob"): - job = ConvexHullJob.ConvexHullJob(node) - job.start() - node.callDecoration("setConvexHullJob", job) - - elif Preferences.getInstance().getValue("physics/automatic_push_free"): + node.callDecoration("recomputeConvexHull") + + if Preferences.getInstance().getValue("physics/automatic_push_free"): # Check for collisions between convex hulls for other_node in BreadthFirstIterator(root): # Ignore root, ourselves and anything that is not a normal SceneNode. From be145d02b3ba43466367f6af0679248b17252d2b Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 24 May 2016 20:42:21 +0200 Subject: [PATCH 026/112] Updated the cura code for removal of MeshBuilder.getMesh(). Contributes to CURA-1504 --- cura/BuildVolume.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index dd76095d9a..71db735f0a 100644 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -104,7 +104,7 @@ class BuildVolume(SceneNode): mb.addLine(Vector(min_w, max_h, min_d), Vector(min_w, max_h, max_d), color = self.VolumeOutlineColor) mb.addLine(Vector(max_w, max_h, min_d), Vector(max_w, max_h, max_d), color = self.VolumeOutlineColor) - self.setMeshData(mb.getData()) + self.setMeshData(mb.build()) mb = MeshBuilder() mb.addQuad( @@ -116,7 +116,7 @@ class BuildVolume(SceneNode): for n in range(0, 6): v = mb.getVertex(n) mb.setVertexUVCoordinates(n, v[0], v[2]) - self._grid_mesh = mb.getData() + self._grid_mesh = mb.build() disallowed_area_height = 0.1 disallowed_area_size = 0 @@ -141,7 +141,7 @@ class BuildVolume(SceneNode): size = 0 disallowed_area_size = max(size, disallowed_area_size) - self._disallowed_area_mesh = mb.getData() + self._disallowed_area_mesh = mb.build() else: self._disallowed_area_mesh = None From a2b5128c05c9cf48f37a96f53097fc6c8d19cdcf Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 24 May 2016 20:51:49 +0200 Subject: [PATCH 027/112] Updated the cura code for removal of MeshBuilder.getMesh(). Contributes to CURA-1504 --- cura/Layer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Layer.py b/cura/Layer.py index a95fbf64ef..904e5528a3 100644 --- a/cura/Layer.py +++ b/cura/Layer.py @@ -96,4 +96,4 @@ class Layer: builder.addQuad(point1, point2, point3, point4, color = poly_color) - return builder.getData() \ No newline at end of file + return builder.build() From 3915dec42659d26ed1c6f1aef408ae4fa2564534 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Tue, 24 May 2016 20:56:41 +0200 Subject: [PATCH 028/112] Only remove the old convex hull shadow when a tool is really being used. Contributes to CURA-1504 --- cura/ConvexHullNode.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cura/ConvexHullNode.py b/cura/ConvexHullNode.py index b5a2df518d..3d00edd288 100644 --- a/cura/ConvexHullNode.py +++ b/cura/ConvexHullNode.py @@ -1,6 +1,7 @@ # Copyright (c) 2015 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. +from UM.Application import Application from UM.Scene.SceneNode import SceneNode from UM.Resources import Resources from UM.Math.Color import Color @@ -8,7 +9,6 @@ from UM.Math.Vector import Vector from UM.Mesh.MeshBuilder import MeshBuilder # To create a mesh to display the convex hull with. from UM.View.GL.OpenGL import OpenGL -from UM.Logger import spy class ConvexHullNode(SceneNode): ## Convex hull node is a special type of scene node that is used to display a 2D area, to indicate the @@ -83,8 +83,9 @@ class ConvexHullNode(SceneNode): return True def _onNodePositionChanged(self, node): - if node.callDecoration("getConvexHull"): - self.setParent(None) # Garbage collection should delete this node after a while. + if Application.getInstance().getController().isToolOperationActive(): + if node.callDecoration("getConvexHull"): + self.setParent(None) # Garbage collection should delete this node after a while. def _onNodeParentChanged(self, node): if node.getParent(): From 6b71326df9763d228e95175930f944e4e3fb11d9 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Wed, 25 May 2016 15:44:56 +0200 Subject: [PATCH 029/112] Deleted ConvexHullJob. We no longer need it. Contributes to CURA-1504 --- cura/ConvexHullJob.py | 157 ------------------------------------------ 1 file changed, 157 deletions(-) delete mode 100644 cura/ConvexHullJob.py diff --git a/cura/ConvexHullJob.py b/cura/ConvexHullJob.py deleted file mode 100644 index 09d23b7104..0000000000 --- a/cura/ConvexHullJob.py +++ /dev/null @@ -1,157 +0,0 @@ -# Copyright (c) 2015 Ultimaker B.V. -# Cura is released under the terms of the AGPLv3 or higher. - -from UM.Job import Job -from UM.Application import Application -from UM.Math.Polygon import Polygon -from UM.Logger import Logger - -import numpy -import copy -from . import ConvexHullNode - -## Job to async calculate the convex hull of a node. -class ConvexHullJob(Job): - def __init__(self, node): - super().__init__() - - self._node = node - - def run(self): - if not self._node: - return - - ################################################################# - # Node Convex Hull - ################################################################# - - ## If the scene node is a group, use the hull of the children to calculate its hull. - if self._node.callDecoration("isGroup"): - hull = Polygon(numpy.zeros((0, 2), dtype=numpy.int32)) - for child in self._node.getChildren(): - child_hull = child.callDecoration("getConvexHull") - if child_hull: - hull.setPoints(numpy.append(hull.getPoints(), child_hull.getPoints(), axis = 0)) - - if hull.getPoints().size < 3: - self._node.callDecoration("setConvexHull", None) - self._node.callDecoration("setConvexHullJob", None) - return - - Job.yieldThread() - - else: - if not self._node.getMeshData(): - return - mesh = self._node.getMeshData() - vertex_data = mesh.getTransformed(self._node.getWorldTransformation()).getVertices() - # Don't use data below 0. - # TODO; We need a better check for this as this gives poor results for meshes with long edges. - vertex_data = vertex_data[vertex_data[:,1] >= 0] - - # Round the vertex data to 1/10th of a mm, then remove all duplicate vertices - # This is done to greatly speed up further convex hull calculations as the convex hull - # becomes much less complex when dealing with highly detailed models. - vertex_data = numpy.round(vertex_data, 1) - - vertex_data = vertex_data[:, [0, 2]] # Drop the Y components to project to 2D. - - # Grab the set of unique points. - # - # This basically finds the unique rows in the array by treating them as opaque groups of bytes - # which are as long as the 2 float64s in each row, and giving this view to numpy.unique() to munch. - # See http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array - vertex_byte_view = numpy.ascontiguousarray(vertex_data).view( - numpy.dtype((numpy.void, vertex_data.dtype.itemsize * vertex_data.shape[1]))) - _, idx = numpy.unique(vertex_byte_view, return_index=True) - vertex_data = vertex_data[idx] # Select the unique rows by index. - - hull = Polygon(vertex_data) - - # First, calculate the normal convex hull around the points - hull = hull.getConvexHull() - - # Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull. - # This is done because of rounding errors. - hull = hull.getMinkowskiHull(Polygon(numpy.array([[-0.5, -0.5], [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]], numpy.float32))) - - ################################################################# - # Print Head Exclusion Zone - ################################################################# - - - # - # TODO - # ConvexHullDecorator should use a memoization strategy in its getters. - # Make MeshData immutable - - profile = Application.getInstance().getMachineManager().getWorkingProfile() - if profile: - if profile.getSettingValue("print_sequence") == "one_at_a_time" and not self._node.getParent().callDecoration("isGroup"): - # Printing one at a time and it's not an object in a group - self._node.callDecoration("setConvexHullBoundary", copy.deepcopy(hull)) - head_and_fans = Polygon(numpy.array(profile.getSettingValue("machine_head_with_fans_polygon"), numpy.float32)) - - # Full head hull is used to actually check the order. - full_head_hull = hull.getMinkowskiHull(head_and_fans) - self._node.callDecoration("setConvexHullHeadFull", full_head_hull) - mirrored = copy.deepcopy(head_and_fans) - mirrored.mirror([0, 0], [0, 1]) #Mirror horizontally. - mirrored.mirror([0, 0], [1, 0]) #Mirror vertically. - head_and_fans = head_and_fans.intersectionConvexHulls(mirrored) - - # Min head hull is used for the push free - min_head_hull = hull.getMinkowskiHull(head_and_fans) - self._node.callDecoration("setConvexHullHead", min_head_hull) - hull = hull.getMinkowskiHull(Polygon(numpy.array(profile.getSettingValue("machine_head_polygon"),numpy.float32))) - else: - self._node.callDecoration("setConvexHullHead", None) - if self._node.getParent() is None: # Node was already deleted before job is done. - self._node.callDecoration("setConvexHullNode",None) - self._node.callDecoration("setConvexHull", None) - self._node.callDecoration("setConvexHullJob", None) - return - - hull_node = ConvexHullNode.ConvexHullNode(self._node, hull, Application.getInstance().getController().getScene().getRoot()) - self._node.callDecoration("setConvexHullNode", hull_node) - self._node.callDecoration("setConvexHull", hull) - self._node.callDecoration("setConvexHullJob", None) - - if self._node.getParent() and self._node.getParent().callDecoration("isGroup"): - job = self._node.getParent().callDecoration("getConvexHullJob") - if job: - job.cancel() - self._node.getParent().callDecoration("setConvexHull", None) - hull_node = self._node.getParent().callDecoration("getConvexHullNode") - if hull_node: - hull_node.setParent(None) - - try: - Logger.log('d', 'ConvexHullJob getConvexHull:' + dumpPoly(self._node.callDecoration("getConvexHull"))) - Logger.log('d', 'ConvexHullJob new getConvexHull:' + dumpPoly(self._node.callDecoration("newGetConvexHull"))) - except Exception: - pass - - try: - Logger.log('d', 'ConvexHullJob getConvexHullHeadFull:' + dumpPoly(self._node.callDecoration("getConvexHullHeadFull"))) - Logger.log('d', 'ConvexHullJob new getConvexHullHeadFull:' + dumpPoly(self._node.callDecoration("newGetConvexHullHeadFull"))) - except Exception: - pass - - try: - Logger.log('d', 'ConvexHullJob getConvexHullHead:' + dumpPoly(self._node.callDecoration("getConvexHullHead"))) - Logger.log('d', 'ConvexHullJob new getConvexHullHead:' + dumpPoly(self._node.callDecoration("newGetConvexHullHead"))) - except Exception: - pass - - try: - Logger.log('d', 'ConvexHullJob getConvexHullBoundary:' + dumpPoly(self._node.callDecoration("getConvexHullBoundary"))) - Logger.log('d', 'ConvexHullJob new getConvexHullBoundary:' + dumpPoly(self._node.callDecoration("newGetConvexHullBoundary"))) - except Exception: - pass - -def dumpPoly(poly): - if poly is None: - return "None" - else: - return repr(poly.getPoints()) From 5d533d642db6a905374a908ba7cb4f5c07d42f94 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Wed, 25 May 2016 15:47:12 +0200 Subject: [PATCH 030/112] PlatformPhysics doesn't need ConvexHullJob either. Contributes to CURA-1504 --- cura/PlatformPhysics.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index b0863ccfd7..c43d0d09d7 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -14,7 +14,6 @@ from UM.Preferences import Preferences from cura.ConvexHullDecorator import ConvexHullDecorator from . import PlatformPhysicsOperation -from . import ConvexHullJob from . import ZOffsetDecorator import copy From 7e3dd3d443dfbda122bd14f0c2b73ba6f6831e13 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Wed, 25 May 2016 15:51:12 +0200 Subject: [PATCH 031/112] Removed some debug. Contributes to CURA-1504 --- cura/ConvexHullDecorator.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index 1d03c250e5..c42ab4f339 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -10,7 +10,7 @@ import numpy ## The convex hull decorator is a scene node decorator that adds the convex hull functionality to a scene node. # If a scene node has a convex hull decorator, it will have a shadow in which other objects can not be printed. class ConvexHullDecorator(SceneNodeDecorator): - def __init__(self,): + def __init__(self): super().__init__() self._convex_hull_node = None @@ -65,10 +65,8 @@ class ConvexHullDecorator(SceneNodeDecorator): convex_hull = self.getConvexHull() if self._convex_hull_node: if self._convex_hull_node.getHull() == convex_hull: - Logger.log('d', 'ConvexHullDecorator not creating a new ConvexHullNode') return self._convex_hull_node.setParent(None) - Logger.log('d', 'ConvexHullDecorator creating ConvexHullNode') hull_node = ConvexHullNode.ConvexHullNode(self._node, convex_hull, Application.getInstance().getController().getScene().getRoot()) self._convex_hull_node = hull_node From 5f638f6e69b85d64d1904bac8c4c25417294e209 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Thu, 26 May 2016 14:39:22 +0200 Subject: [PATCH 032/112] Better handling of degenerate convex hull cases. Contributes to CURA-1504 --- cura/ConvexHullDecorator.py | 66 +++++++++++++++++++------------------ cura/ConvexHullNode.py | 14 ++++---- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index c42ab4f339..2a8f55d09e 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -130,46 +130,48 @@ class ConvexHullDecorator(SceneNodeDecorator): return rounded_hull else: - if not self._node.getMeshData(): - return None - mesh = self._node.getMeshData() - world_transform = self._node.getWorldTransformation() + rounded_hull = None + if self._node.getMeshData(): + mesh = self._node.getMeshData() + world_transform = self._node.getWorldTransformation() - # Check the cache - if mesh is self._2d_convex_hull_mesh and world_transform == self._2d_convex_hull_mesh_world_transform: - # Logger.log('d', 'Cache hit in _compute2DConvexHull mesh path') - return self._2d_convex_hull_mesh_result + # Check the cache + if mesh is self._2d_convex_hull_mesh and world_transform == self._2d_convex_hull_mesh_world_transform: + # Logger.log('d', 'Cache hit in _compute2DConvexHull mesh path') + return self._2d_convex_hull_mesh_result - vertex_data = mesh.getConvexHullTransformedVertices(world_transform) - # Don't use data below 0. - # TODO; We need a better check for this as this gives poor results for meshes with long edges. - vertex_data = vertex_data[vertex_data[:,1] >= 0] + vertex_data = mesh.getConvexHullTransformedVertices(world_transform) + # Don't use data below 0. + # TODO; We need a better check for this as this gives poor results for meshes with long edges. + vertex_data = vertex_data[vertex_data[:,1] >= 0] - # Round the vertex data to 1/10th of a mm, then remove all duplicate vertices - # This is done to greatly speed up further convex hull calculations as the convex hull - # becomes much less complex when dealing with highly detailed models. - vertex_data = numpy.round(vertex_data, 1) + if len(vertex_data) >= 4: + # Round the vertex data to 1/10th of a mm, then remove all duplicate vertices + # This is done to greatly speed up further convex hull calculations as the convex hull + # becomes much less complex when dealing with highly detailed models. + vertex_data = numpy.round(vertex_data, 1) - vertex_data = vertex_data[:, [0, 2]] # Drop the Y components to project to 2D. + vertex_data = vertex_data[:, [0, 2]] # Drop the Y components to project to 2D. - # Grab the set of unique points. - # - # This basically finds the unique rows in the array by treating them as opaque groups of bytes - # which are as long as the 2 float64s in each row, and giving this view to numpy.unique() to munch. - # See http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array - vertex_byte_view = numpy.ascontiguousarray(vertex_data).view( - numpy.dtype((numpy.void, vertex_data.dtype.itemsize * vertex_data.shape[1]))) - _, idx = numpy.unique(vertex_byte_view, return_index=True) - vertex_data = vertex_data[idx] # Select the unique rows by index. + # Grab the set of unique points. + # + # This basically finds the unique rows in the array by treating them as opaque groups of bytes + # which are as long as the 2 float64s in each row, and giving this view to numpy.unique() to munch. + # See http://stackoverflow.com/questions/16970982/find-unique-rows-in-numpy-array + vertex_byte_view = numpy.ascontiguousarray(vertex_data).view( + numpy.dtype((numpy.void, vertex_data.dtype.itemsize * vertex_data.shape[1]))) + _, idx = numpy.unique(vertex_byte_view, return_index=True) + vertex_data = vertex_data[idx] # Select the unique rows by index. - hull = Polygon(vertex_data) + hull = Polygon(vertex_data) - # First, calculate the normal convex hull around the points - convex_hull = hull.getConvexHull() + if len(vertex_data) >= 4: + # First, calculate the normal convex hull around the points + convex_hull = hull.getConvexHull() - # Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull. - # This is done because of rounding errors. - rounded_hull = convex_hull.getMinkowskiHull(Polygon(numpy.array([[-0.5, -0.5], [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]], numpy.float32))) + # Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull. + # This is done because of rounding errors. + rounded_hull = convex_hull.getMinkowskiHull(Polygon(numpy.array([[-0.5, -0.5], [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]], numpy.float32))) # Store the result in the cache self._2d_convex_hull_mesh = mesh diff --git a/cura/ConvexHullNode.py b/cura/ConvexHullNode.py index 3d00edd288..2d88604b6e 100644 --- a/cura/ConvexHullNode.py +++ b/cura/ConvexHullNode.py @@ -39,9 +39,10 @@ class ConvexHullNode(SceneNode): self._convex_hull_head_mesh = None self._hull = hull - hull_mesh = self.createHullMesh(self._hull.getPoints()) - if hull_mesh: - self.setMeshData(hull_mesh) + if self._hull: + hull_mesh = self.createHullMesh(self._hull.getPoints()) + if hull_mesh: + self.setMeshData(hull_mesh) convex_hull_head = self._node.callDecoration("getConvexHullHead") if convex_hull_head: self._convex_hull_head_mesh = self.createHullMesh(convex_hull_head.getPoints()) @@ -76,9 +77,10 @@ class ConvexHullNode(SceneNode): self._shader.setUniformValue("u_color", self._color) if self.getParent(): - renderer.queueNode(self, transparent = True, shader = self._shader, backface_cull = True, sort = -8) - if self._convex_hull_head_mesh: - renderer.queueNode(self, shader = self._shader, transparent = True, mesh = self._convex_hull_head_mesh, backface_cull = True, sort = -8) + if self.getMeshData(): + renderer.queueNode(self, transparent = True, shader = self._shader, backface_cull = True, sort = -8) + if self._convex_hull_head_mesh: + renderer.queueNode(self, shader = self._shader, transparent = True, mesh = self._convex_hull_head_mesh, backface_cull = True, sort = -8) return True From 4cc0026af3cd1cf33f5ccb8a3cf6f4614037aea8 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Wed, 15 Jun 2016 16:22:48 +0200 Subject: [PATCH 033/112] Minor rework in response to code review. Contributes to CURA-1504 --- cura/ConvexHullDecorator.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index 2a8f55d09e..7efc8c7ffb 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -2,7 +2,6 @@ from UM.Scene.SceneNodeDecorator import SceneNodeDecorator from UM.Application import Application from UM.Math.Polygon import Polygon -from UM.Logger import Logger from . import ConvexHullNode import numpy @@ -113,7 +112,6 @@ class ConvexHullDecorator(SceneNodeDecorator): # Check the cache if child_polygon == self._2d_convex_hull_group_child_polygon: - # Logger.log('d', 'Cache hit in _compute2DConvexHull group path') return self._2d_convex_hull_group_result # First, calculate the normal convex hull around the points @@ -137,7 +135,6 @@ class ConvexHullDecorator(SceneNodeDecorator): # Check the cache if mesh is self._2d_convex_hull_mesh and world_transform == self._2d_convex_hull_mesh_world_transform: - # Logger.log('d', 'Cache hit in _compute2DConvexHull mesh path') return self._2d_convex_hull_mesh_result vertex_data = mesh.getConvexHullTransformedVertices(world_transform) From 9e1b10d1b87864a70a8ea4c89e4faec0f0527cb7 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Thu, 16 Jun 2016 20:02:21 +0200 Subject: [PATCH 034/112] CURA-1615: Updating GCodeProfileReader I got the plugin most of all working. At least the "successfully" imported profile XY" dialog appears. But sadly the profile does not appear in the list of profiles after that. I can only guess something is blocking here. Additionally it should be noted that G-Code exported from Cura 2.1.x does not work here anymore on Cura 2.2.x. --- .../GCodeProfileReader/GCodeProfileReader.py | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 11cc249657..4e1604fdc0 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -1,19 +1,21 @@ # Copyright (c) 2015 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -from UM.Application import Application #To get the machine manager to create the new profile in. -from UM.Settings.Profile import Profile -from UM.Settings.ProfileReader import ProfileReader -from UM.Logger import Logger +import os import re #Regular expressions for parsing escape characters in the settings. +from UM.Application import Application #To get the machine manager to create the new profile in. +from UM.Settings.InstanceContainer import InstanceContainer +from UM.Logger import Logger + +from cura.ProfileReader import ProfileReader ## A class that reads profile data from g-code files. # # It reads the profile data from g-code files and stores it in a new profile. # This class currently does not process the rest of the g-code in any way. class GCodeProfileReader(ProfileReader): - ## The file format version of the serialised g-code. + ## The file format version of the serialized g-code. # # It can only read settings with the same version as the version it was # written with. If the file format is changed in a way that breaks reverse @@ -51,31 +53,32 @@ class GCodeProfileReader(ProfileReader): # Loading all settings from the file. # They are all at the end, but Python has no reverse seek any more since Python3. # TODO: Consider moving settings to the start? - serialised = "" # Will be filled with the serialised profile. + serialized = "" # Will be filled with the serialized profile. try: with open(file_name) as f: for line in f: if line.startswith(prefix): # Remove the prefix and the newline from the line and add it to the rest. - serialised += line[prefix_length : -1] + serialized += line[prefix_length : -1] except IOError as e: Logger.log("e", "Unable to open file %s for reading: %s", file_name, str(e)) return None - - # Un-escape the serialised profile. + + # Un-escape the serialized profile. pattern = re.compile("|".join(GCodeProfileReader.escape_characters.keys())) # Perform the replacement with a regular expression. - serialised = pattern.sub(lambda m: GCodeProfileReader.escape_characters[re.escape(m.group(0))], serialised) + serialized = pattern.sub(lambda m: GCodeProfileReader.escape_characters[re.escape(m.group(0))], serialized) + Logger.log("i", "Serialized the following from %s: %s" %(file_name, repr(serialized))) - # Apply the changes to the current profile. - profile = Profile(machine_manager = Application.getInstance().getMachineManager(), read_only = False) + # Create an empty profile with the name of the G-code file + profile = InstanceContainer(os.path.basename(os.path.splitext(file_name)[0])) + profile.addMetaDataEntry("type", "quality") try: - profile.unserialise(serialised) - profile.setType(None) # Force type to none so it's correctly added. + profile.deserialize(serialized) profile.setReadOnly(False) - profile.setDirty(True) except Exception as e: # Not a valid g-code file. Logger.log("e", "Unable to serialise the profile: %s", str(e)) return None + return profile \ No newline at end of file From 42a860535c80b91c9c858f412c02ef0e7be51cc2 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Thu, 16 Jun 2016 20:19:03 +0200 Subject: [PATCH 035/112] Updating API to 3 --- plugins/GCodeProfileReader/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/GCodeProfileReader/__init__.py b/plugins/GCodeProfileReader/__init__.py index 1f4ced2ae6..690ef69376 100644 --- a/plugins/GCodeProfileReader/__init__.py +++ b/plugins/GCodeProfileReader/__init__.py @@ -13,7 +13,7 @@ def getMetaData(): "author": "Ultimaker", "version": "1.0", "description": catalog.i18nc("@info:whatsthis", "Provides support for importing profiles from g-code files."), - "api": 2 + "api": 3 }, "profile_reader": [ { From 29f7c240c42830cef787102b087c17a55ac1b00f Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Thu, 16 Jun 2016 20:37:32 +0200 Subject: [PATCH 036/112] CURA-1615: Updating SlicingInfoPlugin Just bumped the API version to 3 and added a message that is sent to the log that data was sent to the given URL. As slicing is broken here, because of "Arcus Error (5, native 32): Could not send message size" this also needs testing here. --- plugins/SliceInfoPlugin/SliceInfo.py | 6 +++++- plugins/SliceInfoPlugin/__init__.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index c2e8b9a147..6a9e821b10 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -8,6 +8,7 @@ from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.SceneNode import SceneNode from UM.Message import Message from UM.i18n import i18nCatalog +from UM.Logger import Logger import collections import json @@ -25,6 +26,8 @@ catalog = i18nCatalog("cura") # The data is only sent when the user in question gave permission to do so. All data is anonymous and # no model files are being sent (Just a SHA256 hash of the model). class SliceInfo(Extension): + info_url = "https://stats.youmagine.com/curastats/slice" + def __init__(self): super().__init__() Application.getInstance().getOutputDeviceManager().writeStarted.connect(self._onWriteStarted) @@ -114,7 +117,8 @@ class SliceInfo(Extension): # Submit data try: - f = urllib.request.urlopen("https://stats.youmagine.com/curastats/slice", data = binary_data, timeout = 1) + f = urllib.request.urlopen(self.info_url, data = binary_data, timeout = 1) + Logger.log("i", "Sent anonymous slice info to %s", self.info_url) except Exception as e: print("Exception occured", e) diff --git a/plugins/SliceInfoPlugin/__init__.py b/plugins/SliceInfoPlugin/__init__.py index da9111b2e4..f6e77fbf22 100644 --- a/plugins/SliceInfoPlugin/__init__.py +++ b/plugins/SliceInfoPlugin/__init__.py @@ -11,7 +11,7 @@ def getMetaData(): "author": "Ultimaker", "version": "1.0", "description": catalog.i18nc("@info:whatsthis", "Submits anonymous slice info. Can be disabled through preferences."), - "api": 2 + "api": 3 } } From 65f2afeebdd06248715fbb9bf155934bcd3bb102 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Fri, 17 Jun 2016 11:36:39 +0200 Subject: [PATCH 037/112] Use the same id as set when exporting Nothing special. Doesn't fix anything.. --- plugins/GCodeProfileReader/GCodeProfileReader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 4e1604fdc0..a9d59e9d96 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -72,7 +72,7 @@ class GCodeProfileReader(ProfileReader): Logger.log("i", "Serialized the following from %s: %s" %(file_name, repr(serialized))) # Create an empty profile with the name of the G-code file - profile = InstanceContainer(os.path.basename(os.path.splitext(file_name)[0])) + profile = InstanceContainer("G-code-imported-profile") profile.addMetaDataEntry("type", "quality") try: profile.deserialize(serialized) From 200529e8c93aed813b211d394775fe0907d6d6dd Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Fri, 17 Jun 2016 11:43:23 +0200 Subject: [PATCH 038/112] Removing setReadOnly(False) The profile is writable by default. --- plugins/GCodeProfileReader/GCodeProfileReader.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index a9d59e9d96..3cff7167b5 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -76,7 +76,6 @@ class GCodeProfileReader(ProfileReader): profile.addMetaDataEntry("type", "quality") try: profile.deserialize(serialized) - profile.setReadOnly(False) except Exception as e: # Not a valid g-code file. Logger.log("e", "Unable to serialise the profile: %s", str(e)) return None From 95116926388674371feb95ac93e15a4481b642ce Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Fri, 17 Jun 2016 12:10:34 +0200 Subject: [PATCH 039/112] Replace old MachineManager with GlobalContainerStack Also removing unused variable. --- plugins/SliceInfoPlugin/SliceInfo.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index 6a9e821b10..a31c25cb06 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -47,7 +47,6 @@ class SliceInfo(Extension): def _onWriteStarted(self, output_device): if not Preferences.getInstance().getValue("info/send_slice_info"): return # Do nothing, user does not want to send data - settings = Application.getInstance().getMachineManager().getWorkingProfile() # Load all machine definitions and put them in machine_settings dict #setting_file_name = Application.getInstance().getActiveMachineInstance().getMachineSettings()._json_file @@ -69,11 +68,11 @@ class SliceInfo(Extension): break - profile_values = settings.getChangedSettings() # TODO: @UnusedVariable + settings = Application.getInstance().getGlobalContainerStack() # Get total material used (in mm^3) print_information = Application.getInstance().getPrintInformation() - material_radius = 0.5 * settings.getSettingValue("material_diameter") + material_radius = 0.5 * settings.getProperty("material_diameter", "value") material_used = math.pi * material_radius * material_radius * print_information.materialAmount #Volume of material used # Get model information (bounding boxes, hashes and transformation matrix) From 4ca247cf3753cedd77919778187bc0e4e43c88e9 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Fri, 17 Jun 2016 12:41:24 +0200 Subject: [PATCH 040/112] Changing the profile name to something unique. Imported profiles will be now called "Custom profile ()" --- plugins/GCodeProfileReader/GCodeProfileReader.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 3cff7167b5..8b8809df57 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -7,6 +7,8 @@ import re #Regular expressions for parsing escape characters in the settings. from UM.Application import Application #To get the machine manager to create the new profile in. from UM.Settings.InstanceContainer import InstanceContainer from UM.Logger import Logger +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") from cura.ProfileReader import ProfileReader @@ -71,7 +73,7 @@ class GCodeProfileReader(ProfileReader): serialized = pattern.sub(lambda m: GCodeProfileReader.escape_characters[re.escape(m.group(0))], serialized) Logger.log("i", "Serialized the following from %s: %s" %(file_name, repr(serialized))) - # Create an empty profile with the name of the G-code file + # Create an empty profile - the id will be changed later profile = InstanceContainer("G-code-imported-profile") profile.addMetaDataEntry("type", "quality") try: @@ -80,4 +82,9 @@ class GCodeProfileReader(ProfileReader): Logger.log("e", "Unable to serialise the profile: %s", str(e)) return None + #Creating a unique name using the filename of the GCode + new_name = catalog.i18nc("@label", "Custom profile (%s)") %(os.path.splitext(os.path.basename(file_name))[0]) + profile.setName(new_name) + profile._id = new_name + return profile \ No newline at end of file From cbb8eebf7212a24114b49cd45ee81b9123e6620d Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Fri, 17 Jun 2016 12:52:14 +0200 Subject: [PATCH 041/112] Correcting and adding different things to SliceInfo * Replace regular print() with Logger.logException() * Adding log message that reporting is turned off * Rename variable "settings" to "global_container_stack". Should be less misleading. --- plugins/SliceInfoPlugin/SliceInfo.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index a31c25cb06..62a8f422c1 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -46,6 +46,7 @@ class SliceInfo(Extension): def _onWriteStarted(self, output_device): if not Preferences.getInstance().getValue("info/send_slice_info"): + Logger.log("d", "'info/send_slice_info' is turned off.") return # Do nothing, user does not want to send data # Load all machine definitions and put them in machine_settings dict @@ -68,11 +69,11 @@ class SliceInfo(Extension): break - settings = Application.getInstance().getGlobalContainerStack() + global_container_stack = Application.getInstance().getGlobalContainerStack() # Get total material used (in mm^3) print_information = Application.getInstance().getPrintInformation() - material_radius = 0.5 * settings.getProperty("material_diameter", "value") + material_radius = 0.5 * global_container_stack.getProperty("material_diameter", "value") material_used = math.pi * material_radius * material_radius * print_information.materialAmount #Volume of material used # Get model information (bounding boxes, hashes and transformation matrix) @@ -119,6 +120,6 @@ class SliceInfo(Extension): f = urllib.request.urlopen(self.info_url, data = binary_data, timeout = 1) Logger.log("i", "Sent anonymous slice info to %s", self.info_url) except Exception as e: - print("Exception occured", e) + Logger.logException("e", e) f.close() From 4beec2982e8386b5ce0606ee2ef9541c14ae7fd6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Jun 2016 15:23:15 +0200 Subject: [PATCH 042/112] Fixed typo CURA-1385 --- cura/MachineActionManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index be94d1696c..37993e252f 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -87,7 +87,7 @@ class MachineActionManager: else: return set() - ## Get all actions that need to be perfomed upon first start of a given machine. + ## Get all actions that need to be performed upon first start of a given machine. # Note that contrary to required / supported actions a list is returned (as it could be required to run the same # action multiple times). # \param machine The machine you want the first start actions of @@ -113,4 +113,4 @@ class MachineActionManager: if key in self._machine_actions: return self._machine_actions[key] else: - return None \ No newline at end of file + return None From af3e4e3a15fb116a4dc2cc47b575ddfc6657788a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Jun 2016 15:45:10 +0200 Subject: [PATCH 043/112] Machine actions can now be used as a plugin type for Cura CURA-1385 --- cura/CuraApplication.py | 3 +++ cura/MachineActionManager.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 5f5880e3d5..a44cada17b 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -44,6 +44,7 @@ from . import ZOffsetDecorator from . import CuraSplashScreen from . import MachineManagerModel from . import ContainerSettingsModel +from . import MachineActionManager from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS from PyQt5.QtGui import QColor, QIcon @@ -100,6 +101,8 @@ class CuraApplication(QtApplication): SettingDefinition.addSupportedProperty("settable_globally", DefinitionPropertyType.Any, default = True) SettingDefinition.addSettingType("extruder", int, str, UM.Settings.Validator) + self._machine_action_manager = MachineActionManager.MachineActionManager() + super().__init__(name = "cura", version = CuraVersion, buildtype = CuraBuildType) self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png"))) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index 37993e252f..d2ebfc6799 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -2,6 +2,8 @@ # Cura is released under the terms of the AGPLv3 or higher. from UM.Logger import Logger +from UM.PluginRegistry import PluginRegistry # So MachineAction can be added as plugin type + ## Raised when trying to add an unknown machine action as a required action class UnknownMachineAction(Exception): @@ -27,6 +29,8 @@ class MachineActionManager: ## Dict of all actions that need to be done when first added by machine reference. self._first_start_actions = {} + PluginRegistry.addType("machine_action", self.addMachineAction) + ## Add a required action to a machine # Raises an exception when the action is not recognised. def addRequiredAction(self, machine, action_key): From 6f7affa2bfd72b60f35eaf0ed5b1004046e31464 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Jun 2016 17:22:49 +0200 Subject: [PATCH 044/112] Machine actions can now be triggered from QML CURA-1385 --- cura/CuraApplication.py | 7 ++++ cura/MachineAction.py | 9 ++++- cura/MachineActionManager.py | 73 +++++++++++++++++------------------- 3 files changed, 50 insertions(+), 39 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index a44cada17b..ac3911504f 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -369,6 +369,7 @@ class CuraApplication(QtApplication): qmlRegisterSingletonType(MachineManagerModel.MachineManagerModel, "Cura", 1, 0, "MachineManager", MachineManagerModel.createMachineManagerModel) + qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager) self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml")) self._qml_import_paths.append(Resources.getPath(self.ResourceTypes.QmlFiles)) self.initializeEngine() @@ -385,6 +386,12 @@ class CuraApplication(QtApplication): self.exec_() + ## Get the machine action manager + # We ignore any **kwargs given to this, as we also register the machine manager as qml singleton. + # It wants to give this function an engine and script engine, but we don't care about that. + def getMachineActionManager(self, **kwargs): + return self._machine_action_manager + ## Handle Qt events def event(self, event): if event.type() == QEvent.FileOpen: diff --git a/cura/MachineAction.py b/cura/MachineAction.py index aaa3d9615d..ba40135916 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -1,7 +1,7 @@ # Copyright (c) 2016 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -from PyQt5.QtCore import QObject +from PyQt5.QtCore import QObject, pyqtSlot from UM.PluginObject import PluginObject @@ -16,3 +16,10 @@ class MachineAction(QObject, PluginObject): def getLabel(self): return self._label + + @pyqtSlot() + def execute(self): + self._execute() + + def _execute(self): + raise NotImplementedError("Execute() must be implemented") \ No newline at end of file diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index d2ebfc6799..072c41118e 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -1,9 +1,9 @@ # Copyright (c) 2016 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. from UM.Logger import Logger - from UM.PluginRegistry import PluginRegistry # So MachineAction can be added as plugin type +from PyQt5.QtCore import QObject, pyqtSlot ## Raised when trying to add an unknown machine action as a required action class UnknownMachineAction(Exception): @@ -15,55 +15,51 @@ class NotUniqueMachineAction(Exception): pass -class MachineActionManager: - def __init__(self): - ## Dict of all known machine actions - self._machine_actions = {} +class MachineActionManager(QObject): + def __init__(self, parent = None): + super().__init__(parent) - ## Dict of all required actions by machine reference. - self._required_actions = {} - - ## Dict of all supported actions by machine reference - self._supported_actions = {} - - ## Dict of all actions that need to be done when first added by machine reference. - self._first_start_actions = {} + self._machine_actions = {} # Dict of all known machine actions + self._required_actions = {} # Dict of all required actions by machine reference. + self._supported_actions = {} # Dict of all supported actions by machine reference + self._first_start_actions = {} # Dict of all actions that need to be done when first added by machine reference + # Add machine_action as plugin type PluginRegistry.addType("machine_action", self.addMachineAction) ## Add a required action to a machine # Raises an exception when the action is not recognised. - def addRequiredAction(self, machine, action_key): + def addRequiredAction(self, machine_id, action_key): if action_key in self._machine_actions: - if machine in self._required_actions: - self._required_actions[machine] |= {self._machine_actions[action_key]} + if machine_id in self._required_actions: + self._required_actions[machine_id] |= {self._machine_actions[action_key]} else: - self._required_actions[machine] = {self._machine_actions[action_key]} + self._required_actions[machine_id] = {self._machine_actions[action_key]} else: - raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine.getKey())) + raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine_id.getKey())) ## Add a supported action to a machine. - def addSupportedAction(self, machine, action_key): + def addSupportedAction(self, machine_id, action_key): if action_key in self._machine_actions: - if machine in self._supported_actions: - self._supported_actions[machine] |= {self._machine_actions[action_key]} + if machine_id in self._supported_actions: + self._supported_actions[machine_id] |= {self._machine_actions[action_key]} else: - self._supported_actions[machine] = {self._machine_actions[action_key]} + self._supported_actions[machine_id] = {self._machine_actions[action_key]} else: - Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine.getKey()) + Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id.getKey()) ## Add an action to the first start list of a machine. - def addFirstStartAction(self, machine, action_key, index = None): + def addFirstStartAction(self, machine_id, action_key, index = None): if action_key in self._machine_actions: - if machine in self._first_start_actions: + if machine_id in self._first_start_actions: if index is not None: - self._first_start_actions[machine].insert(index, self._machine_actions[action_key]) + self._first_start_actions[machine_id].insert(index, self._machine_actions[action_key]) else: - self._first_start_actions[machine].append(self._machine_actions[action_key]) + self._first_start_actions[machine_id].append(self._machine_actions[action_key]) else: - self._first_start_actions[machine] = [self._machine_actions[action_key]] + self._first_start_actions[machine_id] = [self._machine_actions[action_key]] else: - Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine.getKey()) + Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id.getKey()) ## Add a (unique) MachineAction # if the Key of the action is not unique, an exception is raised. @@ -76,18 +72,19 @@ class MachineActionManager: ## Get all actions supported by given machine # \param machine The machine you want the supported actions of # \returns set of supported actions. - def getSupportedActions(self, machine): - if machine in self._supported_actions: - return self._supported_actions[machine] + @pyqtSlot(str, result = "QVariantList") + def getSupportedActions(self, machine_id): + if machine_id in self._supported_actions: + return self._supported_actions[machine_id] else: return set() ## Get all actions required by given machine # \param machine The machine you want the required actions of # \returns set of required actions. - def getRequiredActions(self, machine): - if machine in self._required_actions: - return self._required_actions[machine] + def getRequiredActions(self, machine_id): + if machine_id in self._required_actions: + return self._required_actions[machine_id] else: return set() @@ -96,9 +93,9 @@ class MachineActionManager: # action multiple times). # \param machine The machine you want the first start actions of # \returns List of actions. - def getFirstStartActions(self, machine): - if machine in self._first_start_actions: - return self._first_start_actions[machine] + def getFirstStartActions(self, machine_id): + if machine_id in self._first_start_actions: + return self._first_start_actions[machine_id] else: return [] From 8f450d0d2fe71441a796618c5784f3e1d14b2368 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Sat, 18 Jun 2016 14:05:32 +0200 Subject: [PATCH 045/112] Sending serialized global_settings Containers currently don't have a function to return their content as JSON or dict --- plugins/SliceInfoPlugin/SliceInfo.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index 62a8f422c1..c97e436e06 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -49,26 +49,6 @@ class SliceInfo(Extension): Logger.log("d", "'info/send_slice_info' is turned off.") return # Do nothing, user does not want to send data - # Load all machine definitions and put them in machine_settings dict - #setting_file_name = Application.getInstance().getActiveMachineInstance().getMachineSettings()._json_file - machine_settings = {} - #with open(setting_file_name, "rt", -1, "utf-8") as f: - # data = json.load(f, object_pairs_hook = collections.OrderedDict) - #machine_settings[os.path.basename(setting_file_name)] = copy.deepcopy(data) - active_machine_definition= Application.getInstance().getMachineManager().getActiveMachineInstance().getMachineDefinition() - data = active_machine_definition._json_data - # Loop through inherited json files - setting_file_name = active_machine_definition._path - while True: - if "inherits" in data: - inherited_setting_file_name = os.path.dirname(setting_file_name) + "/" + data["inherits"] - with open(inherited_setting_file_name, "rt", -1, "utf-8") as f: - data = json.load(f, object_pairs_hook = collections.OrderedDict) - machine_settings[os.path.basename(inherited_setting_file_name)] = copy.deepcopy(data) - else: - break - - global_container_stack = Application.getInstance().getGlobalContainerStack() # Get total material used (in mm^3) @@ -102,7 +82,7 @@ class SliceInfo(Extension): "processor": platform.processor(), "machine": platform.machine(), "platform": platform.platform(), - "machine_settings": json.dumps(machine_settings), + "global_settings": global_container_stack.serialize(), "version": Application.getInstance().getVersion(), "modelhash": "None", "printtime": str(print_information.currentPrintTime), From eb6abdf773def2a1282cc0b8584e56ee8101d404 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Sat, 18 Jun 2016 14:07:14 +0200 Subject: [PATCH 046/112] Move f.close() into try: In case urlopen() fails, e.g. because of a missing internet connection, f will be indefined. --- plugins/SliceInfoPlugin/SliceInfo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index c97e436e06..7ca9e0241e 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -99,7 +99,6 @@ class SliceInfo(Extension): try: f = urllib.request.urlopen(self.info_url, data = binary_data, timeout = 1) Logger.log("i", "Sent anonymous slice info to %s", self.info_url) + f.close() except Exception as e: Logger.logException("e", e) - - f.close() From 83c1ee80823e1459d1f9b005898ed64cc6624e55 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 20 Jun 2016 10:52:18 +0200 Subject: [PATCH 047/112] Required/supported/first run actions are now added to the manager CURA-1385 --- cura/MachineActionManager.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index 072c41118e..af6e36353c 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -3,6 +3,9 @@ from UM.Logger import Logger from UM.PluginRegistry import PluginRegistry # So MachineAction can be added as plugin type +from UM.Settings.ContainerRegistry import ContainerRegistry +from UM.Settings.DefinitionContainer import DefinitionContainer + from PyQt5.QtCore import QObject, pyqtSlot ## Raised when trying to add an unknown machine action as a required action @@ -27,6 +30,28 @@ class MachineActionManager(QObject): # Add machine_action as plugin type PluginRegistry.addType("machine_action", self.addMachineAction) + # Ensure that all containers that were registered before creation of this registry are also handled. + # This should not have any effect, but it makes it safer if we ever refactor the order of things. + for container in ContainerRegistry.getInstance().findDefinitionContainers(): + self._onContainerAdded(container) + + ContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded) + + def _onContainerAdded(self, container): + ## Ensure that the actions are added to this manager + if isinstance(container, DefinitionContainer): + supported_actions = container.getMetaDataEntry("supported_actions", []) + for action in supported_actions: + self.addSupportedAction(container.getId(), action) + + required_actions = container.getMetaDataEntry("required_actions", []) + for action in required_actions: + self.addRequiredAction(container.getId(), action) + + first_start_actions = container.getMetaDataEntry("first_start_actions", []) + for action in first_start_actions: + self.addFirstStartAction(container.getId(), action) + ## Add a required action to a machine # Raises an exception when the action is not recognised. def addRequiredAction(self, machine_id, action_key): From 8237047907807aeccd4257e759f429b4692ef054 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 20 Jun 2016 13:46:05 +0200 Subject: [PATCH 048/112] Actions are now added as buttons to machinePages CURA-1385 --- cura/CuraApplication.py | 4 ++-- cura/MachineAction.py | 12 ++++++++++-- cura/MachineActionManager.py | 8 ++++---- resources/qml/Preferences/MachinesPage.qml | 13 +++++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index ac3911504f..b2bf471aa3 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -387,9 +387,9 @@ class CuraApplication(QtApplication): self.exec_() ## Get the machine action manager - # We ignore any **kwargs given to this, as we also register the machine manager as qml singleton. + # We ignore any *args given to this, as we also register the machine manager as qml singleton. # It wants to give this function an engine and script engine, but we don't care about that. - def getMachineActionManager(self, **kwargs): + def getMachineActionManager(self, *args): return self._machine_action_manager ## Handle Qt events diff --git a/cura/MachineAction.py b/cura/MachineAction.py index ba40135916..67c4566f53 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -1,7 +1,7 @@ # Copyright (c) 2016 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -from PyQt5.QtCore import QObject, pyqtSlot +from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal from UM.PluginObject import PluginObject @@ -11,12 +11,20 @@ class MachineAction(QObject, PluginObject): self._key = key self._label = label + labelChanged = pyqtSignal() + def getKey(self): return self._key - def getLabel(self): + @pyqtProperty(str, notify = labelChanged) + def label(self): return self._label + def setLabel(self, label): + if self._label != label: + self._label = label + self.labelChanged.emit() + @pyqtSlot() def execute(self): self._execute() diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index af6e36353c..287ed89891 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -61,7 +61,7 @@ class MachineActionManager(QObject): else: self._required_actions[machine_id] = {self._machine_actions[action_key]} else: - raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine_id.getKey())) + raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine_id)) ## Add a supported action to a machine. def addSupportedAction(self, machine_id, action_key): @@ -71,7 +71,7 @@ class MachineActionManager(QObject): else: self._supported_actions[machine_id] = {self._machine_actions[action_key]} else: - Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id.getKey()) + Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id) ## Add an action to the first start list of a machine. def addFirstStartAction(self, machine_id, action_key, index = None): @@ -84,7 +84,7 @@ class MachineActionManager(QObject): else: self._first_start_actions[machine_id] = [self._machine_actions[action_key]] else: - Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id.getKey()) + Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id) ## Add a (unique) MachineAction # if the Key of the action is not unique, an exception is raised. @@ -100,7 +100,7 @@ class MachineActionManager(QObject): @pyqtSlot(str, result = "QVariantList") def getSupportedActions(self, machine_id): if machine_id in self._supported_actions: - return self._supported_actions[machine_id] + return list(self._supported_actions[machine_id]) else: return set() diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index faef019deb..d12b4563f3 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -41,6 +41,19 @@ UM.ManagementPage anchors.fill: parent; spacing: UM.Theme.getSize("default_margin").height; + Row + { + Repeater + { + id: machineActionRepeater + model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.activeDefinitionId) + Button + { + text: machineActionRepeater.model[index].label; + } + } + } + Label { text: base.currentItem && base.currentItem.name ? base.currentItem.name : "" From 8af2b076a7bba12ae1c01eb6db50d14b81893456 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 20 Jun 2016 13:51:27 +0200 Subject: [PATCH 049/112] Added plugin for UM machine actions CURA-1385 --- .../BedLevelMachineAction.py | 9 ++++++++ plugins/UltimakerMachineActions/__init__.py | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 plugins/UltimakerMachineActions/BedLevelMachineAction.py create mode 100644 plugins/UltimakerMachineActions/__init__.py diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.py b/plugins/UltimakerMachineActions/BedLevelMachineAction.py new file mode 100644 index 0000000000..b45e6e9300 --- /dev/null +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.py @@ -0,0 +1,9 @@ +from cura.MachineAction import MachineAction + +class BedLevelMachineAction(MachineAction): + def __init__(self): + super().__init__("BedLevel", "Level bed") + + def _execute(self): + pass + diff --git a/plugins/UltimakerMachineActions/__init__.py b/plugins/UltimakerMachineActions/__init__.py new file mode 100644 index 0000000000..1807fa1f1e --- /dev/null +++ b/plugins/UltimakerMachineActions/__init__.py @@ -0,0 +1,21 @@ +# Copyright (c) 2016 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. + +from . import BedLevelMachineAction + +from UM.i18n import i18nCatalog +catalog = i18nCatalog("cura") + +def getMetaData(): + return { + "plugin": { + "name": catalog.i18nc("@label", "Ultimaker machine actions"), + "author": "Ultimaker", + "version": "1.0", + "description": catalog.i18nc("@info:whatsthis", "Provides machine actions for Ultimaker machines (such as bed leveling wizard, selecting upgrades, etc)"), + "api": 3 + } + } + +def register(app): + return { "machine_action": BedLevelMachineAction.BedLevelMachineAction() } From 81602e9ccd71117652dcb1ff6dc8be3103144914 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Jun 2016 12:47:34 +0200 Subject: [PATCH 050/112] Machine action can now create displayItems CURA-1385 --- cura/MachineAction.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/cura/MachineAction.py b/cura/MachineAction.py index 67c4566f53..3958d62a70 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -1,8 +1,15 @@ # Copyright (c) 2016 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal +from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal, QUrl +from PyQt5.QtQml import QQmlComponent, QQmlContext + from UM.PluginObject import PluginObject +from UM.PluginRegistry import PluginRegistry + +from UM.Application import Application + +import os class MachineAction(QObject, PluginObject): @@ -10,6 +17,11 @@ class MachineAction(QObject, PluginObject): super().__init__() self._key = key self._label = label + self._qml_url = "" + + self._component = None + self._context = None + self._view = None labelChanged = pyqtSignal() @@ -30,4 +42,19 @@ class MachineAction(QObject, PluginObject): self._execute() def _execute(self): - raise NotImplementedError("Execute() must be implemented") \ No newline at end of file + raise NotImplementedError("Execute() must be implemented") + + def _createViewFromQML(self): + path = QUrl.fromLocalFile( + os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._qml_url)) + self._component = QQmlComponent(Application.getInstance()._engine, path) + self._context = QQmlContext(Application.getInstance()._engine.rootContext()) + self._context.setContextProperty("manager", self) + self._view = self._component.create(self._context) + + @pyqtProperty(QObject, constant = True) + def displayItem(self): + if not self._component: + self._createViewFromQML() + + return self._view \ No newline at end of file From 924af37dff058e71435bfcc3fa0652cdd0d17c73 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Jun 2016 13:30:36 +0200 Subject: [PATCH 051/112] Fleshing out of bedleveling action CURA-1385 --- cura/MachineAction.py | 14 +++- .../BedLevelMachineAction.py | 44 ++++++++++ .../BedLevelMachineAction.qml | 82 +++++++++++++++++++ resources/qml/Preferences/MachinesPage.qml | 3 + 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 plugins/UltimakerMachineActions/BedLevelMachineAction.qml diff --git a/cura/MachineAction.py b/cura/MachineAction.py index 3958d62a70..d3e0449fc6 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -17,7 +17,7 @@ class MachineAction(QObject, PluginObject): super().__init__() self._key = key self._label = label - self._qml_url = "" + self._qml_url = "" self._component = None self._context = None @@ -41,6 +41,18 @@ class MachineAction(QObject, PluginObject): def execute(self): self._execute() + ## Reset the action to it's default state. + # This should not be re-implemented by child classes, instead re-implement _reset. + # /sa _reset + @pyqtSlot() + def reset(self): + self._reset() + + ## Protected implementation of reset. + # /sa reset() + def _reset(self): + pass + def _execute(self): raise NotImplementedError("Execute() must be implemented") diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.py b/plugins/UltimakerMachineActions/BedLevelMachineAction.py index b45e6e9300..7be3a38ae7 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.py +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.py @@ -1,9 +1,53 @@ from cura.MachineAction import MachineAction +from PyQt5.QtCore import pyqtSlot + +from UM.Application import Application + +from cura.PrinterOutputDevice import PrinterOutputDevice + class BedLevelMachineAction(MachineAction): def __init__(self): super().__init__("BedLevel", "Level bed") + self._qml_url = "BedLevelMachineAction.qml" + self._bed_level_position = 0 def _execute(self): pass + def _reset(self): + self._bed_level_position = 0 + printer_output_devices = self._getPrinterOutputDevices() + if printer_output_devices: + printer_output_devices[0].homeBed() + printer_output_devices[0].moveHead(0, 0, 3) + printer_output_devices[0].homeHead() + + def _getPrinterOutputDevices(self): + return [printer_output_device for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices() if isinstance(printer_output_device, PrinterOutputDevice)] + + @pyqtSlot() + def moveToNextLevelPosition(self): + output_devices = self._getPrinterOutputDevices() + if output_devices: # We found at least one output device + output_device = output_devices[0] + + if self._bed_level_position == 0: + output_device.moveHead(0, 0, 3) + output_device.homeHead() + output_device.moveHead(0, 0, 3) + output_device.moveHead(Application.getInstance().getGlobalContainerStack().getProperty("machine_width") - 10, 0, 0) + output_device.moveHead(0, 0, -3) + self._bed_level_position += 1 + elif self._bed_level_position == 1: + output_device.moveHead(0, 0, 3) + output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width") / 2, Application.getInstance().getGlobalContainerStack().getProperty("machine_depth") - 10, 0) + output_device.moveHead(0, 0, -3) + self._bed_level_position += 1 + elif self._bed_level_position == 2: + output_device.moveHead(0, 0, 3) + output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width") / 2 + 10, -(Application.getInstance().getGlobalContainerStack().getProperty("machine_depth") + 10), 0) + output_device.moveHead(0, 0, -3) + self._bed_level_position += 1 + elif self._bed_level_position >= 3: + pass \ No newline at end of file diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml new file mode 100644 index 0000000000..d1a43d97f2 --- /dev/null +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml @@ -0,0 +1,82 @@ +// Copyright (c) 2015 Ultimaker B.V. +// Cura is released under the terms of the AGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.1 + +import UM 1.2 as UM +import Cura 1.0 as Cura + + +// The action items always need to be wrapped in a component. +Component +{ + Item + { + id: wizardPage + anchors.fill: parent; + + UM.I18nCatalog { id: catalog; name: "cura"; } + + Label + { + id: pageTitle + width: parent.width + text: catalog.i18nc("@title", "Bed Leveling") + wrapMode: Text.WordWrap + font.pointSize: 18; + } + Label + { + id: pageDescription + anchors.top: pageTitle.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + width: parent.width + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "To make sure your prints will come out great, you can now adjust your buildplate. When you click 'Move to Next Position' the nozzle will move to the different positions that can be adjusted.") + } + Label + { + id: bedlevelingText + anchors.top: pageDescription.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + width: parent.width + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "For every position; insert a piece of paper under the nozzle and adjust the print bed height. The print bed height is right when the paper is slightly gripped by the tip of the nozzle.") + } + + Item + { + id: bedlevelingWrapper + anchors.top: bedlevelingText.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.horizontalCenter: parent.horizontalCenter + height: skipBedlevelingButton.height + width: bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height < wizardPage.width ? bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height : wizardPage.width + Button + { + id: bedlevelingButton + anchors.top: parent.top + anchors.left: parent.left + text: catalog.i18nc("@action:button","Move to Next Position"); + onClicked: + { + + } + } + + Button + { + id: skipBedlevelingButton + anchors.top: parent.width < wizardPage.width ? parent.top : bedlevelingButton.bottom + anchors.topMargin: parent.width < wizardPage.width ? 0 : UM.Theme.getSize("default_margin").height/2 + anchors.left: parent.width < wizardPage.width ? bedlevelingButton.right : parent.left + anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0 + text: catalog.i18nc("@action:button","Skip bed leveling"); + onClicked: {} + } + } + } +} diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index d12b4563f3..8aa03c2c43 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -47,6 +47,7 @@ UM.ManagementPage { id: machineActionRepeater model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.activeDefinitionId) + Button { text: machineActionRepeater.model[index].label; @@ -54,6 +55,8 @@ UM.ManagementPage } } + + Label { text: base.currentItem && base.currentItem.name ? base.currentItem.name : "" From 181d16aad8c1e14aa020d3e5fdb6491a698016a3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Jun 2016 14:34:53 +0200 Subject: [PATCH 052/112] Running machine actions outside of first run is now possible CURA-1385 --- .../BedLevelMachineAction.qml | 6 ++++-- resources/qml/Preferences/MachinesPage.qml | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml index d1a43d97f2..b392358dd5 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml @@ -63,7 +63,7 @@ Component text: catalog.i18nc("@action:button","Move to Next Position"); onClicked: { - + manager.moveToNextLevelPosition() } } @@ -75,7 +75,9 @@ Component anchors.left: parent.width < wizardPage.width ? bedlevelingButton.right : parent.left anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0 text: catalog.i18nc("@action:button","Skip bed leveling"); - onClicked: {} + onClicked: + { + } } } } diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 8aa03c2c43..3535bfbaf0 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -51,11 +51,27 @@ UM.ManagementPage Button { text: machineActionRepeater.model[index].label; + onClicked: + { + actionDialog.sourceComponent = machineActionRepeater.model[index].displayItem + actionDialog.show() + } } } } + UM.Dialog + { + id: actionDialog + // We need to use a property because a window has it's own context. + property var sourceComponent + + Loader + { + sourceComponent: actionDialog.sourceComponent + } + } Label { From 65751d7400e2719f222edec2a02c82a3cb262246 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Jun 2016 16:19:44 +0200 Subject: [PATCH 053/112] Added completed signal to machine action, so model can notify display that it is completed CURA-1385 --- cura/MachineAction.py | 12 ++++++++++++ .../BedLevelMachineAction.qml | 3 ++- resources/qml/MachineAction.qml | 10 ++++++++++ resources/qml/Preferences/MachinesPage.qml | 12 +++++------- 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 resources/qml/MachineAction.qml diff --git a/cura/MachineAction.py b/cura/MachineAction.py index d3e0449fc6..8bdd02fe26 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -22,8 +22,10 @@ class MachineAction(QObject, PluginObject): self._component = None self._context = None self._view = None + self._finished = False labelChanged = pyqtSignal() + onFinished = pyqtSignal() def getKey(self): return self._key @@ -46,6 +48,7 @@ class MachineAction(QObject, PluginObject): # /sa _reset @pyqtSlot() def reset(self): + self._finished = False self._reset() ## Protected implementation of reset. @@ -53,9 +56,18 @@ class MachineAction(QObject, PluginObject): def _reset(self): pass + @pyqtSlot() + def setFinished(self): + self._finished = True + self.onFinished.emit() + def _execute(self): raise NotImplementedError("Execute() must be implemented") + @pyqtProperty(bool, notify = onFinished) + def finished(self): + return self._finished + def _createViewFromQML(self): path = QUrl.fromLocalFile( os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._qml_url)) diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml index b392358dd5..8a3bf8d96a 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml @@ -11,7 +11,7 @@ import Cura 1.0 as Cura // The action items always need to be wrapped in a component. -Component +Cura.MachineAction { Item { @@ -77,6 +77,7 @@ Component text: catalog.i18nc("@action:button","Skip bed leveling"); onClicked: { + manager.setFinished() } } } diff --git a/resources/qml/MachineAction.qml b/resources/qml/MachineAction.qml new file mode 100644 index 0000000000..ca8a22141d --- /dev/null +++ b/resources/qml/MachineAction.qml @@ -0,0 +1,10 @@ +import QtQuick 2.2 + +Item +{ + id: contentItem + // Connect the finished property change to completed signal. + property var finished: manager.finished + onFinishedChanged: if(manager.finished) {completed()} + signal completed() +} \ No newline at end of file diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 3535bfbaf0..dcc5e3d9c1 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -53,7 +53,7 @@ UM.ManagementPage text: machineActionRepeater.model[index].label; onClicked: { - actionDialog.sourceComponent = machineActionRepeater.model[index].displayItem + actionDialog.content = machineActionRepeater.model[index].displayItem actionDialog.show() } } @@ -63,13 +63,11 @@ UM.ManagementPage UM.Dialog { id: actionDialog - - // We need to use a property because a window has it's own context. - property var sourceComponent - - Loader + property var content + onContentChanged: { - sourceComponent: actionDialog.sourceComponent + contents = content; + content.onCompleted.connect(hide) } } From 671a6105a2db91da8949b8817a37f88375b40478 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Jun 2016 16:22:54 +0200 Subject: [PATCH 054/112] Setting a action to finished also causes it to be reset CURA-1385 --- cura/MachineAction.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cura/MachineAction.py b/cura/MachineAction.py index 8bdd02fe26..64d78ddd54 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -59,6 +59,7 @@ class MachineAction(QObject, PluginObject): @pyqtSlot() def setFinished(self): self._finished = True + self._reset() self.onFinished.emit() def _execute(self): From fb1313cedaa2678108d39a0eaaa12d9f5d8e3aae Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Jun 2016 16:23:31 +0200 Subject: [PATCH 055/112] BedLevel action now resets once it did all the steps CURA-1385 --- plugins/UltimakerMachineActions/BedLevelMachineAction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.py b/plugins/UltimakerMachineActions/BedLevelMachineAction.py index 7be3a38ae7..7a424d9cb4 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.py +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.py @@ -50,4 +50,4 @@ class BedLevelMachineAction(MachineAction): output_device.moveHead(0, 0, -3) self._bed_level_position += 1 elif self._bed_level_position >= 3: - pass \ No newline at end of file + self.setFinished() \ No newline at end of file From 6f6d70ad0f0343e582ff837582a137f7f5e9d4cf Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 21 Jun 2016 17:00:26 +0200 Subject: [PATCH 056/112] Added upgradeFirmware as machineAction CURA-1385 --- .../BedLevelMachineAction.qml | 5 +- .../UpgradeFirmwareMachineAction.py | 6 ++ .../UpgradeFirmwareMachineAction.qml | 84 +++++++++++++++++++ plugins/UltimakerMachineActions/__init__.py | 3 +- 4 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.py create mode 100644 plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml index 8a3bf8d96a..5d1140e03d 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Ultimaker B.V. +// Copyright (c) 2016 Ultimaker B.V. // Cura is released under the terms of the AGPLv3 or higher. import QtQuick 2.2 @@ -10,12 +10,11 @@ import UM 1.2 as UM import Cura 1.0 as Cura -// The action items always need to be wrapped in a component. Cura.MachineAction { Item { - id: wizardPage + id: bedLevelMachineAction anchors.fill: parent; UM.I18nCatalog { id: catalog; name: "cura"; } diff --git a/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.py b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.py new file mode 100644 index 0000000000..7d696a871e --- /dev/null +++ b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.py @@ -0,0 +1,6 @@ +from cura.MachineAction import MachineAction + +class UpgradeFirmwareMachineAction(MachineAction): + def __init__(self): + super().__init__("UpgradeFirmware", "Upgrade Firmware") + self._qml_url = "UpgradeFirmwareMachineAction.qml" \ No newline at end of file diff --git a/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml new file mode 100644 index 0000000000..e4dd43a8d6 --- /dev/null +++ b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml @@ -0,0 +1,84 @@ +// Copyright (c) 2016 Ultimaker B.V. +// Cura is released under the terms of the AGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.1 + +import UM 1.2 as UM +import Cura 1.0 as Cura + + +Cura.MachineAction +{ + Item + { + id: upgradeFirmwareMachineAction + + UM.I18nCatalog { id: catalog; name:"cura"} + + Label + { + id: pageTitle + width: parent.width + text: catalog.i18nc("@title", "Upgrade Firmware") + wrapMode: Text.WordWrap + font.pointSize: 18 + } + Label + { + id: pageDescription + anchors.top: pageTitle.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + width: parent.width + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "Firmware is the piece of software running directly on your 3D printer. This firmware controls the step motors, regulates the temperature and ultimately makes your printer work.") + } + + Label + { + id: upgradeText1 + anchors.top: pageDescription.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + width: parent.width + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "The firmware shipping with new Ultimakers works, but upgrades have been made to make better prints, and make calibration easier."); + } + + Label + { + id: upgradeText2 + anchors.top: upgradeText1.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + width: parent.width + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "Cura requires these new features and thus your firmware will most likely need to be upgraded. You can do so now."); + } + Item + { + anchors.top: upgradeText2.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.horizontalCenter: parent.horizontalCenter + width: upgradeButton.width + skipUpgradeButton.width + UM.Theme.getSize("default_margin").height < upgradeFirmwareMachineAction.width ? upgradeButton.width + skipUpgradeButton.width + UM.Theme.getSize("default_margin").height : upgradeFirmwareMachineAction.width + Button + { + id: upgradeButton + anchors.top: parent.top + anchors.left: parent.left + text: catalog.i18nc("@action:button","Upgrade to Marlin Firmware"); + onClicked: Cura.USBPrinterManager.updateAllFirmware() + } + Button + { + id: skipUpgradeButton + anchors.top: parent.width < upgradeFirmwareMachineAction.width ? parent.top : upgradeButton.bottom + anchors.topMargin: parent.width < upgradeFirmwareMachineAction.width ? 0 : UM.Theme.getSize("default_margin").height / 2 + anchors.left: parent.width < upgradeFirmwareMachineAction.width ? upgradeButton.right : parent.left + anchors.leftMargin: parent.width < upgradeFirmwareMachineAction.width ? UM.Theme.getSize("default_margin").width : 0 + text: catalog.i18nc("@action:button", "Skip Upgrade"); + onClicked: manager.setFinished() + } + } + } +} \ No newline at end of file diff --git a/plugins/UltimakerMachineActions/__init__.py b/plugins/UltimakerMachineActions/__init__.py index 1807fa1f1e..08d6db5076 100644 --- a/plugins/UltimakerMachineActions/__init__.py +++ b/plugins/UltimakerMachineActions/__init__.py @@ -2,6 +2,7 @@ # Cura is released under the terms of the AGPLv3 or higher. from . import BedLevelMachineAction +from . import UpgradeFirmwareMachineAction from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") @@ -18,4 +19,4 @@ def getMetaData(): } def register(app): - return { "machine_action": BedLevelMachineAction.BedLevelMachineAction() } + return { "machine_action": BedLevelMachineAction.BedLevelMachineAction(), "machine_action": UpgradeFirmwareMachineAction.UpgradeFirmwareMachineAction() } From bd703e65afc37b3a700e4526c4fcf3bd19410540 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 16 Jun 2016 10:14:17 +0200 Subject: [PATCH 057/112] Fix variant vs nozzle CURA-333 --- cura/ExtruderManager.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index b6739740f5..f9079c6328 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -111,7 +111,7 @@ class ExtruderManager(QObject): ## Creates a container stack for an extruder train. # # The container stack has an extruder definition at the bottom, which is - # linked to a machine definition. Then it has a nozzle profile, a material + # linked to a machine definition. Then it has a variant profile, a material # profile, a quality profile and a user profile, in that order. # # The resulting container stack is added to the registry. @@ -136,29 +136,29 @@ class ExtruderManager(QObject): container_stack.addMetaDataEntry("position", position) container_stack.addContainer(extruder_definition) - #Find the nozzle to use for this extruder. - nozzle = container_registry.getEmptyInstanceContainer() - if machine_definition.getMetaDataEntry("has_nozzles", default = "False") == "True": - #First add any nozzle. Later, overwrite with preference if the preference is valid. - nozzles = container_registry.findInstanceContainers(machine = machine_id, type = "nozzle") - if len(nozzles) >= 1: - nozzle = nozzles[0] - preferred_nozzle_id = machine_definition.getMetaDataEntry("preferred_nozzle") - if preferred_nozzle_id: - preferred_nozzles = container_registry.findInstanceContainers(id = preferred_nozzle_id, type = "nozzle") - if len(preferred_nozzles) >= 1: - nozzle = preferred_nozzles[0] + #Find the variant to use for this extruder. + variant = container_registry.getEmptyInstanceContainer() + if machine_definition.getMetaDataEntry("has_variants", default = "False") == "True": + #First add any variant. Later, overwrite with preference if the preference is valid. + variants = container_registry.findInstanceContainers(machine = machine_id, type = "variant") + if len(variants) >= 1: + variant = variants[0] + preferred_variant_id = machine_definition.getMetaDataEntry("preferred_variant") + if preferred_variant_id: + preferred_variants = container_registry.findInstanceContainers(id = preferred_variant_id, type = "variant") + if len(preferred_variants) >= 1: + variant = preferred_variants[0] else: - UM.Logger.log("w", "The preferred nozzle \"%s\" of machine %s doesn't exist or is not a nozzle profile.", preferred_nozzle_id, machine_id) - #And leave it at the default nozzle. - container_stack.addContainer(nozzle) + UM.Logger.log("w", "The preferred variant \"%s\" of machine %s doesn't exist or is not a variant profile.", preferred_variant_id, machine_id) + #And leave it at the default variant. + container_stack.addContainer(variant) - #Find a material to use for this nozzle. + #Find a material to use for this variant. material = container_registry.getEmptyInstanceContainer() if machine_definition.getMetaDataEntry("has_materials", default = "False") == "True": #First add any material. Later, overwrite with preference if the preference is valid. - if machine_definition.getMetaDataEntry("has_nozzle_materials", default = "False") == "True": - materials = container_registry.findInstanceContainers(type = "material", machine = machine_id, nozzle = nozzle.getId()) + if machine_definition.getMetaDataEntry("has_variant_materials", default = "False") == "True": + materials = container_registry.findInstanceContainers(type = "material", machine = machine_id, variant = variant.getId()) else: materials = container_registry.findInstanceContainers(type = "material", machine = machine_id) if len(materials) >= 1: @@ -175,7 +175,7 @@ class ExtruderManager(QObject): #Find a quality to use for this extruder. quality = container_registry.getEmptyInstanceContainer() - + #First add any quality. Later, overwrite with preference if the preference is valid. qualities = container_registry.findInstanceContainers(type = "quality") if len(qualities) >= 1: From ee7cfe273e9491e91f3673a023568fa098b0cd23 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 16 Jun 2016 10:41:50 +0200 Subject: [PATCH 058/112] Fix check for has_variants & has_materials These are defined as bool values instead of strings in UM2+ definitions, so I would expect other machine definitions (including jedi) also use bools. CURA-333 --- cura/ExtruderManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index f9079c6328..c83f8d9af7 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -138,7 +138,7 @@ class ExtruderManager(QObject): #Find the variant to use for this extruder. variant = container_registry.getEmptyInstanceContainer() - if machine_definition.getMetaDataEntry("has_variants", default = "False") == "True": + if machine_definition.getMetaDataEntry("has_variants"): #First add any variant. Later, overwrite with preference if the preference is valid. variants = container_registry.findInstanceContainers(machine = machine_id, type = "variant") if len(variants) >= 1: @@ -155,7 +155,7 @@ class ExtruderManager(QObject): #Find a material to use for this variant. material = container_registry.getEmptyInstanceContainer() - if machine_definition.getMetaDataEntry("has_materials", default = "False") == "True": + if machine_definition.getMetaDataEntry("has_materials"): #First add any material. Later, overwrite with preference if the preference is valid. if machine_definition.getMetaDataEntry("has_variant_materials", default = "False") == "True": materials = container_registry.findInstanceContainers(type = "material", machine = machine_id, variant = variant.getId()) From 825fcc2020413b9bb05fc954596151adeee5c84a Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 16 Jun 2016 12:47:08 +0200 Subject: [PATCH 059/112] Fix filtering of variants and materials by definition instead of by machine CURA-333 --- cura/ExtruderManager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index c83f8d9af7..5d0ad612cf 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -140,7 +140,7 @@ class ExtruderManager(QObject): variant = container_registry.getEmptyInstanceContainer() if machine_definition.getMetaDataEntry("has_variants"): #First add any variant. Later, overwrite with preference if the preference is valid. - variants = container_registry.findInstanceContainers(machine = machine_id, type = "variant") + variants = container_registry.findInstanceContainers(definition = machine_id, type = "variant") if len(variants) >= 1: variant = variants[0] preferred_variant_id = machine_definition.getMetaDataEntry("preferred_variant") @@ -158,9 +158,9 @@ class ExtruderManager(QObject): if machine_definition.getMetaDataEntry("has_materials"): #First add any material. Later, overwrite with preference if the preference is valid. if machine_definition.getMetaDataEntry("has_variant_materials", default = "False") == "True": - materials = container_registry.findInstanceContainers(type = "material", machine = machine_id, variant = variant.getId()) + materials = container_registry.findInstanceContainers(type = "material", definition = machine_id, variant = variant.getId()) else: - materials = container_registry.findInstanceContainers(type = "material", machine = machine_id) + materials = container_registry.findInstanceContainers(type = "material", definition = machine_id) if len(materials) >= 1: material = materials[0] preferred_material_id = machine_definition.getMetaDataEntry("preferred_material") From d0626f8c8ae93cf3a614b2b2bbd4dcdfe4ff0c7e Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 16 Jun 2016 15:32:44 +0200 Subject: [PATCH 060/112] Add hypothetical multiextrusion printer to test --- .../definitions/hypothetical_multi.def.json | 35 +++++++++++++++++++ .../hypothetical_multi_extruder_1.def.json | 19 ++++++++++ .../hypothetical_multi_extruder_2.def.json | 19 ++++++++++ .../hypothetical_multi_extruder_3.def.json | 19 ++++++++++ .../hypothetical_multi_extruder_4.def.json | 19 ++++++++++ .../variants/hypothetical_multi_0.4.inst.cfg | 11 ++++++ .../variants/hypothetical_multi_0.6.inst.cfg | 11 ++++++ 7 files changed, 133 insertions(+) create mode 100644 resources/definitions/hypothetical_multi.def.json create mode 100644 resources/extruders/hypothetical_multi_extruder_1.def.json create mode 100644 resources/extruders/hypothetical_multi_extruder_2.def.json create mode 100644 resources/extruders/hypothetical_multi_extruder_3.def.json create mode 100644 resources/extruders/hypothetical_multi_extruder_4.def.json create mode 100644 resources/variants/hypothetical_multi_0.4.inst.cfg create mode 100644 resources/variants/hypothetical_multi_0.6.inst.cfg diff --git a/resources/definitions/hypothetical_multi.def.json b/resources/definitions/hypothetical_multi.def.json new file mode 100644 index 0000000000..e60c9acabd --- /dev/null +++ b/resources/definitions/hypothetical_multi.def.json @@ -0,0 +1,35 @@ +{ + "id": "hypothetical_multi", + "version": 2, + "name": "Hypothetical Multiextrusion printer", + "inherits": "fdmprinter", + "metadata": { + "author": "fieldOfView", + "manufacturer": "fieldOfView", + "category": "fieldOfView", + "visible": true, + "file_formats": "text/x-gcode", + "machine_extruder_trains": + { + "0": "hypothetical_multi_extruder_1", + "1": "hypothetical_multi_extruder_2", + "2": "hypothetical_multi_extruder_3", + "3": "hypothetical_multi_extruder_4" + }, + "preferred_material": "*pla*", + "preferred_quality": "*normal*", + "has_variants": true, + "has_materials": true + }, + + + + "overrides": { + "machine_width": { "default_value": 220 }, + "machine_depth": { "default_value": 215 }, + "machine_height": { "default_value": 200 }, + "machine_heated_bed": { "default_value": true }, + "machine_show_variants": { "default_value": true }, + "machine_extruder_count": { "default_value": 4 } + } +} diff --git a/resources/extruders/hypothetical_multi_extruder_1.def.json b/resources/extruders/hypothetical_multi_extruder_1.def.json new file mode 100644 index 0000000000..6b75d33079 --- /dev/null +++ b/resources/extruders/hypothetical_multi_extruder_1.def.json @@ -0,0 +1,19 @@ +{ + "id": "hypothetical_multi_extruder_1", + "version": 2, + "name": "1st Extruder", + "inherits": "fdmextruder", + "metadata": { + "machine": "hypothetical_multi", + "position": "0" + }, + + "overrides": { + "extruder_nr": { + "default_value": 0, + "maximum_value": "3" + }, + "machine_nozzle_offset_x": { "default_value": 0.0 }, + "machine_nozzle_offset_y": { "default_value": 0.0 } + } +} diff --git a/resources/extruders/hypothetical_multi_extruder_2.def.json b/resources/extruders/hypothetical_multi_extruder_2.def.json new file mode 100644 index 0000000000..9c3c1b265b --- /dev/null +++ b/resources/extruders/hypothetical_multi_extruder_2.def.json @@ -0,0 +1,19 @@ +{ + "id": "hypothetical_multi_extruder_2", + "version": 2, + "name": "2nd Extruder", + "inherits": "fdmextruder", + "metadata": { + "machine": "hypothetical_multi", + "position": "1" + }, + + "overrides": { + "extruder_nr": { + "default_value": 1, + "maximum_value": "3" + }, + "machine_nozzle_offset_x": { "default_value": 18.0 }, + "machine_nozzle_offset_y": { "default_value": 0.0 } + } +} diff --git a/resources/extruders/hypothetical_multi_extruder_3.def.json b/resources/extruders/hypothetical_multi_extruder_3.def.json new file mode 100644 index 0000000000..e888f79895 --- /dev/null +++ b/resources/extruders/hypothetical_multi_extruder_3.def.json @@ -0,0 +1,19 @@ +{ + "id": "hypothetical_multi_extruder_3", + "version": 2, + "name": "3rd Extruder", + "inherits": "fdmextruder", + "metadata": { + "machine": "hypothetical_multi", + "position": "2" + }, + + "overrides": { + "extruder_nr": { + "default_value": 2, + "maximum_value": "3" + }, + "machine_nozzle_offset_x": { "default_value": 0.0 }, + "machine_nozzle_offset_y": { "default_value": 18.0 } + } +} diff --git a/resources/extruders/hypothetical_multi_extruder_4.def.json b/resources/extruders/hypothetical_multi_extruder_4.def.json new file mode 100644 index 0000000000..bb1ac4d1cd --- /dev/null +++ b/resources/extruders/hypothetical_multi_extruder_4.def.json @@ -0,0 +1,19 @@ +{ + "id": "hypothetical_multi_extruder_4", + "version": 2, + "name": "4th Extruder", + "inherits": "fdmextruder", + "metadata": { + "machine": "hypothetical_multi", + "position": "3" + }, + + "overrides": { + "extruder_nr": { + "default_value": 3, + "maximum_value": "3" + }, + "machine_nozzle_offset_x": { "default_value": 18.0 }, + "machine_nozzle_offset_y": { "default_value": 18.0 } + } +} diff --git a/resources/variants/hypothetical_multi_0.4.inst.cfg b/resources/variants/hypothetical_multi_0.4.inst.cfg new file mode 100644 index 0000000000..7d84e65ef4 --- /dev/null +++ b/resources/variants/hypothetical_multi_0.4.inst.cfg @@ -0,0 +1,11 @@ +[general] +name = 0.4 mm +version = 2 +definition = hypothetical_multi + +[metadata] +author = fieldOfView +type = variant + +[values] +machine_nozzle_size = 0.4 diff --git a/resources/variants/hypothetical_multi_0.6.inst.cfg b/resources/variants/hypothetical_multi_0.6.inst.cfg new file mode 100644 index 0000000000..bf441be897 --- /dev/null +++ b/resources/variants/hypothetical_multi_0.6.inst.cfg @@ -0,0 +1,11 @@ +[general] +name = 0.6 mm +version = 2 +definition = hypothetical_multi + +[metadata] +author = fieldOfView +type = variant + +[values] +machine_nozzle_size = 0.6 From f083d41353b8fce03f281f454ccfc8980f46ff54 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 16 Jun 2016 17:54:31 +0200 Subject: [PATCH 061/112] Update extrudermodel when material is changed So the swatch updates, and we can use the materialname for extruder selection later on CURA-333 --- cura/ExtrudersModel.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cura/ExtrudersModel.py b/cura/ExtrudersModel.py index 3ba6c5a99a..e4512210f6 100644 --- a/cura/ExtrudersModel.py +++ b/cura/ExtrudersModel.py @@ -46,12 +46,17 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): self._add_global = False + self._active_extruder_stack = None + #Listen to changes. manager = cura.ExtruderManager.ExtruderManager.getInstance() manager.extrudersChanged.connect(self._updateExtruders) #When the list of extruders changes in general. - UM.Application.globalContainerStackChanged.connect(self._updateExtruders) #When the current machine changes. + UM.Application.getInstance().globalContainerStackChanged.connect(self._updateExtruders) #When the current machine changes. self._updateExtruders() + manager.activeExtruderChanged.connect(self._onActiveExtruderChanged) + self._onActiveExtruderChanged() + def setAddGlobal(self, add): if add != self._add_global: self._add_global = add @@ -63,6 +68,23 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): def addGlobal(self): return self._add_global + def _onActiveExtruderChanged(self): + manager = cura.ExtruderManager.ExtruderManager.getInstance() + active_extruder_stack = manager.getActiveExtruderStack() + if self._active_extruder_stack != active_extruder_stack: + if self._active_extruder_stack: + self._active_extruder_stack.containersChanged.disconnect(self._onExtruderStackContainersChanged) + + if active_extruder_stack: + # Update the model when the material container is changed + active_extruder_stack.containersChanged.connect(self._onExtruderStackContainersChanged) + self._active_extruder_stack = active_extruder_stack + + + def _onExtruderStackContainersChanged(self, container): + if container.getMetaDataEntry("type") == "material": + self._updateExtruders() + ## Update the list of extruders. # # This should be called whenever the list of extruders changes. From 68ee4f0ea113427a3507ebfc26e992ad04497fe0 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 21 Jun 2016 07:13:19 +0200 Subject: [PATCH 062/112] Format extrudername to include material name CURA-333 --- cura/ExtrudersModel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cura/ExtrudersModel.py b/cura/ExtrudersModel.py index e4512210f6..a2a066690f 100644 --- a/cura/ExtrudersModel.py +++ b/cura/ExtrudersModel.py @@ -107,7 +107,10 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): self.appendItem(item) for extruder in manager.getMachineExtruders(global_container_stack.getBottom().getId()): + extruder_name = extruder.getName() material = extruder.findContainer({ "type": "material" }) + if material: + extruder_name = "%s (%s)" % (material.getName(), extruder_name) position = extruder.getBottom().getMetaDataEntry("position", default = "0") #Position in the definition. try: position = int(position) @@ -117,7 +120,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): colour = material.getMetaDataEntry("color_code", default = default_colour) if material else default_colour item = { #Construct an item with only the relevant information. "id": extruder.getId(), - "name": extruder.getName(), + "name": extruder_name, "colour": colour, "index": position } From eba2451cf22b20e1ce0f122a9f6cd308cec0b219 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 21 Jun 2016 08:59:43 +0200 Subject: [PATCH 063/112] Add tooltip to extruder-tabs CURA-333 --- resources/qml/SidebarHeader.qml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 55a104a21f..5d5e187a61 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -50,7 +50,7 @@ Column text: Cura.MachineManager.activeMachineName; height: UM.Theme.getSize("setting_control").height - tooltip: Cura.MachineManager.activeMachineName; + tooltip: Cura.MachineManager.activeMachineName anchors.verticalCenter: parent.verticalCenter style: UM.Theme.styles.sidebar_header_button @@ -117,8 +117,9 @@ Column width: ListView.view.width / extrudersModel.rowCount() text: model.name - exclusiveGroup: extruderMenuGroup; - checkable: true; + tooltip: model.name + exclusiveGroup: extruderMenuGroup + checkable: true checked: base.currentExtruderIndex == index onClicked: From 92905ada34125f102cde4b8eac0815e2a56054e3 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 21 Jun 2016 15:53:52 +0200 Subject: [PATCH 064/112] Show true extrudernames in Simple Mode support extruder selection combobox CURA-333 --- cura/ExtrudersModel.py | 3 +++ resources/qml/SidebarSimple.qml | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cura/ExtrudersModel.py b/cura/ExtrudersModel.py index a2a066690f..7edbb8b7c5 100644 --- a/cura/ExtrudersModel.py +++ b/cura/ExtrudersModel.py @@ -85,6 +85,8 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): if container.getMetaDataEntry("type") == "material": self._updateExtruders() + modelChanged = pyqtSignal() + ## Update the list of extruders. # # This should be called whenever the list of extruders changes. @@ -127,3 +129,4 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): self.appendItem(item) self.sort(lambda item: item["index"]) + self.modelChanged.emit() diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/SidebarSimple.qml index 80870ac29f..6e6e28be3b 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/SidebarSimple.qml @@ -319,11 +319,13 @@ Item id: extruderModel Component.onCompleted: populateExtruderModel() } - Connections + + //: Invisible list used to populate the extrudelModel + ListView { - id: machineChange - target: Cura.MachineManager - onGlobalContainerChanged: populateExtruderModel() + id: extruders + model: Cura.ExtrudersModel { onModelChanged: populateExtruderModel() } + visible: false } } @@ -331,11 +333,13 @@ Item { extruderModel.clear(); extruderModel.append({ - text: catalog.i18nc("@label", "Don't print support") + text: catalog.i18nc("@label", "Don't print support"), + color: "" }) - for(var extruder = 0; extruder < machineExtruderCount.properties.value ; extruder++) { + for(var extruderNr = 0; extruderNr < extruders.model.rowCount() ; extruderNr++) { extruderModel.append({ - text: catalog.i18nc("@label", "Print using Extruder %1").arg(extruder + 1) + text: catalog.i18nc("@label", "Print using %1").arg(extruders.model.getItem(extruderNr).name), + color: extruders.model.getItem(extruderNr).colour }) } } From 5d8a9a2cdad665b2d09b324153759123764d2d61 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 21 Jun 2016 17:19:15 +0200 Subject: [PATCH 065/112] Keep the same material and quality when switching nozzle or material CURA-333 --- cura/MachineManagerModel.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/cura/MachineManagerModel.py b/cura/MachineManagerModel.py index 2960d48ed1..70953ee712 100644 --- a/cura/MachineManagerModel.py +++ b/cura/MachineManagerModel.py @@ -376,11 +376,16 @@ class MachineManagerModel(QObject): return old_material = self._active_container_stack.findContainer({"type":"material"}) + old_quality = self._active_container_stack.findContainer({"type": "quality"}) if old_material: material_index = self._active_container_stack.getContainerIndex(old_material) self._active_container_stack.replaceContainer(material_index, containers[0]) - self.setActiveQuality(self._updateQualityContainer(self._active_container_stack.getBottom(), containers[0]).id) + preferred_quality_name = None + if old_quality: + preferred_quality_name = old_quality.getName() + + self.setActiveQuality(self._updateQualityContainer(self._global_container_stack.getBottom(), containers[0], preferred_quality_name).id) @pyqtSlot(str) def setActiveVariant(self, variant_id): @@ -389,11 +394,16 @@ class MachineManagerModel(QObject): return old_variant = self._active_container_stack.findContainer({"type": "variant"}) + old_material = self._active_container_stack.findContainer({"type": "material"}) if old_variant: variant_index = self._active_container_stack.getContainerIndex(old_variant) self._active_container_stack.replaceContainer(variant_index, containers[0]) - self.setActiveMaterial(self._updateMaterialContainer(self._active_container_stack.getBottom(), containers[0]).id) + preferred_material = None + if old_material: + preferred_material = old_material.getId() + + self.setActiveMaterial(self._updateMaterialContainer(self._global_container_stack.getBottom(), containers[0], preferred_material).id) @pyqtSlot(str) def setActiveQuality(self, quality_id): @@ -503,7 +513,7 @@ class MachineManagerModel(QObject): return self._empty_variant_container - def _updateMaterialContainer(self, definition, variant_container = None): + def _updateMaterialContainer(self, definition, variant_container = None, preferred_material = None): if not definition.getMetaDataEntry("has_materials"): return self._empty_material_container @@ -517,7 +527,8 @@ class MachineManagerModel(QObject): else: search_criteria["definition"] = "fdmprinter" - preferred_material = definition.getMetaDataEntry("preferred_material") + if not preferred_material: + preferred_material = definition.getMetaDataEntry("preferred_material") if preferred_material: search_criteria["id"] = preferred_material @@ -527,7 +538,7 @@ class MachineManagerModel(QObject): return self._empty_material_container - def _updateQualityContainer(self, definition, material_container = None): + def _updateQualityContainer(self, definition, material_container = None, preferred_quality_name = None): search_criteria = { "type": "quality" } if definition.getMetaDataEntry("has_machine_quality"): @@ -538,9 +549,12 @@ class MachineManagerModel(QObject): else: search_criteria["definition"] = "fdmprinter" - preferred_quality = definition.getMetaDataEntry("preferred_quality") - if preferred_quality: - search_criteria["id"] = preferred_quality + if preferred_quality_name: + search_criteria["name"] = preferred_quality_name + else: + preferred_quality = definition.getMetaDataEntry("preferred_quality") + if preferred_quality: + search_criteria["id"] = preferred_quality containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(**search_criteria) if containers: From f5bdc0295c2059ca7559870aee399415cafb992a Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 21 Jun 2016 18:30:34 +0200 Subject: [PATCH 066/112] Use color specified by material or nozzle to render objects CURA-345 --- plugins/SolidView/SolidView.py | 35 ++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 71b29c8186..8ff11a441a 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -10,9 +10,11 @@ from UM.View.Renderer import Renderer from UM.View.GL.OpenGL import OpenGL +from cura.ExtrudersModel import ExtrudersModel + import math -## Standard view for mesh models. +## Standard view for mesh models. class SolidView(View): def __init__(self): super().__init__() @@ -22,6 +24,8 @@ class SolidView(View): self._enabled_shader = None self._disabled_shader = None + self._extruders_model = ExtrudersModel() + def beginRendering(self): scene = self.getController().getScene() renderer = self.getRenderer() @@ -50,15 +54,38 @@ class SolidView(View): # TODO: Find a better way to handle this #if node.getBoundingBoxMesh(): # renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(),mode = Renderer.RenderLines) + + uniforms = {} + if self._extruders_model.rowCount() > 0: + # Get color to render this mesh in from ExtrudersModel + extruder_index = 0 + extruder_id = node.callDecoration("getActiveExtruder") + if extruder_id: + extruder_index = self._extruders_model.find("id", extruder_id) + if extruder_index: + extruder_color = self._extruders_model.getItem(extruder_index)["colour"] + + try: + # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs + # an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0]) + uniforms["diffuse_color"] = [ + int(extruder_color[1:3], 16) / 255, + int(extruder_color[3:5], 16) / 255, + int(extruder_color[5:7], 16) / 255, + 1.0 + ] + except: + pass + if hasattr(node, "_outside_buildarea"): if node._outside_buildarea: renderer.queueNode(node, shader = self._disabled_shader) else: - renderer.queueNode(node, shader = self._enabled_shader) + renderer.queueNode(node, shader = self._enabled_shader, uniforms = uniforms) else: - renderer.queueNode(node, material = self._enabled_shader) + renderer.queueNode(node, material = self._enabled_shader, uniforms = uniforms) if node.callDecoration("isGroup"): - renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(),mode = Renderer.RenderLines) + renderer.queueNode(scene.getRoot(), mesh = node.getBoundingBoxMesh(), mode = Renderer.RenderLines) def endRendering(self): pass From 963a2092efefb62f8f8b1216f0a7d05bbebb884d Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 21 Jun 2016 18:49:27 +0200 Subject: [PATCH 067/112] Change spelling of "colour" to "color" for consistency I know "colour" is the more correct spelling, but Qt uses the spelling "color" and we have already adopted that spelling in a number of places. CURA-333 --- cura/ExtrudersModel.py | 22 +++++++++---------- .../PerObjectSettingsPanel.qml | 2 +- plugins/SolidView/SolidView.py | 2 +- resources/qml/Settings/SettingExtruder.qml | 2 +- resources/qml/SidebarHeader.qml | 2 +- resources/qml/SidebarSimple.qml | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cura/ExtrudersModel.py b/cura/ExtrudersModel.py index 7edbb8b7c5..e300a9d73f 100644 --- a/cura/ExtrudersModel.py +++ b/cura/ExtrudersModel.py @@ -18,8 +18,8 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): ## Human-readable name of the extruder. NameRole = Qt.UserRole + 2 - ## Colour of the material loaded in the extruder. - ColourRole = Qt.UserRole + 3 + ## Color of the material loaded in the extruder. + ColorRole = Qt.UserRole + 3 ## Index of the extruder, which is also the value of the setting itself. # @@ -28,9 +28,9 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): # containers. IndexRole = Qt.UserRole + 4 - ## List of colours to display if there is no material or the material has no known - # colour. - defaultColours = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"] + ## List of colors to display if there is no material or the material has no known + # color. + defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"] ## Initialises the extruders model, defining the roles and listening for # changes in the data. @@ -41,7 +41,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): self.addRoleName(self.IdRole, "id") self.addRoleName(self.NameRole, "name") - self.addRoleName(self.ColourRole, "colour") + self.addRoleName(self.ColorRole, "color") self.addRoleName(self.IndexRole, "index") self._add_global = False @@ -99,11 +99,11 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): if self._add_global: material = global_container_stack.findContainer({ "type": "material" }) - colour = material.getMetaDataEntry("color_code", default = self.defaultColours[0]) if material else self.defaultColours[0] + color = material.getMetaDataEntry("color_code", default = self.defaultColors[0]) if material else self.defaultColors[0] item = { "id": global_container_stack.getId(), "name": "Global", - "colour": colour, + "color": color, "index": -1 } self.appendItem(item) @@ -118,12 +118,12 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): position = int(position) except ValueError: #Not a proper int. position = -1 - default_colour = self.defaultColours[position] if position >= 0 and position < len(self.defaultColours) else defaultColours[0] - colour = material.getMetaDataEntry("color_code", default = default_colour) if material else default_colour + default_color = self.defaultColors[position] if position >= 0 and position < len(self.defaultColors) else defaultColors[0] + color = material.getMetaDataEntry("color_code", default = default_color) if material else default_color item = { #Construct an item with only the relevant information. "id": extruder.getId(), "name": extruder_name, - "colour": colour, + "color": color, "index": position } self.appendItem(item) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index aa4a749e92..6c506b9404 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -78,7 +78,7 @@ Item { anchors.leftMargin: UM.Theme.getSize("default_lining").width anchors.verticalCenter: parent.verticalCenter - color: extruders_model.getItem(extruderSelector.currentIndex).colour + color: extruders_model.getItem(extruderSelector.currentIndex).color border.width: UM.Theme.getSize("default_lining").width border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border") } diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 8ff11a441a..6f63e332c9 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -63,7 +63,7 @@ class SolidView(View): if extruder_id: extruder_index = self._extruders_model.find("id", extruder_id) if extruder_index: - extruder_color = self._extruders_model.getItem(extruder_index)["colour"] + extruder_color = self._extruders_model.getItem(extruder_index)["color"] try: # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index 72c5299b15..5c21b1f269 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -64,7 +64,7 @@ SettingItem anchors.leftMargin: UM.Theme.getSize("default_lining").width anchors.verticalCenter: parent.verticalCenter - color: extruders_model.getItem(control.currentIndex).colour + color: extruders_model.getItem(control.currentIndex).color border.width: UM.Theme.getSize("default_lining").width border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border") } diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 5d5e187a61..dd30e7d807 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -151,7 +151,7 @@ Column anchors.leftMargin: (parent.height - height) / 2 anchors.verticalCenter: parent.verticalCenter - color: model.colour + color: model.color border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("toggle_checked") } diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/SidebarSimple.qml index 6e6e28be3b..26d552610d 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/SidebarSimple.qml @@ -339,7 +339,7 @@ Item for(var extruderNr = 0; extruderNr < extruders.model.rowCount() ; extruderNr++) { extruderModel.append({ text: catalog.i18nc("@label", "Print using %1").arg(extruders.model.getItem(extruderNr).name), - color: extruders.model.getItem(extruderNr).colour + color: extruders.model.getItem(extruderNr).color }) } } From 3fcfbb4e488abdbd4fb7274ea48458ec3199dba7 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 21 Jun 2016 22:10:50 +0200 Subject: [PATCH 068/112] Fix extruder color when no extruder_nr has been added to an object CURA-345 --- plugins/SolidView/SolidView.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 6f63e332c9..f69ac61a02 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -61,21 +61,20 @@ class SolidView(View): extruder_index = 0 extruder_id = node.callDecoration("getActiveExtruder") if extruder_id: - extruder_index = self._extruders_model.find("id", extruder_id) - if extruder_index: - extruder_color = self._extruders_model.getItem(extruder_index)["color"] + extruder_index = max(0, self._extruders_model.find("id", extruder_id)) - try: - # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs - # an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0]) - uniforms["diffuse_color"] = [ - int(extruder_color[1:3], 16) / 255, - int(extruder_color[3:5], 16) / 255, - int(extruder_color[5:7], 16) / 255, - 1.0 - ] - except: - pass + extruder_color = self._extruders_model.getItem(extruder_index)["color"] + try: + # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs + # an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0]) + uniforms["diffuse_color"] = [ + int(extruder_color[1:3], 16) / 255, + int(extruder_color[3:5], 16) / 255, + int(extruder_color[5:7], 16) / 255, + 1.0 + ] + except: + pass if hasattr(node, "_outside_buildarea"): if node._outside_buildarea: From 6fa1fb9d2f3d86a39d46d01bf0e315ca7a911dfd Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 22 Jun 2016 09:23:22 +0200 Subject: [PATCH 069/112] Select "Global" tab when switching to a machine that has multiple extruders. CURA-333 --- resources/qml/SidebarHeader.qml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index dd30e7d807..01de068220 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -13,7 +13,7 @@ Column id: base; property int totalHeightHeader: childrenRect.height - property int currentExtruderIndex; + property int currentExtruderIndex: -1; spacing: UM.Theme.getSize("default_margin").height @@ -111,6 +111,16 @@ Column model: Cura.ExtrudersModel { id: extrudersModel; addGlobal: true } + Connections + { + target: Cura.MachineManager + onGlobalContainerChanged: + { + base.currentExtruderIndex = -1; + ExtruderManager.setActiveExtruderIndex(index); + } + } + delegate: Button { height: ListView.view.height From b17d62124302ccf1c74fcc3ae4f1e39ae9512c29 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 22 Jun 2016 09:24:59 +0200 Subject: [PATCH 070/112] Disable nozzle/material selection on the global tab The global tab has no nozzle/material by definition. CURA-333 --- resources/qml/SidebarHeader.qml | 7 +++++-- resources/themes/cura/styles.qml | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 01de068220..ceb4cec38b 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -155,6 +155,7 @@ Column Rectangle { id: swatch + visible: index > -1 height: UM.Theme.getSize("setting_control").height / 2 width: height anchors.left: parent.left @@ -169,8 +170,8 @@ Column Label { anchors.verticalCenter: parent.verticalCenter - anchors.left: swatch.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width / 2 + anchors.left: swatch.visible ? swatch.right : parent.left + anchors.leftMargin: swatch.visible ? UM.Theme.getSize("default_margin").width / 2 : UM.Theme.getSize("default_margin").width anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2 @@ -227,6 +228,7 @@ Column text: Cura.MachineManager.activeVariantName tooltip: Cura.MachineManager.activeVariantName; visible: Cura.MachineManager.hasVariants + enabled: !extrudersList.visible || base.currentExtruderIndex > -1 height: UM.Theme.getSize("setting_control").height width: materialSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width @@ -271,6 +273,7 @@ Column text: Cura.MachineManager.activeMaterialName tooltip: Cura.MachineManager.activeMaterialName visible: Cura.MachineManager.hasMaterials + enabled: !extrudersList.visible || base.currentExtruderIndex > -1 height: UM.Theme.getSize("setting_control").height width: variantSelection.visible ? (parent.width - UM.Theme.getSize("default_margin").width) / 2 : parent.width diff --git a/resources/themes/cura/styles.qml b/resources/themes/cura/styles.qml index 1428c3d40a..3fdc7c896e 100644 --- a/resources/themes/cura/styles.qml +++ b/resources/themes/cura/styles.qml @@ -11,9 +11,10 @@ QtObject { property Component sidebar_header_button: Component { ButtonStyle { background: Rectangle { - color: Theme.getColor("setting_control") + color: control.enabled ? Theme.getColor("setting_control") : Theme.getColor("setting_control_disabled") border.width: Theme.getSize("default_lining").width - border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border") + border.color: !control.enabled ? Theme.getColor("setting_control_disabled_border") : + control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border") UM.RecolorImage { id: downArrow anchors.verticalCenter: parent.verticalCenter @@ -23,12 +24,12 @@ QtObject { height: Theme.getSize("standard_arrow").height sourceSize.width: width sourceSize.height: width - color: Theme.getColor("setting_category_text") + color: control.enabled ? Theme.getColor("setting_category_text") : Theme.getColor("setting_control_disabled_text") source: Theme.getIcon("arrow_bottom") } Label { id: sidebarComboBoxLabel - color: Theme.getColor("setting_control_text") + color: control.enabled ? Theme.getColor("setting_control_text") : Theme.getColor("setting_control_disabled_text") text: control.text; elide: Text.ElideRight; anchors.left: parent.left; From 6adc4ef2842173ebb90834d4c9f94ea694883d71 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 22 Jun 2016 10:19:44 +0200 Subject: [PATCH 071/112] Revert "Change spelling of "colour" to "color" for consistency" This reverts commit 963a2092efefb62f8f8b1216f0a7d05bbebb884d. I still say we should use "colour" for consistency, but that change should not be part of this branch. CURA-333 --- cura/ExtrudersModel.py | 22 +++++++++---------- .../PerObjectSettingsPanel.qml | 2 +- plugins/SolidView/SolidView.py | 2 +- resources/qml/Settings/SettingExtruder.qml | 2 +- resources/qml/SidebarHeader.qml | 2 +- resources/qml/SidebarSimple.qml | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cura/ExtrudersModel.py b/cura/ExtrudersModel.py index e300a9d73f..7edbb8b7c5 100644 --- a/cura/ExtrudersModel.py +++ b/cura/ExtrudersModel.py @@ -18,8 +18,8 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): ## Human-readable name of the extruder. NameRole = Qt.UserRole + 2 - ## Color of the material loaded in the extruder. - ColorRole = Qt.UserRole + 3 + ## Colour of the material loaded in the extruder. + ColourRole = Qt.UserRole + 3 ## Index of the extruder, which is also the value of the setting itself. # @@ -28,9 +28,9 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): # containers. IndexRole = Qt.UserRole + 4 - ## List of colors to display if there is no material or the material has no known - # color. - defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"] + ## List of colours to display if there is no material or the material has no known + # colour. + defaultColours = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"] ## Initialises the extruders model, defining the roles and listening for # changes in the data. @@ -41,7 +41,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): self.addRoleName(self.IdRole, "id") self.addRoleName(self.NameRole, "name") - self.addRoleName(self.ColorRole, "color") + self.addRoleName(self.ColourRole, "colour") self.addRoleName(self.IndexRole, "index") self._add_global = False @@ -99,11 +99,11 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): if self._add_global: material = global_container_stack.findContainer({ "type": "material" }) - color = material.getMetaDataEntry("color_code", default = self.defaultColors[0]) if material else self.defaultColors[0] + colour = material.getMetaDataEntry("color_code", default = self.defaultColours[0]) if material else self.defaultColours[0] item = { "id": global_container_stack.getId(), "name": "Global", - "color": color, + "colour": colour, "index": -1 } self.appendItem(item) @@ -118,12 +118,12 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): position = int(position) except ValueError: #Not a proper int. position = -1 - default_color = self.defaultColors[position] if position >= 0 and position < len(self.defaultColors) else defaultColors[0] - color = material.getMetaDataEntry("color_code", default = default_color) if material else default_color + default_colour = self.defaultColours[position] if position >= 0 and position < len(self.defaultColours) else defaultColours[0] + colour = material.getMetaDataEntry("color_code", default = default_colour) if material else default_colour item = { #Construct an item with only the relevant information. "id": extruder.getId(), "name": extruder_name, - "color": color, + "colour": colour, "index": position } self.appendItem(item) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index 6c506b9404..aa4a749e92 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -78,7 +78,7 @@ Item { anchors.leftMargin: UM.Theme.getSize("default_lining").width anchors.verticalCenter: parent.verticalCenter - color: extruders_model.getItem(extruderSelector.currentIndex).color + color: extruders_model.getItem(extruderSelector.currentIndex).colour border.width: UM.Theme.getSize("default_lining").width border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border") } diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index f69ac61a02..30b2105522 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -63,7 +63,7 @@ class SolidView(View): if extruder_id: extruder_index = max(0, self._extruders_model.find("id", extruder_id)) - extruder_color = self._extruders_model.getItem(extruder_index)["color"] + extruder_color = self._extruders_model.getItem(extruder_index)["colour"] try: # Colors are passed as rgb hex strings (eg "#ffffff"), and the shader needs # an rgba list of floats (eg [1.0, 1.0, 1.0, 1.0]) diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index 5c21b1f269..72c5299b15 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -64,7 +64,7 @@ SettingItem anchors.leftMargin: UM.Theme.getSize("default_lining").width anchors.verticalCenter: parent.verticalCenter - color: extruders_model.getItem(control.currentIndex).color + color: extruders_model.getItem(control.currentIndex).colour border.width: UM.Theme.getSize("default_lining").width border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border") } diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index ceb4cec38b..a2304d1d3e 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -162,7 +162,7 @@ Column anchors.leftMargin: (parent.height - height) / 2 anchors.verticalCenter: parent.verticalCenter - color: model.color + color: model.colour border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("toggle_checked") } diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/SidebarSimple.qml index 26d552610d..6e6e28be3b 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/SidebarSimple.qml @@ -339,7 +339,7 @@ Item for(var extruderNr = 0; extruderNr < extruders.model.rowCount() ; extruderNr++) { extruderModel.append({ text: catalog.i18nc("@label", "Print using %1").arg(extruders.model.getItem(extruderNr).name), - color: extruders.model.getItem(extruderNr).color + color: extruders.model.getItem(extruderNr).colour }) } } From 8cfc0737ac26a286e787e1420151e3af36aeaa33 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 11:49:35 +0200 Subject: [PATCH 072/112] First run actions are now properly handled CURA-1385 --- cura/MachineActionManager.py | 1 + .../BedLevelMachineAction.qml | 10 +++--- resources/qml/AddMachineDialog.qml | 2 ++ resources/qml/Cura.qml | 35 +++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index 287ed89891..c26d38331c 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -89,6 +89,7 @@ class MachineActionManager(QObject): ## Add a (unique) MachineAction # if the Key of the action is not unique, an exception is raised. def addMachineAction(self, action): + print("ADDING ACTIOONNN", action) if action.getKey() not in self._machine_actions: self._machine_actions[action.getKey()] = action else: diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml index 5d1140e03d..381c79b076 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml @@ -53,7 +53,7 @@ Cura.MachineAction anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.horizontalCenter: parent.horizontalCenter height: skipBedlevelingButton.height - width: bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height < wizardPage.width ? bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height : wizardPage.width + width: bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height < bedLevelMachineAction.width ? bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height : bedLevelMachineAction.width Button { id: bedlevelingButton @@ -69,10 +69,10 @@ Cura.MachineAction Button { id: skipBedlevelingButton - anchors.top: parent.width < wizardPage.width ? parent.top : bedlevelingButton.bottom - anchors.topMargin: parent.width < wizardPage.width ? 0 : UM.Theme.getSize("default_margin").height/2 - anchors.left: parent.width < wizardPage.width ? bedlevelingButton.right : parent.left - anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0 + anchors.top: parent.width < bedLevelMachineAction.width ? parent.top : bedlevelingButton.bottom + anchors.topMargin: parent.width < bedLevelMachineAction.width ? 0 : UM.Theme.getSize("default_margin").height/2 + anchors.left: parent.width < bedLevelMachineAction.width ? bedlevelingButton.right : parent.left + anchors.leftMargin: parent.width < bedLevelMachineAction.width ? UM.Theme.getSize("default_margin").width : 0 text: catalog.i18nc("@action:button","Skip bed leveling"); onClicked: { diff --git a/resources/qml/AddMachineDialog.qml b/resources/qml/AddMachineDialog.qml index 9d2d1a24ff..38221030ea 100644 --- a/resources/qml/AddMachineDialog.qml +++ b/resources/qml/AddMachineDialog.qml @@ -18,6 +18,7 @@ UM.Dialog title: catalog.i18nc("@title:window", "Add Printer") property string activeManufacturer: "Ultimaker"; + signal machineAdded(string id) function getMachineName() { var name = machineList.model.getItem(machineList.currentIndex).name @@ -162,6 +163,7 @@ UM.Dialog base.visible = false var item = machineList.model.getItem(machineList.currentIndex); Cura.MachineManager.addMachine(machineName.text, item.id) + base.machineAdded(item.id) // Emit signal that the user added a machine. } } diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 6dd57e17c8..90143f4817 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -771,6 +771,41 @@ UM.MainWindow AddMachineDialog { id: addMachineDialog + onMachineAdded: + { + firstRunWizard.start(id) + } + } + + // Dialog to handle first run machine actions + UM.Wizard + { + id: firstRunWizard; + + title: catalog.i18nc("@title:window", "Add Printer") + property var machine; + + function start(id) + { + var actions = Cura.MachineActionManager.getFirstStartActions(id) + resetPages() // Remove previous pages + + for (var i = 0; i < actions.length; i++) + { + firstRunWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title", actions[i].label)); + //firstRunWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title","blarg")); + console.log("ZOMGIE", i, actions[i].displayItem) + //firstRunWizard.appendPage(test, catalog.i18nc("@title", "Add Printer")); + } + + //Only start if there are actions to perform. + if (actions.length > 0) + { + firstRunWizard.currentPage = 0; + console.log(firstRunWizard.currentPage) + show() + } + } } Connections From e1828a768967496789223d4eb8b15e75dea1ab7a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 12:59:35 +0200 Subject: [PATCH 073/112] Removed stray debug print CURA-1385 --- cura/MachineActionManager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index c26d38331c..287ed89891 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -89,7 +89,6 @@ class MachineActionManager(QObject): ## Add a (unique) MachineAction # if the Key of the action is not unique, an exception is raised. def addMachineAction(self, action): - print("ADDING ACTIOONNN", action) if action.getKey() not in self._machine_actions: self._machine_actions[action.getKey()] = action else: From dcafb7d83a87c683b2c1d3da10e89ddfef31b0b6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 13:10:10 +0200 Subject: [PATCH 074/112] Removed Execute, as it's no longer used CURA-1385 --- cura/MachineAction.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cura/MachineAction.py b/cura/MachineAction.py index 64d78ddd54..6a4df0fce1 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -39,10 +39,6 @@ class MachineAction(QObject, PluginObject): self._label = label self.labelChanged.emit() - @pyqtSlot() - def execute(self): - self._execute() - ## Reset the action to it's default state. # This should not be re-implemented by child classes, instead re-implement _reset. # /sa _reset @@ -62,9 +58,6 @@ class MachineAction(QObject, PluginObject): self._reset() self.onFinished.emit() - def _execute(self): - raise NotImplementedError("Execute() must be implemented") - @pyqtProperty(bool, notify = onFinished) def finished(self): return self._finished From e78bd92b7f6980adc9965463704f8f347825f0cf Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Wed, 22 Jun 2016 14:01:23 +0200 Subject: [PATCH 075/112] SliceInfo: Adding all containers as serialized data --- plugins/SliceInfoPlugin/SliceInfo.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index 7ca9e0241e..6053e20f98 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -26,8 +26,8 @@ catalog = i18nCatalog("cura") # The data is only sent when the user in question gave permission to do so. All data is anonymous and # no model files are being sent (Just a SHA256 hash of the model). class SliceInfo(Extension): - info_url = "https://stats.youmagine.com/curastats/slice" - + info_url = "https://stats.youmagine.com/curastats/slice" + def __init__(self): super().__init__() Application.getInstance().getOutputDeviceManager().writeStarted.connect(self._onWriteStarted) @@ -82,7 +82,7 @@ class SliceInfo(Extension): "processor": platform.processor(), "machine": platform.machine(), "platform": platform.platform(), - "global_settings": global_container_stack.serialize(), + "settings": global_container_stack.serialize(), # global_container with references on used containers "version": Application.getInstance().getVersion(), "modelhash": "None", "printtime": str(print_information.currentPrintTime), @@ -90,6 +90,8 @@ class SliceInfo(Extension): "language": Preferences.getInstance().getValue("general/language"), "materials_profiles ": {} } + for container in global_container_stack.getContainers(): + submitted_data["settings_%s" %(container.getId())] = container.serialize() # This can be anything, eg. INI, JSON, etc. # Convert data to bytes submitted_data = urllib.parse.urlencode(submitted_data) From 1dc29fb984d3106695e078ffc1736cd31863dfef Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Wed, 22 Jun 2016 14:02:11 +0200 Subject: [PATCH 076/112] SliceInfo: Correctly output the print time --- plugins/SliceInfoPlugin/SliceInfo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index 7ca9e0241e..9af90c02e0 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -85,7 +85,7 @@ class SliceInfo(Extension): "global_settings": global_container_stack.serialize(), "version": Application.getInstance().getVersion(), "modelhash": "None", - "printtime": str(print_information.currentPrintTime), + "printtime": print_information.currentPrintTime.getDisplayString(), "filament": material_used, "language": Preferences.getInstance().getValue("general/language"), "materials_profiles ": {} From 4bc5883ad792078ade196610ee83adb967c95d8f Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Wed, 22 Jun 2016 14:30:20 +0200 Subject: [PATCH 077/112] SliceInfo: Check for available data before submitting it The code here is self-explaining again.. --- plugins/SliceInfoPlugin/SliceInfo.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index bef725cae0..f98e2d8da4 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -91,7 +91,15 @@ class SliceInfo(Extension): "materials_profiles ": {} } for container in global_container_stack.getContainers(): - submitted_data["settings_%s" %(container.getId())] = container.serialize() # This can be anything, eg. INI, JSON, etc. + container_id = container.getId() + container_serialized = container.serialize() + if container_serialized: + submitted_data["settings_%s" %(container_id)] = container_serialized # This can be anything, eg. INI, JSON, etc. + else: + Logger.log("i", "No data found in %s to be serialized!", container_id) + + for key in submitted_data.keys(): + print("%s -> %s" %(key, submitted_data[key])) # Convert data to bytes submitted_data = urllib.parse.urlencode(submitted_data) From 3ea11d306375c6f16574ac2d904edd7e6c2cc9ce Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Wed, 22 Jun 2016 14:35:19 +0200 Subject: [PATCH 078/112] SliceInfo: Removing debug code --- plugins/SliceInfoPlugin/SliceInfo.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index f98e2d8da4..a9cfe2d83a 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -98,9 +98,6 @@ class SliceInfo(Extension): else: Logger.log("i", "No data found in %s to be serialized!", container_id) - for key in submitted_data.keys(): - print("%s -> %s" %(key, submitted_data[key])) - # Convert data to bytes submitted_data = urllib.parse.urlencode(submitted_data) binary_data = submitted_data.encode("utf-8") From d5b07d29de86fd53d1a092dd24e2d4e8f0043378 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 14:39:41 +0200 Subject: [PATCH 079/112] Actions are now reset before every run CURA-1385 --- resources/qml/Cura.qml | 5 +---- resources/qml/MachineAction.qml | 5 +++++ resources/qml/Preferences/MachinesPage.qml | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 90143f4817..50a97f2a15 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -792,17 +792,14 @@ UM.MainWindow for (var i = 0; i < actions.length; i++) { + actions[i].displayItem.reset() firstRunWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title", actions[i].label)); - //firstRunWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title","blarg")); - console.log("ZOMGIE", i, actions[i].displayItem) - //firstRunWizard.appendPage(test, catalog.i18nc("@title", "Add Printer")); } //Only start if there are actions to perform. if (actions.length > 0) { firstRunWizard.currentPage = 0; - console.log(firstRunWizard.currentPage) show() } } diff --git a/resources/qml/MachineAction.qml b/resources/qml/MachineAction.qml index ca8a22141d..59fb3946a3 100644 --- a/resources/qml/MachineAction.qml +++ b/resources/qml/MachineAction.qml @@ -7,4 +7,9 @@ Item property var finished: manager.finished onFinishedChanged: if(manager.finished) {completed()} signal completed() + + function reset() + { + manager.reset() + } } \ No newline at end of file diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index dcc5e3d9c1..8a0a7dc096 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -54,6 +54,7 @@ UM.ManagementPage onClicked: { actionDialog.content = machineActionRepeater.model[index].displayItem + machineActionRepeater.model[index].displayItem.reset() actionDialog.show() } } From c297b14e03bb74e2e3be6c524cb46ab412c99ad1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 14:40:58 +0200 Subject: [PATCH 080/112] Added UMO checkup action CURA-1385 --- .../UMOCheckupMachineAction.py | 145 ++++++++++ .../UMOCheckupMachineAction.qml | 267 ++++++++++++++++++ plugins/UltimakerMachineActions/__init__.py | 3 +- 3 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 plugins/UltimakerMachineActions/UMOCheckupMachineAction.py create mode 100644 plugins/UltimakerMachineActions/UMOCheckupMachineAction.qml diff --git a/plugins/UltimakerMachineActions/UMOCheckupMachineAction.py b/plugins/UltimakerMachineActions/UMOCheckupMachineAction.py new file mode 100644 index 0000000000..392f89682f --- /dev/null +++ b/plugins/UltimakerMachineActions/UMOCheckupMachineAction.py @@ -0,0 +1,145 @@ +from cura.MachineAction import MachineAction +from cura.PrinterOutputDevice import PrinterOutputDevice +from UM.Application import Application +from PyQt5.QtCore import pyqtSlot, pyqtSignal, pyqtProperty + +class UMOCheckupMachineAction(MachineAction): + def __init__(self): + super().__init__("UMOCheckup", "Checkup") + self._qml_url = "UMOCheckupMachineAction.qml" + self._hotend_target_temp = 180 + self._bed_target_temp = 60 + self._output_device = None + self._bed_test_completed = False + self._hotend_test_completed = False + + # Endstop tests + self._x_min_endstop_test_completed = False + self._y_min_endstop_test_completed = False + self._z_min_endstop_test_completed = False + + onBedTestCompleted = pyqtSignal() + onHotendTestCompleted = pyqtSignal() + + onXMinEndstopTestCompleted = pyqtSignal() + onYMinEndstopTestCompleted = pyqtSignal() + onZMinEndstopTestCompleted = pyqtSignal() + + bedTemperatureChanged = pyqtSignal() + hotendTemperatureChanged = pyqtSignal() + + def _getPrinterOutputDevices(self): + return [printer_output_device for printer_output_device in + Application.getInstance().getOutputDeviceManager().getOutputDevices() if + isinstance(printer_output_device, PrinterOutputDevice)] + + def _reset(self): + if self._output_device: + self._output_device.bedTemperatureChanged.disconnect(self.bedTemperatureChanged) + self._output_device.hotendTemperaturesChanged.disconnect(self.hotendTemperatureChanged) + self._output_device.bedTemperatureChanged.disconnect(self._onBedTemperatureChanged) + self._output_device.hotendTemperaturesChanged.disconnect(self._onHotendTemperatureChanged) + self._output_device.endstopStateChanged.disconnect(self._onEndstopStateChanged) + try: + self._output_device.stopPollEndstop() + except AttributeError: # Connection is probably not a USB connection. Something went pretty wrong if this happens. + pass + self._output_device = None + + # Ensure everything is reset (and right signals are emitted again) + self._bed_test_completed = False + self.onBedTestCompleted.emit() + self._hotend_test_completed = False + self.onHotendTestCompleted.emit() + + self._x_min_endstop_test_completed = False + self.onXMinEndstopTestCompleted.emit() + self._y_min_endstop_test_completed = False + self.onYMinEndstopTestCompleted.emit() + self._z_min_endstop_test_completed = False + self.onZMinEndstopTestCompleted.emit() + + @pyqtProperty(bool, notify = onBedTestCompleted) + def bedTestCompleted(self): + return self._bed_test_completed + + @pyqtProperty(bool, notify = onHotendTestCompleted) + def hotendTestCompleted(self): + return self._hotend_test_completed + + @pyqtProperty(bool, notify = onXMinEndstopTestCompleted) + def xMinEndstopTestCompleted(self): + return self._x_min_endstop_test_completed + + @pyqtProperty(bool, notify=onYMinEndstopTestCompleted) + def yMinEndstopTestCompleted(self): + return self._y_min_endstop_test_completed + + @pyqtProperty(bool, notify=onZMinEndstopTestCompleted) + def zMinEndstopTestCompleted(self): + return self._z_min_endstop_test_completed + + @pyqtProperty(float, notify = bedTemperatureChanged) + def bedTemperature(self): + if not self._output_device: + return 0 + return self._output_device.bedTemperature + + @pyqtProperty(float, notify=hotendTemperatureChanged) + def hotendTemperature(self): + if not self._output_device: + return 0 + return self._output_device.hotendTemperatures[0] + + def _onHotendTemperatureChanged(self): + if not self._output_device: + return + if not self._hotend_test_completed: + if self._output_device.hotendTemperatures[0] + 10 > self._hotend_target_temp and self._output_device.hotendTemperatures[0] - 10 < self._hotend_target_temp: + self._hotend_test_completed = True + self.onHotendTestCompleted.emit() + + def _onBedTemperatureChanged(self): + if not self._output_device: + return + if not self._bed_test_completed: + if self._output_device.bedTemperature + 5 > self._bed_target_temp and self._output_device.bedTemperature - 5 < self._bed_target_temp: + self._bed_test_completed = True + self.onBedTestCompleted.emit() + + def _onEndstopStateChanged(self, switch_type, state): + if state: + if switch_type == "x_min": + self._x_min_endstop_test_completed = True + self.onXMinEndstopTestCompleted.emit() + elif switch_type == "y_min": + self._y_min_endstop_test_completed = True + self.onYMinEndstopTestCompleted.emit() + elif switch_type == "z_min": + self._z_min_endstop_test_completed = True + self.onZMinEndstopTestCompleted.emit() + + @pyqtSlot() + def startCheck(self): + output_devices = self._getPrinterOutputDevices() + if output_devices: + self._output_device = output_devices[0] + try: + self._output_device.startPollEndstop() + self._output_device.bedTemperatureChanged.connect(self.bedTemperatureChanged) + self._output_device.hotendTemperaturesChanged.connect(self.hotendTemperatureChanged) + self._output_device.bedTemperatureChanged.connect(self._onBedTemperatureChanged) + self._output_device.hotendTemperaturesChanged.connect(self._onHotendTemperatureChanged) + self._output_device.endstopStateChanged.connect(self._onEndstopStateChanged) + except AttributeError: # Connection is probably not a USB connection. Something went pretty wrong if this happens. + pass + + @pyqtSlot() + def heatupHotend(self): + if self._output_device is not None: + self._output_device.setTargetHotendTemperature(0, self._hotend_target_temp) + + @pyqtSlot() + def heatupBed(self): + if self._output_device is not None: + self._output_device.setTargetBedTemperature(self._bed_target_temp) \ No newline at end of file diff --git a/plugins/UltimakerMachineActions/UMOCheckupMachineAction.qml b/plugins/UltimakerMachineActions/UMOCheckupMachineAction.qml new file mode 100644 index 0000000000..4b280b0e8e --- /dev/null +++ b/plugins/UltimakerMachineActions/UMOCheckupMachineAction.qml @@ -0,0 +1,267 @@ +import UM 1.2 as UM +import Cura 1.0 as Cura + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import QtQuick.Window 2.1 + +Cura.MachineAction +{ + Item + { + id: checkupMachineAction + anchors.fill: parent; + UM.I18nCatalog { id: catalog; name:"cura"} + Label + { + id: pageTitle + width: parent.width + text: catalog.i18nc("@title", "Check Printer") + wrapMode: Text.WordWrap + font.pointSize: 18; + } + + Label + { + id: pageDescription + anchors.top: pageTitle.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + width: parent.width + wrapMode: Text.WordWrap + text: catalog.i18nc("@label","It's a good idea to do a few sanity checks on your Ultimaker. You can skip this step if you know your machine is functional"); + } + + Item + { + id: startStopButtons + anchors.top: pageDescription.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.horizontalCenter: parent.horizontalCenter + height: childrenRect.height + width: startCheckButton.width + skipCheckButton.width + UM.Theme.getSize("default_margin").height < checkupMachineAction.width ? startCheckButton.width + skipCheckButton.width + UM.Theme.getSize("default_margin").height : checkupMachineAction.width + Button + { + id: startCheckButton + anchors.top: parent.top + anchors.left: parent.left + text: catalog.i18nc("@action:button","Start Printer Check"); + onClicked: + { + checkupContent.visible = true + startCheckButton.enabled = false + manager.startCheck() + } + } + + Button + { + id: skipCheckButton + anchors.top: parent.width < checkupMachineAction.width ? parent.top : startCheckButton.bottom + anchors.topMargin: parent.width < checkupMachineAction.width ? 0 : UM.Theme.getSize("default_margin").height/2 + anchors.left: parent.width < checkupMachineAction.width ? startCheckButton.right : parent.left + anchors.leftMargin: parent.width < checkupMachineAction.width ? UM.Theme.getSize("default_margin").width : 0 + text: catalog.i18nc("@action:button", "Skip Printer Check"); + onClicked: manager.setFinished() + } + } + + Item + { + id: checkupContent + anchors.top: startStopButtons.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + visible: false + ////////////////////////////////////////////////////////// + Label + { + id: connectionLabel + width: checkupMachineAction.leftRow + anchors.left: parent.left + anchors.top: parent.top + wrapMode: Text.WordWrap + text: catalog.i18nc("@label","Connection: ") + } + Label + { + id: connectionStatus + width: checkupMachineAction.rightRow + anchors.left: connectionLabel.right + anchors.top: parent.top + wrapMode: Text.WordWrap + text: Cura.USBPrinterManager.connectedPrinterList.rowCount() > 0 || base.addOriginalProgress.checkUp[0] ? catalog.i18nc("@info:status","Done"):catalog.i18nc("@info:status","Incomplete") + } + ////////////////////////////////////////////////////////// + Label + { + id: endstopXLabel + width: checkupMachineAction.leftRow + anchors.left: parent.left + anchors.top: connectionLabel.bottom + wrapMode: Text.WordWrap + text: catalog.i18nc("@label","Min endstop X: ") + } + Label + { + id: endstopXStatus + width: checkupMachineAction.rightRow + anchors.left: endstopXLabel.right + anchors.top: connectionLabel.bottom + wrapMode: Text.WordWrap + text: manager.xMinEndstopTestCompleted ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked") + } + ////////////////////////////////////////////////////////////// + Label + { + id: endstopYLabel + width: checkupMachineAction.leftRow + anchors.left: parent.left + anchors.top: endstopXLabel.bottom + wrapMode: Text.WordWrap + text: catalog.i18nc("@label","Min endstop Y: ") + } + Label + { + id: endstopYStatus + width: checkupMachineAction.rightRow + anchors.left: endstopYLabel.right + anchors.top: endstopXLabel.bottom + wrapMode: Text.WordWrap + text: manager.yMinEndstopTestCompleted ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked") + } + ///////////////////////////////////////////////////////////////////// + Label + { + id: endstopZLabel + width: checkupMachineAction.leftRow + anchors.left: parent.left + anchors.top: endstopYLabel.bottom + wrapMode: Text.WordWrap + text: catalog.i18nc("@label","Min endstop Z: ") + } + Label + { + id: endstopZStatus + width: checkupMachineAction.rightRow + anchors.left: endstopZLabel.right + anchors.top: endstopYLabel.bottom + wrapMode: Text.WordWrap + text: manager.zMinEndstopTestCompleted ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked") + } + //////////////////////////////////////////////////////////// + Label + { + id: nozzleTempLabel + width: checkupMachineAction.leftRow + anchors.left: parent.left + anchors.top: endstopZLabel.bottom + wrapMode: Text.WordWrap + text: catalog.i18nc("@label","Nozzle temperature check: ") + } + Label + { + id: nozzleTempStatus + width: checkupMachineAction.rightRow * 0.4 + anchors.top: nozzleTempLabel.top + anchors.left: nozzleTempLabel.right + wrapMode: Text.WordWrap + text: catalog.i18nc("@info:status","Not checked") + } + Item + { + id: nozzleTempButton + width: checkupMachineAction.rightRow * 0.3 + height: nozzleTemp.height + anchors.top: nozzleTempLabel.top + anchors.left: bedTempStatus.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width/2 + Button + { + height: nozzleTemp.height - 2 + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: catalog.i18nc("@action:button","Start Heating") + onClicked: + { + manager.heatupHotend() + nozzleTempStatus.text = catalog.i18nc("@info:progress","Checking") + } + } + } + Label + { + id: nozzleTemp + anchors.top: nozzleTempLabel.top + anchors.left: nozzleTempButton.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width + width: checkupMachineAction.rightRow * 0.2 + wrapMode: Text.WordWrap + text: manager.hotendTemperature + "°C" + font.bold: true + } + ///////////////////////////////////////////////////////////////////////////// + Label + { + id: bedTempLabel + width: checkupMachineAction.leftRow + anchors.left: parent.left + anchors.top: nozzleTempLabel.bottom + wrapMode: Text.WordWrap + text: catalog.i18nc("@label","bed temperature check:") + } + + Label + { + id: bedTempStatus + width: checkupMachineAction.rightRow * 0.4 + anchors.top: bedTempLabel.top + anchors.left: bedTempLabel.right + wrapMode: Text.WordWrap + text: catalog.i18nc("@info:status","Not checked") + } + Item + { + id: bedTempButton + width: checkupMachineAction.rightRow * 0.3 + height: bedTemp.height + anchors.top: bedTempLabel.top + anchors.left: bedTempStatus.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width/2 + Button + { + height: bedTemp.height - 2 + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + text: catalog.i18nc("@action:button","Start Heating") + onClicked: + { + manager.heatupBed() + bedTempStatus.text = catalog.i18nc("@info:progress","Checking") + } + } + } + Label + { + id: bedTemp + width: checkupMachineAction.rightRow * 0.2 + anchors.top: bedTempLabel.top + anchors.left: bedTempButton.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width + wrapMode: Text.WordWrap + text: manager.bedTemperature + "°C" + font.bold: true + } + Label + { + id: resultText + visible: false + anchors.top: bedTemp.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.left: parent.left + width: parent.width + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "Everything is in order! You're done with your CheckUp.") + } + } + } +} \ No newline at end of file diff --git a/plugins/UltimakerMachineActions/__init__.py b/plugins/UltimakerMachineActions/__init__.py index 08d6db5076..4536ad7623 100644 --- a/plugins/UltimakerMachineActions/__init__.py +++ b/plugins/UltimakerMachineActions/__init__.py @@ -3,6 +3,7 @@ from . import BedLevelMachineAction from . import UpgradeFirmwareMachineAction +from . import UMOCheckupMachineAction from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") @@ -19,4 +20,4 @@ def getMetaData(): } def register(app): - return { "machine_action": BedLevelMachineAction.BedLevelMachineAction(), "machine_action": UpgradeFirmwareMachineAction.UpgradeFirmwareMachineAction() } + return { "machine_action": BedLevelMachineAction.BedLevelMachineAction(), "machine_action": UpgradeFirmwareMachineAction.UpgradeFirmwareMachineAction(), "machine_action": UMOCheckupMachineAction.UMOCheckupMachineAction()} From 9641a25f3136cab0c7ccde85b74fac5158654462 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Wed, 22 Jun 2016 14:48:15 +0200 Subject: [PATCH 081/112] Fixed up the convex hull 'shadow' creation and deletion after the merge. Contributes to CURA-1504 --- cura/ConvexHullDecorator.py | 32 ++++++++++++++++++++++++++++---- cura/ConvexHullNode.py | 14 -------------- cura/CuraApplication.py | 1 - 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index fab22f898e..29fa3bce0a 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -19,6 +19,19 @@ class ConvexHullDecorator(SceneNodeDecorator): Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged) self._onGlobalStackChanged() + def setNode(self, node): + previous_node = self._node + if previous_node is not None and node is not previous_node: + previous_node.transformationChanged.connect(self._onChanged) + previous_node.parentChanged.connect(self._onChanged) + + super().setNode(node) + + self._node.transformationChanged.connect(self._onChanged) + self._node.parentChanged.connect(self._onChanged) + + self._onChanged() + ## Force that a new (empty) object is created upon copy. def __deepcopy__(self, memo): return ConvexHullDecorator() @@ -67,16 +80,19 @@ class ConvexHullDecorator(SceneNodeDecorator): return None def recomputeConvexHull(self): - if self._node is None: - return None + root = Application.getInstance().getController().getScene().getRoot() + if self._node is None or not self.__isDescendant(root, self._node): + if self._convex_hull_node: + self._convex_hull_node.setParent(None) + self._convex_hull_node = None + return convex_hull = self.getConvexHull() if self._convex_hull_node: if self._convex_hull_node.getHull() == convex_hull: return self._convex_hull_node.setParent(None) - hull_node = ConvexHullNode.ConvexHullNode(self._node, convex_hull, - Application.getInstance().getController().getScene().getRoot()) + hull_node = ConvexHullNode.ConvexHullNode(self._node, convex_hull, root) self._convex_hull_node = hull_node def _onSettingValueChanged(self, key, property_name): @@ -205,3 +221,11 @@ class ConvexHullDecorator(SceneNodeDecorator): self._global_stack.containersChanged.connect(self._onChanged) self._onChanged() + + ## Returns true if node is a descendent or the same as the root node. + def __isDescendant(self, root, node): + if node is None: + return False + if root is node: + return True + return self.__isDescendant(root, node.getParent()) diff --git a/cura/ConvexHullNode.py b/cura/ConvexHullNode.py index 2d88604b6e..be571d111e 100644 --- a/cura/ConvexHullNode.py +++ b/cura/ConvexHullNode.py @@ -1,7 +1,6 @@ # Copyright (c) 2015 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -from UM.Application import Application from UM.Scene.SceneNode import SceneNode from UM.Resources import Resources from UM.Math.Color import Color @@ -31,8 +30,6 @@ class ConvexHullNode(SceneNode): # The node this mesh is "watching" self._node = node - self._node.transformationChanged.connect(self._onNodePositionChanged) - self._node.parentChanged.connect(self._onNodeParentChanged) self._node.decoratorsChanged.connect(self._onNodeDecoratorsChanged) self._onNodeDecoratorsChanged(self._node) @@ -84,17 +81,6 @@ class ConvexHullNode(SceneNode): return True - def _onNodePositionChanged(self, node): - if Application.getInstance().getController().isToolOperationActive(): - if node.callDecoration("getConvexHull"): - self.setParent(None) # Garbage collection should delete this node after a while. - - def _onNodeParentChanged(self, node): - if node.getParent(): - self.setParent(self._original_parent) - else: - self.setParent(None) - def _onNodeDecoratorsChanged(self, node): self._color = Color(35, 35, 35, 0.5) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index c9e7e701c4..12818e1e87 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -741,7 +741,6 @@ class CuraApplication(QtApplication): # Add all individual nodes to the selection Selection.add(child) - child.callDecoration("setConvexHull", None) op.push() # Note: The group removes itself from the scene once all its children have left it, From 5aab4686cafec09361b8b8700b4e2fb2540efef0 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 14:50:05 +0200 Subject: [PATCH 082/112] Layout fixes CURA-1385 --- .../UltimakerMachineActions/UMOCheckupMachineAction.qml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/UltimakerMachineActions/UMOCheckupMachineAction.qml b/plugins/UltimakerMachineActions/UMOCheckupMachineAction.qml index 4b280b0e8e..1c3ac84010 100644 --- a/plugins/UltimakerMachineActions/UMOCheckupMachineAction.qml +++ b/plugins/UltimakerMachineActions/UMOCheckupMachineAction.qml @@ -8,10 +8,13 @@ import QtQuick.Window 2.1 Cura.MachineAction { + anchors.fill: parent; Item { id: checkupMachineAction anchors.fill: parent; + property int leftRow: checkupMachineAction.width * 0.40 + property int rightRow: checkupMachineAction.width * 0.60 UM.I18nCatalog { id: catalog; name:"cura"} Label { @@ -72,6 +75,8 @@ Cura.MachineAction anchors.top: startStopButtons.bottom anchors.topMargin: UM.Theme.getSize("default_margin").height visible: false + width: parent.width + height: 250 ////////////////////////////////////////////////////////// Label { @@ -217,7 +222,7 @@ Cura.MachineAction anchors.top: bedTempLabel.top anchors.left: bedTempLabel.right wrapMode: Text.WordWrap - text: catalog.i18nc("@info:status","Not checked") + text: manager.bedTestCompleted ? catalog.i18nc("@info:status","Not checked"): catalog.i18nc("@info:status","Checked") } Item { @@ -236,7 +241,6 @@ Cura.MachineAction onClicked: { manager.heatupBed() - bedTempStatus.text = catalog.i18nc("@info:progress","Checking") } } } From 631ef8e6784f38aa8948809eae4ba369e438e1c9 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Wed, 22 Jun 2016 15:06:03 +0200 Subject: [PATCH 083/112] Reimplement the "no convex hull when using a tool" functionality. Contributes to CURA-1504 --- cura/ConvexHullDecorator.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index 29fa3bce0a..9fccd46988 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -17,6 +17,9 @@ class ConvexHullDecorator(SceneNodeDecorator): self._global_stack = None Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged) + Application.getInstance().getController().toolOperationStarted.connect(self._onChanged) + Application.getInstance().getController().toolOperationStopped.connect(self._onChanged) + self._onGlobalStackChanged() def setNode(self, node): @@ -80,8 +83,9 @@ class ConvexHullDecorator(SceneNodeDecorator): return None def recomputeConvexHull(self): - root = Application.getInstance().getController().getScene().getRoot() - if self._node is None or not self.__isDescendant(root, self._node): + controller = Application.getInstance().getController() + root = controller.getScene().getRoot() + if self._node is None or controller.isToolOperationActive() or not self.__isDescendant(root, self._node): if self._convex_hull_node: self._convex_hull_node.setParent(None) self._convex_hull_node = None From 4e854700f1525b60c530f9b3e7509128fe6d21cb Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 15:24:37 +0200 Subject: [PATCH 084/112] Machine_action plugin objects are now added as list CURA-1385 --- plugins/UltimakerMachineActions/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UltimakerMachineActions/__init__.py b/plugins/UltimakerMachineActions/__init__.py index 4536ad7623..39734d00e3 100644 --- a/plugins/UltimakerMachineActions/__init__.py +++ b/plugins/UltimakerMachineActions/__init__.py @@ -20,4 +20,4 @@ def getMetaData(): } def register(app): - return { "machine_action": BedLevelMachineAction.BedLevelMachineAction(), "machine_action": UpgradeFirmwareMachineAction.UpgradeFirmwareMachineAction(), "machine_action": UMOCheckupMachineAction.UMOCheckupMachineAction()} + return { "machine_action": [BedLevelMachineAction.BedLevelMachineAction(), UpgradeFirmwareMachineAction.UpgradeFirmwareMachineAction(), UMOCheckupMachineAction.UMOCheckupMachineAction()]} From b62118dc1cb8ff2287a80a51387aae4ab9b6d836 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 15:29:54 +0200 Subject: [PATCH 085/112] Added supported actions to all UM machines CURA-1385 --- resources/definitions/ultimaker2.def.json | 3 ++- resources/definitions/ultimaker2_extended.def.json | 3 ++- resources/definitions/ultimaker2_extended_plus.def.json | 3 ++- resources/definitions/ultimaker2_go.def.json | 3 ++- resources/definitions/ultimaker2_plus.def.json | 3 ++- resources/definitions/ultimaker_original.def.json | 7 +------ resources/definitions/ultimaker_original_plus.def.json | 6 +----- 7 files changed, 12 insertions(+), 16 deletions(-) diff --git a/resources/definitions/ultimaker2.def.json b/resources/definitions/ultimaker2.def.json index 7b2222e5b3..ec1c97fd2c 100644 --- a/resources/definitions/ultimaker2.def.json +++ b/resources/definitions/ultimaker2.def.json @@ -12,7 +12,8 @@ "icon": "icon_ultimaker2.png", "platform": "ultimaker2_platform.obj", "platform_texture": "Ultimaker2backplate.png", - "platform_offset": [9, 0, 0] + "platform_offset": [9, 0, 0], + "supported_actions":["UpgradeFirmware"] }, "overrides": { "machine_start_gcode" : { diff --git a/resources/definitions/ultimaker2_extended.def.json b/resources/definitions/ultimaker2_extended.def.json index e3c7d1fd01..cead008643 100644 --- a/resources/definitions/ultimaker2_extended.def.json +++ b/resources/definitions/ultimaker2_extended.def.json @@ -10,7 +10,8 @@ "file_formats": "text/x-gcode", "icon": "icon_ultimaker2.png", "platform": "ultimaker2_platform.obj", - "platform_texture": "Ultimaker2Extendedbackplate.png" + "platform_texture": "Ultimaker2Extendedbackplate.png", + "supported_actions": ["UpgradeFirmware"] }, "overrides": { diff --git a/resources/definitions/ultimaker2_extended_plus.def.json b/resources/definitions/ultimaker2_extended_plus.def.json index 50f0e73b9f..23b308461d 100644 --- a/resources/definitions/ultimaker2_extended_plus.def.json +++ b/resources/definitions/ultimaker2_extended_plus.def.json @@ -9,7 +9,8 @@ "category": "Ultimaker", "file_formats": "text/x-gcode", "platform": "ultimaker2_platform.obj", - "platform_texture": "Ultimaker2ExtendedPlusbackplate.png" + "platform_texture": "Ultimaker2ExtendedPlusbackplate.png", + "supported_actions":["UpgradeFirmware"] }, "overrides": { diff --git a/resources/definitions/ultimaker2_go.def.json b/resources/definitions/ultimaker2_go.def.json index d3ef53d633..27b179eef9 100644 --- a/resources/definitions/ultimaker2_go.def.json +++ b/resources/definitions/ultimaker2_go.def.json @@ -11,7 +11,8 @@ "icon": "icon_ultimaker2.png", "platform": "ultimaker2go_platform.obj", "platform_texture": "Ultimaker2Gobackplate.png", - "platform_offset": [0, 0, 0] + "platform_offset": [0, 0, 0], + "supported_actions":["UpgradeFirmware"] }, "overrides": { diff --git a/resources/definitions/ultimaker2_plus.def.json b/resources/definitions/ultimaker2_plus.def.json index 4432fab170..d5a7c9f4f1 100644 --- a/resources/definitions/ultimaker2_plus.def.json +++ b/resources/definitions/ultimaker2_plus.def.json @@ -16,7 +16,8 @@ "has_variants": true, "has_materials": true, "has_machine_materials": true, - "has_machine_quality": true + "has_machine_quality": true, + "supported_actions":["UpgradeFirmware"] }, "overrides": { diff --git a/resources/definitions/ultimaker_original.def.json b/resources/definitions/ultimaker_original.def.json index 55668946a0..16fcf49ab7 100644 --- a/resources/definitions/ultimaker_original.def.json +++ b/resources/definitions/ultimaker_original.def.json @@ -14,12 +14,7 @@ "has_materials": true, "preferred_material": "*pla*", "preferred_quality": "*normal*", - "pages": [ - "SelectUpgradedParts", - "UpgradeFirmware", - "UltimakerCheckup", - "BedLeveling" - ] + "supported_actions":[ "UMOCheckup", "UpgradeFirmware"] }, "overrides": { diff --git a/resources/definitions/ultimaker_original_plus.def.json b/resources/definitions/ultimaker_original_plus.def.json index 830050beb0..566573aa00 100644 --- a/resources/definitions/ultimaker_original_plus.def.json +++ b/resources/definitions/ultimaker_original_plus.def.json @@ -11,11 +11,7 @@ "icon": "icon_ultimaker.png", "platform": "ultimaker2_platform.obj", "platform_texture": "UltimakerPlusbackplate.png", - "pages": [ - "UpgradeFirmware", - "UltimakerCheckup", - "BedLeveling" - ] + "supported_actions":[ "UMOCheckup", "UpgradeFirmware", "BedLevel"] }, "overrides": { From 1912722d316eb88691acb89cec02107cde56748e Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 15:35:23 +0200 Subject: [PATCH 086/112] Fixed requesting size of machine for bedLeveling CURA-1385 --- plugins/UltimakerMachineActions/BedLevelMachineAction.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.py b/plugins/UltimakerMachineActions/BedLevelMachineAction.py index 7a424d9cb4..b6b52c552e 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.py +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.py @@ -36,17 +36,17 @@ class BedLevelMachineAction(MachineAction): output_device.moveHead(0, 0, 3) output_device.homeHead() output_device.moveHead(0, 0, 3) - output_device.moveHead(Application.getInstance().getGlobalContainerStack().getProperty("machine_width") - 10, 0, 0) + output_device.moveHead(Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") - 10, 0, 0) output_device.moveHead(0, 0, -3) self._bed_level_position += 1 elif self._bed_level_position == 1: output_device.moveHead(0, 0, 3) - output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width") / 2, Application.getInstance().getGlobalContainerStack().getProperty("machine_depth") - 10, 0) + output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value" ) / 2, Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") - 10, 0) output_device.moveHead(0, 0, -3) self._bed_level_position += 1 elif self._bed_level_position == 2: output_device.moveHead(0, 0, 3) - output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width") / 2 + 10, -(Application.getInstance().getGlobalContainerStack().getProperty("machine_depth") + 10), 0) + output_device.moveHead(-Application.getInstance().getGlobalContainerStack().getProperty("machine_width", "value") / 2 + 10, -(Application.getInstance().getGlobalContainerStack().getProperty("machine_depth", "value") + 10), 0) output_device.moveHead(0, 0, -3) self._bed_level_position += 1 elif self._bed_level_position >= 3: From 458749ca4e90db88817b40df2e971eb524f5ba5d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 15:35:44 +0200 Subject: [PATCH 087/112] Removed old wizard pages CURA-1385 --- resources/qml/WizardPages/AddMachine.qml | 243 ----------- resources/qml/WizardPages/Bedleveling.qml | 132 ------ .../qml/WizardPages/SelectUpgradedParts.qml | 85 ---- .../qml/WizardPages/UltimakerCheckup.qml | 378 ------------------ resources/qml/WizardPages/UpgradeFirmware.qml | 78 ---- 5 files changed, 916 deletions(-) delete mode 100644 resources/qml/WizardPages/AddMachine.qml delete mode 100644 resources/qml/WizardPages/Bedleveling.qml delete mode 100644 resources/qml/WizardPages/SelectUpgradedParts.qml delete mode 100644 resources/qml/WizardPages/UltimakerCheckup.qml delete mode 100644 resources/qml/WizardPages/UpgradeFirmware.qml diff --git a/resources/qml/WizardPages/AddMachine.qml b/resources/qml/WizardPages/AddMachine.qml deleted file mode 100644 index e4d40d7723..0000000000 --- a/resources/qml/WizardPages/AddMachine.qml +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright (c) 2015 Ultimaker B.V. -// Cura is released under the terms of the AGPLv3 or higher. - -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Window 2.1 -import QtQuick.Controls.Styles 1.1 - -import UM 1.1 as UM - -Item -{ - id: base - - property string activeManufacturer: "Ultimaker"; - - property variant wizard: null; - - property bool visibility: base.wizard.visible - onVisibilityChanged: - { - machineName.text = getMachineName() - } - - function getMachineName() - { - var name = machineList.model.getItem(machineList.currentIndex).name - - return name - } - - Connections - { - target: base.wizard - onNextClicked: //You can add functions here that get triggered when the final button is clicked in the wizard-element - { - base.wizard.resetPages() - saveMachine() - } - onBackClicked: base.wizard.resetPages() - } - - Label - { - id: title - anchors.left: parent.left - anchors.top: parent.top - text: catalog.i18nc("@title", "Add Printer") - font.pointSize: 18; - } - - Label - { - id: subTitle - anchors.left: parent.left - anchors.top: title.bottom - text: catalog.i18nc("@label", "Please select the type of printer:"); - } - - ScrollView - { - id: machinesHolder - - anchors - { - left: parent.left; - top: subTitle.bottom; - right: parent.right; - bottom: machineNameHolder.top; - } - - ListView - { - id: machineList - - model: UM.MachineDefinitionsModel { id: machineDefinitionsModel; showVariants: false; } - focus: true - - section.property: "manufacturer" - section.delegate: Button { - text: section - style: ButtonStyle { - background: Rectangle { - border.width: 0 - color: "transparent"; - height: UM.Theme.getSize("standard_list_lineheight").height - width: machineList.width - } - label: Label { - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("standard_arrow").width + UM.Theme.getSize("default_margin").width - text: control.text - color: palette.windowText - font.bold: true - UM.RecolorImage { - id: downArrow - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.left - anchors.rightMargin: UM.Theme.getSize("default_margin").width - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - sourceSize.width: width - sourceSize.height: width - color: palette.windowText - source: base.activeManufacturer == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right") - } - } - } - - onClicked: { - base.activeManufacturer = section; - machineList.currentIndex = machineList.model.find("manufacturer", section) - machineName.text = getMachineName() - } - } - - delegate: RadioButton { - id: machineButton - - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("standard_list_lineheight").width - - opacity: 1; - height: UM.Theme.getSize("standard_list_lineheight").height; - - checked: ListView.isCurrentItem; - - exclusiveGroup: printerGroup; - - text: model.name - - onClicked: { - ListView.view.currentIndex = index; - machineName.text = getMachineName() - } - - states: State { - name: "collapsed"; - when: base.activeManufacturer != model.manufacturer; - - PropertyChanges { target: machineButton; opacity: 0; height: 0; } - } - - transitions: [ - Transition { - to: "collapsed"; - SequentialAnimation { - NumberAnimation { property: "opacity"; duration: 75; } - NumberAnimation { property: "height"; duration: 75; } - } - }, - Transition { - from: "collapsed"; - SequentialAnimation { - NumberAnimation { property: "height"; duration: 75; } - NumberAnimation { property: "opacity"; duration: 75; } - } - } - ] - } - } - } - - - - Column - { - id: machineNameHolder - anchors.bottom: parent.bottom; - - Item - { - height: errorMessage.lineHeight - anchors.bottom: insertNameLabel.top - anchors.bottomMargin: insertNameLabel.height * errorMessage.lineCount - Label - { - id: errorMessage - property bool show: false - width: base.width - height: errorMessage.show ? errorMessage.lineHeight : 0 - visible: errorMessage.show - text: catalog.i18nc("@label", "This printer name has already been used. Please choose a different printer name."); - wrapMode: Text.WordWrap - Behavior on height {NumberAnimation {duration: 75; }} - color: UM.Theme.getColor("error") - } - } - - Label - { - id: insertNameLabel - text: catalog.i18nc("@label:textbox", "Printer Name:"); - } - TextField - { - id: machineName; - text: getMachineName() - implicitWidth: UM.Theme.getSize("standard_list_input").width - maximumLength: 40 - } - } - - function saveMachine() - { - if(machineList.currentIndex != -1) - { - var item = machineList.model.getItem(machineList.currentIndex); - machineList.model.createInstance(machineName.text, item.id) - - var pages = machineList.model.getItem(machineList.currentIndex).pages - - // Insert new pages (if any) - for(var i = 0; i < pages.length; i++) - { - switch(pages[i]) { - case "SelectUpgradedParts": - base.wizard.appendPage(Qt.resolvedUrl("SelectUpgradedParts.qml"), catalog.i18nc("@title", "Select Upgraded Parts")); - break; - case "SelectUpgradedPartsUM2": - base.wizard.appendPage(Qt.resolvedUrl("SelectUpgradedPartsUM2.qml"), catalog.i18nc("@title", "Select Upgraded Parts")); - break; - case "UpgradeFirmware": - base.wizard.appendPage(Qt.resolvedUrl("UpgradeFirmware.qml"), catalog.i18nc("@title", "Upgrade Firmware")); - break; - case "UltimakerCheckup": - base.wizard.appendPage(Qt.resolvedUrl("UltimakerCheckup.qml"), catalog.i18nc("@title", "Check Printer")); - break; - case "BedLeveling": - base.wizard.appendPage(Qt.resolvedUrl("Bedleveling.qml"), catalog.i18nc("@title", "Bed Levelling")); - break; - default: - base.wizard.appendPage(Qt.resolvedUrl("%1.qml".arg(pages[i])), pages[i]) - break; - } - } - } - } - - ExclusiveGroup { id: printerGroup; } - UM.I18nCatalog { id: catalog; name: "cura"; } - SystemPalette { id: palette } -} diff --git a/resources/qml/WizardPages/Bedleveling.qml b/resources/qml/WizardPages/Bedleveling.qml deleted file mode 100644 index 1a7b85a07b..0000000000 --- a/resources/qml/WizardPages/Bedleveling.qml +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) 2015 Ultimaker B.V. -// Cura is released under the terms of the AGPLv3 or higher. - -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Layouts 1.1 -import QtQuick.Window 2.1 - -import UM 1.1 as UM -import Cura 1.0 as Cura -import ".." - -Item -{ - id: wizardPage - property int leveling_state: 0 - property bool three_point_leveling: true - property int platform_width: UM.MachineManager.getSettingValue("machine_width") - property int platform_height: UM.MachineManager.getSettingValue("machine_depth") - anchors.fill: parent; - property variant printer_connection: Cura.USBPrinterManager.connectedPrinterList.getItem(0).printer - Component.onCompleted: - { - printer_connection.homeBed() - printer_connection.moveHead(0, 0, 3) - printer_connection.homeHead() - } - UM.I18nCatalog { id: catalog; name:"cura"} - property variant wizard: null; - - Label - { - id: pageTitle - width: parent.width - text: catalog.i18nc("@title", "Bed Leveling") - wrapMode: Text.WordWrap - font.pointSize: 18; - } - - Label - { - id: pageDescription - anchors.top: pageTitle.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","To make sure your prints will come out great, you can now adjust your buildplate. When you click 'Move to Next Position' the nozzle will move to the different positions that can be adjusted.") - } - Label - { - id: bedlevelingText - anchors.top: pageDescription.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label", "For every postition; insert a piece of paper under the nozzle and adjust the print bed height. The print bed height is right when the paper is slightly gripped by the tip of the nozzle.") - } - - Item{ - id: bedlevelingWrapper - anchors.top: bedlevelingText.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.horizontalCenter: parent.horizontalCenter - height: skipBedlevelingButton.height - width: bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height < wizardPage.width ? bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height : wizardPage.width - Button - { - id: bedlevelingButton - anchors.top: parent.top - anchors.left: parent.left - text: catalog.i18nc("@action:button","Move to Next Position"); - onClicked: - { - if(wizardPage.leveling_state == 0) - { - printer_connection.moveHead(0, 0, 3) - printer_connection.homeHead() - printer_connection.moveHead(0, 0, 3) - printer_connection.moveHead(platform_width - 10, 0, 0) - printer_connection.moveHead(0, 0, -3) - } - if(wizardPage.leveling_state == 1) - { - printer_connection.moveHead(0, 0, 3) - printer_connection.moveHead(-platform_width/2, platform_height - 10, 0) - printer_connection.moveHead(0, 0, -3) - } - if(wizardPage.leveling_state == 2) - { - printer_connection.moveHead(0, 0, 3) - printer_connection.moveHead(-platform_width/2 + 10, -(platform_height + 10), 0) - printer_connection.moveHead(0, 0, -3) - } - wizardPage.leveling_state++ - if (wizardPage.leveling_state >= 3){ - resultText.visible = true - skipBedlevelingButton.enabled = false - bedlevelingButton.enabled = false - wizardPage.leveling_state = 0 - } - } - } - - Button - { - id: skipBedlevelingButton - anchors.top: parent.width < wizardPage.width ? parent.top : bedlevelingButton.bottom - anchors.topMargin: parent.width < wizardPage.width ? 0 : UM.Theme.getSize("default_margin").height/2 - anchors.left: parent.width < wizardPage.width ? bedlevelingButton.right : parent.left - anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0 - text: catalog.i18nc("@action:button","Skip Bedleveling"); - onClicked: base.nextPage() - } - } - - Label - { - id: resultText - visible: false - anchors.top: bedlevelingWrapper.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.left: parent.left - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label", "Everything is in order! You're done with bedleveling.") - } - - function threePointLeveling(width, height) - { - - } -} diff --git a/resources/qml/WizardPages/SelectUpgradedParts.qml b/resources/qml/WizardPages/SelectUpgradedParts.qml deleted file mode 100644 index a49401ada9..0000000000 --- a/resources/qml/WizardPages/SelectUpgradedParts.qml +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2015 Ultimaker B.V. -// Cura is released under the terms of the AGPLv3 or higher. - -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Window 2.1 - -import UM 1.1 as UM - -Item -{ - id: wizardPage - property string title - - SystemPalette{id: palette} - UM.I18nCatalog { id: catalog; name:"cura"} - - Component.onDestruction: - { - if (heatedBedCheckBox1.checked == true || heatedBedCheckBox2.checked == true){ - UM.MachineManager.setMachineSettingValue("machine_heated_bed", true) - } - } - Label - { - id: pageTitle - width: parent.width - text: catalog.i18nc("@title", "Select Upgraded Parts") - wrapMode: Text.WordWrap - font.pointSize: 18 - } - Label - { - id: pageDescription - anchors.top: pageTitle.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","To assist you in having better default settings for your Ultimaker. Cura would like to know which upgrades you have in your machine:") - } - - Item - { - id: pageCheckboxes - height: childrenRect.height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.top: pageDescription.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width - UM.Theme.getSize("default_margin").width - CheckBox - { - id: heatedBedCheckBox1 - text: catalog.i18nc("@option:check","Heated printer bed") - y: extruderCheckBox.height * 1 - checked: false - onClicked: { - if (heatedBedCheckBox2.checked == true) - heatedBedCheckBox2.checked = false - } - } - CheckBox - { - id: heatedBedCheckBox2 - text: catalog.i18nc("@option:check","Heated printer bed (self built)") - y: extruderCheckBox.height * 2 - checked: false - onClicked: { - if (heatedBedCheckBox1.checked == true) - heatedBedCheckBox1.checked = false - } - } - } - - Label - { - width: parent.width - anchors.top: pageCheckboxes.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","If you bought your Ultimaker after october 2012 you will have the Extruder drive upgrade. If you do not have this upgrade, it is highly recommended to improve reliability. This upgrade can be bought from the Ultimaker webshop or found on thingiverse as thing:26094"); - } - - ExclusiveGroup { id: printerGroup; } -} diff --git a/resources/qml/WizardPages/UltimakerCheckup.qml b/resources/qml/WizardPages/UltimakerCheckup.qml deleted file mode 100644 index a57174a53d..0000000000 --- a/resources/qml/WizardPages/UltimakerCheckup.qml +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright (c) 2015 Ultimaker B.V. -// Cura is released under the terms of the AGPLv3 or higher. - -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Window 2.1 - -import UM 1.1 as UM - -Item -{ - id: wizardPage - property string title - property int leftRow: wizardPage.width*0.40 - property int rightRow: wizardPage.width*0.60 - anchors.fill: parent; - property bool x_min_pressed: false - property bool y_min_pressed: false - property bool z_min_pressed: false - property bool heater_works: false - property int extruder_target_temp: 0 - property int bed_target_temp: 0 - UM.I18nCatalog { id: catalog; name:"cura"} - property var checkupProgress: { - "connection": false, - "endstopX": wizardPage.x_min_pressed, - "endstopY": wizardPage.y_min_pressed, - "endstopZ": wizardPage.z_min_pressed, - "nozzleTemp": false, - "bedTemp": false - } - - property variant printer_connection: { - if (Cura.USBPrinterManager.connectedPrinterList.rowCount() != 0){ - wizardPage.checkupProgress.connection = true - return Cura.USBPrinterManager.connectedPrinterList.getItem(0).printer - } - else { - return null - } - } - - function checkTotalCheckUp(){ - var allDone = true - for(var property in checkupProgress){ - if (checkupProgress[property] == false){ - allDone = false - } - } - if (allDone == true){ - skipCheckButton.enabled = false - resultText.visible = true - } - } - - Component.onCompleted: - { - if (printer_connection != null){ - printer_connection.startPollEndstop() - } - } - Component.onDestruction: - { - if (printer_connection != null){ - printer_connection.stopPollEndstop() - } - } - Label - { - id: pageTitle - width: parent.width - text: catalog.i18nc("@title", "Check Printer") - wrapMode: Text.WordWrap - font.pointSize: 18; - } - - Label - { - id: pageDescription - anchors.top: pageTitle.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","It's a good idea to do a few sanity checks on your Ultimaker. You can skip this step if you know your machine is functional"); - } - - Item{ - id: startStopButtons - anchors.top: pageDescription.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.horizontalCenter: parent.horizontalCenter - height: childrenRect.height - width: startCheckButton.width + skipCheckButton.width + UM.Theme.getSize("default_margin").height < wizardPage.width ? startCheckButton.width + skipCheckButton.width + UM.Theme.getSize("default_margin").height : wizardPage.width - Button - { - id: startCheckButton - anchors.top: parent.top - anchors.left: parent.left - //enabled: !alreadyTested - text: catalog.i18nc("@action:button","Start Printer Check"); - onClicked: { - checkupContent.visible = true - startCheckButton.enabled = false - printer_connection.homeHead() - } - } - - Button - { - id: skipCheckButton - anchors.top: parent.width < wizardPage.width ? parent.top : startCheckButton.bottom - anchors.topMargin: parent.width < wizardPage.width ? 0 : UM.Theme.getSize("default_margin").height/2 - anchors.left: parent.width < wizardPage.width ? startCheckButton.right : parent.left - anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0 - //enabled: !alreadyTested - text: catalog.i18nc("@action:button","Skip Printer Check"); - onClicked: base.nextPage() - } - } - - Item{ - id: checkupContent - anchors.top: startStopButtons.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - visible: false - ////////////////////////////////////////////////////////// - Label - { - id: connectionLabel - width: wizardPage.leftRow - anchors.left: parent.left - anchors.top: parent.top - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","Connection: ") - } - Label - { - id: connectionStatus - width: wizardPage.rightRow - anchors.left: connectionLabel.right - anchors.top: parent.top - wrapMode: Text.WordWrap - text: Cura.USBPrinterManager.connectedPrinterList.rowCount() > 0 || base.addOriginalProgress.checkUp[0] ? catalog.i18nc("@info:status","Done"):catalog.i18nc("@info:status","Incomplete") - } - ////////////////////////////////////////////////////////// - Label - { - id: endstopXLabel - width: wizardPage.leftRow - anchors.left: parent.left - anchors.top: connectionLabel.bottom - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","Min endstop X: ") - } - Label - { - id: endstopXStatus - width: wizardPage.rightRow - anchors.left: endstopXLabel.right - anchors.top: connectionLabel.bottom - wrapMode: Text.WordWrap - text: x_min_pressed ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked") - } - ////////////////////////////////////////////////////////////// - Label - { - id: endstopYLabel - width: wizardPage.leftRow - anchors.left: parent.left - anchors.top: endstopXLabel.bottom - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","Min endstop Y: ") - } - Label - { - id: endstopYStatus - width: wizardPage.rightRow - anchors.left: endstopYLabel.right - anchors.top: endstopXLabel.bottom - wrapMode: Text.WordWrap - text: y_min_pressed ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked") - } - ///////////////////////////////////////////////////////////////////// - Label - { - id: endstopZLabel - width: wizardPage.leftRow - anchors.left: parent.left - anchors.top: endstopYLabel.bottom - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","Min endstop Z: ") - } - Label - { - id: endstopZStatus - width: wizardPage.rightRow - anchors.left: endstopZLabel.right - anchors.top: endstopYLabel.bottom - wrapMode: Text.WordWrap - text: z_min_pressed ? catalog.i18nc("@info:status","Works") : catalog.i18nc("@info:status","Not checked") - } - //////////////////////////////////////////////////////////// - Label - { - id: nozzleTempLabel - width: wizardPage.leftRow - anchors.left: parent.left - anchors.top: endstopZLabel.bottom - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","Nozzle temperature check: ") - } - Label - { - id: nozzleTempStatus - width: wizardPage.rightRow * 0.4 - anchors.top: nozzleTempLabel.top - anchors.left: nozzleTempLabel.right - wrapMode: Text.WordWrap - text: catalog.i18nc("@info:status","Not checked") - } - Item - { - id: nozzleTempButton - width: wizardPage.rightRow * 0.3 - height: nozzleTemp.height - anchors.top: nozzleTempLabel.top - anchors.left: bedTempStatus.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width/2 - Button - { - height: nozzleTemp.height - 2 - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - text: catalog.i18nc("@action:button","Start Heating") - onClicked: - { - if(printer_connection != null) - { - nozzleTempStatus.text = catalog.i18nc("@info:progress","Checking") - printer_connection.setTargetHotendTemperature(0, 190) - wizardPage.extruder_target_temp = 190 - } - } - } - } - Label - { - id: nozzleTemp - anchors.top: nozzleTempLabel.top - anchors.left: nozzleTempButton.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width - width: wizardPage.rightRow * 0.2 - wrapMode: Text.WordWrap - text: printer_connection != null ? printer_connection.hotendTemperatures[0] + "°C" : "0°C" - font.bold: true - } - ///////////////////////////////////////////////////////////////////////////// - Label - { - id: bedTempLabel - width: wizardPage.leftRow - anchors.left: parent.left - anchors.top: nozzleTempLabel.bottom - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","bed temperature check:") - } - - Label - { - id: bedTempStatus - width: wizardPage.rightRow * 0.4 - anchors.top: bedTempLabel.top - anchors.left: bedTempLabel.right - wrapMode: Text.WordWrap - text: catalog.i18nc("@info:status","Not checked") - } - Item - { - id: bedTempButton - width: wizardPage.rightRow * 0.3 - height: bedTemp.height - anchors.top: bedTempLabel.top - anchors.left: bedTempStatus.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width/2 - Button - { - height: bedTemp.height - 2 - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - text: catalog.i18nc("@action:button","Start Heating") - onClicked: - { - if(printer_connection != null) - { - bedTempStatus.text = catalog.i18nc("@info:progress","Checking") - printer_connection.setTargetBedTemperature(60) - wizardPage.bed_target_temp = 60 - } - } - } - } - Label - { - id: bedTemp - width: wizardPage.rightRow * 0.2 - anchors.top: bedTempLabel.top - anchors.left: bedTempButton.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width - wrapMode: Text.WordWrap - text: printer_connection != null ? printer_connection.bedTemperature + "°C": "0°C" - font.bold: true - } - Label - { - id: resultText - visible: false - anchors.top: bedTemp.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.left: parent.left - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label", "Everything is in order! You're done with your CheckUp.") - } - } - - - Connections - { - target: printer_connection - onEndstopStateChanged: - { - if(key == "x_min") - { - x_min_pressed = true - checkTotalCheckUp() - } - if(key == "y_min") - { - y_min_pressed = true - checkTotalCheckUp() - } - if(key == "z_min") - { - z_min_pressed = true - checkTotalCheckUp() - } - } - - onHotendTemperaturesChanged: - { - if(printer_connection.hotendTemperatures[0] > wizardPage.extruder_target_temp - 10 && printer_connection.hotendTemperatures[0] < wizardPage.extruder_target_temp + 10) - { - if(printer_connection != null) - { - nozzleTempStatus.text = catalog.i18nc("@info:status","Works") - wizardPage.checkupProgress.nozzleTemp = true - checkTotalCheckUp() - printer_connection.setTargetHotendTemperature(0, 0) - } - } - } - onBedTemperatureChanged: - { - if(printer_connection.bedTemperature > wizardPage.bed_target_temp - 5 && printer_connection.bedTemperature < wizardPage.bed_target_temp + 5) - { - bedTempStatus.text = catalog.i18nc("@info:status","Works") - wizardPage.checkupProgress.bedTemp = true - checkTotalCheckUp() - printer_connection.setTargetBedTemperature(0) - } - } - } - - ExclusiveGroup - { - id: printerGroup; - } -} \ No newline at end of file diff --git a/resources/qml/WizardPages/UpgradeFirmware.qml b/resources/qml/WizardPages/UpgradeFirmware.qml deleted file mode 100644 index 18bad132c6..0000000000 --- a/resources/qml/WizardPages/UpgradeFirmware.qml +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2015 Ultimaker B.V. -// Cura is released under the terms of the AGPLv3 or higher. - -import QtQuick 2.2 -import QtQuick.Controls 1.1 -import QtQuick.Window 2.1 - -import UM 1.1 as UM - -Item -{ - id: wizardPage - property string title - - SystemPalette{id: palette} - UM.I18nCatalog { id: catalog; name:"cura"} - property variant printer_connection: Cura.USBPrinterManager.connectedPrinterList.rowCount() != 0 ? Cura.USBPrinterManager.connectedPrinterList.getItem(0).printer : null - Label - { - id: pageTitle - width: parent.width - text: catalog.i18nc("@title", "Upgrade Firmware") - wrapMode: Text.WordWrap - font.pointSize: 18 - } - Label - { - id: pageDescription - anchors.top: pageTitle.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","Firmware is the piece of software running directly on your 3D printer. This firmware controls the step motors, regulates the temperature and ultimately makes your printer work.") - } - - Label - { - id: upgradeText1 - anchors.top: pageDescription.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","The firmware shipping with new Ultimakers works, but upgrades have been made to make better prints, and make calibration easier."); - } - - Label - { - id: upgradeText2 - anchors.top: upgradeText1.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - width: parent.width - wrapMode: Text.WordWrap - text: catalog.i18nc("@label","Cura requires these new features and thus your firmware will most likely need to be upgraded. You can do so now."); - } - Item{ - anchors.top: upgradeText2.bottom - anchors.topMargin: UM.Theme.getSize("default_margin").height - anchors.horizontalCenter: parent.horizontalCenter - width: upgradeButton.width + skipUpgradeButton.width + UM.Theme.getSize("default_margin").height < wizardPage.width ? upgradeButton.width + skipUpgradeButton.width + UM.Theme.getSize("default_margin").height : wizardPage.width - Button { - id: upgradeButton - anchors.top: parent.top - anchors.left: parent.left - text: catalog.i18nc("@action:button","Upgrade to Marlin Firmware"); - onClicked: Cura.USBPrinterManager.updateAllFirmware() - } - Button { - id: skipUpgradeButton - anchors.top: parent.width < wizardPage.width ? parent.top : upgradeButton.bottom - anchors.topMargin: parent.width < wizardPage.width ? 0 : UM.Theme.getSize("default_margin").height/2 - anchors.left: parent.width < wizardPage.width ? upgradeButton.right : parent.left - anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0 - text: catalog.i18nc("@action:button","Skip Upgrade"); - onClicked: base.nextPage() - } - } - ExclusiveGroup { id: printerGroup; } -} \ No newline at end of file From 23ca2a3f5496550e66e810126cf5d2c1b9d0d32c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 15:37:22 +0200 Subject: [PATCH 088/112] Fixed layout issues CURA-1385 --- plugins/UltimakerMachineActions/BedLevelMachineAction.qml | 1 + plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml index 381c79b076..d043c20df5 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml @@ -12,6 +12,7 @@ import Cura 1.0 as Cura Cura.MachineAction { + anchors.fill: parent; Item { id: bedLevelMachineAction diff --git a/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml index e4dd43a8d6..3686d6f990 100644 --- a/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml +++ b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml @@ -12,6 +12,7 @@ import Cura 1.0 as Cura Cura.MachineAction { + anchors.fill: parent; Item { id: upgradeFirmwareMachineAction From 65a8cf1c4520351e8b9072b9dbf0b85581a5c855 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Wed, 22 Jun 2016 16:51:56 +0200 Subject: [PATCH 089/112] 'One at a time' printing was broken due to a regression in the convex hull decorator. Contributes to CURA-1504 --- cura/ConvexHullDecorator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index 9fccd46988..4aa6584dc5 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -47,7 +47,7 @@ class ConvexHullDecorator(SceneNodeDecorator): hull = self._compute2DConvexHull() if self._global_stack and self._node: if self._global_stack.getProperty("print_sequence", "value") == "one_at_a_time" and not self._node.getParent().callDecoration("isGroup"): - hull = hull.getMinkowskiHull(Polygon(numpy.array(self._global_stack.getProperty("machine_head_polygon"), numpy.float32))) + hull = hull.getMinkowskiHull(Polygon(numpy.array(self._global_stack.getProperty("machine_head_polygon", "value"), numpy.float32))) return hull ## Get the convex hull of the node with the full head size @@ -77,7 +77,7 @@ class ConvexHullDecorator(SceneNodeDecorator): return None if self._global_stack: - if self._global_stack("print_sequence") == "one_at_a_time" and not self._node.getParent().callDecoration("isGroup"): + if self._global_stack.getProperty("print_sequence", "value") == "one_at_a_time" and not self._node.getParent().callDecoration("isGroup"): # Printing one at a time and it's not an object in a group return self._compute2DConvexHull() return None @@ -193,7 +193,7 @@ class ConvexHullDecorator(SceneNodeDecorator): return rounded_hull def _getHeadAndFans(self): - return Polygon(numpy.array(self._global_stack.getProperty("machine_head_with_fans_polygon"), numpy.float32)) + return Polygon(numpy.array(self._global_stack.getProperty("machine_head_with_fans_polygon", "value"), numpy.float32)) def _compute2DConvexHeadFull(self): return self._compute2DConvexHull().getMinkowskiHull(self._getHeadAndFans()) From a35873a31bf629617f3ff12d1e71184f07b4638d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 17:04:31 +0200 Subject: [PATCH 090/112] Removed test files CURA-333 --- .../definitions/hypothetical_multi.def.json | 35 ------------------- .../hypothetical_multi_extruder_1.def.json | 19 ---------- .../hypothetical_multi_extruder_2.def.json | 19 ---------- .../hypothetical_multi_extruder_3.def.json | 19 ---------- .../hypothetical_multi_extruder_4.def.json | 19 ---------- .../variants/hypothetical_multi_0.4.inst.cfg | 11 ------ .../variants/hypothetical_multi_0.6.inst.cfg | 11 ------ 7 files changed, 133 deletions(-) delete mode 100644 resources/definitions/hypothetical_multi.def.json delete mode 100644 resources/extruders/hypothetical_multi_extruder_1.def.json delete mode 100644 resources/extruders/hypothetical_multi_extruder_2.def.json delete mode 100644 resources/extruders/hypothetical_multi_extruder_3.def.json delete mode 100644 resources/extruders/hypothetical_multi_extruder_4.def.json delete mode 100644 resources/variants/hypothetical_multi_0.4.inst.cfg delete mode 100644 resources/variants/hypothetical_multi_0.6.inst.cfg diff --git a/resources/definitions/hypothetical_multi.def.json b/resources/definitions/hypothetical_multi.def.json deleted file mode 100644 index e60c9acabd..0000000000 --- a/resources/definitions/hypothetical_multi.def.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "id": "hypothetical_multi", - "version": 2, - "name": "Hypothetical Multiextrusion printer", - "inherits": "fdmprinter", - "metadata": { - "author": "fieldOfView", - "manufacturer": "fieldOfView", - "category": "fieldOfView", - "visible": true, - "file_formats": "text/x-gcode", - "machine_extruder_trains": - { - "0": "hypothetical_multi_extruder_1", - "1": "hypothetical_multi_extruder_2", - "2": "hypothetical_multi_extruder_3", - "3": "hypothetical_multi_extruder_4" - }, - "preferred_material": "*pla*", - "preferred_quality": "*normal*", - "has_variants": true, - "has_materials": true - }, - - - - "overrides": { - "machine_width": { "default_value": 220 }, - "machine_depth": { "default_value": 215 }, - "machine_height": { "default_value": 200 }, - "machine_heated_bed": { "default_value": true }, - "machine_show_variants": { "default_value": true }, - "machine_extruder_count": { "default_value": 4 } - } -} diff --git a/resources/extruders/hypothetical_multi_extruder_1.def.json b/resources/extruders/hypothetical_multi_extruder_1.def.json deleted file mode 100644 index 6b75d33079..0000000000 --- a/resources/extruders/hypothetical_multi_extruder_1.def.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "hypothetical_multi_extruder_1", - "version": 2, - "name": "1st Extruder", - "inherits": "fdmextruder", - "metadata": { - "machine": "hypothetical_multi", - "position": "0" - }, - - "overrides": { - "extruder_nr": { - "default_value": 0, - "maximum_value": "3" - }, - "machine_nozzle_offset_x": { "default_value": 0.0 }, - "machine_nozzle_offset_y": { "default_value": 0.0 } - } -} diff --git a/resources/extruders/hypothetical_multi_extruder_2.def.json b/resources/extruders/hypothetical_multi_extruder_2.def.json deleted file mode 100644 index 9c3c1b265b..0000000000 --- a/resources/extruders/hypothetical_multi_extruder_2.def.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "hypothetical_multi_extruder_2", - "version": 2, - "name": "2nd Extruder", - "inherits": "fdmextruder", - "metadata": { - "machine": "hypothetical_multi", - "position": "1" - }, - - "overrides": { - "extruder_nr": { - "default_value": 1, - "maximum_value": "3" - }, - "machine_nozzle_offset_x": { "default_value": 18.0 }, - "machine_nozzle_offset_y": { "default_value": 0.0 } - } -} diff --git a/resources/extruders/hypothetical_multi_extruder_3.def.json b/resources/extruders/hypothetical_multi_extruder_3.def.json deleted file mode 100644 index e888f79895..0000000000 --- a/resources/extruders/hypothetical_multi_extruder_3.def.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "hypothetical_multi_extruder_3", - "version": 2, - "name": "3rd Extruder", - "inherits": "fdmextruder", - "metadata": { - "machine": "hypothetical_multi", - "position": "2" - }, - - "overrides": { - "extruder_nr": { - "default_value": 2, - "maximum_value": "3" - }, - "machine_nozzle_offset_x": { "default_value": 0.0 }, - "machine_nozzle_offset_y": { "default_value": 18.0 } - } -} diff --git a/resources/extruders/hypothetical_multi_extruder_4.def.json b/resources/extruders/hypothetical_multi_extruder_4.def.json deleted file mode 100644 index bb1ac4d1cd..0000000000 --- a/resources/extruders/hypothetical_multi_extruder_4.def.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "hypothetical_multi_extruder_4", - "version": 2, - "name": "4th Extruder", - "inherits": "fdmextruder", - "metadata": { - "machine": "hypothetical_multi", - "position": "3" - }, - - "overrides": { - "extruder_nr": { - "default_value": 3, - "maximum_value": "3" - }, - "machine_nozzle_offset_x": { "default_value": 18.0 }, - "machine_nozzle_offset_y": { "default_value": 18.0 } - } -} diff --git a/resources/variants/hypothetical_multi_0.4.inst.cfg b/resources/variants/hypothetical_multi_0.4.inst.cfg deleted file mode 100644 index 7d84e65ef4..0000000000 --- a/resources/variants/hypothetical_multi_0.4.inst.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[general] -name = 0.4 mm -version = 2 -definition = hypothetical_multi - -[metadata] -author = fieldOfView -type = variant - -[values] -machine_nozzle_size = 0.4 diff --git a/resources/variants/hypothetical_multi_0.6.inst.cfg b/resources/variants/hypothetical_multi_0.6.inst.cfg deleted file mode 100644 index bf441be897..0000000000 --- a/resources/variants/hypothetical_multi_0.6.inst.cfg +++ /dev/null @@ -1,11 +0,0 @@ -[general] -name = 0.6 mm -version = 2 -definition = hypothetical_multi - -[metadata] -author = fieldOfView -type = variant - -[values] -machine_nozzle_size = 0.6 From a6bb0c804ae21f0c10fef21d25f2e498ce927964 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 22 Jun 2016 17:19:14 +0200 Subject: [PATCH 091/112] Fix minor codereview issues CURA-333 --- cura/ExtrudersModel.py | 1 + plugins/SolidView/SolidView.py | 2 +- resources/qml/SidebarSimple.qml | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cura/ExtrudersModel.py b/cura/ExtrudersModel.py index 7edbb8b7c5..c8c5a21274 100644 --- a/cura/ExtrudersModel.py +++ b/cura/ExtrudersModel.py @@ -82,6 +82,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel): def _onExtruderStackContainersChanged(self, container): + # The ExtrudersModel needs to be updated when the material-name or -color changes, because the user identifies extruders by material-name if container.getMetaDataEntry("type") == "material": self._updateExtruders() diff --git a/plugins/SolidView/SolidView.py b/plugins/SolidView/SolidView.py index 30b2105522..ddbc06d119 100644 --- a/plugins/SolidView/SolidView.py +++ b/plugins/SolidView/SolidView.py @@ -73,7 +73,7 @@ class SolidView(View): int(extruder_color[5:7], 16) / 255, 1.0 ] - except: + except ValueError: pass if hasattr(node, "_outside_buildarea"): diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/SidebarSimple.qml index 6e6e28be3b..56c4385297 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/SidebarSimple.qml @@ -336,10 +336,10 @@ Item text: catalog.i18nc("@label", "Don't print support"), color: "" }) - for(var extruderNr = 0; extruderNr < extruders.model.rowCount() ; extruderNr++) { + for(var extruderNumber = 0; extruderNumber < extruders.model.rowCount() ; extruderNumber++) { extruderModel.append({ - text: catalog.i18nc("@label", "Print using %1").arg(extruders.model.getItem(extruderNr).name), - color: extruders.model.getItem(extruderNr).colour + text: catalog.i18nc("@label", "Print using %1").arg(extruders.model.getItem(extruderNumber).name), + color: extruders.model.getItem(extruderNumber).colour }) } } From 08411e943c6273ed985fadcfc01575bfba011f04 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 22 Jun 2016 18:46:24 +0200 Subject: [PATCH 092/112] Reenable Per Object Settings tool in simple mode if the current printer has multiextrusion and tweak Per Object Settings panel size CURA-333 --- .../PerObjectSettingsPanel.qml | 14 ++++++++++-- .../PerObjectSettingsTool.py | 22 ++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index aa4a749e92..b237d60716 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -24,10 +24,20 @@ Item { anchors.top: parent.top; anchors.left: parent.left; - spacing: UM.Theme.getSize("default_margin").height; + spacing: UM.Theme.getSize("default_margin").height Row { + spacing: UM.Theme.getSize("default_margin").width + Label + { + text: catalog.i18nc("@label", "Print object with") + anchors.verticalCenter: extruderSelector.verticalCenter + + color: UM.Theme.getColor("setting_control_text") + font: UM.Theme.getFont("default") + visible: extruderSelector.visible + } ComboBox { id: extruderSelector @@ -40,7 +50,7 @@ Item { } visible: extruders_model.rowCount() > 1 textRole: "name" - width: items.width + width: UM.Theme.getSize("setting_control").width height: UM.Theme.getSize("section").height MouseArea { diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index 416d8cce6a..f80d9cbf9c 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -16,10 +16,17 @@ class PerObjectSettingsTool(Tool): self.setExposedProperties("SelectedObjectId", "ContainerID", "SelectedActiveExtruder") - Preferences.getInstance().preferenceChanged.connect(self._onPreferenceChanged) + self._advanced_mode = False + self._multi_extrusion = False + Selection.selectionChanged.connect(self.propertyChanged) + + Preferences.getInstance().preferenceChanged.connect(self._onPreferenceChanged) self._onPreferenceChanged("cura/active_mode") + Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged) + self._onGlobalContainerChanged() + def event(self, event): return False @@ -55,5 +62,14 @@ class PerObjectSettingsTool(Tool): def _onPreferenceChanged(self, preference): if preference == "cura/active_mode": - enabled = Preferences.getInstance().getValue(preference)==1 - Application.getInstance().getController().toolEnabledChanged.emit(self._plugin_id, enabled) \ No newline at end of file + self._advanced_mode = Preferences.getInstance().getValue(preference) == 1 + self._updateEnabled() + + def _onGlobalContainerChanged(self): + global_container_stack = Application.getInstance().getGlobalContainerStack() + if global_container_stack: + self._multi_extrusion = global_container_stack.getProperty("machine_extruder_count", "value") > 1 + self._updateEnabled() + + def _updateEnabled(self): + Application.getInstance().getController().toolEnabledChanged.emit(self._plugin_id, self._advanced_mode or self._multi_extrusion) \ No newline at end of file From 688accfab7d4fff9ab15a57114445d89ae69c230 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Wed, 22 Jun 2016 23:25:04 +0200 Subject: [PATCH 093/112] GCodeProfileReader: Removing useless containername --- plugins/GCodeProfileReader/GCodeProfileReader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 8b8809df57..89046bcecf 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -74,7 +74,7 @@ class GCodeProfileReader(ProfileReader): Logger.log("i", "Serialized the following from %s: %s" %(file_name, repr(serialized))) # Create an empty profile - the id will be changed later - profile = InstanceContainer("G-code-imported-profile") + profile = InstanceContainer("") profile.addMetaDataEntry("type", "quality") try: profile.deserialize(serialized) @@ -87,4 +87,4 @@ class GCodeProfileReader(ProfileReader): profile.setName(new_name) profile._id = new_name - return profile \ No newline at end of file + return profile From 7c606b21b5a5da0b2cb0e485f173227bd5a551bb Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 23 Jun 2016 10:18:27 +0200 Subject: [PATCH 094/112] Remove some trailing spaces CURA-1615 --- plugins/GCodeProfileReader/GCodeProfileReader.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py index 89046bcecf..5dcea88aed 100644 --- a/plugins/GCodeProfileReader/GCodeProfileReader.py +++ b/plugins/GCodeProfileReader/GCodeProfileReader.py @@ -23,7 +23,7 @@ class GCodeProfileReader(ProfileReader): # written with. If the file format is changed in a way that breaks reverse # compatibility, increment this version number! version = 1 - + ## Dictionary that defines how characters are escaped when embedded in # g-code. # @@ -65,7 +65,7 @@ class GCodeProfileReader(ProfileReader): except IOError as e: Logger.log("e", "Unable to open file %s for reading: %s", file_name, str(e)) return None - + # Un-escape the serialized profile. pattern = re.compile("|".join(GCodeProfileReader.escape_characters.keys())) @@ -81,10 +81,10 @@ class GCodeProfileReader(ProfileReader): except Exception as e: # Not a valid g-code file. Logger.log("e", "Unable to serialise the profile: %s", str(e)) return None - - #Creating a unique name using the filename of the GCode + + #Creating a unique name using the filename of the GCode new_name = catalog.i18nc("@label", "Custom profile (%s)") %(os.path.splitext(os.path.basename(file_name))[0]) profile.setName(new_name) profile._id = new_name - + return profile From 45dca3f878919c0e7dc7de941692d46839090367 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 11:09:55 +0200 Subject: [PATCH 095/112] Refactoring (Renaming variables so they are more clear & update documentation) --- cura/CuraVersion.py.in | 5 --- cura/MachineActionManager.py | 68 ++++++++++++++++++------------------ tests/TestMachineAction.py | 6 ++-- 3 files changed, 37 insertions(+), 42 deletions(-) delete mode 100644 cura/CuraVersion.py.in diff --git a/cura/CuraVersion.py.in b/cura/CuraVersion.py.in deleted file mode 100644 index 5ad819b1fc..0000000000 --- a/cura/CuraVersion.py.in +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2015 Ultimaker B.V. -# Cura is released under the terms of the AGPLv3 or higher. - -CuraVersion = "@CURA_VERSION@" -CuraBuildType = "@CURA_BUILDTYPE@" \ No newline at end of file diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index 287ed89891..b022553b59 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -9,12 +9,12 @@ from UM.Settings.DefinitionContainer import DefinitionContainer from PyQt5.QtCore import QObject, pyqtSlot ## Raised when trying to add an unknown machine action as a required action -class UnknownMachineAction(Exception): +class UnknownMachineActionError(Exception): pass ## Raised when trying to add a machine action that does not have an unique key. -class NotUniqueMachineAction(Exception): +class NotUniqueMachineActionError(Exception): pass @@ -23,9 +23,9 @@ class MachineActionManager(QObject): super().__init__(parent) self._machine_actions = {} # Dict of all known machine actions - self._required_actions = {} # Dict of all required actions by machine reference. - self._supported_actions = {} # Dict of all supported actions by machine reference - self._first_start_actions = {} # Dict of all actions that need to be done when first added by machine reference + self._required_actions = {} # Dict of all required actions by definition ID + self._supported_actions = {} # Dict of all supported actions by definition ID + self._first_start_actions = {} # Dict of all actions that need to be done when first added by definition ID # Add machine_action as plugin type PluginRegistry.addType("machine_action", self.addMachineAction) @@ -54,37 +54,37 @@ class MachineActionManager(QObject): ## Add a required action to a machine # Raises an exception when the action is not recognised. - def addRequiredAction(self, machine_id, action_key): + def addRequiredAction(self, definition_id, action_key): if action_key in self._machine_actions: - if machine_id in self._required_actions: - self._required_actions[machine_id] |= {self._machine_actions[action_key]} + if definition_id in self._required_actions: + self._required_actions[definition_id] |= {self._machine_actions[action_key]} else: - self._required_actions[machine_id] = {self._machine_actions[action_key]} + self._required_actions[definition_id] = {self._machine_actions[action_key]} else: - raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine_id)) + raise UnknownMachineActionError("Action %s, which is required for %s is not known." % (action_key, definition_id)) ## Add a supported action to a machine. - def addSupportedAction(self, machine_id, action_key): + def addSupportedAction(self, definition_id, action_key): if action_key in self._machine_actions: - if machine_id in self._supported_actions: - self._supported_actions[machine_id] |= {self._machine_actions[action_key]} + if definition_id in self._supported_actions: + self._supported_actions[definition_id] |= {self._machine_actions[action_key]} else: - self._supported_actions[machine_id] = {self._machine_actions[action_key]} + self._supported_actions[definition_id] = {self._machine_actions[action_key]} else: - Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id) + Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, definition_id) ## Add an action to the first start list of a machine. - def addFirstStartAction(self, machine_id, action_key, index = None): + def addFirstStartAction(self, definition_id, action_key, index = None): if action_key in self._machine_actions: - if machine_id in self._first_start_actions: + if definition_id in self._first_start_actions: if index is not None: - self._first_start_actions[machine_id].insert(index, self._machine_actions[action_key]) + self._first_start_actions[definition_id].insert(index, self._machine_actions[action_key]) else: - self._first_start_actions[machine_id].append(self._machine_actions[action_key]) + self._first_start_actions[definition_id].append(self._machine_actions[action_key]) else: - self._first_start_actions[machine_id] = [self._machine_actions[action_key]] + self._first_start_actions[definition_id] = [self._machine_actions[action_key]] else: - Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id) + Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, definition_id) ## Add a (unique) MachineAction # if the Key of the action is not unique, an exception is raised. @@ -92,35 +92,35 @@ class MachineActionManager(QObject): if action.getKey() not in self._machine_actions: self._machine_actions[action.getKey()] = action else: - raise NotUniqueMachineAction("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey()) + raise NotUniqueMachineActionError("MachineAction with key %s was already added. Actions must have unique keys.", action.getKey()) ## Get all actions supported by given machine - # \param machine The machine you want the supported actions of + # \param definition_id The ID of the definition you want the supported actions of # \returns set of supported actions. @pyqtSlot(str, result = "QVariantList") - def getSupportedActions(self, machine_id): - if machine_id in self._supported_actions: - return list(self._supported_actions[machine_id]) + def getSupportedActions(self, definition_id): + if definition_id in self._supported_actions: + return list(self._supported_actions[definition_id]) else: return set() ## Get all actions required by given machine - # \param machine The machine you want the required actions of + # \param definition_id The ID of the definition you want the required actions of # \returns set of required actions. - def getRequiredActions(self, machine_id): - if machine_id in self._required_actions: - return self._required_actions[machine_id] + def getRequiredActions(self, definition_id): + if definition_id in self._required_actions: + return self._required_actions[definition_id] else: return set() ## Get all actions that need to be performed upon first start of a given machine. # Note that contrary to required / supported actions a list is returned (as it could be required to run the same # action multiple times). - # \param machine The machine you want the first start actions of + # \param definition_id The ID of the definition that you want to get the "on added" actions for. # \returns List of actions. - def getFirstStartActions(self, machine_id): - if machine_id in self._first_start_actions: - return self._first_start_actions[machine_id] + def getFirstStartActions(self, definition_id): + if definition_id in self._first_start_actions: + return self._first_start_actions[definition_id] else: return [] diff --git a/tests/TestMachineAction.py b/tests/TestMachineAction.py index 736f7015ac..1d593e92a1 100644 --- a/tests/TestMachineAction.py +++ b/tests/TestMachineAction.py @@ -3,7 +3,7 @@ import pytest from cura.MachineAction import MachineAction -from cura.MachineActionManager import MachineActionManager, NotUniqueMachineAction, UnknownMachineAction +from cura.MachineActionManager import MachineActionManager, NotUniqueMachineActionError, UnknownMachineActionError class Machine: def __init__(self, key = ""): @@ -26,7 +26,7 @@ def test_addMachineAction(): assert machine_manager.getMachineAction("key_that_doesnt_exist") is None # Adding the same machine action is not allowed. - with pytest.raises(NotUniqueMachineAction): + with pytest.raises(NotUniqueMachineActionError): machine_manager.addMachineAction(test_action) # Check that the machine has no supported actions yet. @@ -48,7 +48,7 @@ def test_addMachineAction(): assert machine_manager.getRequiredActions(test_machine) == set() ## Ensure that only known actions can be added. - with pytest.raises(UnknownMachineAction): + with pytest.raises(UnknownMachineActionError): machine_manager.addRequiredAction(test_machine, "key_that_doesnt_exist") ## Check if adding single required action works From a7deb53acfffa8d410e74f8f83dbbc3199a6f472 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 11:12:06 +0200 Subject: [PATCH 096/112] Added BedLevel as supported action to UMO --- resources/definitions/ultimaker_original.def.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/definitions/ultimaker_original.def.json b/resources/definitions/ultimaker_original.def.json index 16fcf49ab7..e95431c99e 100644 --- a/resources/definitions/ultimaker_original.def.json +++ b/resources/definitions/ultimaker_original.def.json @@ -14,7 +14,7 @@ "has_materials": true, "preferred_material": "*pla*", "preferred_quality": "*normal*", - "supported_actions":[ "UMOCheckup", "UpgradeFirmware"] + "supported_actions":["UMOCheckup", "UpgradeFirmware", "BedLevel"] }, "overrides": { From 3f3a93ae8ab718266dff4f8cd2753064d7e9116c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 11:12:58 +0200 Subject: [PATCH 097/112] Refactoring; Renaming firstRunWizard to machineActionsWizard CURA-1385 --- resources/qml/Cura.qml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 50a97f2a15..a27c232e5e 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -773,14 +773,14 @@ UM.MainWindow id: addMachineDialog onMachineAdded: { - firstRunWizard.start(id) + machineActionsWizard.start(id) } } // Dialog to handle first run machine actions UM.Wizard { - id: firstRunWizard; + id: machineActionsWizard; title: catalog.i18nc("@title:window", "Add Printer") property var machine; @@ -793,13 +793,13 @@ UM.MainWindow for (var i = 0; i < actions.length; i++) { actions[i].displayItem.reset() - firstRunWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title", actions[i].label)); + machineActionsWizard.appendPage(actions[i].displayItem, catalog.i18nc("@title", actions[i].label)); } //Only start if there are actions to perform. if (actions.length > 0) { - firstRunWizard.currentPage = 0; + machineActionsWizard.currentPage = 0; show() } } From cd6092581b01f870fa60675516b95987d9bb563d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 11:17:28 +0200 Subject: [PATCH 098/112] Removed extraneous space CURA-1385 --- resources/definitions/ultimaker_original_plus.def.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/definitions/ultimaker_original_plus.def.json b/resources/definitions/ultimaker_original_plus.def.json index 566573aa00..0e7bf3bddd 100644 --- a/resources/definitions/ultimaker_original_plus.def.json +++ b/resources/definitions/ultimaker_original_plus.def.json @@ -11,7 +11,7 @@ "icon": "icon_ultimaker.png", "platform": "ultimaker2_platform.obj", "platform_texture": "UltimakerPlusbackplate.png", - "supported_actions":[ "UMOCheckup", "UpgradeFirmware", "BedLevel"] + "supported_actions":["UMOCheckup", "UpgradeFirmware", "BedLevel"] }, "overrides": { From d499d59d971a826d1a9938fe57424cda3ca9bbd8 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 11:19:54 +0200 Subject: [PATCH 099/112] Restored accidental delete --- cura/CuraVersion.py.in | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cura/CuraVersion.py.in diff --git a/cura/CuraVersion.py.in b/cura/CuraVersion.py.in new file mode 100644 index 0000000000..5ad819b1fc --- /dev/null +++ b/cura/CuraVersion.py.in @@ -0,0 +1,5 @@ +# Copyright (c) 2015 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. + +CuraVersion = "@CURA_VERSION@" +CuraBuildType = "@CURA_BUILDTYPE@" \ No newline at end of file From 35a8e7ca943b9b855931ccfbe440ce29ec7548bc Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 11:41:13 +0200 Subject: [PATCH 100/112] Added missing decorator CURA-1385 --- cura/MachineActionManager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index b022553b59..b50bb95e7f 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -118,6 +118,7 @@ class MachineActionManager(QObject): # action multiple times). # \param definition_id The ID of the definition that you want to get the "on added" actions for. # \returns List of actions. + @pyqtSlot(str, result="QVariantList") def getFirstStartActions(self, definition_id): if definition_id in self._first_start_actions: return self._first_start_actions[definition_id] From 6909cf211a6d9ed423eb596d8e7b2a45ed1a4b80 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 11:42:18 +0200 Subject: [PATCH 101/112] Fixed layout CURA-1385 --- .../UltimakerMachineActions/UpgradeFirmwareMachineAction.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml index 3686d6f990..37e4eae2d3 100644 --- a/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml +++ b/plugins/UltimakerMachineActions/UpgradeFirmwareMachineAction.qml @@ -16,7 +16,7 @@ Cura.MachineAction Item { id: upgradeFirmwareMachineAction - + anchors.fill: parent; UM.I18nCatalog { id: catalog; name:"cura"} Label From b14ae9419039d8abbcf9c52bdedebec72823d10d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 13:10:57 +0200 Subject: [PATCH 102/112] Starting UMOCheckup before connection was established now works correctly CURA-1385 --- .../UMOCheckupMachineAction.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugins/UltimakerMachineActions/UMOCheckupMachineAction.py b/plugins/UltimakerMachineActions/UMOCheckupMachineAction.py index 392f89682f..0c8bf3480f 100644 --- a/plugins/UltimakerMachineActions/UMOCheckupMachineAction.py +++ b/plugins/UltimakerMachineActions/UMOCheckupMachineAction.py @@ -18,6 +18,11 @@ class UMOCheckupMachineAction(MachineAction): self._y_min_endstop_test_completed = False self._z_min_endstop_test_completed = False + self._check_started = False + + Application.getInstance().getOutputDeviceManager().outputDevicesChanged.connect(self._onOutputDevicesChanged) + + onBedTestCompleted = pyqtSignal() onHotendTestCompleted = pyqtSignal() @@ -28,6 +33,13 @@ class UMOCheckupMachineAction(MachineAction): bedTemperatureChanged = pyqtSignal() hotendTemperatureChanged = pyqtSignal() + def _onOutputDevicesChanged(self): + # Check if this action was started, but no output device was found the first time. + # If so, re-try now that an output device has been added/removed. + if self._output_device is None and self._check_started: + self.startCheck() + + def _getPrinterOutputDevices(self): return [printer_output_device for printer_output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices() if @@ -46,6 +58,8 @@ class UMOCheckupMachineAction(MachineAction): pass self._output_device = None + self._check_started = False + # Ensure everything is reset (and right signals are emitted again) self._bed_test_completed = False self.onBedTestCompleted.emit() @@ -121,6 +135,7 @@ class UMOCheckupMachineAction(MachineAction): @pyqtSlot() def startCheck(self): + self._check_started = True output_devices = self._getPrinterOutputDevices() if output_devices: self._output_device = output_devices[0] From de361225315405f74c34cbd4c558da8bf43d9a5a Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 23 Jun 2016 13:31:01 +0200 Subject: [PATCH 103/112] Use the expanded categories from Cura to expand the proper categories on startup --- resources/qml/Settings/SettingView.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 4be2326b0a..39f0f833b8 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -29,8 +29,10 @@ ScrollView model: UM.SettingDefinitionsModel { id: definitionsModel; containerId: Cura.MachineManager.activeDefinitionId - exclude: ["machine_settings"] visibilityHandler: UM.SettingPreferenceVisibilityHandler { } + exclude: ["machine_settings"] + expanded: Printer.expandedCategories + onExpandedChanged: Printer.setExpandedCategories(expanded) filter: { From 10d572eae3c903516febe61567633a4e4dc36ed7 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 23 Jun 2016 13:32:04 +0200 Subject: [PATCH 104/112] Fix expanded settings for Per Object settings tool --- plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index b237d60716..546b7086e6 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -153,6 +153,8 @@ Item { { id: addedSettingsModel; containerId: Cura.MachineManager.activeDefinitionId + expanded: [ "*" ] + visibilityHandler: Cura.PerObjectSettingVisibilityHandler { selectedObjectId: UM.ActiveTool.properties.getValue("SelectedObjectId") @@ -215,9 +217,8 @@ Item { style: ButtonStyle { - background: Rectangle + background: Item { - color: control.hovered ? control.parent.style.controlHighlightColor : control.parent.style.controlColor; UM.RecolorImage { anchors.verticalCenter: parent.verticalCenter @@ -340,6 +341,8 @@ Item { "settable_per_mesh": true } visibilityHandler: UM.SettingPreferenceVisibilityHandler {} + expanded: [ "*" ] + exclude: [ "machine_settings" ] } delegate:Loader { From cc027ddf418ca0b00ff5f686079232e266992634 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 23 Jun 2016 13:32:20 +0200 Subject: [PATCH 105/112] Remove unused code --- resources/qml/Settings/SettingTextField.qml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/resources/qml/Settings/SettingTextField.qml b/resources/qml/Settings/SettingTextField.qml index bf6fc34c93..18a55c7a50 100644 --- a/resources/qml/Settings/SettingTextField.qml +++ b/resources/qml/Settings/SettingTextField.qml @@ -19,11 +19,6 @@ SettingItem border.width: UM.Theme.getSize("default_lining").width border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") - property variant parentValue: value //From parent loader - function notifyReset() { - input.text = format(parentValue) - } - color: { if (!enabled) { From 9f9de493f74df77ac1f31ac35ae4663f62bfea3c Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 23 Jun 2016 13:32:31 +0200 Subject: [PATCH 106/112] Clean up indentation --- resources/qml/Settings/SettingItem.qml | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index e98c06329d..2d5e9ffa7e 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -34,34 +34,34 @@ Item { property string tooltipText: { - var affects = settingDefinitionsModel.getRequiredBy(definition.key, "value") - var affected_by = settingDefinitionsModel.getRequires(definition.key, "value") + var affects = settingDefinitionsModel.getRequiredBy(definition.key, "value") + var affected_by = settingDefinitionsModel.getRequires(definition.key, "value") - var affected_by_list = "" - for(var i in affected_by) - { - affected_by_list += "
  • %1
  • \n".arg(affected_by[i].label) - } + var affected_by_list = "" + for(var i in affected_by) + { + affected_by_list += "
  • %1
  • \n".arg(affected_by[i].label) + } - var affects_list = "" - for(var i in affects) - { - affects_list += "
  • %1
  • \n".arg(affects[i].label) - } + var affects_list = "" + for(var i in affects) + { + affects_list += "
  • %1
  • \n".arg(affects[i].label) + } - var tooltip = "%1\n

    %2

    ".arg(definition.label).arg(definition.description) + var tooltip = "%1\n

    %2

    ".arg(definition.label).arg(definition.description) - if(affects_list != "") - { - tooltip += "
    %1\n
      \n%2
    ".arg(catalog.i18nc("@label", "Affects")).arg(affects_list) - } + if(affects_list != "") + { + tooltip += "
    %1\n
      \n%2
    ".arg(catalog.i18nc("@label", "Affects")).arg(affects_list) + } - if(affected_by_list != "") - { - tooltip += "
    %1\n
      \n%2
    ".arg(catalog.i18nc("@label", "Affected By")).arg(affected_by_list) - } + if(affected_by_list != "") + { + tooltip += "
    %1\n
      \n%2
    ".arg(catalog.i18nc("@label", "Affected By")).arg(affected_by_list) + } - return tooltip + return tooltip } MouseArea From 8c8caa2cac110273407763b9efaccd783e26927e Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 23 Jun 2016 13:33:07 +0200 Subject: [PATCH 107/112] Use the right property for the property provider Otherwise we get a bunch of errors from the per object settings tool --- resources/qml/Settings/SettingItem.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index 2d5e9ffa7e..1e69704995 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -236,7 +236,7 @@ Item { { id: controlContainer; - enabled: provider.isValueUsed + enabled: propertyProvider.isValueUsed anchors.right: parent.right; anchors.rightMargin: UM.Theme.getSize("default_margin").width From 38ce6cd4b859d249158d907918320b1655d207e0 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Thu, 23 Jun 2016 13:33:51 +0200 Subject: [PATCH 108/112] Make PerObjectSettingVisiblityHandler inherit SettingVisiblityHandler and some other cleanup --- .../PerObjectSettingVisibilityHandler.py | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py index 381d45b1c2..57bff4f0de 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingVisibilityHandler.py @@ -3,36 +3,44 @@ from UM.Application import Application from UM.Settings.SettingInstance import SettingInstance from UM.Logger import Logger +import UM.Settings.Models + from cura.SettingOverrideDecorator import SettingOverrideDecorator ## The per object setting visibility handler ensures that only setting defintions that have a matching instance Container # are returned as visible. -class PerObjectSettingVisibilityHandler(QObject): +class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHandler): def __init__(self, parent = None, *args, **kwargs): super().__init__(parent = parent, *args, **kwargs) - self._selected_object_id = None - visibilityChanged = pyqtSignal() + self._selected_object_id = None + self._node = None + self._stack = None def setSelectedObjectId(self, id): - self._selected_object_id = id - self.visibilityChanged.emit() + if id != self._selected_object_id: + self._selected_object_id = id + + self._node = Application.getInstance().getController().getScene().findObject(self._selected_object_id) + if self._node: + self._stack = self._node.callDecoration("getStack") + + self.visibilityChanged.emit() @pyqtProperty("quint64", fset = setSelectedObjectId) def selectedObjectId(self): - pass + return self._selected_object_id def setVisible(self, visible): - node = Application.getInstance().getController().getScene().findObject(self._selected_object_id) - if not node: + if not self._node: return - stack = node.callDecoration("getStack") - if not stack: - node.addDecorator(SettingOverrideDecorator()) - stack = node.callDecoration("getStack") - settings = stack.getTop() - all_instances = settings.findInstances(**{}) + if not self._stack: + self._node.addDecorator(SettingOverrideDecorator()) + self._stack = self._node.callDecoration("getStack") + + settings = self._stack.getTop() + all_instances = settings.findInstances() visibility_changed = False # Flag to check if at the end the signal needs to be emitted # Remove all instances that are not in visibility list @@ -41,13 +49,12 @@ class PerObjectSettingVisibilityHandler(QObject): settings.removeInstance(instance.definition.key) visibility_changed = True - # Add all instances that are not added, but are in visiblity list + # Add all instances that are not added, but are in visibility list for item in visible: if not settings.getInstance(item): - definition_container = Application.getInstance().getGlobalContainerStack().getBottom() - definitions = definition_container.findDefinitions(key = item) - if definitions: - settings.addInstance(SettingInstance(definitions[0], settings)) + definition = self._stack.getSettingDefinition(item) + if definition: + settings.addInstance(SettingInstance(definition, settings)) visibility_changed = True else: Logger.log("w", "Unable to add instance (%s) to perobject visibility because we couldn't find the matching definition", item) @@ -57,20 +64,16 @@ class PerObjectSettingVisibilityHandler(QObject): def getVisible(self): visible_settings = set() - node = Application.getInstance().getController().getScene().findObject(self._selected_object_id) - if not node: + if not self._node: return visible_settings - stack = node.callDecoration("getStack") - if not stack: + if not self._stack: return visible_settings - settings = stack.getTop() + settings = self._stack.getTop() if not settings: return visible_settings - all_instances = settings.findInstances(**{}) - for instance in all_instances: - visible_settings.add(instance.definition.key) + visible_settings = set(map(lambda i: i.definition.key, settings.findInstances())) return visible_settings From 3f7f6f8a2317957dc684c5fa43e43ee7f9dbd7dc Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 23 Jun 2016 14:08:38 +0200 Subject: [PATCH 109/112] Skip containers that can not be serialized CURA-1445 --- plugins/SliceInfoPlugin/SliceInfo.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index a9cfe2d83a..50b6275bf0 100644 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/plugins/SliceInfoPlugin/SliceInfo.py @@ -92,7 +92,12 @@ class SliceInfo(Extension): } for container in global_container_stack.getContainers(): container_id = container.getId() - container_serialized = container.serialize() + try: + container_serialized = container.serialize() + except NotImplementedError: + Logger.log("w", "Container %s could not be serialized!", container_id) + continue + if container_serialized: submitted_data["settings_%s" %(container_id)] = container_serialized # This can be anything, eg. INI, JSON, etc. else: From 0faecf9b34a2b8a5955b05d5e9f7dca03d7e8482 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 23 Jun 2016 13:43:50 +0200 Subject: [PATCH 110/112] Rearrange MachineActions on Machines page CURA-1385 --- resources/qml/Preferences/MachinesPage.qml | 38 +++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 8a0a7dc096..dd9a7b42a7 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -36,13 +36,27 @@ UM.ManagementPage renameEnabled: base.currentItem != null activateEnabled: base.currentItem != null && base.currentItem.id != Cura.MachineManager.activeMachineId - Flow + Item { - anchors.fill: parent; - spacing: UM.Theme.getSize("default_margin").height; + visible: base.currentItem != null + anchors.fill: parent + + Label + { + id: machineName + text: base.currentItem && base.currentItem.name ? base.currentItem.name : "" + font: UM.Theme.getFont("large") + width: parent.width + elide: Text.ElideRight + } Row { + id: machineActions + anchors.left: parent.left + anchors.top: machineName.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + Repeater { id: machineActionRepeater @@ -72,16 +86,18 @@ UM.ManagementPage } } - Label + Row { - text: base.currentItem && base.currentItem.name ? base.currentItem.name : "" - font: UM.Theme.getFont("large") - width: parent.width - elide: Text.ElideRight - } + anchors.top: machineActions.visible ? machineActions.bottom : machineActions.anchors.top + anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.left: parent.left + anchors.right: parent.right - Label { text: catalog.i18nc("@label", "Type"); width: parent.width * 0.2; } - Label { text: base.currentItem && base.currentItem.typeName ? base.currentItem.typeName : ""; width: parent.width * 0.7; } + spacing: UM.Theme.getSize("default_margin").height + + Label { text: catalog.i18nc("@label", "Type") } + Label { text: base.currentItem ? base.currentItem.metadata.definition_name : "" } + } UM.I18nCatalog { id: catalog; name: "uranium"; } From 0b02a5f12bbb13fdd8f390d3cccacc4ed7ddd843 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 16:38:04 +0200 Subject: [PATCH 111/112] Machine actions are now when selected (instead of active) machine change CURA-1385 --- cura/MachineManagerModel.py | 8 ++++++-- resources/qml/Preferences/MachinesPage.qml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cura/MachineManagerModel.py b/cura/MachineManagerModel.py index 70953ee712..3466cd6428 100644 --- a/cura/MachineManagerModel.py +++ b/cura/MachineManagerModel.py @@ -286,7 +286,6 @@ class MachineManagerModel(QObject): self.setActiveQuality(new_container_id) self.updateQualityContainerFromUserContainer() - @pyqtSlot(str, result=str) def duplicateContainer(self, container_id): if not self._active_container_stack: @@ -357,7 +356,6 @@ class MachineManagerModel(QObject): self.setActiveQuality(containers[0].getId()) self.activeQualityChanged.emit() - @pyqtSlot() def updateQualityContainerFromUserContainer(self): if not self._active_container_stack: @@ -496,6 +494,12 @@ class MachineManagerModel(QObject): return False + @pyqtSlot(str, result = str) + def getDefinitionByMachineId(self, machine_id): + containers = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id=machine_id) + if containers: + return containers[0].getBottom().getId() + def _updateVariantContainer(self, definition): if not definition.getMetaDataEntry("has_variants"): return self._empty_variant_container diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 8a0a7dc096..5d96361306 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -46,7 +46,7 @@ UM.ManagementPage Repeater { id: machineActionRepeater - model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.activeDefinitionId) + model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.getDefinitionByMachineId(base.currentItem.id)) Button { From e8743abe68da4403b361e3c9f91bd7a2f917eba5 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 23 Jun 2016 18:44:06 +0200 Subject: [PATCH 112/112] Set a sensible minimum width for the window --- cura/CuraApplication.py | 4 ++++ resources/qml/Cura.qml | 5 +++++ resources/themes/cura/theme.json | 1 + 3 files changed, 10 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 08c8513933..54f287d841 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -809,3 +809,7 @@ class CuraApplication(QtApplication): def _addProfileWriter(self, profile_writer): pass + + @pyqtSlot("QSize") + def setMinimumWindowSize(self, size): + self.getMainWindow().setMinimumSize(size) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index a27c232e5e..ef26218332 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -17,6 +17,11 @@ UM.MainWindow title: catalog.i18nc("@title:window","Cura"); viewportRect: Qt.rect(0, 0, (base.width - sidebar.width) / base.width, 1.0) + Component.onCompleted: + { + Printer.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size")) + } + Item { id: backgroundItem; diff --git a/resources/themes/cura/theme.json b/resources/themes/cura/theme.json index acd60e2646..595d0b95c2 100644 --- a/resources/themes/cura/theme.json +++ b/resources/themes/cura/theme.json @@ -157,6 +157,7 @@ }, "sizes": { + "window_minimum_size": [70, 54], "window_margin": [1.0, 1.0], "default_margin": [1.0, 1.0], "default_lining": [0.08, 0.08],