From 96f8e70e40ccd87f49531f12daf651e82659449a Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 31 Jul 2017 17:58:03 +0200 Subject: [PATCH 1/4] Update containerStackId for limit_to_extruder settings when active machine has been changed CURA-4105 --- resources/qml/Settings/SettingView.qml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 822322ad2d..af8c86cbc4 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -266,6 +266,32 @@ Item containerStackId: Cura.MachineManager.activeMachineId key: model.key watchedProperties: [ "limit_to_extruder" ] + + // When the activeMachineId got changed, the binding for limit_to_extruder which updates + // provider.containerStackId doesn't get triggered. This handle makes sure that will happen. + onContainerStackIdChanged: + { + if(!model.settable_per_extruder || machineExtruderCount.properties.value == 1) + { + //Not settable per extruder or there only is global, so we must pick global. + provider.containerStackId = Cura.MachineManager.activeMachineId; + return; + } + if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) + { + //We have limit_to_extruder, so pick that stack. + provider.containerStackId = ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)]; + return; + } + if(ExtruderManager.activeExtruderStackId) + { + //We're on an extruder tab. Pick the current extruder. + provider.containerStackId = ExtruderManager.activeExtruderStackId; + return; + } + //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab. + provider.containerStackId = Cura.MachineManager.activeMachineId; + } } UM.SettingPropertyProvider From 05879e0dfcecd78bf1e2bf91f6b52c70ff0967d6 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 1 Aug 2017 09:39:33 +0200 Subject: [PATCH 2/4] EngineBackend should trigger auto-slice on changes CURA-4107 CuraEngineBackend should trigger auto-slice on value changes, not changes on the active extruder. --- .../CuraEngineBackend/CuraEngineBackend.py | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 98f8473225..3710d33965 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -88,10 +88,6 @@ class CuraEngineBackend(QObject, Backend): Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged) self._onGlobalStackChanged() - self._active_extruder_stack = None - ExtruderManager.getInstance().activeExtruderChanged.connect(self._onActiveExtruderChanged) - self._onActiveExtruderChanged() - Application.getInstance().stacksValidationFinished.connect(self._onStackErrorCheckFinished) # A flag indicating if an error check was scheduled @@ -622,6 +618,7 @@ class CuraEngineBackend(QObject, Backend): for extruder in extruders: extruder.propertyChanged.disconnect(self._onSettingChanged) + extruder.containersChanged.disconnect(self._onChanged) self._global_container_stack = Application.getInstance().getGlobalContainerStack() @@ -631,23 +628,9 @@ class CuraEngineBackend(QObject, Backend): extruders = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId())) for extruder in extruders: extruder.propertyChanged.connect(self._onSettingChanged) - self._onActiveExtruderChanged() + extruder.containersChanged.connect(self._onChanged) self._onChanged() - def _onActiveExtruderChanged(self): - if self._global_container_stack: - # Connect all extruders of the active machine. This might cause a few connects that have already happend, - # but that shouldn't cause issues as only new / unique connections are added. - extruders = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId())) - for extruder in extruders: - extruder.propertyChanged.connect(self._onSettingChanged) - if self._active_extruder_stack: - self._active_extruder_stack.containersChanged.disconnect(self._onChanged) - - self._active_extruder_stack = ExtruderManager.getInstance().getActiveExtruderStack() - if self._active_extruder_stack: - self._active_extruder_stack.containersChanged.connect(self._onChanged) - def _onProcessLayersFinished(self, job): self._process_layers_job = None From 792feaade6bfe44a91f438a1eece5d29557cb2b1 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 1 Aug 2017 09:40:49 +0200 Subject: [PATCH 3/4] Always create a definition changes container for a newly created stack CURA-4107 A newly created stack will have an empty definition changes container by default, but when a machine or extruder gets activate, Cura will create a definition changes container for it if it has an empty one. This lazy creation caused the problem when after Cura creates a multi-extrusion machine for the first time, switching to a different extruder tab will cause an extruder stack change, which eventually triggers an unnecessary auto-slice. --- cura/Settings/CuraStackBuilder.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cura/Settings/CuraStackBuilder.py b/cura/Settings/CuraStackBuilder.py index ff05a1e00a..a15797cf7f 100644 --- a/cura/Settings/CuraStackBuilder.py +++ b/cura/Settings/CuraStackBuilder.py @@ -93,6 +93,8 @@ class CuraStackBuilder: # assume the material and variant have already been set. if "definition_changes" in kwargs: stack.setDefinitionChangesById(kwargs["definition_changes"]) + else: + stack.setDefinitionChanges(cls._createDefinitionChangesContainer(stack, new_stack_id + "_settings")) if "variant" in kwargs: stack.setVariantById(kwargs["variant"]) @@ -140,6 +142,8 @@ class CuraStackBuilder: # assume the material and variant have already been set. if "definition_changes" in kwargs: stack.setDefinitionChangesById(kwargs["definition_changes"]) + else: + stack.setDefinitionChanges(cls._createDefinitionChangesContainer(stack, new_stack_id + "_settings")) if "variant" in kwargs: stack.setVariantById(kwargs["variant"]) @@ -158,3 +162,17 @@ class CuraStackBuilder: registry.addContainer(user_container) return stack + + @classmethod + def _createDefinitionChangesContainer(cls, container_stack, container_name, container_index = None): + from cura.CuraApplication import CuraApplication + definition_changes_container = InstanceContainer(container_name) + definition = container_stack.getBottom() + definition_changes_container.setDefinition(definition) + definition_changes_container.addMetaDataEntry("type", "definition_changes") + definition_changes_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion) + + ContainerRegistry.getInstance().addContainer(definition_changes_container) + container_stack.definitionChanges = definition_changes_container + + return definition_changes_container From cf25515b90c23f1a6c35e74b80b590272d04456c Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 1 Aug 2017 10:25:48 +0200 Subject: [PATCH 4/4] Make SettingView update its value upon global stack change CURA-4105 Cleaner way to make SettingView update its value when the global stack gets changed. --- resources/qml/Settings/SettingView.qml | 36 ++++++-------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index af8c86cbc4..485d364b2d 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -238,10 +238,16 @@ Item when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0); value: { + // associate this binding with Cura.MachineManager.activeMachineId in the beginning so this + // binding will be triggered when activeMachineId is changed too. + // Otherwise, if this value only depends on the extruderIds, it won't get updated when the + // machine gets changed. + var activeMachineId = Cura.MachineManager.activeMachineId; + if(!model.settable_per_extruder || machineExtruderCount.properties.value == 1) { //Not settable per extruder or there only is global, so we must pick global. - return Cura.MachineManager.activeMachineId; + return activeMachineId; } if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) { @@ -254,7 +260,7 @@ Item return ExtruderManager.activeExtruderStackId; } //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab. - return Cura.MachineManager.activeMachineId; + return activeMachineId; } } @@ -266,32 +272,6 @@ Item containerStackId: Cura.MachineManager.activeMachineId key: model.key watchedProperties: [ "limit_to_extruder" ] - - // When the activeMachineId got changed, the binding for limit_to_extruder which updates - // provider.containerStackId doesn't get triggered. This handle makes sure that will happen. - onContainerStackIdChanged: - { - if(!model.settable_per_extruder || machineExtruderCount.properties.value == 1) - { - //Not settable per extruder or there only is global, so we must pick global. - provider.containerStackId = Cura.MachineManager.activeMachineId; - return; - } - if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) - { - //We have limit_to_extruder, so pick that stack. - provider.containerStackId = ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)]; - return; - } - if(ExtruderManager.activeExtruderStackId) - { - //We're on an extruder tab. Pick the current extruder. - provider.containerStackId = ExtruderManager.activeExtruderStackId; - return; - } - //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab. - provider.containerStackId = Cura.MachineManager.activeMachineId; - } } UM.SettingPropertyProvider