From 225a205d97ddc4de0534b112d7f92f41cd5994c1 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Fri, 12 Jan 2018 09:19:03 +0100 Subject: [PATCH 1/4] Fixes for material duplication and editing, small refactoring - CURA-4787 --- resources/qml/Preferences/MaterialView.qml | 52 ++++++++++----------- resources/qml/Preferences/MaterialsPage.qml | 9 ---- 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/resources/qml/Preferences/MaterialView.qml b/resources/qml/Preferences/MaterialView.qml index c3f36f5125..b2307fe4f6 100644 --- a/resources/qml/Preferences/MaterialView.qml +++ b/resources/qml/Preferences/MaterialView.qml @@ -72,7 +72,7 @@ TabView width: scrollView.columnWidth; text: properties.name; readOnly: !base.editingEnabled; - onEditingFinished: base.setName(properties.name, text) + onEditingFinished: base.updateMaterialDisplayName(properties.name, text) } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Brand") } @@ -82,11 +82,7 @@ TabView width: scrollView.columnWidth; text: properties.supplier; readOnly: !base.editingEnabled; - onEditingFinished: - { - base.setMetaDataEntry("brand", properties.supplier, text); - pane.objectList.currentIndex = pane.getIndexById(base.containerId); - } + onEditingFinished: base.updateMaterialSupplier(properties.supplier, text) } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Material Type") } @@ -95,15 +91,10 @@ TabView width: scrollView.columnWidth; text: properties.material_type; readOnly: !base.editingEnabled; - onEditingFinished: - { - base.setMetaDataEntry("material", properties.material_type, text); - pane.objectList.currentIndex = pane.getIndexById(base.containerId) - } + onEditingFinished: base.updateMaterialType(properties.material_type, text) } Label { width: scrollView.columnWidth; height: parent.rowHeight; verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color") } - Row { width: scrollView.columnWidth height: parent.rowHeight @@ -128,13 +119,6 @@ TabView } } - // make sure the color stays connected after changing the color - Binding { - target: colorSelector - property: "color" - value: properties.color_code - } - // pretty color name text field ReadOnlyTextField { id: colorLabel; @@ -453,14 +437,28 @@ TabView return 0; } - function setName(old_value, new_value) - { - if(old_value != new_value) - { - Cura.ContainerManager.setContainerName(base.containerId, new_value); - // update material name label. not so pretty, but it works - materialProperties.name = new_value; - pane.objectList.currentIndex = pane.getIndexById(base.containerId) + // update the display name of the material + function updateMaterialDisplayName (old_name, new_name) { + + // don't change when new name is the same + if (old_name == new_name) { + return } + + // update the values + Cura.ContainerManager.setContainerName(base.containerId, new_name) + materialProperties.name = new_name + } + + // update the type of the material + function updateMaterialType (old_type, new_type) { + base.setMetaDataEntry("material", old_type, new_type) + materialProperties.material_type = new_type + } + + // update the supplier of the material + function updateMaterialSupplier (old_supplier, new_supplier) { + base.setMetaDataEntry("brand", old_supplier, new_supplier) + materialProperties.supplier = new_supplier } } diff --git a/resources/qml/Preferences/MaterialsPage.qml b/resources/qml/Preferences/MaterialsPage.qml index 6b041b895a..228f9c8ea2 100644 --- a/resources/qml/Preferences/MaterialsPage.qml +++ b/resources/qml/Preferences/MaterialsPage.qml @@ -153,15 +153,6 @@ UM.ManagementPage forceActiveFocus() Cura.ContainerManager.createMaterial() } - - Connections - { - target: base.objectList.model - onItemsChanged: - { - base.objectList.currentIndex = base.getIndexById(Cura.MachineManager.activeMaterialId); - } - } }, // Duplicate button From 8b3bd71b36ac764dd8750a06108f6ba92fabd47f Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 12 Jan 2018 09:57:32 +0100 Subject: [PATCH 2/4] Get extruders list from GlobalStack itself CURA-4784 --- plugins/CuraEngineBackend/CuraEngineBackend.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index e7db4a12dd..e1035af679 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -722,7 +722,7 @@ class CuraEngineBackend(QObject, Backend): if self._global_container_stack: self._global_container_stack.propertyChanged.disconnect(self._onSettingChanged) self._global_container_stack.containersChanged.disconnect(self._onChanged) - extruders = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId())) + extruders = list(self._global_container_stack.extruders.values()) for extruder in extruders: extruder.propertyChanged.disconnect(self._onSettingChanged) @@ -733,7 +733,7 @@ class CuraEngineBackend(QObject, Backend): if self._global_container_stack: self._global_container_stack.propertyChanged.connect(self._onSettingChanged) # Note: Only starts slicing when the value changed. self._global_container_stack.containersChanged.connect(self._onChanged) - extruders = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId())) + extruders = list(self._global_container_stack.extruders.values()) for extruder in extruders: extruder.propertyChanged.connect(self._onSettingChanged) extruder.containersChanged.connect(self._onChanged) From 225b03e98ee1d92467176a1fd1ef3605ce0999c7 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 12 Jan 2018 09:58:06 +0100 Subject: [PATCH 3/4] No need for the extra extrudersAdded signal CURA-4784 --- cura/Settings/ExtruderManager.py | 4 ---- plugins/CuraEngineBackend/CuraEngineBackend.py | 1 - 2 files changed, 5 deletions(-) diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index b5f9a35914..351843ae14 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -49,9 +49,6 @@ class ExtruderManager(QObject): ## Notify when the user switches the currently active extruder. activeExtruderChanged = pyqtSignal() - ## The signal notifies subscribers if extruders are added - extrudersAdded = pyqtSignal() - ## Gets the unique identifier of the currently active extruder stack. # # The currently active extruder stack is the stack that is currently being @@ -409,7 +406,6 @@ class ExtruderManager(QObject): if extruders_changed: self.extrudersChanged.emit(global_stack_id) - self.extrudersAdded.emit() self.setActiveExtruderIndex(0) ## Get all extruder values for a certain setting. diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index e1035af679..3272fb019d 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -88,7 +88,6 @@ class CuraEngineBackend(QObject, Backend): # self._global_container_stack = None Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged) - Application.getInstance().getExtruderManager().extrudersAdded.connect(self._onGlobalStackChanged) self._onGlobalStackChanged() Application.getInstance().stacksValidationFinished.connect(self._onStackErrorCheckFinished) From d1b5744f57632305c4e01fe492d5de7a9a197748 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Fri, 12 Jan 2018 10:58:36 +0100 Subject: [PATCH 4/4] Also fix gcode output for legacy UM3 networking, switch to monitor AFTER starting transferring G-code to catch potential errors before --- .../UM3NetworkPrinting/ClusterUM3OutputDevice.py | 5 +++-- .../UM3NetworkPrinting/LegacyUM3OutputDevice.py | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 45c152ee2f..7bdf6090de 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -76,8 +76,6 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._cluster_size = int(properties.get(b"cluster_size", 0)) def requestWrite(self, nodes, file_name=None, filter_by_machine=False, file_handler=None, **kwargs): - # Notify the UI that a switch to the print monitor should happen - Application.getInstance().getController().setActiveStage("MonitorStage") self.writeStarted.emit(self) gcode_dict = getattr(Application.getInstance().getController().getScene(), "gcode_dict", []) @@ -95,6 +93,9 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): else: self.sendPrintJob() + # Notify the UI that a switch to the print monitor should happen + Application.getInstance().getController().setActiveStage("MonitorStage") + def _spawnPrinterSelectionDialog(self): if self._printer_selection_dialog is None: path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "PrintWindow.qml") diff --git a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py index 786b97d034..a63adadd54 100644 --- a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py @@ -175,15 +175,18 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice): # Not authenticated, so unable to send job. return - # Notify the UI that a switch to the print monitor should happen - Application.getInstance().getController().setActiveStage("MonitorStage") self.writeStarted.emit(self) - self._gcode = getattr(Application.getInstance().getController().getScene(), "gcode_list", []) - if not self._gcode: + gcode_dict = getattr(Application.getInstance().getController().getScene(), "gcode_dict", []) + active_build_plate_id = Application.getInstance().getBuildPlateModel().activeBuildPlate + gcode_list = gcode_dict[active_build_plate_id] + + if not gcode_list: # Unable to find g-code. Nothing to send return + self._gcode = gcode_list + errors = self._checkForErrors() if errors: text = i18n_catalog.i18nc("@label", "Unable to start a new print job.") @@ -229,6 +232,9 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice): # No warnings or errors, so we're good to go. self._startPrint() + # Notify the UI that a switch to the print monitor should happen + Application.getInstance().getController().setActiveStage("MonitorStage") + def _startPrint(self): Logger.log("i", "Sending print job to printer.") if self._sending_gcode: