From 633d14d92585e67749b736b0f400af3d1066472d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 28 Apr 2016 17:21:09 +0200 Subject: [PATCH 01/48] 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 02/48] 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 03/48] 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 04/48] 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 05/48] 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 06/48] 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 07/48] 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 08/48] 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 09/48] 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 10/48] 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 11/48] 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 12/48] 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 13/48] 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 14/48] 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 15/48] 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 16/48] 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 17/48] 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 4beec2982e8386b5ce0606ee2ef9541c14ae7fd6 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 17 Jun 2016 15:23:15 +0200 Subject: [PATCH 18/48] 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 19/48] 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 20/48] 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 83c1ee80823e1459d1f9b005898ed64cc6624e55 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 20 Jun 2016 10:52:18 +0200 Subject: [PATCH 21/48] 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 22/48] 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 23/48] 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 24/48] 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 25/48] 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 26/48] 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 27/48] 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 28/48] 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 29/48] 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 30/48] 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 8cfc0737ac26a286e787e1420151e3af36aeaa33 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 11:49:35 +0200 Subject: [PATCH 31/48] 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 32/48] 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 33/48] 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 d5b07d29de86fd53d1a092dd24e2d4e8f0043378 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 14:39:41 +0200 Subject: [PATCH 34/48] 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 35/48] 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 5aab4686cafec09361b8b8700b4e2fb2540efef0 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 14:50:05 +0200 Subject: [PATCH 36/48] 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 4e854700f1525b60c530f9b3e7509128fe6d21cb Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 22 Jun 2016 15:24:37 +0200 Subject: [PATCH 37/48] 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 38/48] 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 39/48] 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 40/48] 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 41/48] 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 45dca3f878919c0e7dc7de941692d46839090367 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 23 Jun 2016 11:09:55 +0200 Subject: [PATCH 42/48] 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 43/48] 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 44/48] 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 45/48] 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 46/48] 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 47/48] 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 48/48] 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